ip-1.4.1: Library for IP and MAC addresses

Safe HaskellNone
LanguageHaskell2010

Net.Types

Synopsis

Documentation

newtype IPv4 Source #

A 32-bit Internet Protocol version 4 address. To use this with the network library, it is necessary to use Network.Socket.htonl to convert the underlying Word32 from host byte order to network byte order.

Constructors

IPv4 

Fields

Instances
Bounded IPv4 Source # 
Instance details

Defined in Net.IPv4

Enum IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

succ :: IPv4 -> IPv4 #

pred :: IPv4 -> IPv4 #

toEnum :: Int -> IPv4 #

fromEnum :: IPv4 -> Int #

enumFrom :: IPv4 -> [IPv4] #

enumFromThen :: IPv4 -> IPv4 -> [IPv4] #

enumFromTo :: IPv4 -> IPv4 -> [IPv4] #

enumFromThenTo :: IPv4 -> IPv4 -> IPv4 -> [IPv4] #

Eq IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

(==) :: IPv4 -> IPv4 -> Bool #

(/=) :: IPv4 -> IPv4 -> Bool #

Ord IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

compare :: IPv4 -> IPv4 -> Ordering #

(<) :: IPv4 -> IPv4 -> Bool #

(<=) :: IPv4 -> IPv4 -> Bool #

(>) :: IPv4 -> IPv4 -> Bool #

(>=) :: IPv4 -> IPv4 -> Bool #

max :: IPv4 -> IPv4 -> IPv4 #

min :: IPv4 -> IPv4 -> IPv4 #

Read IPv4 Source # 
Instance details

Defined in Net.IPv4

Show IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

showsPrec :: Int -> IPv4 -> ShowS #

show :: IPv4 -> String #

showList :: [IPv4] -> ShowS #

Generic IPv4 Source # 
Instance details

Defined in Net.IPv4

Associated Types

type Rep IPv4 :: * -> * #

Methods

from :: IPv4 -> Rep IPv4 x #

to :: Rep IPv4 x -> IPv4 #

Hashable IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

hashWithSalt :: Int -> IPv4 -> Int #

hash :: IPv4 -> Int #

ToJSON IPv4 Source # 
Instance details

Defined in Net.IPv4

ToJSONKey IPv4 Source # 
Instance details

Defined in Net.IPv4

FromJSON IPv4 Source # 
Instance details

Defined in Net.IPv4

FromJSONKey IPv4 Source # 
Instance details

Defined in Net.IPv4

Storable IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

sizeOf :: IPv4 -> Int #

alignment :: IPv4 -> Int #

peekElemOff :: Ptr IPv4 -> Int -> IO IPv4 #

pokeElemOff :: Ptr IPv4 -> Int -> IPv4 -> IO () #

peekByteOff :: Ptr b -> Int -> IO IPv4 #

pokeByteOff :: Ptr b -> Int -> IPv4 -> IO () #

peek :: Ptr IPv4 -> IO IPv4 #

poke :: Ptr IPv4 -> IPv4 -> IO () #

Bits IPv4 Source #

Note: we use network order (big endian) as opposed to host order (little endian) which differs from the underlying IPv4 type representation.

Instance details

Defined in Net.IPv4

FiniteBits IPv4 Source # 
Instance details

Defined in Net.IPv4

NFData IPv4 Source # 
Instance details

Defined in Net.IPv4

Methods

rnf :: IPv4 -> () #

Prim IPv4 Source # 
Instance details

Defined in Net.IPv4

Unbox IPv4 Source # 
Instance details

Defined in Net.IPv4

Vector Vector IPv4 Source # 
Instance details

Defined in Net.IPv4

MVector MVector IPv4 Source # 
Instance details

Defined in Net.IPv4

type Rep IPv4 Source # 
Instance details

Defined in Net.IPv4

