Inet6Address class in Java

java.net.Inet6Address

This class represents an Internet Protocol version 6 (IPv6) address.

Textual representation of IP addresses Textual representation of IPv6 address used as input to the method takes one of the following forms:

1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the hexadecimal values of the eight 16-bit pieces of the address. This is the full form. For example, 1080:0:0:0:8:800:200C:417A

Note that it is not necessary to write the leading zeros in an individual field. However, there must be at least one numeral in every field, except as described below.

2. Due to some methods of allocating certain styles of IPv6addresses, it will be common for addresses to contain long strings of zero bits. In order to make writing addresses containing zero bits easier, a special syntax is available to compress the zeros. The use of "::" indicates multiple groups of 16-bits of zeros. The "::" can only appear once in an address. The "::" can also be used to compress the leading and/or trailing zeros in an address. For example, 1080::8:800:200C:417A

3. An alternative form that is sometimes more convenient when dealing with a mixed environment of IPv4 and IPv6 nodes is x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of the six high-order 16-bit pieces of the address and the 'd'sare the decimal values of the four low-order 8-bit pieces of the standard IPv4 representation address, for example,

::FFFF:129.144.52.38 ::129.144.52.38

where "::FFFF:d.d.d.d" and "::d.d.d.d" are, respectively, the general forms of an IPv4-mapped IPv6 address and anIPv4-compatible IPv6 address. Note that the IPv4 portion must be in the "d.d.d.d" form.

The following forms are invalid:

::FFFF:d.d.d ::FFFF:d.d ::d.d.d ::d.d

The following form:

::FFFF:d is valid, however, it is an unconventional representation of the IPv4-compatible IPv6 address, ::255.255.0.d while "::d" corresponds to the general IPv6 address"0:0:0:0:0:0:0:d".

For methods that return a textual representation as output value, the full form is used. Inet6Address will return the full form because it is unambiguous when used in combination with other textual data.

Some methods of Inet6Address class

equals(Object)This method compares this object against the specified object. The result is true if and only if the argument is not null and it represents the same IP address as this object.

getAddress()This method returns the raw IP address of this InetAddress object.

Inet6Address.getByAddress(String, byte[], int)This method creates an Inet6Address in the exact manner of InetAddress.getByAddress(String, byte []) except that the IPv6 scope_id is set to the given numeric value. The scope_id is not checked to determine it corresponds to any interface on the system.

Inet6Address.getByAddress(String, byte[], NetworkInterface)This method creates an Inet6Address in the exact manner of InetAddress.getByAddress(String, byte []) except that the IPv6 scope_id is set to the value corresponding to the given interface for the address type specified in addr.

getHostAddress()This method returns the IP address string in textual presentation.

getScopedInterface()This method would return the scoped interface if this instance was created with a scoped interface.

getScopeId()This method returns the numeric scopeId if this instance is associated with an interface.

hashCode()This method returns a hashcode for this IP address.

isAnyLocalAddress()Utility routine to check if the InetAddress is a wildcard address.

isIPv4CompatibleAddress()Utility routine to check if the InetAddress is an IPv4-compatible IPv6 address.

isLinkLocalAddress()Utility routine to check if the InetAddress is a link-local address.

isLoopbackAddress()Utility routine to check if the InetAddress is a loopback address.

isMCGlobal()Utility routine to check if the multicast address has global scope.

isMCLinkLocal()Utility routine to check if the multicast address has link scope.

isMCNodeLocal()Utility routine to check if the multicast address has node scope.

isMCOrgLocal()Utility routine to check if the multicast address has organization scope.

isMCSiteLocal()Utility routine to check if the multicast address has site scope.

isMulticastAddress()Utility routine to check if the InetAddress is an IP multicast address.

isSiteLocalAddress()Utility routine to check if the InetAddress is a site-local address.

No comments:

Post a Comment