Module inet.ipaddr

Class IPv6Address.IPv6Zone

java.lang.Object
inet.ipaddr.ipv6.IPv6Address.IPv6Zone
All Implemented Interfaces:
Serializable
Enclosing class:
IPv6Address

public static class IPv6Address.IPv6Zone extends Object implements 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:
  • Constructor Details

    • IPv6Zone

      public 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.

      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(NetworkInterface networkInterface)
      Constructs a zone that will use an interface name with the address.
      Parameters:
      networkInterface -
  • Method Details

    • 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 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 class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getName

      public String getName()
    • toString

      public String toString()
      Overrides:
      toString in class Object