Class CIDR4

java.lang.Object
org.jboss.netty.handler.ipfilter.CIDR
org.jboss.netty.handler.ipfilter.CIDR4
All Implemented Interfaces:
Comparable<CIDR>

public class CIDR4 extends CIDR
  • Field Details

    • addressInt

      private int addressInt
      The integer for the base address
    • addressEndInt

      private final int addressEndInt
      The integer for the end address
  • Constructor Details

  • Method Details

    • getEndAddress

      public InetAddress getEndAddress()
      Specified by:
      getEndAddress in class CIDR
      Returns:
      the end address of this block.
    • compareTo

      public int compareTo(CIDR arg)
    • contains

      public boolean contains(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.
      Specified by:
      contains in class CIDR
      Returns:
      returns true if the given IP address is inside the currently set network.
    • 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 InetAddress intToIPv4Address(int addr) throws UnknownHostException
      Convert an integer into an (IPv4) InetAddress.
      Returns:
      the created InetAddress
      Throws:
      UnknownHostException
    • ipv4AddressToInt

      private static int ipv4AddressToInt(InetAddress addr)
      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.