Commit graph

445 commits

Author SHA1 Message Date
Sami Kerola
30238e9d1c build-sys: use non-recursive build
For reasons see excellent paper 'Recursive Make Considered Harmful' by
Peter Miller.

References: http://miller.emu.id.au/pmiller/books/rmch/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-24 22:46:04 +01:00
Sami Kerola
0495ea4edf build-sys: fix gnulib function order
gl_EARLY should be called before gl_INIT

References: http://www.gnu.org/software/gnulib/manual/html_node/Initial-import.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-24 21:12:37 +01:00
Sami Kerola
ab535d8ab1 tests: add a test for one ip range
A regression test for commit ffffbc9 fix.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-22 23:16:18 +01:00
Sami Kerola
ffffbc96cc getdata: make single address ranges work
The dhcpd.conf can contain single IP range definitions, such as

range 10.20.30.40;

and they must be understood similar way as the range definiton would have
two IP's that are the same IP, e.g.,

range 10.20.30.40 10.20.30.40;

Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-22 23:08:21 +01:00
Sami Kerola
b24fc42ec8 getdata: make a lease address detection more robust
The commit 805d353584 did not fix all
possible problem cases.  This commit attempts to address remaining
issues.

Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-22 22:47:25 +01:00
Sami Kerola
1a7649beb3 tests: check how command works with invalid input
Lack of this check resulted to bug that was shipped to users, which was
fixed in commit 805d353.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-21 14:37:34 +01:00
Sami Kerola
805d353584 getdata: certain input files caused SIGSEGV
When dhcpd.conf file got to be parsed such way that IP version could not
be determined the dhcpd.lease file parsing resulted to SIGSEGV.

Reported-by: Joey D. <jobewan@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-21 14:30:21 +01:00
Sami Kerola
5966360f12 getdata: posix_fadvise() error checking
Helmut reported run of 'make check' failing in debian pbuilder
environment.  The posix_fadvise() functions were failing with a message
such as

 dhcpd-pools: parse_config: fadvise ../tests/confs/complete: Cannot allocate memory

which to me is likely error in how an error is determined.  Relying on
errno value not being mangled by libc is unreliable.  Attempt to fix this
is simple, check return values of these function calls and ignore the
errno.

Reported-by: Helmut Grohne <h.grohne@cygnusnetworks.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-21 14:05:59 +01:00
Sami Kerola
90c1a4e4c5 build-sys: reorder gnulib macro in relation to C standard
When ./bootstrap has ran it tells to

  - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC_C99,

Also AC_USE_SYSTEM_EXTENSIONS is needed to suppress spurious gnulib
warnings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:17:52 +01:00
Sami Kerola
3e677d8a24 tests: binding states commit needs to be reflected in expected results
The commit b858a4778b changed a little bit
to which category various binding states fall into.  That has to be
reflected in expected test results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:04:24 +01:00
Sami Kerola
7c34231004 build-sys: update git-version-gen from gnulib
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:04:24 +01:00
Sami Kerola
d2b7d10dbc build-sys: ensure distribution has version file
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:04:23 +01:00
Sami Kerola
327b601ea4 docs: fix spelling mistakes in manual page
Also quote dashes used in EXAMPLEs section.

Reported-by: Helmut Grohne <h.grohne@cygnusnetworks.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:04:23 +01:00
Sami Kerola
5ee1aca2b9 build-sys: add git-version-gen and test.sh to release package
Without this patch autoreconf, when done with release tarball, fails like
this:

$ autoreconf -f -i
sh: 1: build-aux/git-version-gen: not found
configure.ac:12: error: AC_INIT should be called with package and version arguments
/usr/share/aclocal-1.11/init.m4:26: AM_INIT_AUTOMAKE is expanded from...
configure.ac:12: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: /usr/bin/autom4te failed with exit status: 1
autoreconf: aclocal failed with exit status: 1

Further down the road tests start to fail after autoreconf.

