Package org.jruby.ext.socket
Class SocketUtilsIPV6.IPv6Address
java.lang.Object
org.jruby.ext.socket.SocketUtilsIPV6.IPv6Address
- Enclosing class:
SocketUtilsIPV6
-
Method Summary
Modifier and TypeMethodDescriptionadd
(int value) Addition.fromString
(String string) Create an IPv6 address from its String representation.long
long
boolean
Returns true if the address is an IPv4-mapped IPv6 address.maskWithNetworkMask
(SocketUtilsIPV6.IPv6NetworkMask networkMask) Mask the address with the given network mask.Calculate the maximum address with the given network mask.int
int
int
int
subtract
(int value) Subtraction.toString()
Returns a string representation of the IPv6 address.
-
Method Details
-
fromString
Create an IPv6 address from its String representation. For example "1234:5678:abcd:0000:9876:3210:ffff:ffff" or "2001::ff" or even "::". IPv4-Mapped IPv6 addresses such as "::ffff:123.456.123.456" are also supported.- Parameters:
string
- string representation- Returns:
- IPv6 address
-
toInetAddress
- Throws:
UnknownHostException
-
add
Addition. Will never overflow, but wraps around when the highest ip address has been reached.- Parameters:
value
- value to add- Returns:
- new IPv6 address
-
subtract
Subtraction. Will never underflow, but wraps around when the lowest ip address has been reached.- Parameters:
value
- value to subtract- Returns:
- new IPv6 address
-
maskWithNetworkMask
Mask the address with the given network mask.- Parameters:
networkMask
- network mask- Returns:
- an address of which the last 128 - networkMask.asPrefixLength() bits are zero
-
maximumAddressWithNetworkMask
public SocketUtilsIPV6.IPv6Address maximumAddressWithNetworkMask(SocketUtilsIPV6.IPv6NetworkMask networkMask) Calculate the maximum address with the given network mask.- Parameters:
networkMask
- network mask- Returns:
- an address of which the last 128 - networkMask.asPrefixLength() bits are one
-
isIPv4Mapped
public boolean isIPv4Mapped()Returns true if the address is an IPv4-mapped IPv6 address. In these addresses, the first 80 bits are zero, the next 16 bits are one, and the remaining 32 bits are the IPv4 address.- Returns:
- true if the address is an IPv4-mapped IPv6 addresses.
-
toString
Returns a string representation of the IPv6 address. It will use shorthand notation and special notation for IPv4-mapped IPv6 addresses whenever possible. -
getHighBits
public long getHighBits() -
getLowBits
public long getLowBits() -
numberOfTrailingZeroes
public int numberOfTrailingZeroes() -
numberOfTrailingOnes
public int numberOfTrailingOnes() -
numberOfLeadingZeroes
public int numberOfLeadingZeroes() -
numberOfLeadingOnes
public int numberOfLeadingOnes()
-