IPv6Addr-1.0.4: Library to deal with IPv6 address text representations.

Safe HaskellNone
LanguageHaskell2010

Text.IPv6Addr

Contents

Synopsis

Documentation

maybeIPv6Addr :: Text -> Maybe IPv6Addr Source #

Returns Just the text representation of a canonized IPv6Addr in conformation with RFC 5952, or Nothing.

maybeIPv6Addr "0:0::FFFF:192.0.2.128" == Just (IPv6Addr "::ffff:192.0.2.128")

maybePureIPv6Addr :: Text -> Maybe IPv6Addr Source #

Returns Just a pure IPv6Addr, or Nothing.

maybePureIPv6Addr "::ffff:192.0.2.128" == Just (IPv6Addr "::ffff:c000:280")

maybeFullIPv6Addr :: Text -> Maybe IPv6Addr Source #

Returns Just a pure and fully expanded IPv6Addr, or Nothing.

maybeFullIPv6Addr "::ffff:192.0.2.128" == Just (IPv6Addr "0000:0000:0000:0000:0000:ffff:c000:0280")

sameIPv6Addr :: Text -> Text -> Bool Source #

Returns True if arguments are two textual representations of a same IPv6 address.

Conversions

fromIPv6Addr :: IPv6Addr -> Text Source #

Returns the Text of an IPv6 address.

toIPv6 :: IPv6Addr -> IPv6 Source #

Given an IPv6addr, returns the corresponding IPv6 address.

toHostName :: IPv6Addr -> HostName Source #

Given an IPv6Addr, returns the corresponding HostName.

toIP6ARPA :: IPv6Addr -> Text Source #

Returns the reverse lookup domain name corresponding of the given IPv6 address (RFC 3596 Section 2.5).

toIP6ARPA (IPv6Addr "4321:0:1:2:3:4:567:89ab") == "b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.ARPA."

toUNC :: IPv6Addr -> Text Source #

Returns the Windows UNC path name of the given IPv6 Address.

toUNC (IPv6Addr "2001:0DB8:002a:1005:230:48ff:fe73:989d") == "2001-db8-2a-1005-230-48ff-fe73-989d.ipv6-literal.net"

Utilities

getIPv6AddrOf :: String -> IO (Maybe IPv6Addr) Source #

Returns Just the canonized IPv6Addr of the given local network interface, or Nothing.

getIPv6AddrOf "eth0"

randIPv6Addr :: IO IPv6Addr Source #

Returns a random IPv6Addr.

randIPv6AddrWithPrefix :: Maybe Text -> IO (Maybe IPv6Addr) Source #

Returns a random IPv6Addr, optionally with the given prefix.

randIPv6AddrWithPrefix (Just "4321:0:1:2:3:4")

Manipulations

data IPv6AddrToken Source #

Constructors

SixteenBit !Text

A four hexadecimal digits group representing a 16-Bit chunk

AllZeros

An all zeros 16-Bit chunk

Colon

A separator between 16-Bit chunks

DoubleColon

A double-colon stands for a unique compression of many consecutive 16-Bit chunks

IPv4Addr !Text

An embedded IPv4 address as representation of the last 32-Bit

randIPv6AddrChunk :: String -> IO IPv6AddrToken Source #

Returns Just a random SixteenBit token based on a mask "____", each underscore being replaced by a random hexadecimal digit.

randIPv6AddrChunk "_f__" == Just (SixteenBit "bfd4")

randPartialIPv6Addr :: Int -> IO [IPv6AddrToken] Source #

Generates a random partial IPv6Addr with n SixteenBit.

macAddrToIPv6AddrTokens :: Text -> Maybe [IPv6AddrToken] Source #

Given a MAC address, returns Just the corresponding IPv6AddrToken list, or Nothing.

macAddrToIPv6AddrTokens "fa:1d:58:cc:95:16" == Just [SixteenBit "fa1d",Colon,SixteenBit "58cc",Colon,SixteenBit "9516"]

getTokIPv6AddrOf :: String -> IO (Maybe [IPv6AddrToken]) Source #

Given a valid name of a local network interface, returns Just the list of tokens of the interface's IPv6 address, or Nothing.

getTokIPv6AddrOf "eth0" == Just [SixteenBit "fe80",DoubleColon,SixteenBit "fa1d",Colon,SixteenBit "58cc",Colon,SixteenBit "9516"]

getTokMacAddrOf :: String -> IO (Maybe [IPv6AddrToken]) Source #

Given a valid name of a local network interface, returns Just the corresponding list of IPv6AddrToken of the interface's MAC Address, or Nothing.

getTokMacAddrOf "eth0" == Just [SixteenBit "fa1d",Colon,SixteenBit "58cc",Colon,SixteenBit "9516"]