This class borrowed some of its methods from a modified fork of the Inet6Util class which was part of Apache Harmony.
Modifier and Type | Class and Description |
---|---|
private static class |
Modifier and Type | Field and Description |
---|---|
private static final int | IPV4_MAX_CHAR_BETWEEN_SEPARATOR
Maximum amount of value adding characters in between IPV4 separators |
private static final boolean | IPV4_PREFERRED
|
private static final int | IPV4_SEPARATORS
Number of separators that must be present in an IPv4 string |
private static final boolean | IPV6_ADDRESSES_PREFERRED
|
private static final int | IPV6_BYTE_COUNT
Number of bytes needed to represent an IPV6 value |
private static final int | IPV6_MAX_CHAR_BETWEEN_SEPARATOR
Maximum amount of value adding characters in between IPV6 separators |
private static final int | IPV6_MAX_CHAR_COUNT
The maximum number of characters for an IPV6 string with no scope |
private static final int | IPV6_MAX_SEPARATORS
Maximum number of separators that must be present in an IPv6 string |
private static final int | IPV6_MIN_SEPARATORS
Minimum number of separators that must be present in an IPv6 string |
private static final int | IPV6_WORD_COUNT
This defines how many words (represented as ints) are needed to represent an IPv6 address |
public static final InetAddress | LOCALHOST
The |
public static final Inet4Address | LOCALHOST4
The |
public static final Inet6Address | LOCALHOST6
The |
private static final InternalLogger | logger
The logger being used by this class |
public static final NetworkInterface | LOOPBACK_IF
The loopback |
public static final Collection | NETWORK_INTERFACES
An unmodifiable Collection of all the interfaces on this machine. |
public static final int | SOMAXCONN
The SOMAXCONN value of the current machine. |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static String | bytesToIpAddress(byte[] bytes)
Converts 4-byte or 16-byte data into an IPv4 or IPv6 string respectively. |
public static String | bytesToIpAddress(byte[] bytes, int offset, int length)
Converts 4-byte or 16-byte data into an IPv4 or IPv6 string respectively. |
public static byte[] | createByteArrayFromIpAddressString(String ipAddressString)
Creates an byte[] based on an ipAddressString. |
public static InetAddress | createInetAddressFromIpAddressString(String ipAddressString)
Creates an |
private static int | |
public static Inet6Address | getByName(CharSequence
CharSequence IP address to be converted to a Inet6Address Returns the |
public static Inet6Address | getByName(CharSequence
CharSequence IP address to be converted to a Inet6Address
Returns the |
public static String | Returns: the host stringThe address addr)Returns |
pack-priv static byte[] | Returns: byte array representation of theip or null if not a valid IP address.CharSequence IP address to be converted to a Inet6Address
Returns the byte array representation of a |
private static boolean | Returns:
The value to checked if is within value, int start (inclusive) and end (exclusive)The start of the range (inclusive) start, int The end of the range (exclusive) end)Does a range check on |
public static String | |
public static int | |
private static byte | |
public static boolean | isIpV4StackPreferred()
Returns |
public static boolean | isIpV6AddressesPreferred()
Returns |
private static boolean | |
public static boolean | Returns: true, if the string represents an IPV4 address in dotted notation, false otherwiseTakes a |
public static boolean | Returns: true, if the string represents an IPV4 address in dotted notation, false otherwiseTakes a |
private static boolean | |
private static boolean | |
private static boolean | |
private static boolean | |
private static boolean | |
private static boolean | |
private static boolean | |
private static boolean | |
public static boolean | |
public static boolean | |
private static boolean | |
private static StringBuilder | |
private static Integer | sysctlGetInt(String
The key which the return value corresponds to. sysctlKey)This will execute sysctl with the |
public static String | Returns: String containing the text-formatted IP addressInetAddress to be converted to an address stringReturns the |
public static String | Returns: String containing the text-formatted IP addressInetAddress to be converted to an address string
Returns the |
private static String | |
public static String | Returns: String containing the text-formatted IP addressInetSocketAddress to be converted to an address stringReturns the |
public static String | |
pack-priv static byte[] |
IPV4_MAX_CHAR_BETWEEN_SEPARATOR | back to summary |
---|---|
private static final int IPV4_MAX_CHAR_BETWEEN_SEPARATOR Maximum amount of value adding characters in between IPV4 separators |
IPV4_PREFERRED | back to summary |
---|---|
private static final boolean IPV4_PREFERRED
|
IPV4_SEPARATORS | back to summary |
---|---|
private static final int IPV4_SEPARATORS Number of separators that must be present in an IPv4 string |
IPV6_ADDRESSES_PREFERRED | back to summary |
---|---|
private static final boolean IPV6_ADDRESSES_PREFERRED
|
IPV6_BYTE_COUNT | back to summary |
---|---|
private static final int IPV6_BYTE_COUNT Number of bytes needed to represent an IPV6 value |
IPV6_MAX_CHAR_BETWEEN_SEPARATOR | back to summary |
---|---|
private static final int IPV6_MAX_CHAR_BETWEEN_SEPARATOR Maximum amount of value adding characters in between IPV6 separators |
IPV6_MAX_CHAR_COUNT | back to summary |
---|---|
private static final int IPV6_MAX_CHAR_COUNT The maximum number of characters for an IPV6 string with no scope |
IPV6_MAX_SEPARATORS | back to summary |
---|---|
private static final int IPV6_MAX_SEPARATORS Maximum number of separators that must be present in an IPv6 string |
IPV6_MIN_SEPARATORS | back to summary |
---|---|
private static final int IPV6_MIN_SEPARATORS Minimum number of separators that must be present in an IPv6 string |
IPV6_WORD_COUNT | back to summary |
---|---|
private static final int IPV6_WORD_COUNT This defines how many words (represented as ints) are needed to represent an IPv6 address |
LOCALHOST | back to summary |
---|---|
public static final InetAddress LOCALHOST The |
LOCALHOST4 | back to summary |
---|---|
public static final Inet4Address LOCALHOST4 The |
LOCALHOST6 | back to summary |
---|---|
public static final Inet6Address LOCALHOST6 The |
logger | back to summary |
---|---|
private static final InternalLogger logger The logger being used by this class |
LOOPBACK_IF | back to summary |
---|---|
public static final NetworkInterface LOOPBACK_IF The loopback |
NETWORK_INTERFACES | back to summary |
---|---|
public static final Collection<NetworkInterface> NETWORK_INTERFACES An unmodifiable Collection of all the interfaces on this machine. |
SOMAXCONN | back to summary |
---|---|
public static final int SOMAXCONN The SOMAXCONN value of the current machine. If failed to get the value, |
NetUtil | back to summary |
---|---|
private NetUtil() A constructor to stop this class being constructed. |
bytesToIpAddress | back to summary |
---|---|
public static String bytesToIpAddress(byte[] bytes) Converts 4-byte or 16-byte data into an IPv4 or IPv6 string respectively.
|
bytesToIpAddress | back to summary |
---|---|
public static String bytesToIpAddress(byte[] bytes, int offset, int length) Converts 4-byte or 16-byte data into an IPv4 or IPv6 string respectively.
|
createByteArrayFromIpAddressString | back to summary |
---|---|
public static byte[] createByteArrayFromIpAddressString(String ipAddressString) Creates an byte[] based on an ipAddressString. No error handling is performed here. |
createInetAddressFromIpAddressString | back to summary |
---|---|
public static InetAddress createInetAddressFromIpAddressString(String ipAddressString) Creates an |
decimalDigit | back to summary |
---|---|
private static int decimalDigit(String str, int pos) |
getByName | back to summary |
---|---|
public static Inet6Address getByName(CharSequence ip) Returns the
This method will treat all IPv4 type addresses as "IPv4 mapped" (see
|
getByName | back to summary |
---|---|
public static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped) Returns the
The
|
getHostname | back to summary |
---|---|
public static String getHostname(InetSocketAddress addr) Returns
|
getIPv6ByName | back to summary |
---|---|
pack-priv static byte[] getIPv6ByName(CharSequence ip, boolean ipv4Mapped) Returns the byte array representation of a
The
|
inRangeEndExclusive | back to summary |
---|---|
private static boolean inRangeEndExclusive(int value, int start, int end) Does a range check on
|
intToIpAddress | back to summary |
---|---|
public static String intToIpAddress(int i) Converts a 32-bit integer into an IPv4 address. |
ipv4AddressToInt | back to summary |
---|---|
public static int ipv4AddressToInt(Inet4Address ipAddress) Convert |
ipv4WordToByte | back to summary |
---|---|
private static byte ipv4WordToByte(String ip, int from, int toExclusive) |
isIpV4StackPreferred | back to summary |
---|---|
public static boolean isIpV4StackPreferred() Returns
|
isIpV6AddressesPreferred | back to summary |
---|---|
public static boolean isIpV6AddressesPreferred() Returns
|
isValidHexChar | back to summary |
---|---|
private static boolean isValidHexChar(char c) |
isValidIpV4Address | back to summary |
---|---|
public static boolean isValidIpV4Address(CharSequence ip) Takes a
|
isValidIpV4Address | back to summary |
---|---|
public static boolean isValidIpV4Address(String ip) Takes a
|
isValidIpV4Address | back to summary |
---|---|
private static boolean isValidIpV4Address(CharSequence ip, int from, int toExcluded) |
isValidIpV4Address | back to summary |
---|---|
private static boolean isValidIpV4Address(String ip, int from, int toExcluded)
|
isValidIpV4Address | back to summary |
---|---|
private static boolean isValidIpV4Address(AsciiString ip, int from, int toExcluded)
|
isValidIpV4Address0 | back to summary |
---|---|
private static boolean isValidIpV4Address0(CharSequence ip, int from, int toExcluded)
|
isValidIPv4Mapped | back to summary |
---|---|
private static boolean isValidIPv4Mapped(byte[] bytes, int currentIndex, int compressBegin, int compressLength) |
isValidIPv4MappedChar | back to summary |
---|---|
private static boolean isValidIPv4MappedChar(char c) |
isValidIPv4MappedSeparators | back to summary |
---|---|
private static boolean isValidIPv4MappedSeparators(byte b0, byte b1, boolean mustBeZero) |
isValidIpV4Word | back to summary |
---|---|
private static boolean isValidIpV4Word(CharSequence word, int from, int toExclusive) |
isValidIpV6Address | back to summary |
---|---|
public static boolean isValidIpV6Address(String ip) |
isValidIpV6Address | back to summary |
---|---|
public static boolean isValidIpV6Address(CharSequence ip) |
isValidNumericChar | back to summary |
---|---|
private static boolean isValidNumericChar(char c) |
newSocketAddressStringBuilder | back to summary |
---|---|
private static StringBuilder newSocketAddressStringBuilder(String host, String port, boolean ipv4) |
sysctlGetInt | back to summary |
---|---|
private static Integer sysctlGetInt(String sysctlKey) throws IOException This will execute sysctl with the |
toAddressString | back to summary |
---|---|
public static String toAddressString(InetAddress ip) Returns the
The output does not include Scope ID.
|
toAddressString | back to summary |
---|---|
public static String toAddressString(InetAddress ip, boolean ipv4Mapped) Returns the
The output does not include Scope ID.
|
toAddressString | back to summary |
---|---|
private static String toAddressString(byte[] bytes, int offset, boolean ipv4Mapped) |
toSocketAddressString | back to summary |
---|---|
public static String toSocketAddressString(InetSocketAddress addr) Returns the The output does not include Scope ID.
|
toSocketAddressString | back to summary |
---|---|
public static String toSocketAddressString(String host, int port) Returns the |
validIpV4ToBytes | back to summary |
---|---|
pack-priv static byte[] validIpV4ToBytes(String ip) |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public Integer |
SoMaxConnAction | back to summary |
---|---|
private SoMaxConnAction() |
run | back to summary |
---|---|
public Integer run() Implements java. Doc from java. Performs the computation. This method will be called by
|