Search in sources :

Example 36 with LinkProperties

use of android.net.LinkProperties in project android_frameworks_base by ResurrectionRemix.

the class IpManager method setLinkProperties.

// Updates all IpManager-related state concerned with LinkProperties.
// Returns a ProvisioningChange for possibly notifying other interested
// parties that are not fronted by IpManager.
private ProvisioningChange setLinkProperties(LinkProperties newLp) {
    if (mApfFilter != null) {
        mApfFilter.setLinkProperties(newLp);
    }
    if (mIpReachabilityMonitor != null) {
        mIpReachabilityMonitor.updateLinkProperties(newLp);
    }
    ProvisioningChange delta = compareProvisioning(mLinkProperties, newLp);
    mLinkProperties = new LinkProperties(newLp);
    if (delta == ProvisioningChange.GAINED_PROVISIONING) {
        // TODO: Add a proper ProvisionedState and cancel the alarm in
        // its enter() method.
        mProvisioningTimeoutAlarm.cancel();
    }
    return delta;
}
Also used : ProvisioningChange(android.net.LinkProperties.ProvisioningChange) LinkProperties(android.net.LinkProperties)

Example 37 with LinkProperties

use of android.net.LinkProperties in project android_frameworks_base by ResurrectionRemix.

the class IpManager method doImmediateProvisioningFailure.

private void doImmediateProvisioningFailure(int failureType) {
    if (DBG) {
        Log.e(mTag, "onProvisioningFailure(): " + failureType);
    }
    recordMetric(failureType);
    mCallback.onProvisioningFailure(new LinkProperties(mLinkProperties));
}
Also used : LinkProperties(android.net.LinkProperties)

Example 38 with LinkProperties

use of android.net.LinkProperties in project android_frameworks_base by ResurrectionRemix.

the class IpManager method resetLinkProperties.

// This needs to be called with care to ensure that our LinkProperties
// are in sync with the actual LinkProperties of the interface. For example,
// we should only call this if we know for sure that there are no IP addresses
// assigned to the interface, etc.
private void resetLinkProperties() {
    mNetlinkTracker.clearLinkProperties();
    mConfiguration = null;
    mDhcpResults = null;
    mTcpBufferSizes = "";
    mHttpProxy = null;
    mLinkProperties = new LinkProperties();
    mLinkProperties.setInterfaceName(mInterfaceName);
}
Also used : LinkProperties(android.net.LinkProperties)

Example 39 with LinkProperties

use of android.net.LinkProperties in project android_frameworks_base by ResurrectionRemix.

the class ConnectivityServiceTest method testRequestCallbackUpdates.

@LargeTest
public void testRequestCallbackUpdates() throws Exception {
    // File a network request for mobile.
    final TestNetworkCallback cellNetworkCallback = new TestRequestUpdateCallback();
    final NetworkRequest cellRequest = new NetworkRequest.Builder().addTransportType(TRANSPORT_CELLULAR).build();
    mCm.requestNetwork(cellRequest, cellNetworkCallback);
    // Bring up the mobile network.
    mCellNetworkAgent = new MockNetworkAgent(TRANSPORT_CELLULAR);
    mCellNetworkAgent.connect(true);
    // We should get onAvailable().
    cellNetworkCallback.expectCallback(CallbackState.AVAILABLE, mCellNetworkAgent);
    // We should get onCapabilitiesChanged(), when the mobile network successfully validates.
    cellNetworkCallback.expectCallback(CallbackState.NETWORK_CAPABILITIES, mCellNetworkAgent);
    cellNetworkCallback.assertNoCallback();
    // Update LinkProperties.
    final LinkProperties lp = new LinkProperties();
    lp.setInterfaceName("foonet_data0");
    mCellNetworkAgent.sendLinkProperties(lp);
    // We should get onLinkPropertiesChanged().
    cellNetworkCallback.expectCallback(CallbackState.LINK_PROPERTIES, mCellNetworkAgent);
    cellNetworkCallback.assertNoCallback();
    // Register a garden variety default network request.
    final TestNetworkCallback dfltNetworkCallback = new TestRequestUpdateCallback();
    mCm.registerDefaultNetworkCallback(dfltNetworkCallback);
    // Only onAvailable() is called; no other information is delivered.
    dfltNetworkCallback.expectCallback(CallbackState.AVAILABLE, mCellNetworkAgent);
    dfltNetworkCallback.assertNoCallback();
    // Request a NetworkCapabilities update; only the requesting callback is notified.
    mCm.requestNetworkCapabilities(dfltNetworkCallback);
    dfltNetworkCallback.expectCallback(CallbackState.NETWORK_CAPABILITIES, mCellNetworkAgent);
    cellNetworkCallback.assertNoCallback();
    dfltNetworkCallback.assertNoCallback();
    // Request a LinkProperties update; only the requesting callback is notified.
    mCm.requestLinkProperties(dfltNetworkCallback);
    dfltNetworkCallback.expectCallback(CallbackState.LINK_PROPERTIES, mCellNetworkAgent);
    cellNetworkCallback.assertNoCallback();
    dfltNetworkCallback.assertNoCallback();
    mCm.unregisterNetworkCallback(dfltNetworkCallback);
    mCm.unregisterNetworkCallback(cellNetworkCallback);
}
Also used : NetworkRequest(android.net.NetworkRequest) LinkProperties(android.net.LinkProperties) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 40 with LinkProperties

use of android.net.LinkProperties in project android_frameworks_base by ResurrectionRemix.

the class LinkPropertiesTest method testIsReachable.

