Add android.net.IpPrefix#contains()
This was originally to avoid RuntimeException in RouteInfo#matches():
When an IPv6 prefix with a length greater than the max permitted
for IPv4 is matched against an Inet4Address, the call to
NetworkUtils throws RuntimeException.
Change-Id: I92e2bd19a4e7d656cf682fd27678da07e211850d
This commit is contained in:
parent
d1027f5338
commit
b98afb001c
1 changed files with 49 additions and 7 deletions
|
|
@ -367,13 +367,7 @@ public final class RouteInfo implements Parcelable {
|
|||
* @return {@code true} if the destination and prefix length cover the given address.
|
||||
*/
|
||||
public boolean matches(InetAddress destination) {
|
||||
if (destination == null) return false;
|
||||
|
||||
// match the route destination and destination with prefix length
|
||||
InetAddress dstNet = NetworkUtils.getNetworkPart(destination,
|
||||
mDestination.getPrefixLength());
|
||||
|
||||
return mDestination.getAddress().equals(dstNet);
|
||||
return mDestination.contains(destination);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue