Win32-dhcp-server-0.1: 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 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.

Instances

String conversions

readIp :: String -> Maybe IpSource

Parse a String 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 Just ip = readIp "192.168.1.100"
>>> toOctets ip
(192, 168, 1, 100)

showIp :: Ip -> StringSource

Represent an Ip as a String.

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

Octet conversions

fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> IpSource

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