Safe Haskell | None |
---|---|
Language | Haskell2010 |
Text.IPv6Addr
Synopsis
- newtype IPv6Addr = IPv6Addr {
- unIPv6Addr :: Text
- maybeIPv6Addr :: Text -> Maybe IPv6Addr
- maybePureIPv6Addr :: Text -> Maybe IPv6Addr
- maybeFullIPv6Addr :: Text -> Maybe IPv6Addr
- sameIPv6Addr :: Text -> Text -> Bool
- toIPv6 :: IPv6Addr -> IPv6
- toHostName :: IPv6Addr -> HostName
- toIP6ARPA :: IPv6Addr -> Text
- toUNC :: IPv6Addr -> Text
- getIPv6AddrOf :: String -> IO (Maybe IPv6Addr)
- randIPv6Addr :: IO IPv6Addr
- randIPv6AddrWithPrefix :: Maybe Text -> IO (Maybe IPv6Addr)
- data IPv6AddrToken
- = SixteenBit !Text
- | AllZeros
- | Colon
- | DoubleColon
- | IPv4Addr !Text
- randIPv6AddrChunk :: String -> IO IPv6AddrToken
- randPartialIPv6Addr :: Int -> IO [IPv6AddrToken]
- macAddrToIPv6AddrTokens :: Text -> Maybe [IPv6AddrToken]
- getTokIPv6AddrOf :: String -> IO (Maybe [IPv6AddrToken])
- getTokMacAddrOf :: String -> IO (Maybe [IPv6AddrToken])
Documentation
Constructors
IPv6Addr | |
Fields
|
sameIPv6Addr :: Text -> Text -> Bool Source #
Returns True
if arguments are two textual representations of a same IPv6 address.
Conversions
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
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 |
Instances
Eq IPv6AddrToken Source # | |
Defined in Text.IPv6Addr Methods (==) :: IPv6AddrToken -> IPv6AddrToken -> Bool # (/=) :: IPv6AddrToken -> IPv6AddrToken -> Bool # | |
Show IPv6AddrToken Source # | |
Defined in Text.IPv6Addr Methods showsPrec :: Int -> IPv6AddrToken -> ShowS # show :: IPv6AddrToken -> String # showList :: [IPv6AddrToken] -> ShowS # |
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 #
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"]