| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Net.IPv4
Description
An IPv4 data type
This module provides the IPv4 data type and functions for working
with it. There are also encoding and decoding functions provided
in this module, but they should be imported from
Net.IPv4.Text and Net.IPv4.ByteString.Char8 instead. They are
defined here so that the FromJSON and ToJSON instances can
use them.
At some point, a highly efficient IPv4-to-ByteString function needs
to be added to this module to take advantage of aeson's new
toEncoding method.
Conversion Functions
fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> IPv4 Source #
Create an IPv4 address from four octets. The first argument
is the most significant octet. The last argument is the least
significant.
Since the Show and Read instances for IPv4 are not generally
usefully, this function is the recommened way to create IPv4 addresses.
For example:
>>>fromOctets 192 168 1 1IPv4 {getIPv4 = 3232235777}
toOctets :: IPv4 -> (Word8, Word8, Word8, Word8) Source #
Convert an IPv4 address into a quadruple of octets. The first
element in the quadruple is the most significant octet. The last
element is the least significant octet.
Special IP Addresses
Range Predicates
private :: IPv4 -> Bool Source #
Checks to see if the IPv4 address belongs to a private
network. The three private networks that are checked are
10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.