android.net.LinkProperties Java Examples

The following examples show how to use android.net.LinkProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalIPUtil.java    From DanDanPlayForAndroid with MIT License 7 votes vote down vote up
private String findLocalIp1(){
    ConnectivityManager connMgr = (ConnectivityManager) IApplication.get_context().getSystemService(Context.CONNECTIVITY_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && connMgr != null) {
        LinkProperties linkProperties;
        String ipAddress = null;
        linkProperties = getLinkProperties(connMgr, NetworkCapabilities.TRANSPORT_VPN);
        if (linkProperties == null)
            linkProperties = getLinkProperties(connMgr, NetworkCapabilities.TRANSPORT_ETHERNET);
        if (linkProperties == null)
            linkProperties = getLinkProperties(connMgr, NetworkCapabilities.TRANSPORT_WIFI);
        if (linkProperties != null)
            ipAddress =  getIp(linkProperties);
        if (ipAddress != null)
            return ipAddress;
    }
    return null;
}
 
Example #2
Source File: NetworkAgentInfo.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public NetworkAgentInfo(Messenger messenger, AsyncChannel ac, Network net, NetworkInfo info,
        LinkProperties lp, NetworkCapabilities nc, int score, Context context, Handler handler,
        NetworkMisc misc, NetworkRequest defaultRequest, ConnectivityService connService) {
    this.messenger = messenger;
    asyncChannel = ac;
    network = net;
    networkInfo = info;
    linkProperties = lp;
    networkCapabilities = nc;
    currentScore = score;
    mConnService = connService;
    mContext = context;
    mHandler = handler;
    networkMonitor = mConnService.createNetworkMonitor(context, handler, this, defaultRequest);
    networkMisc = misc;
}
 
Example #3
Source File: TelephonyRegistry.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
        String apnType, String apn, String reason, LinkProperties linkProperties,
        String failCause) {
    Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
    intent.putExtra(PhoneConstants.STATE_KEY, state);
    intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
    if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
    if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
    if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
    if (linkProperties != null) {
        intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties);
    }
    if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);

    mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
            android.Manifest.permission.READ_PRECISE_PHONE_STATE);
}
 
Example #4
Source File: OffloadController.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void dump(IndentingPrintWriter pw) {
    if (isOffloadDisabled()) {
        pw.println("Offload disabled");
        return;
    }
    final boolean isStarted = started();
    pw.println("Offload HALs " + (isStarted ? "started" : "not started"));
    LinkProperties lp = mUpstreamLinkProperties;
    String upstream = (lp != null) ? lp.getInterfaceName() : null;
    pw.println("Current upstream: " + upstream);
    pw.println("Exempt prefixes: " + mLastLocalPrefixStrs);
    pw.println("NAT timeout update callbacks received during the "
            + (isStarted ? "current" : "last")
            + " offload session: "
            + mNatUpdateCallbacksReceived);
    pw.println("NAT timeout update netlink errors during the "
            + (isStarted ? "current" : "last")
            + " offload session: "
            + mNatUpdateNetlinkErrors);
}
 
Example #5
Source File: AndroidResolverConfigProvider.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initializeApi26Nameservers() throws InitializationException {
  if (context == null) {
    throw new InitializationException("Context must be initialized by calling setContext");
  }

  ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
  Network network = cm.getActiveNetwork();
  if (network == null) {
    // if the device is offline, there's no active network
    return;
  }

  LinkProperties lp = cm.getLinkProperties(network);
  if (lp == null) {
    // can be null for an unknown network, which may happen if networks change
    return;
  }

  for (InetAddress address : lp.getDnsServers()) {
    addNameserver(new InetSocketAddress(address, SimpleResolver.DEFAULT_PORT));
  }

  parseSearchPathList(lp.getDomains(), ",");
}
 
Example #6
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void notifyLinkPropertiesChanged(String iface, TetherInterfaceStateMachine who,
                                         LinkProperties newLp) {
    final int state;
    synchronized (mPublicSync) {
        final TetherState tetherState = mTetherStates.get(iface);
        if (tetherState != null && tetherState.stateMachine.equals(who)) {
            state = tetherState.lastState;
        } else {
            mLog.log("got notification from stale iface " + iface);
            return;
        }
    }

    mLog.log(String.format(
            "OBSERVED LinkProperties update iface=%s state=%s lp=%s",
            iface, IControlsTethering.getStateString(state), newLp));
    final int which = TetherMasterSM.EVENT_IFACE_UPDATE_LINKPROPERTIES;
    mTetherMasterSM.sendMessage(which, state, 0, newLp);
}
 
