From: Michael Orlitzky Date: Sun, 23 May 2010 16:52:41 +0000 (-0400) Subject: Update IPv4Address for the new definition of apply_mask. X-Git-Tag: 0.0.1~24 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=4b16a47bd77a82d63072497514476faeba6b8e83;p=hath.git Update IPv4Address for the new definition of apply_mask. --- diff --git a/src/IPv4Address.hs b/src/IPv4Address.hs index d15f88f..6d1e56e 100644 --- a/src/IPv4Address.hs +++ b/src/IPv4Address.hs @@ -51,41 +51,56 @@ instance Arbitrary IPv4Address where instance Maskable IPv4Address where - apply_mask _ Maskbits.None = IPv4Address.None - apply_mask addr mask - | mask == ThirtyTwo = ipv4address_from_octets oct1 oct2 oct3 oct4 - | mask == ThirtyOne = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Seven) - | mask == Thirty = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Six) - | mask == TwentyNine = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Five) - | mask == TwentyEight = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Four) - | mask == TwentySeven = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Three) - | mask == TwentySix = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 Two) - | mask == TwentyFive = ipv4address_from_octets oct1 oct2 oct3 (apply_mask oct4 One) - | mask == TwentyFour = ipv4address_from_octets oct1 oct2 oct3 (min_octet) - | mask == TwentyThree = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Seven) (min_octet) - | mask == TwentyTwo = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Six) (min_octet) - | mask == TwentyOne = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Five) (min_octet) - | mask == Twenty = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Four) (min_octet) - | mask == Nineteen = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Three) (min_octet) - | mask == Eighteen = ipv4address_from_octets oct1 oct2 (apply_mask oct3 Two) (min_octet) - | mask == Seventeen = ipv4address_from_octets oct1 oct2 (apply_mask oct3 One) (min_octet) - | mask == Sixteen = ipv4address_from_octets oct1 oct2 (min_octet) (min_octet) - | mask == Fifteen = ipv4address_from_octets oct1 (apply_mask oct2 Seven) (min_octet) (min_octet) - | mask == Fourteen = ipv4address_from_octets oct1 (apply_mask oct2 Six) (min_octet) (min_octet) - | mask == Thirteen = ipv4address_from_octets oct1 (apply_mask oct2 Five) (min_octet) (min_octet) - | mask == Twelve = ipv4address_from_octets oct1 (apply_mask oct2 Four) (min_octet) (min_octet) - | mask == Eleven = ipv4address_from_octets oct1 (apply_mask oct2 Three) (min_octet) (min_octet) - | mask == Ten = ipv4address_from_octets oct1 (apply_mask oct2 Two) (min_octet) (min_octet) - | mask == Nine = ipv4address_from_octets oct1 (apply_mask oct2 One) (min_octet) (min_octet) - | mask == Eight = ipv4address_from_octets oct1 (min_octet) (min_octet) (min_octet) - | mask == Seven = ipv4address_from_octets (apply_mask oct1 Seven) (min_octet) (min_octet) (min_octet) - | mask == Six = ipv4address_from_octets (apply_mask oct1 Six) (min_octet) (min_octet) (min_octet) - | mask == Five = ipv4address_from_octets (apply_mask oct1 Five) (min_octet) (min_octet) (min_octet) - | mask == Four = ipv4address_from_octets (apply_mask oct1 Four) (min_octet) (min_octet) (min_octet) - | mask == Three = ipv4address_from_octets (apply_mask oct1 Three) (min_octet) (min_octet) (min_octet) - | mask == Two = ipv4address_from_octets (apply_mask oct1 Two) (min_octet) (min_octet) (min_octet) - | mask == One = ipv4address_from_octets (apply_mask oct1 One) (min_octet) (min_octet) (min_octet) - | mask == Zero = ipv4address_from_octets (min_octet) (min_octet) (min_octet) (min_octet) + apply_mask _ Maskbits.None _ = IPv4Address.None + apply_mask addr mask bit + | mask == ThirtyTwo = addr + | mask == ThirtyOne = addr { octet4 = (apply_mask oct4 Seven bit) } + | mask == Thirty = addr { octet4 = (apply_mask oct4 Six bit) } + | mask == TwentyNine = addr { octet4 = (apply_mask oct4 Five bit) } + | mask == TwentyEight = addr { octet4 = (apply_mask oct4 Four bit) } + | mask == TwentySeven = addr { octet4 = (apply_mask oct4 Three bit) } + | mask == TwentySix = addr { octet4 = (apply_mask oct4 Two bit) } + | mask == TwentyFive = addr { octet4 = (apply_mask oct4 One bit) } + | mask == TwentyFour = addr { octet4 = min_octet } + | mask == TwentyThree = addr { octet3 = (apply_mask oct3 Seven bit), + octet4 = min_octet } + | mask == TwentyTwo = addr { octet3 = (apply_mask oct3 Six bit), + octet4 = min_octet } + | mask == TwentyOne = addr { octet3 = (apply_mask oct3 Five bit), + octet4 = min_octet } + | mask == Twenty = addr { octet3 = (apply_mask oct3 Four bit), + octet4 = min_octet } + | mask == Nineteen = addr { octet3 = (apply_mask oct3 Three bit), + octet4 = min_octet } + | mask == Eighteen = addr { octet3 = (apply_mask oct3 Two bit), + octet4 = min_octet } + | mask == Seventeen = addr { octet3 = (apply_mask oct3 One bit), + octet4 = min_octet } + | mask == Sixteen = addr { octet3 = min_octet, + octet4 = min_octet } + | mask == Fifteen = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Seven bit) } + | mask == Fourteen = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Six bit) } + | mask == Thirteen = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Five bit) } + | mask == Twelve = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Four bit) } + | mask == Eleven = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Three bit) } + | mask == Ten = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 Two bit) } + | mask == Nine = min_address { octet1 = oct1, + octet2 = (apply_mask oct2 One bit) } + | mask == Eight = min_address { octet1 = oct1 } + | mask == Seven = min_address { octet1 = (apply_mask oct1 Seven bit) } + | mask == Six = min_address { octet1 = (apply_mask oct1 Six bit) } + | mask == Five = min_address { octet1 = (apply_mask oct1 Five bit) } + | mask == Four = min_address { octet1 = (apply_mask oct1 Four bit) } + | mask == Three = min_address { octet1 = (apply_mask oct1 Three bit) } + | mask == Two = min_address { octet1 = (apply_mask oct1 Two bit) } + | mask == One = min_address { octet1 = (apply_mask oct1 One bit) } + | mask == Zero = min_address | otherwise = IPv4Address.None where oct1 = (octet1 addr)