Class CIDR4

  • All Implemented Interfaces:
    java.lang.Comparable<CIDR>

    public class CIDR4
    extends CIDR
    • Field Detail

      • addressInt

        private int addressInt
        The integer for the base address
      • addressEndInt

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

      • CIDR4

        protected CIDR4​(java.net.Inet4Address newaddr,
                        int mask)
    • Method Detail

      • getEndAddress

        public java.net.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​(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.
        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 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.