deriving (Eq, Show)
-default_ipv4address :: IPv4Address
-default_ipv4address = IPv4Address (min_octet) (min_octet) (min_octet) (min_octet)
-
-
-ipv4address_from_string :: String -> IPv4Address
-ipv4address_from_string s
- | length s < 32 = default_ipv4address
- | otherwise = IPv4Address (Octet a1 a2 a3 a4 a5 a6 a7 a8) (Octet a9 a10 a11 a12 a13 a14 a15 a16)(Octet a17 a18 a19 a20 a21 a22 a23 a24) (Octet a25 a26 a27 a28 a29 a30 a31 a32)
- where
- a1 = bit_from_char (s !! 0)
- a2 = bit_from_char (s !! 1)
- a3 = bit_from_char (s !! 2)
- a4 = bit_from_char (s !! 3)
- a5 = bit_from_char (s !! 4)
- a6 = bit_from_char (s !! 5)
- a7 = bit_from_char (s !! 6)
- a8 = bit_from_char (s !! 7)
- a9 = bit_from_char (s !! 8)
- a10 = bit_from_char (s !! 9)
- a11 = bit_from_char (s !! 10)
- a12 = bit_from_char (s !! 11)
- a13 = bit_from_char (s !! 12)
- a14 = bit_from_char (s !! 13)
- a15 = bit_from_char (s !! 14)
- a16 = bit_from_char (s !! 15)
- a17 = bit_from_char (s !! 16)
- a18 = bit_from_char (s !! 17)
- a19 = bit_from_char (s !! 18)
- a20 = bit_from_char (s !! 19)
- a21 = bit_from_char (s !! 20)
- a22 = bit_from_char (s !! 21)
- a23 = bit_from_char (s !! 22)
- a24 = bit_from_char (s !! 23)
- a25 = bit_from_char (s !! 24)
- a26 = bit_from_char (s !! 25)
- a27 = bit_from_char (s !! 26)
- a28 = bit_from_char (s !! 27)
- a29 = bit_from_char (s !! 28)
- a30 = bit_from_char (s !! 29)
- a31 = bit_from_char (s !! 30)
- a32 = bit_from_char (s !! 31)
-
-
min_address :: IPv4Address -> Maskbits -> IPv4Address
min_address addr mask
| mask == 32 = IPv4Address oct1 oct2 oct3 oct4