Lines Matching refs:network
133 if (entry.second->getType() == Network::VIRTUAL) {
162 Network* network = getNetworkLocked(netId);
163 if (!network) {
167 if (network->getType() != Network::PHYSICAL) {
168 ALOGE("cannot set default to non-physical network with netId %u", netId);
171 if (int ret = static_cast<PhysicalNetwork*>(network)->addAsDefault()) {
177 Network* network = getNetworkLocked(mDefaultNetId);
178 if (!network || network->getType() != Network::PHYSICAL) {
179 ALOGE("cannot find previously set default network with netId %u", mDefaultNetId);
182 if (int ret = static_cast<PhysicalNetwork*>(network)->removeAsDefault()) {
198 // network, use that network's DNS servers. Do not fall through to the default network even
199 // if the explicitly selected network is a split tunnel VPN: the explicitlySelected bit
203 // If the network is a VPN and it doesn't have DNS servers, use the default network's DNS
204 // servers (through the default network). Otherwise, the query is guaranteed to fail.
206 Network *network = getNetworkLocked(*netId);
207 if (network && network->getType() == Network::VIRTUAL &&
208 !static_cast<VirtualNetwork *>(network)->getHasDns()) {
213 // (possibly falling through to the default network if the VPN doesn't provide a route to
214 // them). Otherwise, use the default network's DNS servers.
219 // TODO: return an error instead of silently doing the DNS lookup on the wrong network.
228 // Returns the NetId that a given UID would use if no network is explicitly selected. Specifically,
229 // the VPN that applies to the UID if any; otherwise, the default network.
239 // applies to the user if any; otherwise, the default network.
241 // In general, we prefer to always set the default network's NetId in connect(), so that if the VPN
242 // is a split-tunnel and disappears later, the socket continues working (since the default network's
249 // traffic to the default network. But it does mean that if the bypassable VPN goes away (and thus
250 // the fallthrough rules also go away), the socket that used to fallthrough to the default network
275 // - [Java] android.net.Network#getAllByName()
320 Network* network = getNetworkLocked(netId);
321 return network && network->getType() == Network::VIRTUAL;
338 ALOGE("inconceivable! setPermission cannot fail on an empty network");
369 ALOGE("cannot destroy local network");
377 // TODO: ioctl(SIOCKILLADDR, ...) to kill all sockets on the old network.
380 Network* network = getNetworkLocked(netId);
382 // If we fail to destroy a network, things will get stuck badly. Therefore, unlike most of the
383 // other network code, ignore failures and attempt to clear out as much state as possible, even
385 int ret = network->clearInterfaces();
388 if (int err = static_cast<PhysicalNetwork*>(network)->removeAsDefault()) {
389 ALOGE("inconceivable! removeAsDefault cannot fail on an empty network");
395 } else if (network->getType() == Network::VIRTUAL) {
403 delete network;
456 Network* network = getNetworkLocked(netId);
457 if (!network) {
461 if (network->getType() != Network::PHYSICAL) {
462 ALOGE("cannot set permissions on non-physical network with netId %u", netId);
466 if (int ret = static_cast<PhysicalNetwork*>(network)->setPermission(permission)) {
475 Network* network = getNetworkLocked(netId);
476 if (!network) {
480 if (network->getType() != Network::VIRTUAL) {
481 ALOGE("cannot add users to non-virtual network with netId %u", netId);
484 if (int ret = static_cast<VirtualNetwork*>(network)->addUsers(uidRanges, mProtectableUsers)) {
492 Network* network = getNetworkLocked(netId);
493 if (!network) {
497 if (network->getType() != Network::VIRTUAL) {
498 ALOGE("cannot remove users from non-virtual network with netId %u", netId);
501 if (int ret = static_cast<VirtualNetwork*>(network)->removeUsers(uidRanges,
543 dw.println("Default network: %u", mDefaultNetId);
549 Network* network = i.second;
550 dw.println(network->toString().c_str());
551 if (network->getType() == Network::PHYSICAL) {
553 Permission permission = reinterpret_cast<PhysicalNetwork*>(network)->getPermission();
572 Network* NetworkController::getNetworkLocked(unsigned netId) const {
579 if (entry.second->getType() == Network::VIRTUAL) {
598 Network* network = getNetworkLocked(netId);
599 if (!network) {
604 // (using SO_PEERCRED). Be safe and deny access to the network, even if it's valid.
612 if (network->getType() == Network::VIRTUAL) {
613 return static_cast<VirtualNetwork*>(network)->appliesToUser(uid) ? 0 : -EPERM;
620 Permission networkPermission = static_cast<PhysicalNetwork*>(network)->getPermission();
661 Network* network = getNetworkLocked(mDefaultNetId);
662 if (!network) {
663 ALOGE("cannot find previously set default network with netId %u", mDefaultNetId);
666 if (network->getType() != Network::PHYSICAL) {
667 ALOGE("inconceivable! default network must be a physical network");
670 Permission permission = static_cast<PhysicalNetwork*>(network)->getPermission();
671 for (const auto& physicalInterface : network->getInterfaces()) {