diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2013-03-27 13:07:18 +0900 |
---|---|---|
committer | Lorenzo Colitti <lorenzo@google.com> | 2013-03-27 19:41:06 +0900 |
commit | fdadc4e242d987c09007df274e01fe678a82331f (patch) | |
tree | f30ab0da5795acb37dd91e982974cb309685c4f8 /core/java/android | |
parent | 05191053545065c9c71afae173d3ab42a2d947fa (diff) | |
download | frameworks_base-fdadc4e242d987c09007df274e01fe678a82331f.zip frameworks_base-fdadc4e242d987c09007df274e01fe678a82331f.tar.gz frameworks_base-fdadc4e242d987c09007df274e01fe678a82331f.tar.bz2 |
Make isHostRoute match only host routes
Currently, isHostRoute returns true iff the gateway address is
the unspecified address (0.0.0.0 or ::). Thus, it will return
true for any route that has no gateway (e.g., a route pointing at
a point-to-point interface), even if the route is not a host
route.
Fix this by checking the prefix length instead. This should be
safe because:
1. mDestination cannot be null, since it's created using new.
2. Host routes created using makeHostRoute (which is what
ConnectivityService calls) always have the correct prefix
lengths (/32 or /128) set.
Bug: 8276725
Change-Id: I14285398823fa6c312349128c7cc216cad4a84c9
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/net/RouteInfo.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java index 3a7abc0..cc3c5f7 100644 --- a/core/java/android/net/RouteInfo.java +++ b/core/java/android/net/RouteInfo.java @@ -132,7 +132,10 @@ public class RouteInfo implements Parcelable { } private boolean isHost() { - return (mGateway.equals(Inet4Address.ANY) || mGateway.equals(Inet6Address.ANY)); + return (mDestination.getAddress() instanceof Inet4Address && + mDestination.getNetworkPrefixLength() == 32) || + (mDestination.getAddress() instanceof Inet6Address && + mDestination.getNetworkPrefixLength() == 128); } private boolean isDefault() { |