public static class IPv6Address.IPv6Zone extends Object implements Serializable
An IPv6 zone distinguishes two IPv6 addresses that are the same. They are used with link-local addresses fe80::/10 to distinguish two interfaces to the link-local network, this is known as the zone id. They are used with site-local addresses to distinguish sites, using the site id, also known as the scope id.
A zone that consists of a scope id is called a scoped zone.
An IPv6 zone will reference an interface by a scoped identifier number or by interface name based on how it was constructed. If constructed with a numeric identifier, whether integer or string, it will always reference by scoped identifier. Otherwise, it will always reference by interface name.
Once constructed, it will always reference using the same method, either interface name or scope id. To reference by the other method you must use a different IPv6Zone instance.
Even though it will always reference using the same method, you can use the IPv6Zone instance to look up the scope id if the instance references by interface name, or to look up the associated interface if the instance references by scope id.
Constructor and Description |
---|
IPv6Zone(int scopeId)
Constructs a zone that will use a scope identifier with the address.
|
IPv6Zone(NetworkInterface networkInterface)
Constructs a zone that will use an interface name with the address.
|
IPv6Zone(String zoneStr)
Constructs a zone that will use the given zone string,
either a non-negative integer indicating a scope identifier,
or the name of a network interface.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
NetworkInterface |
getAssociatedIntf()
If this zone references a network interface, returns that interface,
or null if no interface with the given name exists on the system.
|
MACAddress |
getAssociatedIntfMacAddr()
Returns the MAC address of the associated interface
|
int |
getAssociatedScopeId()
If this zone references a scoped identifier, returns that identifier.
|
String |
getName() |
int |
hashCode() |
boolean |
referencesIntf()
Whether this zone references a network interface.
|
boolean |
referencesScopeId()
Whether this zone references a scope identifier.
|
String |
toString() |
public IPv6Zone(String zoneStr)
A scope identifier is indicated by a sequence of decimal digits.
To create an InetAddress by pairing this zone with an IPv6Address instance, an interface name must reference an existing interface, otherwise the InetAddress cannot be created.
See NetworkInterface
to get a list of existing interfaces or to look up interfaces by name.
zoneStr
- public IPv6Zone(int scopeId)
scopeId
- public IPv6Zone(NetworkInterface networkInterface)
networkInterface
- public boolean referencesIntf()
public boolean referencesScopeId()
public NetworkInterface getAssociatedIntf()
public MACAddress getAssociatedIntfMacAddr()
public int getAssociatedScopeId()
If this zone references a network interface, returns the scope identifier for the addresses of that interface, or -1 if the referenced interface cannot be found on the system, or no single scope identifier was assigned.
public String getName()