Overview -------- Hath is a Haskell program for working with network blocks in CIDR[1] notation. When dealing with blocks of network addresses, there are a few things that you (i.e. I) want to do with them: * Create a regular expression matching the CIDR block(s). This is because grep will throw up if you feed it CIDR. * Combine small blocks into larger ones. For example, if you have two consecutive /24s, they might combine into a larger /23. * View the result of block combination in a useful way. Hath does just that. It takes as its input (via stdin, or a file with the -i parameter) a list of CIDR blocks. From now on, assume we have the following in cidrs.txt: 10.0.0.0/24 10.0.1.0/24 Modes ----- Hath has the following modes: * Regexed This computes a (Perl-compatible) regular expression matching the input CIDR blocks. It's the default mode of operation. $ hath -i cidrs.txt ([^\.0-9](10)\.(0)\.(0)\.(0)[^\.0-9]|[^\.0-9](10)\.(0)\.(1) \.(0)[^\.0-9]) * Reduced This combines small blocks into larger ones where possible, and eliminates redundant blocks. The output should be equivalent to the input, though. $ hath reduced -i cidrs.txt 10.0.0.0/23 * Duped Shows only the blocks that would be removed by reduce; that is, it shows the ones that would get combined into larger blocks or are simply redundant. $ hath duped -i cidrs.txt 10.0.0.0/24 10.0.1.0/24 * Diffed Shows what would change if you used reduce. Uses diff-like notation. $ hath diffed -i cidrs.txt -10.0.0.0/24 -10.0.1.0/24 +10.0.0.0/23 Each of the modes also supports a present-tense flavor; the following are equivalent to their counterparts: regex, reduce, dupe, diff. Bugs ---- Send bugs to the moon[2]. [1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing [2] michael@orlitzky.com