make[4]: Leaving directory `/home/grohne/debian/dhcpd-pools-debian/tests'
make[3]: *** No rule to make target `../tests/test.sh', needed by `check-local'.  Stop.
make[3]: Leaving directory `/home/grohne/debian/dhcpd-pools-debian/tests'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/home/grohne/debian/dhcpd-pools-debian/tests'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/grohne/debian/dhcpd-pools-debian'

Which is a symptom of not having test.sh in distribution.

Reported-by: Helmut Grohne <h.grohne@cygnusnetworks.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-09 21:04:19 +01:00
Cheer Xiao
b858a4778b getdata: treat binding states abandoned, expired and release like free 2013-04-07 20:16:44 +08:00
Sami Kerola
cdf2c81f31 build-sys: update .gitignore
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 23:21:49 +01:00
Sami Kerola
c3e492165c cppcheck: fix variable scoping
[src/dhcpd-pools.c:68]: (style) The scope of the variable 'c' can be reduced.
[src/getdata.c:210]: (style) The scope of the variable 'c' can be reduced.
[src/hash.c:102]: (style) The scope of the variable 'l' can be reduced.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-05 23:13:10 +01:00
Sami Kerola
23aae87356 include: add missing declarations to dhcpd-pool.h
This will fix eight warnings similar to the example below.

sort.c:104:5: warning: no previous declaration for 'comp_ip' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-03-08 23:38:25 +00:00
Sami Kerola
8e2da89c88 tests: add complete check including multiple ranges and shared networks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-16 12:56:22 +00:00
Sami Kerola
f3a476ba52 release: 2.21
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 20:30:32 +00:00
Sami Kerola
625c54d834 docs: fix doxygen make distcheck breakage
The docs directory needs to be handled properly, e.g., create Makefile
which nothing, when doxygen is not enabled.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 20:28:26 +00:00
Sami Kerola
e50d0a7d38 tests: fix make distcheck
It is best to make dhcpd-pools used from PATH, which makes out of tree
build check to work.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 20:28:26 +00:00
Sami Kerola
34f73dbae1 docs: thanks to Cheer Xiao this software has IPv6 support
The prof. Xing Li in Tsinghua University, with LI Zimu, asked Cheer to
make the dhcpd-pools more usable for them which I, as a project
maintainer, could not be more pleased.  Whils making the IPv6 analysis to
work Cheer also fixed various other issues.  Kudos to him, and big thanks
to everyone.

CC: Xing Li <xing@cernet.edu.cn>
CC: LI Zimu <lzm@cernet.edu.cn>
CC: Cheer Xiao <xiaqqaix@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 17:41:38 +00:00
Sami Kerola
632e97834b build-sys: update .gitignore files
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 17:30:01 +00:00
Sami Kerola
3be3f34bd4 build-sys: allow tests run parallel
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-15 17:27:50 +00:00
Cheer Xiao
478bbe1b44 output: fix doc of output_double 2013-01-09 10:19:06 +08:00
Cheer Xiao
ff7ca8c419 tests: update expected/v6
The range size in the old file was also incorrect.
2013-01-08 23:00:57 +08:00
Cheer Xiao
75d979bb00 sort: let comp_* functions compare double 2013-01-08 22:59:35 +08:00
Cheer Xiao
9c4184bd9a counting: Let get_range_size return double 2013-01-08 22:57:33 +08:00
Cheer Xiao
afd9f77051 sort: let field_selector return NULL at the end 2013-01-08 22:57:07 +08:00
Cheer Xiao
6820c9fc09 fix: Put prototype of field_selector back to dhcpd-pools.h
It's needed in main to check unknown field selectors.
2013-01-08 22:52:54 +08:00
Cheer Xiao
6642335c8a counting & output: Convert all counters to double 2013-01-08 22:47:50 +08:00
Cheer Xiao
39e1fb9e5a sort: Get rid of global comparer 2013-01-08 22:41:41 +08:00
Cheer Xiao
137c1d37c2 sort: Use a comparer instead of returner
This resolves the FIXME of sorting ranges according to first_ip in IPv6 mode.
2013-01-08 22:41:36 +08:00
Sami Kerola
4051a953bd smatch scan: fix few warnings
dhcpd-pools.h:79:17: warning: comma at end of enumerator list [-pedantic]
hash.c:85 delete_lease() info: redundant null check on lease->ethernet calling free()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-20 20:04:06 +00:00
Sami Kerola
70c65f4d59 getdata: be consistant with symbolic numbers
The program counts quotes, which is never true/false value, and one of
the symbolic parse state values was missed in bd5ee58.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:38:37 +00:00
Sami Kerola
51143b6b3c clean up: fix few indentation slips
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:28:58 +00:00
Sami Kerola
82df7c98d4 clean up: rename get_order() to merge() and mark static
No other function than mergesort_ranges() can use the merge(), so calling
it with rather generic name and making it static seems right to me.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:26:03 +00:00
Sami Kerola
bd5ee58a3f clean up: convert parsing magic numbers to symbolic values
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:26:03 +00:00
Sami Kerola
4b014eba1c clean up: use enum as symbolic bit masks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 23:25:57 +00:00
Sami Kerola
d3ee104a59 clean up: move global variables to config structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 22:56:07 +00:00
Sami Kerola
b59e980cab hash: make delete to use HASH_ITER if it is available
This commit also makes the functions ansi C compliant by adding void to
function argument list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 22:43:32 +00:00
Sami Kerola
a9d2d9c82f clean up: move code to more proper location
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 22:40:00 +00:00
Sami Kerola
2008e1a047 clean up: remove unused functions
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 22:27:58 +00:00
Sami Kerola
f1411858cb backup counting: fix output regression
The backup count was not printed at all.  This bug was introduced in
version 2.17 (May 2012) when the uthash was taken in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 22:15:14 +00:00
Sami Kerola
3471c91796 docs: add doxygen tags, configuration file, and autotooling
When ./configure --enable-doxygen is used one can browse internal api
documentation from docs/html directory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-09 21:06:32 +00:00
Sami Kerola
aa7928b3ab output ethernet: do not crash if ethernet is missing
Real dhcpd.leases file should always have ethernet address markup, but
test data or malformed files might not have.  Even if the check is 99.99%
useless there are the corner cases, and crashing at them is not good.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-07 22:32:28 +00:00
Sami Kerola
fdc560bab9 ouput format: fix active lease printing
Earlier ethernet address collection did not remove duplicated.  Basically
the problem was the same as in problem fixed in commit
ae7747db87, but this time affecting only
the ethernet addresses.  The fix is, as one can see, to make ethernet
collection to share structure with the lease, so that if one is wrong
both are wrong the same way.

Reported-by: Gilles Bouthenot <gilles.bouthenot@univ-fcomte.fr>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-07 21:55:06 +00:00
Sami Kerola
d8aae53968 tests: add json tests, and make fail output loud
Gilles reported the full-json is currently broken, which the new check
demonstrates.  Luckily the issue occurs only when active leases details
are being queried, leaving the count to be correct.  That said bug is a
bug, and that should be corrected.

Reported-by: Gilles Bouthenot <gilles.bouthenot@univ-fcomte.fr>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-07 20:25:21 +00:00
Sami Kerola
a768049f3e json output: use defined output file for all printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-07 20:12:34 +00:00