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

Safe HaskellNone
LanguageHaskell2010

Text.IPv6Addr

Contents

Synopsis

Documentation

data IPv6Addr Source

Constructors

IPv6Addr Text 

Instances

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.

Utils

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."

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")