- java.lang.Object
-
- inet.ipaddr.ipv6.IPv6Address.IPv6Zone
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- IPv6Address
public static class IPv6Address.IPv6Zone extends java.lang.Object implements java.io.Serializable
A reference to a scope id by number or a network interface by name.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.
- Author:
- scfoley
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IPv6Zone(int scopeId)
Constructs a zone that will use a scope identifier with the address.IPv6Zone(java.lang.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.IPv6Zone(java.net.NetworkInterface networkInterface)
Constructs a zone that will use an interface name with the address.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.net.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 interfaceint
getAssociatedScopeId()
If this zone references a scoped identifier, returns that identifier.java.lang.String
getName()
int
hashCode()
boolean
referencesIntf()
Whether this zone references a network interface.boolean
referencesScopeId()
Whether this zone references a scope identifier.java.lang.String
toString()
-
-
-
Constructor Detail
-
IPv6Zone
public IPv6Zone(java.lang.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.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.- Parameters:
zoneStr
-
-
IPv6Zone
public IPv6Zone(int scopeId)
Constructs a zone that will use a scope identifier with the address.- Parameters:
scopeId
-
-
IPv6Zone
public IPv6Zone(java.net.NetworkInterface networkInterface)
Constructs a zone that will use an interface name with the address.- Parameters:
networkInterface
-
-
-
Method Detail
-
referencesIntf
public boolean referencesIntf()
Whether this zone references a network interface.- Returns:
-
referencesScopeId
public boolean referencesScopeId()
Whether this zone references a scope identifier.- Returns:
-
getAssociatedIntf
public java.net.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. If this zone references a scope id, returns the associated interface.- Returns:
-
getAssociatedIntfMacAddr
public MACAddress getAssociatedIntfMacAddr()
Returns the MAC address of the associated interface- Returns:
-
getAssociatedScopeId
public int getAssociatedScopeId()
If this zone references a scoped identifier, returns that identifier.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.
- Returns:
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getName
public java.lang.String getName()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-