summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-01-23 12:50:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-01-23 12:50:32 +0000
commitae38596bcf2a077753d170c0cad68f4dfde4277b (patch)
tree0daf4da76a183d22ead4be562652f9acda2ea4c0
parent3379c1cb62488393c2c49b5f38483656c7175fa1 (diff)
parent2dfb79a54adeb4bcf1f62332a9db467fce302ced (diff)
downloadframeworks_base-ae38596bcf2a077753d170c0cad68f4dfde4277b.zip
frameworks_base-ae38596bcf2a077753d170c0cad68f4dfde4277b.tar.gz
frameworks_base-ae38596bcf2a077753d170c0cad68f4dfde4277b.tar.bz2
Merge "Support connecting to networks with misconfigured subnet masks." into lmp-mr1-dev
-rw-r--r--core/java/android/net/StaticIpConfiguration.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/java/android/net/StaticIpConfiguration.java b/core/java/android/net/StaticIpConfiguration.java
index 598a503..365f2b6 100644
--- a/core/java/android/net/StaticIpConfiguration.java
+++ b/core/java/android/net/StaticIpConfiguration.java
@@ -76,15 +76,22 @@ public class StaticIpConfiguration implements Parcelable {
/**
* Returns the network routes specified by this object. Will typically include a
- * directly-connected route for the IP address's local subnet and a default route.
+ * directly-connected route for the IP address's local subnet and a default route. If the
+ * default gateway is not covered by the directly-connected route, it will also contain a host
+ * route to the gateway as well. This configuration is arguably invalid, but it used to work
+ * in K and earlier, and other OSes appear to accept it.
*/
public List<RouteInfo> getRoutes(String iface) {
- List<RouteInfo> routes = new ArrayList<RouteInfo>(2);
+ List<RouteInfo> routes = new ArrayList<RouteInfo>(3);
if (ipAddress != null) {
- routes.add(new RouteInfo(ipAddress, null, iface));
+ RouteInfo connectedRoute = new RouteInfo(ipAddress, null, iface);
+ routes.add(connectedRoute);
+ if (gateway != null && !connectedRoute.matches(gateway)) {
+ routes.add(RouteInfo.makeHostRoute(gateway, iface));
+ }
}
if (gateway != null) {
- routes.add(new RouteInfo((LinkAddress) null, gateway, iface));
+ routes.add(new RouteInfo((IpPrefix) null, gateway, iface));
}
return routes;
}