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

Safe HaskellNone




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



data Mac Source

A Mac is a 6-byte unique identifier used in layer-two network addressing. Its Storable instance occupies 6 bytes of memory when poked with the first byte occupying the lowest address, and the last byte occupying the highest address.

A Show instance is omitted to avoid confusion. Use showMac and readMac to convert between Strings.

String conversions

readMac :: Text -> Either String Mac Source

Parse a Text value as a Mac. The string should not use any separators between octets.

>>> let Right mac = readMac "000102030405"
>>> toOctets mac
(0, 1, 2, 3, 4, 5)

showMac :: Text -> Mac -> Text Source

Represent a Mac as a String. The supplied separator will be placed between each octet in the final output.

>>> showMac "" $ fromOctets 0xa 0xb 0xc 0xd 0xe 0xf
>>> showMac ":" $ fromOctets 0x11 0x22 0x33 0x44 0x55 0x66

Octet conversions

fromOctets :: Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Word8 -> Mac Source

A Mac address is 48-bits wide. This function will construct a Mac from 6 octets.

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

Extract each of the 6 octets from a Mac.

Other conversions