Class Subnet
java.lang.Object
org.apache.mina.filter.firewall.Subnet
A IP subnet using the CIDR notation. Currently, only IP version 4
address are supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final longprivate InetAddressprivate intAn int representation of a subnet for IPV4 addressesprivate longAn long representation of a subnet for IPV6 addressesprivate longprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleaninSubnet(InetAddress address) Checks if theInetAddressis within this subnetprivate inttoInt(InetAddress inetAddress) Converts an IP address into an integerprivate longtoLong(InetAddress inetAddress) Converts an IP address into a longtoString()private longtoSubnet(InetAddress address) Converts an IP address to a subnet using the provided mask
-
Field Details
-
IP_MASK_V4
private static final int IP_MASK_V4- See Also:
-
IP_MASK_V6
private static final long IP_MASK_V6- See Also:
-
BYTE_MASK
private static final int BYTE_MASK- See Also:
-
subnet
-
subnetInt
private int subnetIntAn int representation of a subnet for IPV4 addresses -
subnetLong
private long subnetLongAn long representation of a subnet for IPV6 addresses -
subnetMask
private long subnetMask -
suffix
private int suffix
-
-
Constructor Details
-
Subnet
Creates a subnet from CIDR notation. For example, the subnet 192.168.0.0/24 would be created using theInetAddress192.168.0.0 and the mask 24.- Parameters:
subnet- TheInetAddressof the subnetmask- The mask
-
-
Method Details
-
toInt
Converts an IP address into an integer -
toLong
Converts an IP address into a long -
toSubnet
Converts an IP address to a subnet using the provided mask- Parameters:
address- The address to convert into a subnet- Returns:
- The subnet as an integer
-
inSubnet
Checks if theInetAddressis within this subnet- Parameters:
address- TheInetAddressto check- Returns:
- True if the address is within this subnet, false otherwise
-
toString
-
equals
-