This library contains a number of functions for working with subnets. It can validate subnet mask strings, see if an address is inside a given subnet.
Get the String representation for a given CIDR.
fromCIDR 24 == Just "255.255.255.0"Calculates the CIDR length in bits from a subnet mask.
toCIDR "255.255.255.0" == 24
toCIDR "255.255.254.0" == 23Returns the base IP of the given subnet.
base ( "192.168.1.25", "255.255.255.0" ) == Just "192.168.1.0"
base ( "192.168.1.25", "255.255.255.252" ) == Just "192.168.1.24"
base ( "invalid ip", "or invalid subnet" ) == NothingGive a subnet mask, calculates the number of host possible.
hosts "255.255.255.0" == 256Is the IP address in the subnet.
included ( "192.168.1.0", "255.255.255.0" ) "192.168.1.5" == True
included ( "192.168.17.0", "255.255.254.0" ) "192.168.18.5" == False
Check to see if the given subnet is valid.