Class SocketUtilsIPV6.IPv6Address

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

public static class SocketUtilsIPV6.IPv6Address extends Object
  • Field Details

    • N_SHORTS

      private static final int N_SHORTS
      See Also:
    • highBits

      private long highBits
    • lowBits

      private long lowBits
  • Constructor Details

    • IPv6Address

      IPv6Address(long highBits, long lowBits)
    • IPv6Address

      private IPv6Address()
  • 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
    • mergeLongArrayIntoIPv6Address

      private SocketUtilsIPV6.IPv6Address mergeLongArrayIntoIPv6Address(long[] longs)
    • rewriteIPv4MappedNotation

      private String rewriteIPv4MappedNotation(String string)
    • tryParseStringArrayIntoLongArray

      private long[] tryParseStringArrayIntoLongArray(String string, String longNotation)
    • parseStringArrayIntoLongArray

      private long[] parseStringArrayIntoLongArray(String[] strings)
    • expandShortNotation

      private String expandShortNotation(String string)
    • countOccurrences

      private int countOccurrences(String haystack, char needle)
    • generateZeroes

      private String generateZeroes(int number)
    • removeScope

      private String removeScope(String string)
    • 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
    • isLessThanUnsigned

      private boolean isLessThanUnsigned(long a, long b)
    • 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
    • toIPv4MappedAddressString

      private String toIPv4MappedAddressString()
    • toShortHandNotationString

      private String toShortHandNotationString()
    • toArrayOfShortStrings

      private String[] toArrayOfShortStrings()
    • toShortArray

      private short[] toShortArray()
    • inHighRange

      private boolean inHighRange(int shortNumber)
    • startAndLengthOfLongestRunOfZeroes

      int[] startAndLengthOfLongestRunOfZeroes()
    • countConsecutiveZeroes

      private int countConsecutiveZeroes(short[] shorts, int offset)
    • getHighBits

      public long getHighBits()
    • getLowBits

      public long getLowBits()
    • numberOfTrailingZeroes

      public int numberOfTrailingZeroes()
    • numberOfTrailingOnes

      public int numberOfTrailingOnes()
    • numberOfLeadingZeroes

      public int numberOfLeadingZeroes()
    • numberOfLeadingOnes

      public int numberOfLeadingOnes()