combine_all,
contains,
contains_proper,
+ enumerate,
max_octet1,
max_octet2,
max_octet3,
import Data.List (nubBy)
import Data.List.Split (splitOneOf)
-import Data.Maybe (catMaybes, fromJust)
+import Data.Maybe (catMaybes, fromJust, mapMaybe)
import Test.HUnit (assertEqual)
import Test.Framework (Test, testGroup)
-- of its octets (as Ints).
octets_from_cidr_string :: String -> [Octet]
octets_from_cidr_string s =
- catMaybes $ map octet_from_string (take 4 (splitOneOf "./" s))
+ mapMaybe octet_from_string (take 4 (splitOneOf "./" s))
-- | Return Nothing if we can't parse both maskbits and octets from
-- cidr1, then at least mbits1 of an address in cidr2 will match
-- cidr1. For example,
--
--- cidr1 = 192.168.1.0/23, cidr2 = 192.168.1.100/24
+-- cidr1 = 192.168.1.0\/23, cidr2 = 192.168.1.100\/24
--
-- Here, cidr2 contains all of 192.168.1.0 through
-- 192.168.1.255. However, cidr1 contains BOTH 192.168.0.0 through
mbits2 = maskbits cidr2
-
+enumerate :: Cidr -> [IPv4Address]
+enumerate cidr = [(min_host cidr)..(max_host cidr)]
-- HUnit Tests