Lines Matching refs:network
135 if (entry.second->getType() == Network::VIRTUAL) {
164 Network* network = getNetworkLocked(netId);
165 if (!network) {
169 if (network->getType() != Network::PHYSICAL) {
170 ALOGE("cannot set default to non-physical network with netId %u", netId);
173 if (int ret = static_cast<PhysicalNetwork*>(network)->addAsDefault()) {
179 Network* network = getNetworkLocked(mDefaultNetId);
180 if (!network || network->getType() != Network::PHYSICAL) {
181 ALOGE("cannot find previously set default network with netId %u", mDefaultNetId);
184 if (int ret = static_cast<PhysicalNetwork*>(network)->removeAsDefault()) {
212 // network, use that network's DNS servers. Do not fall through to the default network even
213 // if the explicitly selected network is a split tunnel VPN: the explicitlySelected bit
217 // If the network is a VPN and it doesn't have DNS servers, use the default network's DNS
218 // servers (through the default network). Otherwise, the query is guaranteed to fail.
220 Network *network = getNetworkLocked(*netId);
221 if (network && network->getType() == Network::VIRTUAL &&
222 !static_cast<VirtualNetwork *>(network)->getHasDns()) {
227 // (possibly falling through to the default network if the VPN doesn't provide a route to
228 // them). Otherwise, use the default network's DNS servers. We cannot set the explicit bit
229 // because we need to be able to fall through a split tunnel to the default network.
234 // TODO: return an error instead of silently doing the DNS lookup on the wrong network.
248 // Returns the NetId that a given UID would use if no network is explicitly selected. Specifically,
249 // the VPN that applies to the UID if any; otherwise, the default network.
259 // applies to the user if any; otherwise, the default network.
261 // In general, we prefer to always set the default network's NetId in connect(), so that if the VPN
262 // is a split-tunnel and disappears later, the socket continues working (since the default network's
269 // traffic to the default network. But it does mean that if the bypassable VPN goes away (and thus
270 // the fallthrough rules also go away), the socket that used to fallthrough to the default network
301 // - [Java] android.net.Network#getAllByName()
354 Network* network = getNetworkLocked(netId);
355 return network && network->getType() == Network::VIRTUAL;
372 ALOGE("inconceivable! setPermission cannot fail on an empty network");
402 ALOGE("No free network ID");
439 ALOGE("cannot destroy local network");
447 // TODO: ioctl(SIOCKILLADDR, ...) to kill all sockets on the old network.
449 Network* network = getNetworkLocked(netId);
451 // If we fail to destroy a network, things will get stuck badly. Therefore, unlike most of the
452 // other network code, ignore failures and attempt to clear out as much state as possible, even
454 int ret = network->clearInterfaces();
457 if (int err = static_cast<PhysicalNetwork*>(network)->removeAsDefault()) {
458 ALOGE("inconceivable! removeAsDefault cannot fail on an empty network");
464 } else if (network->getType() == Network::VIRTUAL) {
472 delete network;
548 Network* network = getNetworkLocked(netId);
549 if (!network) {
553 if (network->getType() != Network::PHYSICAL) {
554 ALOGE("cannot set permissions on non-physical network with netId %u", netId);
558 if (int ret = static_cast<PhysicalNetwork*>(network)->setPermission(permission)) {
567 Network* network = getNetworkLocked(netId);
568 if (!network) {
572 if (network->getType() != Network::VIRTUAL) {
573 ALOGE("cannot add users to non-virtual network with netId %u", netId);
576 if (int ret = static_cast<VirtualNetwork*>(network)->addUsers(uidRanges, mProtectableUsers)) {
584 Network* network = getNetworkLocked(netId);
585 if (!network) {
589 if (network->getType() != Network::VIRTUAL) {
590 ALOGE("cannot remove users from non-virtual network with netId %u", netId);
593 if (int ret = static_cast<VirtualNetwork*>(network)->removeUsers(uidRanges,
646 // If this IP address is still assigned to another interface in the same network,
649 // TODO: evaluate extending this to all network types.
686 dw.println("Default network: %u", mDefaultNetId);
692 Network* network = i.second;
693 dw.println(network->toString().c_str());
694 if (network->getType() == Network::PHYSICAL) {
696 Permission permission = reinterpret_cast<PhysicalNetwork*>(network)->getPermission();
706 dw.println("Interface <-> last network map:");
731 Network* NetworkController::getNetworkLocked(unsigned netId) const {
738 if (entry.second->getType() == Network::VIRTUAL) {
757 Network* network = getNetworkLocked(netId);
758 if (!network) {
763 // (using SO_PEERCRED). Be safe and deny access to the network, even if it's valid.
771 if (network->getType() == Network::VIRTUAL) {
772 return static_cast<VirtualNetwork*>(network)->appliesToUser(uid) ? 0 : -EPERM;
779 Permission networkPermission = static_cast<PhysicalNetwork*>(network)->getPermission();
822 Network* network = getNetworkLocked(mDefaultNetId);
823 if (!network) {
824 ALOGE("cannot find previously set default network with netId %u", mDefaultNetId);
827 if (network->getType() != Network::PHYSICAL) {
828 ALOGE("inconceivable! default network must be a physical network");
831 Permission permission = static_cast<PhysicalNetwork*>(network)->getPermission();
832 for (const auto& physicalInterface : network->getInterfaces()) {
844 const auto& network = entry.second;
845 if (network->getType() == Network::PHYSICAL && network->getNetId() >= MIN_NET_ID) {