Data structures to express IPv4, IPv6 and IP range.
- data IP
- data IPv4
- toIPv4 :: [Int] -> IPv4
- fromIPv4 :: IPv4 -> [Int]
- data IPv6
- toIPv6 :: [Int] -> IPv6
- fromIPv6 :: IPv6 -> [Int]
- data IPRange
- data AddrRange a
- class Eq a => Addr a where
- makeAddrRange :: Addr a => a -> Int -> AddrRange a
- (>:>) :: Addr a => AddrRange a -> AddrRange a -> Bool
- isMatchedTo :: Addr a => a -> AddrRange a -> Bool
Documentation
IP data
IP range data
The Addr range consists of an address, a contiguous mask, and mask length. The contiguous mask and the mask length are essentially same information but contained for pre calculation.
To create this, use makeAddrRange
or read
"192.0.2.0/24" :: AddrRange
IPv4
.
Also, "192.0.2.0/24" can be used as literal with OverloadedStrings.
Address class
makeAddrRange :: Addr a => a -> Int -> AddrRange aSource
The makeAddrRange
functions takes an Addr
address and a mask
length. It creates a bit mask from the mask length and masks
the Addr
address, then returns AddrRange
made of them.