public final class LinkProperties extends Object implements Parcelable
Modifier and Type | Class and Description |
---|---|
static class |
LinkProperties.CompareResult<T> |
static class |
LinkProperties.ProvisioningChange |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<LinkProperties> |
CREATOR
Implement the Parcelable interface.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
LinkProperties() |
LinkProperties(LinkProperties source) |
Modifier and Type | Method and Description |
---|---|
boolean |
addDnsServer(InetAddress dnsServer)
Adds the given
InetAddress to the list of DNS servers, if not present. |
boolean |
addLinkAddress(LinkAddress address)
Adds a
LinkAddress to this LinkProperties if a LinkAddress of the
same address/prefix does not already exist. |
boolean |
addRoute(RouteInfo route)
Adds a
RouteInfo to this LinkProperties , if not present. |
boolean |
addStackedLink(LinkProperties link)
Adds a stacked link.
|
void |
clear()
Clears this object to its initial state.
|
LinkProperties.CompareResult<LinkAddress> |
compareAddresses(LinkProperties target)
Compares the addresses in this LinkProperties with another
LinkProperties, examining only addresses on the base link.
|
LinkProperties.CompareResult<String> |
compareAllInterfaceNames(LinkProperties target)
Compares all interface names in this LinkProperties with another
LinkProperties, examining both the the base link and all stacked links.
|
LinkProperties.CompareResult<RouteInfo> |
compareAllRoutes(LinkProperties target)
Compares all routes in this LinkProperties with another LinkProperties,
examining both the the base link and all stacked links.
|
LinkProperties.CompareResult<InetAddress> |
compareDnses(LinkProperties target)
Compares the DNS addresses in this LinkProperties with another
LinkProperties, examining only DNS addresses on the base link.
|
static LinkProperties.ProvisioningChange |
compareProvisioning(LinkProperties before,
LinkProperties after)
Compare the provisioning states of two LinkProperties instances.
|
int |
describeContents()
Implement the Parcelable interface
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
List<InetAddress> |
getAddresses()
Returns all the addresses on this link.
|
List<InetAddress> |
getAllAddresses()
Returns all the addresses on this link and all the links stacked above it.
|
List<String> |
getAllInterfaceNames() |
List<LinkAddress> |
getAllLinkAddresses()
Returns all the addresses on this link and all the links stacked above it.
|
List<RouteInfo> |
getAllRoutes()
Returns all the routes on this link and all the links stacked above it.
|
List<InetAddress> |
getDnsServers()
Returns all the
InetAddress for DNS servers on this link. |
String |
getDomains()
Get the DNS domains search path set for this link.
|
ProxyInfo |
getHttpProxy()
Gets the recommended
ProxyInfo (or null ) set on this link. |
String |
getInterfaceName()
Gets the interface name for this link.
|
List<LinkAddress> |
getLinkAddresses()
Returns all the
LinkAddress on this link. |
int |
getMtu()
Gets any non-default MTU size set for this link.
|
List<RouteInfo> |
getRoutes()
Returns all the
RouteInfo set on this link. |
List<LinkProperties> |
getStackedLinks()
Returns all the links stacked on top of this link.
|
String |
getTcpBufferSizes()
Gets the tcp buffer sizes.
|
boolean |
hasGlobalIPv6Address()
Returns true if this link has a global preferred IPv6 address.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
hasIPv4Address()
Returns true if this link has an IPv4 address.
|
boolean |
hasIPv4DefaultRoute()
Returns true if this link has an IPv4 default route.
|
boolean |
hasIPv4DnsServer()
Returns true if this link has an IPv4 DNS server.
|
boolean |
hasIPv6DefaultRoute()
Returns true if this link has an IPv6 default route.
|
boolean |
hasIPv6DnsServer()
Returns true if this link has an IPv6 DNS server.
|
boolean |
isIdenticalAddresses(LinkProperties target)
Compares this
LinkProperties interface addresses against the target |
boolean |
isIdenticalDnses(LinkProperties target)
Compares this
LinkProperties DNS addresses against the target |
boolean |
isIdenticalHttpProxy(LinkProperties target)
Compares this
LinkProperties HttpProxy against the target |
boolean |
isIdenticalInterfaceName(LinkProperties target)
Compares this
LinkProperties interface name against the target |
boolean |
isIdenticalMtu(LinkProperties target)
Compares this
LinkProperties MTU against the target |
boolean |
isIdenticalRoutes(LinkProperties target)
Compares this
LinkProperties Routes against the target |
boolean |
isIdenticalStackedLinks(LinkProperties target)
Compares this
LinkProperties stacked links against the target |
boolean |
isIdenticalTcpBufferSizes(LinkProperties target)
Compares this
LinkProperties Tcp buffer sizes against the target. |
boolean |
isIPv4Provisioned()
Returns true if this link is provisioned for global IPv4 connectivity.
|
boolean |
isIPv6Provisioned()
Returns true if this link is provisioned for global IPv6 connectivity.
|
boolean |
isProvisioned()
Returns true if this link is provisioned for global connectivity,
for at least one Internet Protocol family.
|
boolean |
isReachable(InetAddress ip)
Evaluate whether the
InetAddress is considered reachable. |
static boolean |
isValidMtu(int mtu,
boolean ipv6)
Check the valid MTU range based on IPv4 or IPv6.
|
boolean |
removeDnsServer(InetAddress dnsServer)
Removes the given
InetAddress from the list of DNS servers. |
boolean |
removeLinkAddress(LinkAddress toRemove)
Removes a
LinkAddress from this LinkProperties . |
boolean |
removeRoute(RouteInfo route)
Removes a
RouteInfo from this LinkProperties , if present. |
boolean |
removeStackedLink(String iface)
Removes a stacked link.
|
void |
setDnsServers(Collection<InetAddress> dnsServers)
|
void |
setDomains(String domains)
Sets the DNS domain search path used on this link.
|
void |
setHttpProxy(ProxyInfo proxy)
Sets the recommended
ProxyInfo to use on this link, or null for none. |
void |
setInterfaceName(String iface)
Sets the interface name for this link.
|
void |
setLinkAddresses(Collection<LinkAddress> addresses)
|
void |
setMtu(int mtu)
Sets the Maximum Transmission Unit size to use on this link.
|
void |
setTcpBufferSizes(String tcpBufferSizes)
Sets the tcp buffers sizes to be used when this link is the system default.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Implement the Parcelable interface.
|
public static final Parcelable.Creator<LinkProperties> CREATOR
public LinkProperties()
public LinkProperties(LinkProperties source)
public static LinkProperties.ProvisioningChange compareProvisioning(LinkProperties before, LinkProperties after)
public void setInterfaceName(String iface)
RouteInfo
already set for this
will have their interface changed to match this new value.iface
- The name of the network interface used for this link.public String getInterfaceName()
null
if not set.null
.public List<InetAddress> getAddresses()
LinkProperties
actually contains LinkAddress
objects which also include
prefix lengths for each address. This is a simplified utility alternative to
getLinkAddresses()
.List
of InetAddress
for this link.public List<InetAddress> getAllAddresses()
public boolean addLinkAddress(LinkAddress address)
LinkAddress
to this LinkProperties
if a LinkAddress
of the
same address/prefix does not already exist. If it does exist it is replaced.address
- The LinkAddress
to add.address
was added or updated, false otherwise.public boolean removeLinkAddress(LinkAddress toRemove)
LinkAddress
from this LinkProperties
. Specifically, matches
and LinkAddress
with the same address and prefix.toRemove
- A LinkAddress
specifying the address to remove.public List<LinkAddress> getLinkAddresses()
LinkAddress
on this link. Typically a link will have
one IPv4 address and one or more IPv6 addresses.List
of LinkAddress
for this link.public List<LinkAddress> getAllLinkAddresses()
public void setLinkAddresses(Collection<LinkAddress> addresses)
addresses
- The Collection
of LinkAddress
to set in this
object.public boolean addDnsServer(InetAddress dnsServer)
InetAddress
to the list of DNS servers, if not present.dnsServer
- The InetAddress
to add to the list of DNS servers.public boolean removeDnsServer(InetAddress dnsServer)
InetAddress
from the list of DNS servers.dnsServer
- The InetAddress
to remove from the list of DNS servers.public void setDnsServers(Collection<InetAddress> dnsServers)
addresses
- The Collection
of DNS servers to set in this object.public List<InetAddress> getDnsServers()
InetAddress
for DNS servers on this link.List
of InetAddress
for DNS servers on
this link.public void setDomains(String domains)
domains
- A String
listing in priority order the comma separated
domains to search when resolving host names on this link.public String getDomains()
String
containing the comma separated domains to search when resolving
host names on this link.public void setMtu(int mtu)
mtu
- The MTU to use for this link.public int getMtu()
public void setTcpBufferSizes(String tcpBufferSizes)
tcpBufferSizes
- The tcp buffers sizes to use.public String getTcpBufferSizes()
public boolean addRoute(RouteInfo route)
RouteInfo
to this LinkProperties
, if not present. If the
RouteInfo
had an interface name set and that differs from the interface set for this
LinkProperties
an IllegalArgumentException
will be thrown. The proper
course is to add either un-named or properly named RouteInfo
.route
- A RouteInfo
to add to this object.false
if the route was already present, true
if it was added.public boolean removeRoute(RouteInfo route)
RouteInfo
from this LinkProperties
, if present. The route must
specify an interface and the interface must match the interface of this
LinkProperties
, or it will not be removed.true
if the route was removed, false
if it was not present.public List<RouteInfo> getAllRoutes()
public void setHttpProxy(ProxyInfo proxy)
ProxyInfo
to use on this link, or null
for none.
Note that Http Proxies are only a hint - the system recommends their use, but it does
not enforce it and applications may ignore them.proxy
- A ProxyInfo
defining the HTTP Proxy to use on this link.public ProxyInfo getHttpProxy()
ProxyInfo
(or null
) set on this link.ProxyInfo
set on this linkpublic boolean addStackedLink(LinkProperties link)
link
- The link to add.public boolean removeStackedLink(String iface)
iface
- The interface name of the link to remove.public List<LinkProperties> getStackedLinks()
public void clear()
public int describeContents()
describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public boolean hasIPv4Address()
true
if there is an IPv4 address, false
otherwise.public boolean hasGlobalIPv6Address()
true
if there is a global preferred IPv6 address, false
otherwise.public boolean hasIPv4DefaultRoute()
true
if there is an IPv4 default route, false
otherwise.public boolean hasIPv6DefaultRoute()
true
if there is an IPv6 default route, false
otherwise.public boolean hasIPv4DnsServer()
true
if there is an IPv4 DNS server, false
otherwise.public boolean hasIPv6DnsServer()
true
if there is an IPv6 DNS server, false
otherwise.public boolean isIPv4Provisioned()
true
if the link is provisioned, false
otherwise.public boolean isIPv6Provisioned()
true
if the link is provisioned, false
otherwise.public boolean isProvisioned()
true
if the link is provisioned, false
otherwise.public boolean isReachable(InetAddress ip)
InetAddress
is considered reachable.true
if the given InetAddress
is considered reachable,
false
otherwise.public boolean isIdenticalInterfaceName(LinkProperties target)
LinkProperties
interface name against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalAddresses(LinkProperties target)
LinkProperties
interface addresses against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalDnses(LinkProperties target)
LinkProperties
DNS addresses against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalRoutes(LinkProperties target)
LinkProperties
Routes against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalHttpProxy(LinkProperties target)
LinkProperties
HttpProxy against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalStackedLinks(LinkProperties target)
LinkProperties
stacked links against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalMtu(LinkProperties target)
LinkProperties
MTU against the targettarget
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean isIdenticalTcpBufferSizes(LinkProperties target)
LinkProperties
Tcp buffer sizes against the target.target
- LinkProperties to compare.true
if both are identical, false
otherwise.public boolean equals(Object obj)
Object
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
equals
in class Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public LinkProperties.CompareResult<LinkAddress> compareAddresses(LinkProperties target)
target
- a LinkProperties with the new list of addressespublic LinkProperties.CompareResult<InetAddress> compareDnses(LinkProperties target)
target
- a LinkProperties with the new list of dns addressespublic LinkProperties.CompareResult<RouteInfo> compareAllRoutes(LinkProperties target)
target
- a LinkProperties with the new list of routespublic LinkProperties.CompareResult<String> compareAllInterfaceNames(LinkProperties target)
target
- a LinkProperties with the new list of interface namespublic int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public void writeToParcel(Parcel dest, int flags)
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public static boolean isValidMtu(int mtu, boolean ipv6)