Example #7
Source File: AndroidNetworkLibrary.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
@CalledByNative
private static byte[][] getDnsServers() {
    ConnectivityManager connectivityManager =
            (ConnectivityManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.CONNECTIVITY_SERVICE);
    if (connectivityManager == null) {
        return new byte[0][0];
    }
    Network network = connectivityManager.getActiveNetwork();
    if (network == null) {
        return new byte[0][0];
    }
    LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
    if (linkProperties == null) {
        return new byte[0][0];
    }
    List<InetAddress> dnsServersList = linkProperties.getDnsServers();
    byte[][] dnsServers = new byte[dnsServersList.size()][];
    for (int i = 0; i < dnsServersList.size(); i++) {
        dnsServers[i] = dnsServersList.get(i).getAddress();
    }
    return dnsServers;
}
 
Example #8
Source File: IPv6TetheringCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void setUpstreamNetworkState(NetworkState ns) {
    if (ns == null) {
        mUpstreamNetworkState = null;
    } else {
        // Make a deep copy of the parts we need.
        mUpstreamNetworkState = new NetworkState(
                null,
                new LinkProperties(ns.linkProperties),
                new NetworkCapabilities(ns.networkCapabilities),
                new Network(ns.network),
                null,
                null);
    }

    mLog.log("setUpstreamNetworkState: " + toDebugString(mUpstreamNetworkState));
}
 
Example #9
Source File: Dns.java    From HttpInfo with Apache License 2.0 6 votes vote down vote up
private static String[] readDnsServersFromConnectionManager(Context context) {
    LinkedList<String> dnsServers = new LinkedList<>();
    if (Build.VERSION.SDK_INT >= 21 && context != null) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE);
        if (connectivityManager != null) {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            for (Network network : connectivityManager.getAllNetworks()) {
                NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network);
                if (networkInfo.getType() == activeNetworkInfo.getType()) {
                    LinkProperties lp = connectivityManager.getLinkProperties(network);
                    for (InetAddress addr : lp.getDnsServers()) {
                        dnsServers.add(addr.getHostAddress());
                    }
                }
            }
        }
    }
    return dnsServers.isEmpty() ? new String[0] : dnsServers.toArray(new String[dnsServers.size()]);
}
 
Example #10
Source File: DnsManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void updatePrivateDnsStatus(int netId, LinkProperties lp) {
    // Use the PrivateDnsConfig data pushed to this class instance
    // from ConnectivityService.
    final PrivateDnsConfig privateDnsCfg = mPrivateDnsMap.getOrDefault(netId,
            PRIVATE_DNS_OFF);

    final boolean useTls = privateDnsCfg.useTls;
    final PrivateDnsValidationStatuses statuses =
            useTls ? mPrivateDnsValidationMap.get(netId) : null;
    final boolean validated = (null != statuses) && statuses.hasValidatedServer();
    final boolean strictMode = privateDnsCfg.inStrictMode();
    final String tlsHostname = strictMode ? privateDnsCfg.hostname : null;
    final boolean usingPrivateDns = strictMode || validated;

    lp.setUsePrivateDns(usingPrivateDns);
    lp.setPrivateDnsServerName(tlsHostname);
    if (usingPrivateDns && null != statuses) {
        statuses.fillInValidatedPrivateDns(lp);
    } else {
        lp.setValidatedPrivateDnsServers(Collections.EMPTY_LIST);
    }
}
 
Example #11
Source File: XLinkProperties.java    From XPrivacy with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void after(XParam param) throws Throwable {
	switch (mMethod) {
	case getAddresses:
	case getAllAddresses:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<InetAddress>());
		break;

	case getAllLinkAddresses:
	case getLinkAddresses:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<LinkAddress>());
		break;

	case getStackedLinks:
		if (param.getResult() != null)
			if (isRestricted(param))
				param.setResult(new ArrayList<LinkProperties>());
		break;
	}
}
 
Example #12
Source File: Nat464Xlat.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Removes stacked link on base link and transitions to IDLE state.
 */
