Package org.apache.mina.filter.util
Class SubnetUtils6
java.lang.Object
org.apache.mina.filter.util.SubnetUtils6
Performs subnet calculations given an IPv6 network address and a prefix length.
This is the IPv6 equivalent of SubnetUtils. Addresses are parsed and formatted
using InetAddress, which accepts the text representations described in
RFC 5952.
- Since:
- 3.13.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classContains IPv6 subnet summary information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigIntegerprivate final BigIntegerprivate static final BigIntegerprivate static final intprivate final BigIntegerprivate static final Stringprivate final intprivate static final BigInteger -
Constructor Summary
ConstructorsConstructorDescriptionSubnetUtils6(String cidrNotation) Constructs an instance from a CIDR-notation string, e.g., "2001:db8::1/64".SubnetUtils6(String address, int prefixLength) Constructs an instance from an IPv6 address and prefix length. -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringformat(BigInteger addr) Formats a BigInteger as an IPv6 address string usingInetAddress.getHostAddress().getInfo()Gets aSubnetUtils6.SubnetInfoinstance that contains subnet-specific statistics.private static byte[]toByteArray16(BigInteger value) Converts a BigInteger to a 16-byte array, padding with leading zeros if necessary.private static byte[]Parses an IPv6 address string to a byte array.toString()Returns a summary of this subnet for debugging.
-
Field Details
-
NBITS
private static final int NBITS- See Also:
-
PARSE_FAIL
- See Also:
-
TWO
-
MAX_VALUE
-
address
-
high
-
network
-
prefixLength
private final int prefixLength
-
-
Constructor Details
-
SubnetUtils6
Constructs an instance from a CIDR-notation string, e.g., "2001:db8::1/64".- Parameters:
cidrNotation- a CIDR-notation string, e.g., "2001:db8::1/64".- Throws:
IllegalArgumentException- if the parameter is invalid.
-
SubnetUtils6
Constructs an instance from an IPv6 address and prefix length.- Parameters:
address- an IPv6 address, e.g., "2001:db8::1".prefixLength- the prefix length (0-128).- Throws:
IllegalArgumentException- if the parameters are invalid.
-
-
Method Details
-
format
Formats a BigInteger as an IPv6 address string usingInetAddress.getHostAddress().- Parameters:
addr- the address as a BigInteger.- Returns:
- the formatted IPv6 address string.
- See Also:
-
toByteArray16
Converts a BigInteger to a 16-byte array, padding with leading zeros if necessary.- Parameters:
value- the BigInteger to convert.- Returns:
- a 16-byte array.
-
toBytes
Parses an IPv6 address string to a byte array.- Parameters:
address- the IPv6 address string.- Returns:
- the 16-byte representation.
- Throws:
IllegalArgumentException- if the address cannot be parsed.
-
getInfo
Gets aSubnetUtils6.SubnetInfoinstance that contains subnet-specific statistics.- Returns:
- a new SubnetInfo instance.
-
toString
Returns a summary of this subnet for debugging.Delegates to
SubnetUtils6.SubnetInfo.toString(). This is a diagnostic format and is not suitable for parsing. UseSubnetUtils6.SubnetInfo.getCidrSignature()to obtain a string that can be fed back intoSubnetUtils6(String).
-