Win32-dhcp-server-0.3.1: Win32 DHCP Server Management API

Safe HaskellNone
LanguageHaskell2010

Data.Ip

Contents

Description

This module was taken, with modifications, from the maccatcher package.

Synopsis

Documentation

data Ip Source

An Ip can be used as an IP address or subnet address.

A Show instance is omitted to avoid confusion. Use showIp and readIp to convert between Strings.

String conversions

readIp :: Text -> Either String Ip Source

Parse a Text value as an Ip. The string should be of the form X.X.X.X where each X is a decimal value between 0 and 255 inclusive.

>>> let Right ip = readIp "192.168.1.100"
>>> toOctets ip
(192, 168, 1, 100)

showIp :: Ip -> Text Source

Represent an Ip as a String.

>>> showIp $ fromOctets 192 168 1 100
"192.168.1.100"

Octet conversions

fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> Ip Source

An IP address is 32-bits wide. This function will construct an Ip from 4 octets.

toOctets :: Ip -> (Word8, Word8, Word8, Word8) Source

Extract each of the 4 octets from an Ip.

Other conversions