private void handleInterfaceRemoved(String iface) {
    if (!Objects.equals(mIface, iface)) {
        return;
    }
    if (!isRunning() && !isStopping()) {
        return;
    }

    Slog.i(TAG, "interface " + iface + " removed");
    if (!isStopping()) {
        // Ensure clatd is stopped if stop() has not been called: this likely means that clatd
        // has crashed.
        enterStoppingState();
    }
    enterIdleState();
    LinkProperties lp = new LinkProperties(mNetwork.linkProperties);
    lp.removeStackedLink(iface);
    mNetwork.connService().handleUpdateLinkProperties(mNetwork, lp);
}
 
Example #13
Source File: Nat464Xlat.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Adds stacked link on base link and transitions to RUNNING state.
 */
private void handleInterfaceLinkStateChanged(String iface, boolean up) {
    if (!isStarting() || !up || !Objects.equals(mIface, iface)) {
        return;
    }

    LinkAddress clatAddress = getLinkAddress(iface);
    if (clatAddress == null) {
        Slog.e(TAG, "clatAddress was null for stacked iface " + iface);
        return;
    }

    Slog.i(TAG, String.format("interface %s is up, adding stacked link %s on top of %s",
            mIface, mIface, mBaseIface));
    enterRunningState();
    LinkProperties lp = new LinkProperties(mNetwork.linkProperties);
    lp.addStackedLink(makeLinkProperties(clatAddress));
    mNetwork.connService().handleUpdateLinkProperties(mNetwork, lp);
}
 
Example #14
Source File: Nat464Xlat.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private LinkProperties makeLinkProperties(LinkAddress clatAddress) {
    LinkProperties stacked = new LinkProperties();
    stacked.setInterfaceName(mIface);

    // Although the clat interface is a point-to-point tunnel, we don't
    // point the route directly at the interface because some apps don't
    // understand routes without gateways (see, e.g., http://b/9597256
    // http://b/9597516). Instead, set the next hop of the route to the
    // clat IPv4 address itself (for those apps, it doesn't matter what
    // the IP of the gateway is, only that there is one).
    RouteInfo ipv4Default = new RouteInfo(
            new LinkAddress(Inet4Address.ANY, 0),
            clatAddress.getAddress(), mIface);
    stacked.addRoute(ipv4Default);
    stacked.addLinkAddress(clatAddress);
    return stacked;
}
 
Example #15
Source File: Nat464Xlat.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Copies the stacked clat link in oldLp, if any, to the passed LinkProperties.
 * This is necessary because the LinkProperties in mNetwork come from the transport layer, which
 * has no idea that 464xlat is running on top of it.
 */
public void fixupLinkProperties(LinkProperties oldLp, LinkProperties lp) {
    if (!isRunning()) {
        return;
    }
    if (lp == null || lp.getAllInterfaceNames().contains(mIface)) {
        return;
    }

    Slog.d(TAG, "clatd running, updating NAI for " + mIface);
    for (LinkProperties stacked: oldLp.getStackedLinks()) {
        if (Objects.equals(mIface, stacked.getInterfaceName())) {
            lp.addStackedLink(stacked);
            return;
        }
    }
}
 
Example #16
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
protected void setDnsForwarders(final Network network, final LinkProperties lp) {
    // TODO: Set v4 and/or v6 DNS per available connectivity.
    String[] dnsServers = mConfig.defaultIPv4DNS;
    final Collection<InetAddress> dnses = lp.getDnsServers();
    // TODO: Properly support the absence of DNS servers.
    if (dnses != null && !dnses.isEmpty()) {
        // TODO: remove this invocation of NetworkUtils.makeStrings().
        dnsServers = NetworkUtils.makeStrings(dnses);
    }
    try {
        mNMService.setDnsForwarders(network, dnsServers);
        mLog.log(String.format(
                "SET DNS forwarders: network=%s dnsServers=%s",
                network, Arrays.toString(dnsServers)));
    } catch (Exception e) {
        // TODO: Investigate how this can fail and what exactly
        // happens if/when such failures occur.
        mLog.e("setting DNS forwarders failed, " + e);
        transitionTo(mSetDnsForwardersErrorState);
    }
}
 
Example #17
Source File: MainActivity.java    From Intra with Apache License 2.0 6 votes vote down vote up
private LinkProperties getLinkProperties() {
  ConnectivityManager connectivityManager =
      (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
    // getActiveNetwork() requires M or later.
    return null;
  }
  Network activeNetwork = connectivityManager.getActiveNetwork();
  if (activeNetwork == null) {
    return null;
  }
  return connectivityManager.getLinkProperties(activeNetwork);
}
 
