From: Michael Orlitzky Date: Sun, 2 May 2010 21:05:46 +0000 (-0400) Subject: Replace the Maskbits type alias with the real thing. X-Git-Tag: 0.0.1~76 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=3e3eff58c713987a442b418a3db01335307ac079;p=hath.git Replace the Maskbits type alias with the real thing. --- diff --git a/src/IPv4Address.hs b/src/IPv4Address.hs index 7c5d80d..037698a 100644 --- a/src/IPv4Address.hs +++ b/src/IPv4Address.hs @@ -1,7 +1,6 @@ module IPv4Address ( ipv4address_from_octets, IPv4Address(None), - Maskbits, max_octet1, max_octet2, max_octet3, @@ -14,10 +13,9 @@ module IPv4Address where import Bit +import Maskbits import Octet -type Maskbits = Int - data IPv4Address = None | IPv4Address { octet1 :: Octet, octet2 :: Octet, octet3 :: Octet, @@ -39,7 +37,8 @@ ipv4address_from_octets oct1 oct2 oct3 oct4 min_address :: IPv4Address -> Maskbits -> IPv4Address -min_address addr mask +min_address _ Maskbits.None = IPv4Address.None +min_address addr (Maskbits mask) | mask == 32 = IPv4Address oct1 oct2 oct3 oct4 | mask == 31 = IPv4Address oct1 oct2 oct3 (Octet a25 a26 a27 a28 a29 a30 a31 Zero) | mask == 30 = IPv4Address oct1 oct2 oct3 (Octet a25 a26 a27 a28 a29 a30 Zero Zero) @@ -111,7 +110,8 @@ min_address addr mask max_address :: IPv4Address -> Maskbits -> IPv4Address -max_address addr mask +max_address _ Maskbits.None = IPv4Address.None +max_address addr (Maskbits mask) | mask == 32 = IPv4Address oct1 oct2 oct3 oct4 | mask == 31 = IPv4Address oct1 oct2 oct3 (Octet a25 a26 a27 a28 a29 a30 a31 One) | mask == 30 = IPv4Address oct1 oct2 oct3 (Octet a25 a26 a27 a28 a29 a30 One One)