type Rep IPv4 = D1 (MetaData "IPv4" "Net.IPv4" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" True) (C1 (MetaCons "IPv4" PrefixI True) (S1 (MetaSel (Just "getIPv4") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word32)))
data Vector IPv4 Source # 
Instance details

Defined in Net.IPv4

data MVector s IPv4 Source # 
Instance details

Defined in Net.IPv4

data IPv6 Source #

A 128-bit Internet Protocol version 6 address.

Constructors

IPv6 

Fields

Instances
Bounded IPv6 Source # 
Instance details

Defined in Net.IPv6

Enum IPv6 Source #

Since IPv6 has more inhabitants than Int, the implementation of fromEnum discards information. Currently, enumFromThen and enumFromThenTo emit an error, but this could be remedied if someone wants to provide an implementation of them.

Instance details

Defined in Net.IPv6

Methods

succ :: IPv6 -> IPv6 #

pred :: IPv6 -> IPv6 #

toEnum :: Int -> IPv6 #

fromEnum :: IPv6 -> Int #

enumFrom :: IPv6 -> [IPv6] #

enumFromThen :: IPv6 -> IPv6 -> [IPv6] #

enumFromTo :: IPv6 -> IPv6 -> [IPv6] #

enumFromThenTo :: IPv6 -> IPv6 -> IPv6 -> [IPv6] #

Eq IPv6 Source # 
Instance details

Defined in Net.IPv6

Methods

(==) :: IPv6 -> IPv6 -> Bool #

(/=) :: IPv6 -> IPv6 -> Bool #

Ord IPv6 Source # 
Instance details

Defined in Net.IPv6

Methods

compare :: IPv6 -> IPv6 -> Ordering #

(<) :: IPv6 -> IPv6 -> Bool #

(<=) :: IPv6 -> IPv6 -> Bool #

(>) :: IPv6 -> IPv6 -> Bool #

(>=) :: IPv6 -> IPv6 -> Bool #

max :: IPv6 -> IPv6 -> IPv6 #

min :: IPv6 -> IPv6 -> IPv6 #

Read IPv6 Source # 
Instance details

Defined in Net.IPv6

Show IPv6 Source # 
Instance details

Defined in Net.IPv6

Methods

showsPrec :: Int -> IPv6 -> ShowS #

show :: IPv6 -> String #

showList :: [IPv6] -> ShowS #

Generic IPv6 Source # 
Instance details

Defined in Net.IPv6

Associated Types

type Rep IPv6 :: * -> * #

Methods

from :: IPv6 -> Rep IPv6 x #

to :: Rep IPv6 x -> IPv6 #

ToJSON IPv6 Source # 
Instance details

Defined in Net.IPv6

FromJSON IPv6 Source # 
Instance details

Defined in Net.IPv6

NFData IPv6 Source # 
Instance details

Defined in Net.IPv6

Methods

rnf :: IPv6 -> () #

Prim IPv6 Source # 
Instance details

Defined in Net.IPv6

type Rep IPv6 Source # 
Instance details

Defined in Net.IPv6

type Rep IPv6 = D1 (MetaData "IPv6" "Net.IPv6" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" False) (C1 (MetaCons "IPv6" PrefixI True) (S1 (MetaSel (Just "ipv6A") SourceUnpack SourceStrict DecidedStrict) (Rec0 Word64) :*: S1 (MetaSel (Just "ipv6B") SourceUnpack SourceStrict DecidedStrict) (Rec0 Word64)))

newtype IP Source #

A 32-bit IPv4 address or a 128-bit IPv6 address. Internally, this is just represented as an IPv6 address. The functions provided in Net.IP help simulate constructing and pattern matching on values of this type. All functions and typeclass methods that convert IP values to text will display it as an IPv4 address if possible.

Constructors

IP 

Fields

Instances
Eq IP Source # 
Instance details

Defined in Net.IP

Methods

(==) :: IP -> IP -> Bool #

(/=) :: IP -> IP -> Bool #

Ord IP Source # 
Instance details

Defined in Net.IP

Methods

compare :: IP -> IP -> Ordering #

(<) :: IP -> IP -> Bool #

(<=) :: IP -> IP -> Bool #

(>) :: IP -> IP -> Bool #

(>=) :: IP -> IP -> Bool #

max :: IP -> IP -> IP #

min :: IP -> IP -> IP #

Read IP Source # 
Instance details

Defined in Net.IP

Show IP Source # 
Instance details

Defined in Net.IP

Methods

showsPrec :: Int -> IP -> ShowS #

show :: IP -> String #

showList :: [IP] -> ShowS #

Generic IP Source # 
Instance details

Defined in Net.IP

Associated Types

type Rep IP :: * -> * #

Methods

from :: IP -> Rep IP x #

to :: Rep IP x -> IP #

ToJSON IP Source # 
Instance details

Defined in Net.IP

FromJSON IP Source # 
Instance details

Defined in Net.IP

NFData IP Source # 
Instance details

Defined in Net.IP

Methods

rnf :: IP -> () #

type Rep IP Source # 
Instance details

Defined in Net.IP

type Rep IP = D1 (MetaData "IP" "Net.IP" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" True) (C1 (MetaCons "IP" PrefixI True) (S1 (MetaSel (Just "getIP") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 IPv6)))

data IPv4Range Source #

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.

Constructors

IPv4Range 
Instances
Eq IPv4Range Source # 
Instance details

Defined in Net.IPv4

Ord IPv4Range Source # 
Instance details

Defined in Net.IPv4

Read IPv4Range Source # 
Instance details

Defined in Net.IPv4

Show IPv4Range Source # 
Instance details

Defined in Net.IPv4

Generic IPv4Range Source # 
Instance details

Defined in Net.IPv4

Associated Types

type Rep IPv4Range :: * -> * #

Hashable IPv4Range Source # 
Instance details

Defined in Net.IPv4

ToJSON IPv4Range Source # 
Instance details

Defined in Net.IPv4

FromJSON IPv4Range Source # 
Instance details

Defined in Net.IPv4

Bits IPv4Range Source #

Notes:

  • bit operations use network order (big endian),
  • do not operate on host bits,
  • return a normalized range dropping host bits,
  • and "promote operands" by extending the length to the larger of two ranges.
Instance details

Defined in Net.IPv4

FiniteBits IPv4Range Source #

Note: the size is determined by the range length

Instance details

Defined in Net.IPv4

NFData IPv4Range Source # 
Instance details

Defined in Net.IPv4

Methods

rnf :: IPv4Range -> () #

Unbox IPv4Range Source # 
Instance details

Defined in Net.IPv4

Vector Vector IPv4Range Source # 
Instance details

Defined in Net.IPv4

MVector MVector IPv4Range Source # 
Instance details

Defined in Net.IPv4

type Rep IPv4Range Source # 
Instance details

Defined in Net.IPv4

type Rep IPv4Range = D1 (MetaData "IPv4Range" "Net.IPv4" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" False) (C1 (MetaCons "IPv4Range" PrefixI True) (S1 (MetaSel (Just "ipv4RangeBase") SourceUnpack SourceStrict DecidedStrict) (Rec0 IPv4) :*: S1 (MetaSel (Just "ipv4RangeLength") SourceUnpack SourceStrict DecidedStrict) (Rec0 Word8)))
data Vector IPv4Range Source # 
Instance details

Defined in Net.IPv4

data MVector s IPv4Range Source # 
Instance details

Defined in Net.IPv4

data IPv6Range Source #

Constructors

IPv6Range 
Instances
Eq IPv6Range Source # 
Instance details

Defined in Net.IPv6

Ord IPv6Range Source # 
Instance details

Defined in Net.IPv6

Read IPv6Range Source # 
Instance details

Defined in Net.IPv6

Show IPv6Range Source # 
Instance details

Defined in Net.IPv6

Generic IPv6Range Source # 
Instance details

Defined in Net.IPv6

Associated Types

type Rep IPv6Range :: * -> * #

NFData IPv6Range Source # 
Instance details

Defined in Net.IPv6

Methods

rnf :: IPv6Range -> () #

type Rep IPv6Range Source # 
Instance details

Defined in Net.IPv6

type Rep IPv6Range = D1 (MetaData "IPv6Range" "Net.IPv6" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" False) (C1 (MetaCons "IPv6Range" PrefixI True) (S1 (MetaSel (Just "ipv6RangeBase") SourceUnpack SourceStrict DecidedStrict) (Rec0 IPv6) :*: S1 (MetaSel (Just "ipv6RangeLength") SourceUnpack SourceStrict DecidedStrict) (Rec0 Word8)))

newtype Mac Source #

A 48-bit MAC address. Do not use the data constructor for this type. It is not considered part of the stable API, and it allows you to construct invalid MAC addresses.

Constructors

Mac Word64 
Instances
Bounded Mac Source # 
Instance details

Defined in Net.Mac

Methods

minBound :: Mac #

maxBound :: Mac #

Enum Mac Source # 
Instance details

Defined in Net.Mac

Methods

succ :: Mac -> Mac #

pred :: Mac -> Mac #

toEnum :: Int -> Mac #

fromEnum :: Mac -> Int #

enumFrom :: Mac -> [Mac] #

enumFromThen :: Mac -> Mac -> [Mac] #

enumFromTo :: Mac -> Mac -> [Mac] #

enumFromThenTo :: Mac -> Mac -> Mac -> [Mac] #

Eq Mac Source # 
Instance details

Defined in Net.Mac

Methods

(==) :: Mac -> Mac -> Bool #

(/=) :: Mac -> Mac -> Bool #

Ord Mac Source # 
Instance details

Defined in Net.Mac

Methods

compare :: Mac -> Mac -> Ordering #

(<) :: Mac -> Mac -> Bool #

(<=) :: Mac -> Mac -> Bool #

(>) :: Mac -> Mac -> Bool #

(>=) :: Mac -> Mac -> Bool #

max :: Mac -> Mac -> Mac #

min :: Mac -> Mac -> Mac #

Read Mac Source # 
Instance details

Defined in Net.Mac

Show Mac Source # 
Instance details

Defined in Net.Mac

Methods

showsPrec :: Int -> Mac -> ShowS #

show :: Mac -> String #

showList :: [Mac] -> ShowS #

Generic Mac Source # 
Instance details

Defined in Net.Mac

Associated Types

type Rep Mac :: * -> * #

Methods

from :: Mac -> Rep Mac x #

to :: Rep Mac x -> Mac #

Hashable Mac Source # 
Instance details

Defined in Net.Mac

Methods

hashWithSalt :: Int -> Mac -> Int #

hash :: Mac -> Int #

ToJSON Mac Source # 
Instance details

Defined in Net.Mac

ToJSONKey Mac Source # 
Instance details

Defined in Net.Mac

FromJSON Mac Source # 
Instance details

Defined in Net.Mac

FromJSONKey Mac Source # 
Instance details

Defined in Net.Mac

NFData Mac Source # 
Instance details

Defined in Net.Mac

Methods

rnf :: Mac -> () #

Prim Mac Source #

This only preserves the lower 6 bytes of the 8-byte word that backs a mac address. It runs slower than it would if it used a full 8-byte word, but it consumes less space. When storing millions of mac addresses, this is a good trade to make. When storing a small number of mac address, it might be preferable to make a primitive array of Word64 instead and use the mac address data constructor to coerce between the two.

Instance details

Defined in Net.Mac

type Rep Mac Source # 
Instance details

Defined in Net.Mac

type Rep Mac = D1 (MetaData "Mac" "Net.Mac" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" True) (C1 (MetaCons "Mac" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Word64)))

data MacCodec Source #

Instances
Eq MacCodec Source # 
Instance details

Defined in Net.Mac

Ord MacCodec Source # 
Instance details

Defined in Net.Mac

Read MacCodec Source # 
Instance details

Defined in Net.Mac

Show MacCodec Source # 
Instance details

Defined in Net.Mac

Generic MacCodec Source # 
Instance details

Defined in Net.Mac

Associated Types

type Rep MacCodec :: * -> * #

Methods

from :: MacCodec -> Rep MacCodec x #

to :: Rep MacCodec x -> MacCodec #

type Rep MacCodec Source # 
Instance details

Defined in Net.Mac

type Rep MacCodec = D1 (MetaData "MacCodec" "Net.Mac" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" False) (C1 (MetaCons "MacCodec" PrefixI True) (S1 (MetaSel (Just "macCodecGrouping") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 MacGrouping) :*: S1 (MetaSel (Just "macCodecUpperCase") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Bool)))

data MacGrouping Source #

The format expected by the mac address parser. The Word8 taken by some of these constructors is the ascii value of the character to be used as the separator. This is typically a colon, a hyphen, or a space character. All decoding functions are case insensitive.

Constructors

MacGroupingPairs !Char

Two-character groups, FA:2B:40:09:8C:11

MacGroupingTriples !Char

Three-character groups, 24B-F0A-025-829

MacGroupingQuadruples !Char

Four-character groups, A220.0745.CAC7

MacGroupingNoSeparator

No separator, 24AF4B5B0780

Instances
Eq MacGrouping Source # 
Instance details

Defined in Net.Mac

Ord MacGrouping Source # 
Instance details

Defined in Net.Mac

Read MacGrouping Source # 
Instance details

Defined in Net.Mac

Show MacGrouping Source # 
Instance details

Defined in Net.Mac

Generic MacGrouping Source # 
Instance details

Defined in Net.Mac

Associated Types

type Rep MacGrouping :: * -> * #

type Rep MacGrouping Source # 
Instance details

Defined in Net.Mac

type Rep MacGrouping = D1 (MetaData "MacGrouping" "Net.Mac" "ip-1.4.1-EoFLganEe87B23MDW12YOQ" False) ((C1 (MetaCons "MacGroupingPairs" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Char)) :+: C1 (MetaCons "MacGroupingTriples" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Char))) :+: (C1 (MetaCons "MacGroupingQuadruples" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Char)) :+: C1 (MetaCons "MacGroupingNoSeparator" PrefixI False) (U1 :: * -> *)))