Top Inners Constructors Methods
org.jruby.ext.socket

public Class SocketUtilsIPV6

extends Object
Class Inheritance
Imports
java.net.Inet6Address, .InetAddress, .UnknownHostException, java.util.regex.Pattern

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String
public static String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SocketUtilsIPV6back to summary
public SocketUtilsIPV6()

Method Detail

getIPV6Addressback to summary
public static String getIPV6Address(String ip)
getIPV6NetMaskback to summary
public static String getIPV6NetMask(String ip)
org.jruby.ext.socket back to summary

public Class SocketUtilsIPV6.IPv6Address

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private long
private long
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
IPv6Address(long highBits, long lowBits)

private

Method Summary

Modifier and TypeMethod and Description
public SocketUtilsIPV6.IPv6Address

Returns:

new IPv6 address
add
(int
value to add
value
)

Addition.

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

private int
countOccurrences(String haystack, char needle)

private String
public SocketUtilsIPV6.IPv6Address

Returns:

IPv6 address
fromString
(String
string representation
string
)

Create an IPv6 address from its String representation.

private String
generateZeroes(int number)

public long
public long
private boolean
inHighRange(int shortNumber)

public boolean

Returns:

true if the address is an IPv4-mapped IPv6 addresses.
isIPv4Mapped
()

Returns true if the address is an IPv4-mapped IPv6 address.

private boolean
isLessThanUnsigned(long a, long b)

public SocketUtilsIPV6.IPv6Address

Returns:

an address of which the last 128 - networkMask.asPrefixLength() bits are zero
maskWithNetworkMask
(final SocketUtilsIPV6.IPv6NetworkMask
network mask
networkMask
)

Mask the address with the given network mask.

public SocketUtilsIPV6.IPv6Address

Returns:

an address of which the last 128 - networkMask.asPrefixLength() bits are one
maximumAddressWithNetworkMask
(final SocketUtilsIPV6.IPv6NetworkMask
network mask
networkMask
)

Calculate the maximum address with the given network mask.

private SocketUtilsIPV6.IPv6Address
public int
public int
public int
public int
private long[]
private String
private String
pack-priv int[]
public SocketUtilsIPV6.IPv6Address

Returns:

new IPv6 address
subtract
(int
value to subtract
value
)

Subtraction.

private String[]
public InetAddress
private String
private short[]
private String
public String

Returns:

String representation of the IPv6 address
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the IPv6 address.

