Package org.jboss.netty.handler.ipfilter
Class CIDR4
- java.lang.Object
-
- org.jboss.netty.handler.ipfilter.CIDR
-
- org.jboss.netty.handler.ipfilter.CIDR4
-
-
Field Summary
Fields Modifier and Type Field Description private int
addressEndInt
The integer for the end addressprivate int
addressInt
The integer for the base address-
Fields inherited from class org.jboss.netty.handler.ipfilter.CIDR
baseAddress, cidrMask
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CIDR4(java.net.Inet4Address newaddr, int mask)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(CIDR arg)
boolean
contains(java.net.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.java.net.InetAddress
getEndAddress()
private static java.net.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(java.net.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
-
-
-
-
Method Detail
-
getEndAddress
public java.net.InetAddress getEndAddress()
- Specified by:
getEndAddress
in classCIDR
- Returns:
- the end address of this block.
-
compareTo
public int compareTo(CIDR arg)
-
contains
public boolean contains(java.net.InetAddress inetAddress)
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
private static java.net.InetAddress intToIPv4Address(int addr) throws java.net.UnknownHostException
Convert an integer into an (IPv4) InetAddress.- Returns:
- the created InetAddress
- Throws:
java.net.UnknownHostException
-
ipv4AddressToInt
private static int ipv4AddressToInt(java.net.InetAddress addr)
Given an IPv4 address, convert it into an integer.- Returns:
- the integer representation of the InetAddress
- Throws:
java.lang.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:
java.lang.IllegalArgumentException
- if the address is really an IPv6 address.
-
-