module Cidr
( Cidr,
from_string,
+ is_valid_cidr,
min_first_octet,
max_first_octet,
min_second_octet,
import Data.Char (digitToInt, intToDigit)
import Numeric (readInt, showIntAtBase)
+import Text.Regex.Posix
+
import ListUtils
type Maskbits = Int
maskbits :: Maskbits }
deriving (Show)
+-- Will return True if the passed String is in CIDR notation, False
+-- otherwise.
+is_valid_cidr :: String -> Bool
+is_valid_cidr cidr = cidr =~ "([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}"
+
first :: (a,b,c,d) -> a
first (w,_,_,_) = w
import System.Exit (ExitCode(..), exitWith)
import System.IO (stderr, hPutStrLn)
-import Text.Regex.Posix
-
import Cidr (Cidr,
from_string,
+ is_valid_cidr,
min_first_octet,
min_second_octet,
min_third_octet,
max4 = max_fourth_octet cidr
--- Will return True if the passed String is in CIDR notation, False
--- otherwise.
-is_valid_cidr :: String -> Bool
-is_valid_cidr cidr = cidr =~ "([0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}"
-
-- Take a list of Strings, and return a regular expression matching
-- any of them.
-- Take a CIDR String, and exit with a failure if it's invalid.
validate_or_die :: String -> IO ()
validate_or_die cidr = do
- if (is_valid_cidr cidr)
+ if (Cidr.is_valid_cidr cidr)
then do
return ()
else do