--- Return true if the first argument (a CIDR range) contains the
--- second (another CIDR range). There are a lot of ways we can be fed
--- junk here. For lack of a better alternative, just return False when
--- we are given nonsense.
-contains :: Cidr -> Cidr -> Bool
-contains Cidr.None _ = False
-contains _ Cidr.None = False
-contains (Cidr _ Maskbits.None) _ = False
-contains (Cidr IPv4Address.None _) _ = False
-contains _ (Cidr _ Maskbits.None) = False
-contains _ (Cidr IPv4Address.None _) = False
-
--- If the number of bits in the network part of the first address is
--- larger than the number of bits in the second, there is no way that
--- the first range can contain the second. For, if the number of
--- network bits is larger, then the number of host bits must be
--- smaller, and if cidr1 has fewer hosts than cidr2, cidr1 most
--- certainly does not contain cidr2.
+min_host :: Cidr -> IPv4Address
+min_host (Cidr addr mask) = apply_mask addr mask B.Zero
+
+
+max_host :: Cidr -> IPv4Address
+max_host (Cidr addr mask) = apply_mask addr mask B.One
+
+
+min_octet1 :: Cidr -> Octet
+min_octet1 cidr = octet1 (min_host cidr)
+
+min_octet2 :: Cidr -> Octet
+min_octet2 cidr = octet2 (min_host cidr)
+
+min_octet3 :: Cidr -> Octet
+min_octet3 cidr = octet3 (min_host cidr)
+
+min_octet4 :: Cidr -> Octet
+min_octet4 cidr = octet4 (min_host cidr)
+
+max_octet1 :: Cidr -> Octet
+max_octet1 cidr = octet1 (max_host cidr)
+
+max_octet2 :: Cidr -> Octet
+max_octet2 cidr = octet2 (max_host cidr)
+
+max_octet3 :: Cidr -> Octet
+max_octet3 cidr = octet3 (max_host cidr)
+
+max_octet4 :: Cidr -> Octet
+max_octet4 cidr = octet4 (max_host cidr)
+
+
+
+-- | Return true if the first argument (a CIDR range) contains the
+-- second (another CIDR range). There are a lot of ways we can be
+-- fed junk here. For lack of a better alternative, just return
+-- False when we are given nonsense.
+--
+-- If the number of bits in the network part of the first address is
+-- larger than the number of bits in the second, there is no way
+-- that the first range can contain the second. For, if the number
+-- of network bits is larger, then the number of host bits must be
+-- smaller, and if cidr1 has fewer hosts than cidr2, cidr1 most
+-- certainly does not contain cidr2.