@SmallTest
// Failing.
@Suppress
public void testIsReachable() {
    final LinkProperties v4lp = new LinkProperties();
    assertFalse(v4lp.isReachable(DNS1));
    assertFalse(v4lp.isReachable(DNS2));
    // Add an on-link route, making the on-link DNS server reachable,
    // but there is still no IPv4 address.
    assertTrue(v4lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("75.208.0.0"), 16))));
    assertFalse(v4lp.isReachable(DNS1));
    assertFalse(v4lp.isReachable(DNS2));
    // Adding an IPv4 address (right now, any IPv4 address) means we use
    // the routes to compute likely reachability.
    assertTrue(v4lp.addLinkAddress(new LinkAddress(ADDRV4, 16)));
    assertTrue(v4lp.isReachable(DNS1));
    assertFalse(v4lp.isReachable(DNS2));
    // Adding a default route makes the off-link DNS server reachable.
    assertTrue(v4lp.addRoute(new RouteInfo(GATEWAY1)));
    assertTrue(v4lp.isReachable(DNS1));
    assertTrue(v4lp.isReachable(DNS2));
    final LinkProperties v6lp = new LinkProperties();
    final InetAddress kLinkLocalDns = NetworkUtils.numericToInetAddress("fe80::6:1");
    final InetAddress kLinkLocalDnsWithScope = NetworkUtils.numericToInetAddress("fe80::6:2%43");
    final InetAddress kOnLinkDns = NetworkUtils.numericToInetAddress("2001:db8:85a3::53");
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertFalse(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertFalse(v6lp.isReachable(kOnLinkDns));
    assertFalse(v6lp.isReachable(DNS6));
    // Add a link-local route, making the link-local DNS servers reachable. Because
    // we assume the presence of an IPv6 link-local address, link-local DNS servers
    // are considered reachable, but only those with a non-zero scope identifier.
    assertTrue(v6lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("fe80::"), 64))));
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertFalse(v6lp.isReachable(kOnLinkDns));
    assertFalse(v6lp.isReachable(DNS6));
    // Add a link-local address--nothing changes.
    assertTrue(v6lp.addLinkAddress(LINKADDRV6LINKLOCAL));
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertFalse(v6lp.isReachable(kOnLinkDns));
    assertFalse(v6lp.isReachable(DNS6));
    // Add a global route on link, but no global address yet. DNS servers reachable
    // via a route that doesn't require a gateway: give them the benefit of the
    // doubt and hope the link-local source address suffices for communication.
    assertTrue(v6lp.addRoute(new RouteInfo(new IpPrefix(NetworkUtils.numericToInetAddress("2001:db8:85a3::"), 64))));
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertTrue(v6lp.isReachable(kOnLinkDns));
    assertFalse(v6lp.isReachable(DNS6));
    // Add a global address; the on-link global address DNS server is (still)
    // presumed reachable.
    assertTrue(v6lp.addLinkAddress(new LinkAddress(ADDRV6, 64)));
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertTrue(v6lp.isReachable(kOnLinkDns));
    assertFalse(v6lp.isReachable(DNS6));
    // Adding a default route makes the off-link DNS server reachable.
    assertTrue(v6lp.addRoute(new RouteInfo(GATEWAY62)));
    assertFalse(v6lp.isReachable(kLinkLocalDns));
    assertTrue(v6lp.isReachable(kLinkLocalDnsWithScope));
    assertTrue(v6lp.isReachable(kOnLinkDns));
    assertTrue(v6lp.isReachable(DNS6));
    // Check isReachable on stacked links. This requires that the source IP address be assigned
    // on the interface returned by the route lookup.
    LinkProperties stacked = new LinkProperties();
    // Can't add a stacked link without an interface name.
    stacked.setInterfaceName("v4-test0");
    v6lp.addStackedLink(stacked);
    InetAddress stackedAddress = Address("192.0.0.4");
    LinkAddress stackedLinkAddress = new LinkAddress(stackedAddress, 32);
    assertFalse(v6lp.isReachable(stackedAddress));
    stacked.addLinkAddress(stackedLinkAddress);
    assertFalse(v6lp.isReachable(stackedAddress));
    stacked.addRoute(new RouteInfo(stackedLinkAddress));
    assertTrue(stacked.isReachable(stackedAddress));
    assertTrue(v6lp.isReachable(stackedAddress));
    assertFalse(v6lp.isReachable(DNS1));
    stacked.addRoute(new RouteInfo((IpPrefix) null, stackedAddress));
    assertTrue(v6lp.isReachable(DNS1));
}
Also used : IpPrefix(android.net.IpPrefix) LinkAddress(android.net.LinkAddress) RouteInfo(android.net.RouteInfo) LinkProperties(android.net.LinkProperties) InetAddress(java.net.InetAddress) SmallTest(android.test.suitebuilder.annotation.SmallTest) Suppress(android.test.suitebuilder.annotation.Suppress)

Aggregations

LinkProperties (android.net.LinkProperties)330 LinkAddress (android.net.LinkAddress)78 RouteInfo (android.net.RouteInfo)73 SmallTest (android.test.suitebuilder.annotation.SmallTest)68 InetAddress (java.net.InetAddress)56 Network (android.net.Network)43 NetworkInfo (android.net.NetworkInfo)40 NetworkAgentInfo (com.android.server.connectivity.NetworkAgentInfo)40 RemoteException (android.os.RemoteException)37 NetworkState (android.net.NetworkState)36 NetworkCapabilities (android.net.NetworkCapabilities)25 NetworkRequest (android.net.NetworkRequest)22 ArrayList (java.util.ArrayList)22 ProvisioningChange (android.net.LinkProperties.ProvisioningChange)20 Test (org.junit.Test)19 ConnectivityManager (android.net.ConnectivityManager)17 IpPrefix (android.net.IpPrefix)15 Inet6Address (java.net.Inet6Address)15 UnknownHostException (java.net.UnknownHostException)13 ApfFilter (android.net.apf.ApfFilter)12