Merge "Move shared methods to net shared lib"

This commit is contained in:
Chiachang Wang
2021-02-23 00:58:59 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 44 deletions

View File

@@ -24,6 +24,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.util.Pair;
import com.android.net.module.util.NetUtils;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -59,7 +61,7 @@ public final class IpPrefix implements Parcelable {
throw new IllegalArgumentException(
"IpPrefix has " + address.length + " bytes which is neither 4 nor 16");
}
NetworkUtils.maskRawAddress(address, prefixLength);
NetUtils.maskRawAddress(address, prefixLength);
}
/**
@@ -190,7 +192,7 @@ public final class IpPrefix implements Parcelable {
if (addrBytes == null || addrBytes.length != this.address.length) {
return false;
}
NetworkUtils.maskRawAddress(addrBytes, prefixLength);
NetUtils.maskRawAddress(addrBytes, prefixLength);
return Arrays.equals(this.address, addrBytes);
}
@@ -204,7 +206,7 @@ public final class IpPrefix implements Parcelable {
public boolean containsPrefix(@NonNull IpPrefix otherPrefix) {
if (otherPrefix.getPrefixLength() < prefixLength) return false;
final byte[] otherAddress = otherPrefix.getRawAddress();
NetworkUtils.maskRawAddress(otherAddress, prefixLength);
NetUtils.maskRawAddress(otherAddress, prefixLength);
return Arrays.equals(otherAddress, address);
}