Safe Haskell | None |
---|---|
Language | Haskell2010 |
Range functions
normalize :: IPv4Range -> IPv4Range Source #
Normalize an IPv4Range
. The first result of this is that the
IPv4
inside the IPv4Range
is changed so that the insignificant
bits are zeroed out. For example:
>>>
prRange $ normalize $ IPv4Range (fromOctets 192 168 1 19) 24
192.168.1.0/24>>>
prRange $ normalize $ IPv4Range (fromOctets 192 168 1 163) 28
192.168.1.160/28
The second effect of this is that the mask length is lowered to
be 32 or smaller. Working with IPv4Range
s that have not been
normalized does not cause any issues for this library, although
other applications may reject such ranges (especially those with
a mask length above 32).
Note that normalize
is idempotent, that is:
normalize r == (normalize . normalize) r
member :: IPv4 -> IPv4Range -> Bool Source #
This is provided to mirror the interface provided by Data.Set
. It
behaves just like contains
but with flipped arguments.
member ip r == contains r ip
lowerInclusive :: IPv4Range -> IPv4 Source #
The inclusive lower bound of an IPv4Range
. This is conventionally
understood to be the broadcast address of a subnet. For example:
>>>
I.print $ lowerInclusive $ IPv4Range (fromOctets 10 10 1 160) 25
10.10.1.128
Note that the lower bound of a normalized IPv4Range
is simply the
ip address of the range:
lowerInclusive r == ipv4RangeBase (normalize r)
upperInclusive :: IPv4Range -> IPv4 Source #