-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | IP Routing Table
--
-- IP Routing Table is a tree of IP ranges to search one of them on the
-- longest match base. It is a kind of TRIE with one way branching
-- removed. Both IPv4 and IPv6 are supported.
@package iproute
@version 0.1
-- | Data structures to express IPv4, IPv6 and IP range.
module Data.IP
-- | A class to contain IPv4 and IPv6.
class (Eq a) => IP a
masked :: (IP a) => a -> a -> a
intToMask :: (IP a) => Int -> a
intToTBit :: (IP a) => Int -> a
isZero :: (IP a) => a -> a -> Bool
-- | The abstract data structure to express an IPv4 address. To create
-- this, use toIPv4. Or use read "192.0.2.1" ::
-- IPv4, for example.
data IPv4
-- | The abstract data structure to express an IPv6 address. To create
-- this, use toIPv6. Or use read "2001:DB8::1" ::
-- IPv6, for example.
data IPv6
-- | The toIPv4 function takes a list of Int and returns
-- IPv4. For example, toIPv4 [192,0,2,1].
toIPv4 :: [Int] -> IPv4
-- | The toIPv6 function takes a list of Int and returns
-- IPv6. For example, toIPv6
-- [0x2001,0xDB8,0,0,0,0,0,1].
toIPv6 :: [Int] -> IPv6
-- | The IP range consists of an IP address, a contiguous IP
-- mask, and mask length. The contiguous IP mask and the mask
-- length are essentially same information but contained for pre
-- calculation.
--
-- To create this, use makeIPRange or read "192.0.2.0/24"
-- :: IPRange IPv4, for example.
data (IP a) => IPRange a
-- | The addr function returns an IP address from
-- IPRange.
addr :: IPRange a -> a
-- | The mask function returns a contiguous IP mask from
-- IPRange.
mask :: IPRange a -> a
-- | The mlen function returns a mask length from IPRange.
mlen :: IPRange a -> Int
-- | The >:> operator takes two IPRange. It returns
-- True if the first IPRange contains the second
-- IPRange. Otherwise, it returns False.
(>:>) :: (IP a) => IPRange a -> IPRange a -> Bool
-- | The makeIPRange functions takes an IP address and a mask
-- length. It creates a bit mask from the mask length and masks the
-- IP address, then returns IPRange made of them.
makeIPRange :: (IP a) => a -> Int -> IPRange a
instance (IP a) => Eq (IPRange a)
instance (Ord a, IP a) => Ord (IPRange a)
instance Eq IPv6
instance Ord IPv6
instance Eq IPv4
instance Ord IPv4
instance Read (IPRange IPv6)
instance Read (IPRange IPv4)
instance Read IPv6
instance Read IPv4
instance (IP a, Show a) => Show (IPRange a)
instance Show IPv6
instance Show IPv4
instance IP IPv6
instance IP IPv4
-- | IP routing table is a tree of IPRange to search one of them
-- on the longest match base. It is a kind of TRIE with one way branching
-- removed. Both IPv4 and IPv6 are supported.
module Data.IP.RouteTable
-- | The Tree structure for IP routing table based on TRIE with one way
-- branching removed. This is an abstracted data structure, so you cannot
-- touch its inside. Please use insert or lookup, instead.
data IPRTable k a
-- | The empty function returns an empty IP routing table.
empty :: (IP k) => IPRTable k a
-- | The insert function inserts a value with a key of
-- IPRange to IPRTable and returns a new IPRTable.
insert :: (IP k) => IPRange k -> a -> IPRTable k a -> IPRTable k a
-- | The lookup function looks up IPRTable with a key of
-- IPRange and returns its value if exists.
lookup :: (IP k) => IPRange k -> IPRTable k a -> Maybe a
-- | The fromList function creates a new IP routing table from a
-- list of a pair of IPrange and value.
fromList :: (IP k) => [(IPRange k, a)] -> IPRTable k a
-- | The toList function creates a list of a pair of
-- IPrange and value from an IP routing table.
toList :: (IP k) => IPRTable k a -> [(IPRange k, a)]