-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Library for IP and MAC addresses -- -- Please see README.md @package ip @version 0.8 module Net.Internal attoparsecParseJSON :: Parser a -> Value -> Parser a rightToMaybe :: Either a b -> Maybe b toDotDecimalText :: Word32 -> Text toDotDecimalBuilder :: Word32 -> Builder rangeToDotDecimalText :: Word32 -> Word8 -> Text rangeToDotDecimalBuilder :: Word32 -> Word8 -> Builder -- | I think that this function can be improved. Right now, it always -- allocates enough space for a fifteen-character text rendering of an IP -- address. I think that it should be possible to do more of the math -- upfront and allocate less space. toTextPreAllocated :: Word32 -> Text putAndCount :: Int -> Word8 -> MArray s -> ST s Int zero :: Word16 i2w :: Integral a => a -> Word16 twoDigits :: ByteString threeDigits :: ByteString fromDotDecimalText' :: Text -> Either String Word32 fromDotDecimalText :: Text -> Maybe Word32 rangeFromDotDecimalText' :: (Word32 -> Word8 -> a) -> Text -> Either String a rangeFromDotDecimalText :: (Word32 -> Word8 -> a) -> Text -> Maybe a dotDecimalRangeParser :: (Word32 -> Word8 -> a) -> Parser a -- | This does not do an endOfInput check because it is reused in the range -- parser implementation. dotDecimalParser :: Parser Word32 -- | This is sort of a misnomer. It takes Word32 to make dotDecimalParser -- probably perform better. This is mostly for internal use. fromOctets' :: Word32 -> Word32 -> Word32 -> Word32 -> Word32 mask :: Word8 -> Word32 p24 :: Word32 p20 :: Word32 p16 :: Word32 mask8 :: Word32 mask4 :: Word32 mask12 :: Word32 mask20 :: Word32 mask28 :: Word32 mask16 :: Word32 mask10 :: Word32 mask24 :: Word32 mask32 :: Word32 mask15 :: Word32 module Net.Types -- | A 32-bit Internet Protocol address. newtype IPv4 IPv4 :: Word32 -> IPv4 [getIPv4] :: IPv4 -> Word32 -- | The length should be between 0 and 32. These bounds are inclusive. -- This expectation is not in any way enforced by this library because it -- does not cause errors. A mask length greater than 32 will be treated -- as if it were 32. data IPv4Range IPv4Range :: {-# UNPACK #-} !IPv4 -> {-# UNPACK #-} !Word8 -> IPv4Range [ipv4RangeBase] :: IPv4Range -> {-# UNPACK #-} !IPv4 [ipv4RangeLength] :: IPv4Range -> {-# UNPACK #-} !Word8 instance GHC.Generics.Generic Net.Types.IPv4Range instance GHC.Read.Read Net.Types.IPv4Range instance GHC.Show.Show Net.Types.IPv4Range instance GHC.Classes.Ord Net.Types.IPv4Range instance GHC.Classes.Eq Net.Types.IPv4Range instance GHC.Generics.Generic Net.Types.IPv4 instance Data.Hashable.Class.Hashable Net.Types.IPv4 instance GHC.Enum.Bounded Net.Types.IPv4 instance GHC.Enum.Enum Net.Types.IPv4 instance GHC.Read.Read Net.Types.IPv4 instance GHC.Show.Show Net.Types.IPv4 instance GHC.Classes.Ord Net.Types.IPv4 instance GHC.Classes.Eq Net.Types.IPv4 instance Data.Hashable.Class.Hashable Net.Types.IPv4Range instance Data.Aeson.Types.Class.ToJSON Net.Types.IPv4 instance Data.Aeson.Types.Class.FromJSON Net.Types.IPv4 instance Data.Aeson.Types.Class.ToJSON Net.Types.IPv4Range instance Data.Aeson.Types.Class.FromJSON Net.Types.IPv4Range -- | 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. module Net.IPv4 -- | 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 1
-- IPv4 {getIPv4 = 3232235777}
--
fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> IPv4
-- | 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.
toOctets :: IPv4 -> (Word8, Word8, Word8, Word8)
-- | The IP address representing any host: 0.0.0.0
any :: IPv4
-- | The loopback IP address: 127.0.0.1
loopback :: IPv4
-- | The broadcast IP address: 127.0.0.1
broadcast :: IPv4
-- | 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.
private :: IPv4 -> Bool
-- | Checks to see if the IPv4 address belongs to a reserved
-- network. This includes the three private networks that private
-- checks along with several other ranges that are not used on the public
-- Internet.
reserved :: IPv4 -> Bool
module Net.IPv4.Range
-- | 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 IPv4Ranges 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 --normalize :: IPv4Range -> IPv4Range -- | 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 --member :: IPv4 -> IPv4Range -> Bool -- | 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) --lowerInclusive :: IPv4Range -> IPv4 upperInclusive :: IPv4Range -> IPv4 -- | The RFC1918 24-bit block. Subnet mask: 10.0.0.0/8 private24 :: IPv4Range -- | The RFC1918 20-bit block. Subnet mask: 172.16.0.0/12 private20 :: IPv4Range -- | The RFC1918 16-bit block. Subnet mask: 192.168.0.0/16 private16 :: IPv4Range -- | This only exists for doctests. Do not use it. prRange :: IPv4Range -> IO () module Net.IPv4.Text encode :: IPv4 -> Text decode :: Text -> Maybe IPv4 decodeEither :: Text -> Either String IPv4 builder :: IPv4 -> Builder parser :: Parser IPv4 -- | This exists mostly for testing purposes. print :: IPv4 -> IO () -- | This module exists for the convenience of those who need a -- String representation of an IPv4 address. Using this -- module is discouraged unless the end user is working with a library -- that can only use String to deal with textual data (such as -- pandoc, hxr, or network). module Net.IPv4.String encode :: IPv4 -> String decode :: String -> Maybe IPv4 decodeEither :: String -> Either String IPv4 module Net.IPv4.ByteString.Char8 -- | This should be rewritten to not create Text as an -- intermediate step. encode :: IPv4 -> ByteString -- | This should also be rewritten decode :: ByteString -> Maybe IPv4 builder :: IPv4 -> Builder parser :: Parser IPv4 module Net.Mac data Mac Mac :: {-# UNPACK #-} !Word16 -> {-# UNPACK #-} !Word32 -> Mac [macA] :: Mac -> {-# UNPACK #-} !Word16 [macB] :: Mac -> {-# UNPACK #-} !Word32 toText :: Mac -> Text fromText :: Text -> Maybe Mac fromText' :: Text -> Either String Mac toTextBuilder :: Mac -> Builder -- | This does not do an endOfInput check textParser :: Parser Mac bytestringParser :: Parser Mac fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Mac fromOctets' :: Word16 -> Word16 -> Word32 -> Word32 -> Word32 -> Word32 -> Mac instance GHC.Generics.Generic Net.Mac.Mac instance GHC.Read.Read Net.Mac.Mac instance GHC.Show.Show Net.Mac.Mac instance GHC.Classes.Ord Net.Mac.Mac instance GHC.Classes.Eq Net.Mac.Mac instance Data.Hashable.Class.Hashable Net.Mac.Mac instance Data.Aeson.Types.Class.ToJSON Net.Mac.Mac instance Data.Aeson.Types.Class.FromJSON Net.Mac.Mac module Net.Mac.Text encode :: Mac -> Text decode :: Text -> Maybe Mac decodeEither :: Text -> Either String Mac builder :: Mac -> Builder parser :: Parser Mac module Net.Mac.ByteString.Char8 -- | This is a bad implementation that should be rewritten encode :: Mac -> ByteString -- | This is a bad implementation that should be rewritten decode :: ByteString -> Maybe Mac builder :: Mac -> Builder parser :: Parser Mac