Package org.jboss.netty.handler.ipfilter
Class CIDR4
java.lang.Object
org.jboss.netty.handler.ipfilter.CIDR
org.jboss.netty.handler.ipfilter.CIDR4
- All Implemented Interfaces:
Comparable<CIDR>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
The integer for the end addressprivate int
The integer for the base addressFields inherited from class org.jboss.netty.handler.ipfilter.CIDR
baseAddress, cidrMask
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
contains
(InetAddress inetAddress) Compares the given InetAddress against the CIDR and returns true if the ip is in the subnet-ip-range and false if not.private static InetAddress
intToIPv4Address
(int addr) Convert an integer into an (IPv4) InetAddress.private static int
ipv4AddressToInt
(byte[] address) Given an IPv4 address as array of bytes, convert it into an integer.private static int
ipv4AddressToInt
(InetAddress addr) Given an IPv4 address, convert it into an integer.private static int
ipv4PrefixLengthToLength
(int prefixLength) Given an IPv4 baseAddress length, return the block length.private static int
ipv4PrefixLengthToMask
(int prefixLength) Given a baseAddress length, return a netmask.Methods inherited from class org.jboss.netty.handler.ipfilter.CIDR
equals, getBaseAddress, getIpV4FromIpV6, getIpV6FromIpV4, getMask, hashCode, newCIDR, newCIDR, newCIDR, toString
-
Field Details
-
addressInt
private int addressIntThe integer for the base address -
addressEndInt
private final int addressEndIntThe integer for the end address
-
-
Constructor Details
-
CIDR4
-
-
Method Details
-
getEndAddress
- Specified by:
getEndAddress
in classCIDR
- Returns:
- the end address of this block.
-
compareTo
-
contains
Description copied from class:CIDR
Compares the given InetAddress against the CIDR and returns true if the ip is in the subnet-ip-range and false if not. -
ipv4PrefixLengthToLength
private static int ipv4PrefixLengthToLength(int prefixLength) Given an IPv4 baseAddress length, return the block length. I.e., a baseAddress length of 24 will return 256. -
ipv4PrefixLengthToMask
private static int ipv4PrefixLengthToMask(int prefixLength) Given a baseAddress length, return a netmask. I.e, a baseAddress length of 24 will return 0xFFFFFF00. -
intToIPv4Address
Convert an integer into an (IPv4) InetAddress.- Returns:
- the created InetAddress
- Throws:
UnknownHostException
-
ipv4AddressToInt
Given an IPv4 address, convert it into an integer.- Returns:
- the integer representation of the InetAddress
- Throws:
IllegalArgumentException
- if the address is really an IPv6 address.
-
ipv4AddressToInt
private static int ipv4AddressToInt(byte[] address) Given an IPv4 address as array of bytes, convert it into an integer.- Returns:
- the integer representation of the InetAddress
- Throws:
IllegalArgumentException
- if the address is really an IPv6 address.
-