diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2014-06-11 23:42:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-10 22:12:51 +0000 |
commit | 594b456b6e2aa4142fa31394cdd39bd4cc7a1d3a (patch) | |
tree | 9342b3f7822dbfd3faba2b7dcbb491f62f3303c1 /core/java/android/net | |
parent | 55213c80229cc9cbec328f0ec9a842f5d66c35c2 (diff) | |
parent | 00a0fd650b7a31dffb88c229242bb04fa0b487a4 (diff) | |
download | frameworks_base-594b456b6e2aa4142fa31394cdd39bd4cc7a1d3a.zip frameworks_base-594b456b6e2aa4142fa31394cdd39bd4cc7a1d3a.tar.gz frameworks_base-594b456b6e2aa4142fa31394cdd39bd4cc7a1d3a.tar.bz2 |
Merge "Minor changes to the LinkAddress API docs." into lmp-preview-dev
Diffstat (limited to 'core/java/android/net')
-rw-r--r-- | core/java/android/net/LinkAddress.java | 35 | ||||
-rw-r--r-- | core/java/android/net/RouteInfo.java | 18 |
2 files changed, 30 insertions, 23 deletions
diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java index d07c0b61..5246078 100644 --- a/core/java/android/net/LinkAddress.java +++ b/core/java/android/net/LinkAddress.java @@ -39,18 +39,13 @@ import static android.system.OsConstants.RT_SCOPE_UNIVERSE; * <ul> * <li>An IP address and prefix length (e.g., {@code 2001:db8::1/64} or {@code 192.0.2.1/24}). * The address must be unicast, as multicast addresses cannot be assigned to interfaces. - * <li>Address flags: A bitmask of {@code IFA_F_*} values representing properties - * of the address. - * <li>Address scope: An integer defining the scope in which the address is unique (e.g., - * {@code RT_SCOPE_LINK} or {@code RT_SCOPE_SITE}). - * <ul> - *<p> - * When constructing a {@code LinkAddress}, the IP address and prefix are required. The flags and - * scope are optional. If they are not specified, the flags are set to zero, and the scope will be - * determined based on the IP address (e.g., link-local addresses will be created with a scope of - * {@code RT_SCOPE_LINK}, global addresses with {@code RT_SCOPE_UNIVERSE}, - * etc.) If they are specified, they are not checked for validity. - * + * <li>Address flags: A bitmask of {@code OsConstants.IFA_F_*} values representing properties + * of the address (e.g., {@code android.system.OsConstants.IFA_F_OPTIMISTIC}). + * <li>Address scope: One of the {@code OsConstants.IFA_F_*} values; defines the scope in which + * the address is unique (e.g., + * {@code android.system.OsConstants.RT_SCOPE_LINK} or + * {@code android.system.OsConstants.RT_SCOPE_UNIVERSE}). + * </ul> */ public class LinkAddress implements Parcelable { /** @@ -202,7 +197,9 @@ public class LinkAddress implements Parcelable { /** * Compares this {@code LinkAddress} instance against {@code obj}. Two addresses are equal if - * their address, prefix length, flags and scope are equal. + * their address, prefix length, flags and scope are equal. Thus, for example, two addresses + * that have the same address and prefix length are not equal if one of them is deprecated and + * the other is not. * * @param obj the object to be tested for equality. * @return {@code true} if both objects are equal, {@code false} otherwise. @@ -236,6 +233,7 @@ public class LinkAddress implements Parcelable { * @param other the {@code LinkAddress} to compare to. * @return {@code true} if both objects have the same address and prefix length, {@code false} * otherwise. + * @hide */ public boolean isSameAddressAs(LinkAddress other) { return address.equals(other.address) && prefixLength == other.prefixLength; @@ -251,11 +249,20 @@ public class LinkAddress implements Parcelable { /** * Returns the prefix length of this {@code LinkAddress}. */ - public int getNetworkPrefixLength() { + public int getPrefixLength() { return prefixLength; } /** + * Returns the prefix length of this {@code LinkAddress}. + * TODO: Delete all callers and remove in favour of getPrefixLength(). + * @hide + */ + public int getNetworkPrefixLength() { + return getPrefixLength(); + } + + /** * Returns the flags of this {@code LinkAddress}. */ public int getFlags() { diff --git a/core/java/android/net/RouteInfo.java b/core/java/android/net/RouteInfo.java index 6d65d8f..51ed4f7 100644 --- a/core/java/android/net/RouteInfo.java +++ b/core/java/android/net/RouteInfo.java @@ -119,7 +119,7 @@ public final class RouteInfo implements Parcelable { mHasGateway = (!gateway.isAnyLocalAddress()); mDestination = new LinkAddress(NetworkUtils.getNetworkPart(destination.getAddress(), - destination.getNetworkPrefixLength()), destination.getNetworkPrefixLength()); + destination.getPrefixLength()), destination.getPrefixLength()); if ((destination.getAddress() instanceof Inet4Address && (gateway instanceof Inet4Address == false)) || (destination.getAddress() instanceof Inet6Address && @@ -210,18 +210,18 @@ public final class RouteInfo implements Parcelable { private boolean isHost() { return (mDestination.getAddress() instanceof Inet4Address && - mDestination.getNetworkPrefixLength() == 32) || + mDestination.getPrefixLength() == 32) || (mDestination.getAddress() instanceof Inet6Address && - mDestination.getNetworkPrefixLength() == 128); + mDestination.getPrefixLength() == 128); } private boolean isDefault() { boolean val = false; if (mGateway != null) { if (mGateway instanceof Inet4Address) { - val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0); + val = (mDestination == null || mDestination.getPrefixLength() == 0); } else { - val = (mDestination == null || mDestination.getNetworkPrefixLength() == 0); + val = (mDestination == null || mDestination.getPrefixLength() == 0); } } return val; @@ -306,7 +306,7 @@ public final class RouteInfo implements Parcelable { // match the route destination and destination with prefix length InetAddress dstNet = NetworkUtils.getNetworkPart(destination, - mDestination.getNetworkPrefixLength()); + mDestination.getPrefixLength()); return mDestination.getAddress().equals(dstNet); } @@ -328,8 +328,8 @@ public final class RouteInfo implements Parcelable { for (RouteInfo route : routes) { if (NetworkUtils.addressTypeMatches(route.mDestination.getAddress(), dest)) { if ((bestRoute != null) && - (bestRoute.mDestination.getNetworkPrefixLength() >= - route.mDestination.getNetworkPrefixLength())) { + (bestRoute.mDestination.getPrefixLength() >= + route.mDestination.getPrefixLength())) { continue; } if (route.matches(dest)) bestRoute = route; @@ -392,7 +392,7 @@ public final class RouteInfo implements Parcelable { } else { dest.writeByte((byte) 1); dest.writeByteArray(mDestination.getAddress().getAddress()); - dest.writeInt(mDestination.getNetworkPrefixLength()); + dest.writeInt(mDestination.getPrefixLength()); } if (mGateway == null) { |