Example #18
Source File: MainActivity.java    From Intra with Apache License 2.0 6 votes vote down vote up
private PrivateDnsMode getPrivateDnsMode() {
  if (Build.VERSION.SDK_INT < VERSION_CODES.P) {
    // Private DNS was introduced in P.
    return PrivateDnsMode.NONE;
  }

  LinkProperties linkProperties = getLinkProperties();
  if (linkProperties == null) {
    return PrivateDnsMode.NONE;
  }

  if (linkProperties.getPrivateDnsServerName() != null) {
    return PrivateDnsMode.STRICT;
  }

  if (linkProperties.isPrivateDnsActive()) {
    return PrivateDnsMode.UPGRADED;
  }

  return PrivateDnsMode.NONE;
}
 
Example #19
Source File: Vpn.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Analyzes the passed LinkedProperties to figure out whether it routes to most of the IP space.
 *
 * This returns true if the passed LinkedProperties contains routes to either most of the IPv4
 * space or to most of the IPv6 address space, where "most" is defined by the value of the
 * MOST_IPV{4,6}_ADDRESSES_COUNT constants : if more than this number of addresses are matched
 * by any of the routes, then it's decided that most of the space is routed.
 * @hide
 */
@VisibleForTesting
static boolean providesRoutesToMostDestinations(LinkProperties lp) {
    final List<RouteInfo> routes = lp.getAllRoutes();
    if (routes.size() > MAX_ROUTES_TO_EVALUATE) return true;
    final Comparator<IpPrefix> prefixLengthComparator = IpPrefix.lengthComparator();
    TreeSet<IpPrefix> ipv4Prefixes = new TreeSet<>(prefixLengthComparator);
    TreeSet<IpPrefix> ipv6Prefixes = new TreeSet<>(prefixLengthComparator);
    for (final RouteInfo route : routes) {
        IpPrefix destination = route.getDestination();
        if (destination.isIPv4()) {
            ipv4Prefixes.add(destination);
        } else {
            ipv6Prefixes.add(destination);
        }
    }
    if (NetworkUtils.routedIPv4AddressCount(ipv4Prefixes) > MOST_IPV4_ADDRESSES_COUNT) {
        return true;
    }
    return NetworkUtils.routedIPv6AddressCount(ipv6Prefixes)
            .compareTo(MOST_IPV6_ADDRESSES_COUNT) >= 0;
}
 
Example #20
Source File: LollipopDeviceStateListener.java    From EasyVPN-Free with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
    super.onLinkPropertiesChanged(network, linkProperties);

    if (!linkProperties.toString().equals(mLastLinkProperties)) {
        mLastLinkProperties = linkProperties.toString();
        VpnStatus.logDebug(String.format("Linkproperties of %s: %s", network, linkProperties));
    }
}
 
Example #21
Source File: JNIUtilities.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(23)
public static String getCurrentNetworkInterfaceName(){
	ConnectivityManager cm=(ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
	Network net=cm.getActiveNetwork();
	if(net==null)
		return null;
	LinkProperties props=cm.getLinkProperties(net);
	if(props==null)
		return null;
	return props.getInterfaceName();
}
 
Example #22
Source File: DnsHelper.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
private static String getDnsServer(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm == null)
        return DEFAULT_DNS;

    LinkProperties props = null;

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
        for (Network network : cm.getAllNetworks()) {
            NetworkInfo ni = cm.getNetworkInfo(network);
            if (ni != null && ni.isConnected()) {
                props = cm.getLinkProperties(network);
                Log.i("Old props=" + props);
                break;
            }
        }
    else {
        Network active = cm.getActiveNetwork();
        if (active == null)
            return DEFAULT_DNS;
        props = cm.getLinkProperties(active);
        Log.i("New props=" + props);
    }

    if (props == null)
        return DEFAULT_DNS;

    List<InetAddress> dns = props.getDnsServers();
    if (dns.size() == 0)
        return DEFAULT_DNS;
    else
        return dns.get(0).getHostAddress();
}
 
