diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-02-22 16:00:42 -0800 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-03-02 11:37:32 -0800 |
commit | e590373ea71251cfffc8f22f011e2e6335dce716 (patch) | |
tree | 4fb1c57267a51143b6a0ebaf10174ae89280b6c2 /wifi/java | |
parent | 0390191392e62314d9dfeba655f737a0e2594950 (diff) | |
download | frameworks_base-e590373ea71251cfffc8f22f011e2e6335dce716.zip frameworks_base-e590373ea71251cfffc8f22f011e2e6335dce716.tar.gz frameworks_base-e590373ea71251cfffc8f22f011e2e6335dce716.tar.bz2 |
Start using NetworkUtils.numericToInetAddress.
Generates InetAddresses without risking an accidental dns lookup. For use with supposedly
numeric-only ip address strings.
Change-Id: I694f3976ce1c6382854706f6557ea88a289add3a
Diffstat (limited to 'wifi/java')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 12 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index d411715..f6317f5 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -686,13 +686,15 @@ class WifiConfigStore { } else if (key.equals(IP_ASSIGNMENT_KEY)) { ipAssignment = IpAssignment.valueOf(in.readUTF()); } else if (key.equals(LINK_ADDRESS_KEY)) { - LinkAddress linkAddr = new LinkAddress(InetAddress.getByName( - in.readUTF()), in.readInt()); + LinkAddress linkAddr = new LinkAddress( + NetworkUtils.numericToInetAddress(in.readUTF()), in.readInt()); linkProperties.addLinkAddress(linkAddr); } else if (key.equals(GATEWAY_KEY)) { - linkProperties.addGateway(InetAddress.getByName(in.readUTF())); + linkProperties.addGateway( + NetworkUtils.numericToInetAddress(in.readUTF())); } else if (key.equals(DNS_KEY)) { - linkProperties.addDns(InetAddress.getByName(in.readUTF())); + linkProperties.addDns( + NetworkUtils.numericToInetAddress(in.readUTF())); } else if (key.equals(PROXY_SETTINGS_KEY)) { proxySettings = ProxySettings.valueOf(in.readUTF()); } else if (key.equals(PROXY_HOST_KEY)) { @@ -706,7 +708,7 @@ class WifiConfigStore { } else { Log.e(TAG, "Ignore unknown key " + key + "while reading"); } - } catch (UnknownHostException e) { + } catch (IllegalArgumentException e) { Log.e(TAG, "Ignore invalid address while reading" + e); } } while (true); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index fc42ab8..b21f025 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -999,7 +999,8 @@ public class WifiStateMachine extends HierarchicalStateMachine { ifcg = service.getInterfaceConfig(intf); if (ifcg != null) { /* IP/netmask: 192.168.43.1/255.255.255.0 */ - ifcg.addr = new LinkAddress(InetAddress.getByName("192.168.43.1"), 24); + ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress( + "192.168.43.1"), 24); ifcg.interfaceFlags = "[up]"; service.setInterfaceConfig(intf, ifcg); |