Interface Block<A extends Address<A>>

Type Parameters:
A - the type for the IP version
All Superinterfaces:
AddressSet<A>, Iterable<A>, Range<A>

public interface Block<A extends Address<A>> extends Range<A>

Range interface that forms RFC-4632 Classless Inter-domain Routing block of IP Addresses.

Example: "192.168.0.0/24".

  • First address: 192.168.0.0.
  • Last address: 192.168.0.255.
  • Network mask: 255.255.255.0.
  • Mask size: 24 bits.
  • Size of block: 256 addresses.

See AddressSet for implementation contract.

See Also:
  • Method Details

    • cidrNotation

      default String cidrNotation()
      The block in CIDR notation like 192.168.100.0/24.
      Returns:
      canonical form that can be parsed
      See Also:
    • maskSize

      default int maskSize()
      Mask size in bits as defined by CIDR notation. For 172.26.0.0/16 this returns 16.
      Returns:
      mask size in bits
    • mask

      default A mask()
      The CIDR mask as an IP address. For 172.26.0.0/16 this returns 255.255.0.0.
      
           first OR mask       == first
           last AND mask       == first
           first OR (NOT mask) == last
       
      Returns:
      the mask IP
    • size

      default BigInteger size()
      Number of Addresses in block.
      Specified by:
      size in interface AddressSet<A extends Address<A>>
      Specified by:
      size in interface Range<A extends Address<A>>
      Returns:
      block size
    • subnets

      default Stream<Block<A>> subnets(int size)
      Divides the block into smaller subnets of given bit mask size.
      Parameters:
      size - between maskSize() and Family.width() inclusive
      Returns:
      stream of subnet blocks