iproute-0.1: IP Routing Table

Data.IP

Description

Data structures to express IPv4, IPv6 and IP range.

Synopsis

Documentation

class Eq a => IP a whereSource

A class to contain IPv4 and IPv6.

Methods

masked :: a -> a -> aSource

The masked function takes an IP address and a contiguous IP mask and returned a masked IP address.

intToMask :: Int -> aSource

The intToMask function takes Int and returns a contiguous IP mask.

intToTBit :: Int -> aSource

The intToTBit function takes Int and returns an IP address whose only n-th bit is set.

isZero :: a -> a -> BoolSource

The isZero function takes an IP address and an test bit IP address and returns True is the bit is unset, otherwise returns False.

Instances

data IPv4 Source

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 IPv6 Source

The abstract data structure to express an IPv6 address. To create this, use toIPv6. Or use read "2001:DB8::1" :: IPv6, for example.

toIPv4 :: [Int] -> IPv4Source

The toIPv4 function takes a list of Int and returns IPv4. For example, toIPv4 [192,0,2,1].

toIPv6 :: [Int] -> IPv6Source

The toIPv6 function takes a list of Int and returns IPv6. For example, toIPv6 [0x2001,0xDB8,0,0,0,0,0,1].

data IP a => IPRange a Source

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.

Instances

IP a => Eq (IPRange a) 
(Ord a, IP a) => Ord (IPRange a) 
Read (IPRange IPv6) 
Read (IPRange IPv4) 
(IP a, Show a) => Show (IPRange a) 

addr :: IPRange a -> aSource

The addr function returns an IP address from IPRange.

mask :: IPRange a -> aSource

The mask function returns a contiguous IP mask from IPRange.

mlen :: IPRange a -> IntSource

The mlen function returns a mask length from IPRange.

(>:>) :: IP a => IPRange a -> IPRange a -> BoolSource

The >:> operator takes two IPRange. It returns True if the first IPRange contains the second IPRange. Otherwise, it returns False.

makeIPRange :: IP a => a -> Int -> IPRange aSource

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.