Example #23
Source File: NetworkAgentInfo.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public NetworkState getNetworkState() {
    synchronized (this) {
        // Network objects are outwardly immutable so there is no point in duplicating.
        // Duplicating also precludes sharing socket factories and connection pools.
        final String subscriberId = (networkMisc != null) ? networkMisc.subscriberId : null;
        return new NetworkState(new NetworkInfo(networkInfo),
                new LinkProperties(linkProperties),
                new NetworkCapabilities(networkCapabilities), network, subscriberId, null);
    }
}
 
Example #24
Source File: UpstreamNetworkMonitor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onLinkPropertiesChanged(Network network, LinkProperties newLp) {
    handleLinkProp(network, newLp);
    // TODO(b/110335330): reduce the number of times this is called by
    // only recomputing on the LISTEN_ALL callback.
    recomputeLocalPrefixes();
}
 
Example #25
Source File: LollipopDeviceStateListener.java    From SimpleOpenVpn-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onLinkPropertiesChanged(Network network, LinkProperties linkProperties) {
    super.onLinkPropertiesChanged(network, linkProperties);

    if (!linkProperties.toString().equals(mLastLinkProperties)) {
        mLastLinkProperties = linkProperties.toString();
        VpnStatus.logDebug(String.format("Linkproperties of %s: %s", network, linkProperties));
    }
}
 
Example #26
Source File: AndroidNetworkLibrary.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @returns result of linkProperties.isPrivateDnsActive().
 */
static boolean isPrivateDnsActive(LinkProperties linkProperties) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && linkProperties != null) {
        return ApiHelperForP.isPrivateDnsActive(linkProperties);
    }
    return false;
}
 
Example #27
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void sendOffloadExemptPrefixes(final Set<IpPrefix> localPrefixes) {
    // Add in well-known minimum set.
    PrefixUtils.addNonForwardablePrefixes(localPrefixes);
    // Add tragically hardcoded prefixes.
    localPrefixes.add(PrefixUtils.DEFAULT_WIFI_P2P_PREFIX);

    // Maybe add prefixes or addresses for downstreams, depending on
    // the IP serving mode of each.
    for (TetherInterfaceStateMachine tism : mNotifyList) {
        final LinkProperties lp = tism.linkProperties();

        switch (tism.servingMode()) {
            case IControlsTethering.STATE_UNAVAILABLE:
            case IControlsTethering.STATE_AVAILABLE:
                // No usable LinkProperties in these states.
                continue;
            case IControlsTethering.STATE_TETHERED:
                // Only add IPv4 /32 and IPv6 /128 prefixes. The
                // directly-connected prefixes will be sent as
                // downstream "offload-able" prefixes.
                for (LinkAddress addr : lp.getAllLinkAddresses()) {
                    final InetAddress ip = addr.getAddress();
                    if (ip.isLinkLocalAddress()) continue;
                    localPrefixes.add(PrefixUtils.ipAddressAsPrefix(ip));
                }
                break;
            case IControlsTethering.STATE_LOCAL_ONLY:
                // Add prefixes covering all local IPs.
                localPrefixes.addAll(PrefixUtils.localPrefixesFrom(lp));
                break;
        }
    }

    mOffloadController.setLocalPrefixes(localPrefixes);
}
 
Example #28
Source File: AndroidNetworkLibrary.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @returns result of linkProperties.getPrivateDnsServerName().
 */
private static String getPrivateDnsServerName(LinkProperties linkProperties) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && linkProperties != null) {
        return ApiHelperForP.getPrivateDnsServerName(linkProperties);
    }
    return null;
}
 
Example #29
Source File: UpstreamNetworkMonitor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private static HashSet<IpPrefix> allLocalPrefixes(Iterable<NetworkState> netStates) {
    final HashSet<IpPrefix> prefixSet = new HashSet<>();

    for (NetworkState ns : netStates) {
        final LinkProperties lp = ns.linkProperties;
        if (lp == null) continue;
        prefixSet.addAll(PrefixUtils.localPrefixesFrom(lp));
    }

    return prefixSet;
}
 
Example #30
Source File: IPv6TetheringCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void updateIPv6TetheringInterfaces() {
    for (TetherInterfaceStateMachine sm : mNotifyList) {
        final LinkProperties lp = getInterfaceIPv6LinkProperties(sm);
        sm.sendMessage(TetherInterfaceStateMachine.CMD_IPV6_TETHER_UPDATE, 0, 0, lp);
        break;
    }
}