private long[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

highBitsback to summary
private long highBits
lowBitsback to summary
private long lowBits
N_SHORTSback to summary
private static final int N_SHORTS

Constructor Detail

IPv6Addressback to summary
pack-priv IPv6Address(long highBits, long lowBits)
IPv6Addressback to summary
private IPv6Address()

Method Detail

addback to summary
public SocketUtilsIPV6.IPv6Address add(int value)

Addition. Will never overflow, but wraps around when the highest ip address has been reached.

Parameters
value:int

value to add

Returns:SocketUtilsIPV6.IPv6Address

new IPv6 address

countConsecutiveZeroesback to summary
private int countConsecutiveZeroes(short[] shorts, int offset)
countOccurrencesback to summary
private int countOccurrences(String haystack, char needle)
expandShortNotationback to summary
private String expandShortNotation(String string)
fromStringback to summary
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

string representation

Returns:SocketUtilsIPV6.IPv6Address

IPv6 address

generateZeroesback to summary
private String generateZeroes(int number)
getHighBitsback to summary
public long getHighBits()
getLowBitsback to summary
public long getLowBits()
inHighRangeback to summary
private boolean inHighRange(int shortNumber)
isIPv4Mappedback to summary
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:boolean

true if the address is an IPv4-mapped IPv6 addresses.

isLessThanUnsignedback to summary
private boolean isLessThanUnsigned(long a, long b)
maskWithNetworkMaskback to summary
public SocketUtilsIPV6.IPv6Address maskWithNetworkMask(final SocketUtilsIPV6.IPv6NetworkMask networkMask)

Mask the address with the given network mask.

Parameters
networkMask:SocketUtilsIPV6.IPv6NetworkMask

network mask

Returns:SocketUtilsIPV6.IPv6Address

an address of which the last 128 - networkMask.asPrefixLength() bits are zero

maximumAddressWithNetworkMaskback to summary
public SocketUtilsIPV6.IPv6Address maximumAddressWithNetworkMask(final SocketUtilsIPV6.IPv6NetworkMask networkMask)

Calculate the maximum address with the given network mask.

Parameters
networkMask:SocketUtilsIPV6.IPv6NetworkMask

network mask

Returns:SocketUtilsIPV6.IPv6Address

an address of which the last 128 - networkMask.asPrefixLength() bits are one

mergeLongArrayIntoIPv6Addressback to summary
private SocketUtilsIPV6.IPv6Address mergeLongArrayIntoIPv6Address(long[] longs)
numberOfLeadingOnesback to summary
public int numberOfLeadingOnes()
numberOfLeadingZeroesback to summary
public int numberOfLeadingZeroes()
numberOfTrailingOnesback to summary
public int numberOfTrailingOnes()
numberOfTrailingZeroesback to summary
public int numberOfTrailingZeroes()
parseStringArrayIntoLongArrayback to summary
private long[] parseStringArrayIntoLongArray(String[] strings)
removeScopeback to summary
private String removeScope(String string)
rewriteIPv4MappedNotationback to summary
private String rewriteIPv4MappedNotation(String string)
startAndLengthOfLongestRunOfZeroesback to summary
pack-priv int[] startAndLengthOfLongestRunOfZeroes()
subtractback to summary
public SocketUtilsIPV6.IPv6Address subtract(int value)

Subtraction. Will never underflow, but wraps around when the lowest ip address has been reached.

Parameters
value:int

value to subtract

Returns:SocketUtilsIPV6.IPv6Address

new IPv6 address

toArrayOfShortStringsback to summary
private String[] toArrayOfShortStrings()
toInetAddressback to summary
public InetAddress toInetAddress() throws UnknownHostException
toIPv4MappedAddressStringback to summary
private String toIPv4MappedAddressString()
toShortArrayback to summary
private short[] toShortArray()
toShortHandNotationStringback to summary
private String toShortHandNotationString()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the IPv6 address. It will use shorthand notation and special notation for IPv4-mapped IPv6 addresses whenever possible.

Returns:String

String representation of the IPv6 address

Annotations
@Override
tryParseStringArrayIntoLongArrayback to summary
private long[] tryParseStringArrayIntoLongArray(String string, String longNotation)
org.jruby.ext.socket back to summary

public Class SocketUtilsIPV6.IPv6Network

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private SocketUtilsIPV6.IPv6Address
private SocketUtilsIPV6.IPv6Address
private SocketUtilsIPV6.IPv6Address
private SocketUtilsIPV6.IPv6NetworkMask

Constructor Summary

AccessConstructor and Description
private
IPv6Network(SocketUtilsIPV6.IPv6Address
address
address
,
SocketUtilsIPV6.IPv6NetworkMask
network mask
networkMask
)

Construct from address and network mask.

private

Method Summary

Modifier and TypeMethod and Description
public SocketUtilsIPV6.IPv6Network

Returns:

IPv6 network
fromString
(String
string representation
string
)

Create an IPv6 network from its String representation.

public SocketUtilsIPV6.IPv6NetworkMask
private String
private int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addressback to summary
private SocketUtilsIPV6.IPv6Address address
firstback to summary
private SocketUtilsIPV6.IPv6Address first
lastback to summary
private SocketUtilsIPV6.IPv6Address last
networkMaskback to summary
private SocketUtilsIPV6.IPv6NetworkMask networkMask

Constructor Detail

IPv6Networkback to summary
private IPv6Network(SocketUtilsIPV6.IPv6Address address, SocketUtilsIPV6.IPv6NetworkMask networkMask)

Construct from address and network mask.

Parameters
address:SocketUtilsIPV6.IPv6Address

address

networkMask:SocketUtilsIPV6.IPv6NetworkMask

network mask

IPv6Networkback to summary
private IPv6Network()

Method Detail

fromStringback to summary
public SocketUtilsIPV6.IPv6Network fromString(String string)

Create an IPv6 network from its String representation. For example "1234:5678:abcd:0:0:0:0:0/64" or "2001::ff/128".

Parameters
string:String

string representation

Returns:SocketUtilsIPV6.IPv6Network

IPv6 network

getNetmaskback to summary
public SocketUtilsIPV6.IPv6NetworkMask getNetmask()
parseNetworkAddressback to summary
private String parseNetworkAddress(String string)
parsePrefixLengthback to summary
private int parsePrefixLength(String string)
org.jruby.ext.socket back to summary

public Class SocketUtilsIPV6.IPv6NetworkMask

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
IPv6NetworkMask(int prefixLength)

Method Summary

Modifier and TypeMethod and Description
public SocketUtilsIPV6.IPv6Address
public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

prefixLengthback to summary
private final int prefixLength

Constructor Detail

IPv6NetworkMaskback to summary
pack-priv IPv6NetworkMask(int prefixLength)

Method Detail

asAddressback to summary
public SocketUtilsIPV6.IPv6Address asAddress()
asPrefixLengthback to summary
public int asPrefixLength()