Win32-dhcp-server-0.2: Win32 DHCP Server Management API.

Safe HaskellNone

Data.Ip

Contents

Description

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

Synopsis

Documentation

data Ip

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.

Instances

String conversions

readIp :: Text -> Either String Ip

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

Represent an Ip as a String.

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

Octet conversions

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

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

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

Extract each of the 4 octets from an Ip.

Other conversions