• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

compare/H01-Feb-2014-13489

inaddr/H01-Feb-2014-200146

kids/H01-Feb-2014-11884

mkstr/H01-Feb-2014-166132

netbc/H01-Feb-2014-8457

nums/H01-Feb-2014-7952

parent/H01-Feb-2014-9062

regression/H01-Feb-2014-405333

GNUmakefileH A D01-Feb-2014214 115

MakefileH A D01-Feb-2014168 85

READMEH A D01-Feb-20143.4 KiB6754

run.shH A D01-Feb-201461 31

README

1These test files are basically intended for development use, to test the
2various functions of the library and make sure they do what we expect
3them to.  However, they can also be useful in illustrating how the
4functions work and what their uses are.
5
6Some, like mkstr, can also be particularly useful on their own in certain
7cases.  Note that pretty much all of them use cidr_from_str() and
8cidr_to_str() to take their input and show their output, of course.
9
10Note that there's a "run.sh" program provided in this dir; this uses the
11LD_LIBRARY_PATH environmental variable to allow running the programs
12using the shared library, even though it's not in any of the standard
13system library paths.  Thus, you'd build the programs, then run them with
14an invocation something like "../run.sh ./cidr_mkstr 1.2.3.4/5".
15
16
17Here's a quick rundown of what they cover:
18
19- regression/ contains a perl script intended for automated regression
20  testing.  Currently, it only tests 'mkstr', since the place I'm worried
21  about regressions (and finding always more weird edge cases in) is in
22  cidr_from_str(); the rest of the functions are sufficiently simple that
23  I've not yet found a need for automated testing of them.
24  cidr_from_str() is fiendishly complicated, and fixing one thing often
25  breaks another, so it's needed here.
26
27- compare/ takes two blocks on the command line, and uses cidr_contains()
28  to tell you whether they're the same block, one contains the other, or
29  they're overlapping.
30
31- inaddr/ uses the C library inet_pton() and inet_ntop() functions to
32  double-check cidr_{to,from}_inaddr() and cidr_{to,from}_in6addr() and
33  make sure they act right.  Note that some failures aren't necessarily a
34  problem, since in[6]_addr only store addresses, not netmasks, so it's
35  not surprising if things don't match sometimes.
36
37- kids/ uses cidr_net_subnets() to recursively show all the ways a given
38  netblock can be subnetted.  For safety, this only accepts IPv4 prefixes
39  /24 and longer and IPv6 prefixes /120 and up; otherwise it could be
40  printf()'ing from now until doomsday.  Trying to show every possible
41  subnet of ::/0, for instance, would take JUST a little time (the number
42  of output lines would be on the order of 2**129; put THAT through your
43  sliderule).
44
45- mkstr/ tests cidr_from_str() and cidr_to_str() by taking in subnets
46  from the command line, turning them into CIDR structs, and then
47  spitting out string forms of the structs.  What makes it particularly
48  useful are the wide array of arguments it accepts to try out various
49  combinations of the cidr_to_str() flags and get all the different
50  string representations libcidr can create.  It's handy if you can't be
51  bothered figuring out what an IPv6 address would look like in fully
52  expanded form manually, for instance.  The cidrcalc example program
53  shows a lot of the highlights, but this lets you fudge it just about
54  any way the library supports.
55
56- netbc/ uses the cidr_addr_network() and cidr_addr_broadcast() functions
57  to show the (take a wild guess) network and broadcast addresses of the
58  given netblock(s).
59
60- nums/ calls cidr_numaddr() and cidr_numhost() to show the number of
61  total addresses and host addresses in the given blocks.
62
63- parent/ keeps calling cidr_net_supernet() to find the parent network of
64  the given subnet, and the parent network of that, and the parent
65  network of that, and...   all the way up to 0/0 (rather, the v4 and v6
66  equivalents of 0/0).
67