Filter out addresses that are 0.

If the address is "any" address, i.e. an address which is all zeros
for both IPv4 and IPv6 ignore it.

Bug: 5073048
Change-Id: I8b9f64103aaffd001114a672375ff5f99616c327
This commit is contained in:
Wink Saville
2011-07-25 15:26:56 -07:00
parent deb62be2e8
commit 32d106e154

View File

@@ -142,13 +142,15 @@ public class DataCallState {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new UnknownHostException("Non-numeric ip addr=" + addr); throw new UnknownHostException("Non-numeric ip addr=" + addr);
} }
if (addrPrefixLen == 0) { if (! ia.isAnyLocalAddress()) {
// Assume point to point if (addrPrefixLen == 0) {
addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128; // Assume point to point
addrPrefixLen = (ia instanceof Inet4Address) ? 32 : 128;
}
if (DBG) Log.d(LOG_TAG, "addr/pl=" + addr + "/" + addrPrefixLen);
la = new LinkAddress(ia, addrPrefixLen);
linkProperties.addLinkAddress(la);
} }
if (DBG) Log.d(LOG_TAG, "addr/pl=" + addr + "/" + addrPrefixLen);
la = new LinkAddress(ia, addrPrefixLen);
linkProperties.addLinkAddress(la);
} }
} else { } else {
throw new UnknownHostException("no address for ifname=" + ifname); throw new UnknownHostException("no address for ifname=" + ifname);
@@ -163,21 +165,24 @@ public class DataCallState {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new UnknownHostException("Non-numeric dns addr=" + addr); throw new UnknownHostException("Non-numeric dns addr=" + addr);
} }
linkProperties.addDns(ia); if (! ia.isAnyLocalAddress()) {
linkProperties.addDns(ia);
}
} }
} else if (okToUseSystemPropertyDns){ } else if (okToUseSystemPropertyDns){
String dnsServers[] = new String[2]; String dnsServers[] = new String[2];
dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1");
dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2");
for (String dnsAddr : dnsServers) { for (String dnsAddr : dnsServers) {
InetAddress ia; InetAddress ia;
try { try {
ia = NetworkUtils.numericToInetAddress(dnsAddr); ia = NetworkUtils.numericToInetAddress(dnsAddr);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new UnknownHostException("Non-numeric dns addr=" throw new UnknownHostException("Non-numeric dns addr=" + dnsAddr);
+ dnsAddr); }
} if (! ia.isAnyLocalAddress()) {
linkProperties.addDns(ia); linkProperties.addDns(ia);
}
} }
} else { } else {
throw new UnknownHostException("Empty dns response and no system default dns"); throw new UnknownHostException("Empty dns response and no system default dns");
@@ -199,7 +204,9 @@ public class DataCallState {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw new UnknownHostException("Non-numeric gateway addr=" + addr); throw new UnknownHostException("Non-numeric gateway addr=" + addr);
} }
linkProperties.addRoute(new RouteInfo(ia)); if (! ia.isAnyLocalAddress()) {
linkProperties.addRoute(new RouteInfo(ia));
}
} }
result = SetupResult.SUCCESS; result = SetupResult.SUCCESS;