Class SocketUtilsIPV6.IPv6Address

java.lang.Object
org.jruby.ext.socket.SocketUtilsIPV6.IPv6Address
Enclosing class:
SocketUtilsIPV6

public static class SocketUtilsIPV6.IPv6Address extends Object
  • Method Details

    • fromString

      public SocketUtilsIPV6.IPv6Address fromString(String string)
      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

      public InetAddress toInetAddress() throws UnknownHostException
      Throws:
      UnknownHostException
    • add

      public SocketUtilsIPV6.IPv6Address add(int value)
      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

      public SocketUtilsIPV6.IPv6Address subtract(int value)
      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

      public SocketUtilsIPV6.IPv6Address maskWithNetworkMask(SocketUtilsIPV6.IPv6NetworkMask networkMask)
      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

      public String toString()
      Returns a string representation of the IPv6 address. It will use shorthand notation and special notation for IPv4-mapped IPv6 addresses whenever possible.
      Overrides:
      toString in class Object
      Returns:
      String representation of the IPv6 address
    • getHighBits

      public long getHighBits()
    • getLowBits

      public long getLowBits()
    • numberOfTrailingZeroes

      public int numberOfTrailingZeroes()
    • numberOfTrailingOnes

      public int numberOfTrailingOnes()
    • numberOfLeadingZeroes

      public int numberOfLeadingZeroes()
    • numberOfLeadingOnes

      public int numberOfLeadingOnes()