diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-02-09 13:56:06 -0800 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-02-11 11:06:23 -0800 |
commit | 992564e481af13cbcb058ee801f9254a520c54a1 (patch) | |
tree | 9613622a5b5d7763a6f14c685533813f9a31c476 /wifi | |
parent | 2157f045d3579cb789d7c2c4f892724c7b0b1b39 (diff) | |
download | frameworks_base-992564e481af13cbcb058ee801f9254a520c54a1.zip frameworks_base-992564e481af13cbcb058ee801f9254a520c54a1.tar.gz frameworks_base-992564e481af13cbcb058ee801f9254a520c54a1.tar.bz2 |
Update LinkProperties treatment of gateways
A link can have multiple gateways (think ipv4/ipv6 for a trivial example).
.
bug:3438810
Change-Id: I28c90a6947cd50b82e5ca9a0113148f98b3f4dd8
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index 55d1844..d411715 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -445,7 +445,10 @@ class WifiConfigStore { if (iter.hasNext()) { LinkAddress linkAddress = iter.next(); dhcpInfoInternal.ipAddress = linkAddress.getAddress().getHostAddress(); - dhcpInfoInternal.gateway = linkProperties.getGateway().getHostAddress(); + Iterator<InetAddress>gateways = linkProperties.getGateways().iterator(); + if (gateways.hasNext()) { + dhcpInfoInternal.gateway = gateways.next().getHostAddress(); + } dhcpInfoInternal.prefixLength = linkAddress.getNetworkPrefixLength(); Iterator<InetAddress> dnsIterator = linkProperties.getDnses().iterator(); dhcpInfoInternal.dns1 = dnsIterator.next().getHostAddress(); @@ -582,8 +585,7 @@ class WifiConfigStore { out.writeUTF(linkAddr.getAddress().getHostAddress()); out.writeInt(linkAddr.getNetworkPrefixLength()); } - InetAddress gateway = linkProperties.getGateway(); - if (gateway != null) { + for (InetAddress gateway : linkProperties.getGateways()) { out.writeUTF(GATEWAY_KEY); out.writeUTF(gateway.getHostAddress()); } @@ -688,7 +690,7 @@ class WifiConfigStore { in.readUTF()), in.readInt()); linkProperties.addLinkAddress(linkAddr); } else if (key.equals(GATEWAY_KEY)) { - linkProperties.setGateway(InetAddress.getByName(in.readUTF())); + linkProperties.addGateway(InetAddress.getByName(in.readUTF())); } else if (key.equals(DNS_KEY)) { linkProperties.addDns(InetAddress.getByName(in.readUTF())); } else if (key.equals(PROXY_SETTINGS_KEY)) { @@ -999,15 +1001,17 @@ class WifiConfigStore { .getLinkAddresses(); Collection<InetAddress> currentDnses = currentConfig.linkProperties.getDnses(); Collection<InetAddress> newDnses = newConfig.linkProperties.getDnses(); - InetAddress currentGateway = currentConfig.linkProperties.getGateway(); - InetAddress newGateway = newConfig.linkProperties.getGateway(); - - boolean linkAddressesDiffer = !currentLinkAddresses.containsAll(newLinkAddresses) || - (currentLinkAddresses.size() != newLinkAddresses.size()); - boolean dnsesDiffer = !currentDnses.containsAll(newDnses) || - (currentDnses.size() != newDnses.size()); - boolean gatewaysDiffer = (currentGateway == null) || - !currentGateway.equals(newGateway); + Collection<InetAddress> currentGateways = + currentConfig.linkProperties.getGateways(); + Collection<InetAddress> newGateways = newConfig.linkProperties.getGateways(); + + boolean linkAddressesDiffer = + (currentLinkAddresses.size() != newLinkAddresses.size()) || + !currentLinkAddresses.containsAll(newLinkAddresses); + boolean dnsesDiffer = (currentDnses.size() != newDnses.size()) || + !currentDnses.containsAll(newDnses); + boolean gatewaysDiffer = (currentGateways.size() != newGateways.size()) || + !currentGateways.containsAll(newGateways); if ((currentConfig.ipAssignment != newConfig.ipAssignment) || linkAddressesDiffer || @@ -1087,7 +1091,9 @@ class WifiConfigStore { for (LinkAddress linkAddr : config.linkProperties.getLinkAddresses()) { linkProperties.addLinkAddress(linkAddr); } - linkProperties.setGateway(config.linkProperties.getGateway()); + for (InetAddress gateway : config.linkProperties.getGateways()) { + linkProperties.addGateway(gateway); + } for (InetAddress dns : config.linkProperties.getDnses()) { linkProperties.addDns(dns); } |