From 761c9560d701c8dcd2727a4489a87e9fb0a60d11 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 28 Nov 2012 19:48:10 +0000 Subject: [PATCH 001/313] build-sys: remove c++ compiler check I have no idea why that was there. My guess is that I had no idea at the time I added the line what it does. Signed-off-by: Sami Kerola --- configure.ac | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9299cb1..269889c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# -*- Autoconf -*- +# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.64) @@ -17,7 +17,6 @@ AC_GNU_SOURCE # Checks for programs AC_PROG_AWK -AC_PROG_CC_C99 gl_EARLY gl_INIT AC_C_RESTRICT From 6684772550119a1beee42699535ba2e33e333a66 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 28 Nov 2012 19:50:42 +0000 Subject: [PATCH 002/313] tools: add indent command configuration file And reindent all files. Reference: http://www.gnu.org/software/indent/ Signed-off-by: Sami Kerola --- src/.indent.pro | 2 ++ src/analyze.c | 5 +++-- src/dhcpd-pools.c | 14 ++++++------ src/dhcpd-pools.h | 55 ++++++++++++++++++++++++++--------------------- src/getdata.c | 5 ++--- src/sort.c | 5 +++-- 6 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 src/.indent.pro diff --git a/src/.indent.pro b/src/.indent.pro new file mode 100644 index 0000000..34e832f --- /dev/null +++ b/src/.indent.pro @@ -0,0 +1,2 @@ +-linux -Tuintmax_t -TFILE -Tsize_t -Toff_t -Ttime_t -ppi1 + diff --git a/src/analyze.c b/src/analyze.c index cd738ff..d38db6b 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -42,7 +42,8 @@ #include "dhcpd-pools.h" /* Clean up data */ -static int ip_sort(const struct leases_t *restrict a, const struct leases_t *restrict b) +static int ip_sort(const struct leases_t *restrict a, + const struct leases_t *restrict b) { if (a->ip < b->ip) return -1; @@ -56,7 +57,7 @@ int prepare_data(void) /* Sort leases */ HASH_SORT(leases, ip_sort); /* Sort ranges */ - qsort(ranges, (size_t) num_ranges, sizeof(struct range_t), &rangecomp); + qsort(ranges, (size_t)num_ranges, sizeof(struct range_t), &rangecomp); return 0; } diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index f50c48a..26a353b 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -101,7 +101,7 @@ int main(int argc, char **argv) fullhtml = false; /* Make sure some output format is selected by default */ - strncpy(config.output_format, OUTPUT_FORMAT, (size_t) 1); + strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1); /* Default sort order is by IPs small to big */ config.reverse_order = false; @@ -125,7 +125,7 @@ int main(int argc, char **argv) break; case 'f': /* Output format */ - strncpy(config.output_format, optarg, (size_t) 1); + strncpy(config.output_format, optarg, (size_t)1); break; case 's': /* Output sorting option */ @@ -133,10 +133,10 @@ int main(int argc, char **argv) if (5 < sorts) { warnx ("main: only first 5 sort orders will be used"); - strncpy(config.sort, optarg, (size_t) 5); + strncpy(config.sort, optarg, (size_t)5); sorts = 5; } else { - strncpy(config.sort, optarg, (size_t) sorts); + strncpy(config.sort, optarg, (size_t)sorts); } for (i = 0; i < sorts; i++) { field_selector(config.sort[i]); @@ -165,11 +165,13 @@ int main(int argc, char **argv) break; case OPT_WARN: strcpy(config.output_format, "a"); - config.warning = strtod_or_err(optarg, "illegal argument"); + config.warning = + strtod_or_err(optarg, "illegal argument"); break; case OPT_CRIT: strcpy(config.output_format, "a"); - config.critical = strtod_or_err(optarg, "illegal argument"); + config.critical = + strtod_or_err(optarg, "illegal argument"); break; case 'v': /* Print version */ diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index b14a25b..0b98497 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -36,20 +36,20 @@ #ifndef DHCPD_POOLS_H # define DHCPD_POOLS_H 1 -#include -#include -#include -#include -#include -#include +# include +# include +# include +# include +# include +# include -#ifdef HAVE_BUILTIN_EXPECT -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -#else -# define likely(x) (x) -# define unlikely(x) (x) -#endif +# ifdef HAVE_BUILTIN_EXPECT +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif /* Structures and unions */ struct configuration_t { @@ -89,7 +89,7 @@ enum ltype { BACKUP }; struct leases_t { - uint32_t ip; /* ip as key */ + uint32_t ip; /* ip as key */ enum ltype type; UT_hash_handle hh; }; @@ -113,31 +113,35 @@ struct macaddr_t *macaddr; /* Function prototypes */ int prepare_memory(void); int parse_leases(void); -void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) +void parse_config(int, const char *__restrict, + struct shared_network_t *__restrict) __attribute__ ((nonnull(2, 3))); void nth_field(char *__restrict dest, const char *__restrict src) __attribute__ ((nonnull(1, 2))) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((__hot__)) -#endif +# endif ; int prepare_data(void); int do_counting(void); -void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) +void flip_ranges(struct range_t *__restrict ranges, + struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ int xstrstr(const char *__restrict a, const char *__restrict b, int len) __attribute__ ((nonnull(1, 2))) -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((__hot__)) -#endif +# endif ; -double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); +double strtod_or_err(const char *__restrict str, + const char *__restrict errmesg); void print_version(void) __attribute__ ((noreturn)); void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ -int intcomp(const void *__restrict x, const void *__restrict y) __attribute__ ((nonnull(1, 2))); +int intcomp(const void *__restrict x, const void *__restrict y) + __attribute__ ((nonnull(1, 2))); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ @@ -153,7 +157,8 @@ unsigned long int ret_tcperc(struct range_t r); void field_selector(char c); int get_order(struct range_t *__restrict left, struct range_t *__restrict right) __attribute__ ((nonnull(1, 2))); -void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) +void mergesort_ranges(struct range_t *__restrict orig, int size, + struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); /* output function pointer and functions */ int (*output_analysis) (void); @@ -166,8 +171,8 @@ int output_alarming(void); void clean_up(void); /* Hash functions */ void add_lease(int ip, enum ltype type); -struct leases_t * find_lease(int ip); -void delete_lease(struct leases_t * lease); +struct leases_t *find_lease(int ip); +void delete_lease(struct leases_t *lease); void delete_all_leases(); #endif /* DHCPD_POOLS_H */ diff --git a/src/getdata.c b/src/getdata.c index e10798f..9270581 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -368,9 +368,8 @@ void parse_config(int is_include, const char *restrict config_file, RANGES *= 2; ranges = xrealloc(ranges, - sizeof(struct - range_t) * - RANGES); + sizeof(struct + range_t) * RANGES); range_p = ranges + num_ranges; } newclause = true; diff --git a/src/sort.c b/src/sort.c index 4230511..c018e45 100644 --- a/src/sort.c +++ b/src/sort.c @@ -59,7 +59,7 @@ int rangecomp(const void *restrict r1, const void *restrict r2) (((struct range_t *)r2)->first_ip)) return -1; if ((((struct range_t *)r2)->first_ip) < - (((struct range_t *)r1)->first_ip)) + (((struct range_t *)r1)->first_ip)) return 1; return 0; } @@ -174,7 +174,8 @@ int get_order(struct range_t *restrict left, struct range_t *restrict right) return (0); } -void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *restrict temp) +void mergesort_ranges(struct range_t *restrict orig, int size, + struct range_t *restrict temp) { int left, right, i; struct range_t hold; From 71bcee14e9db16b8fe805c53612285bcae6e1102 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 29 Nov 2012 19:58:38 +0000 Subject: [PATCH 003/313] tests: add basic tests The tests can be ran using 'make check'. Signed-off-by: Sami Kerola --- Makefile.am | 2 +- configure.ac | 1 + tests/.gitignore | 3 +++ tests/Makefile.am | 16 ++++++++++++++ tests/bootp | 1 + tests/confs/bootp | 5 +++++ tests/confs/leading0 | 5 +++++ tests/confs/simple | 5 +++++ tests/expected/bootp | 10 +++++++++ tests/expected/leading0 | 10 +++++++++ tests/expected/simple | 10 +++++++++ tests/leading0 | 1 + tests/leases/bootp | 1 + tests/leases/leading0 | 1 + tests/leases/simple | 48 +++++++++++++++++++++++++++++++++++++++++ tests/simple | 1 + tests/test.sh | 15 +++++++++++++ 17 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 tests/.gitignore create mode 100644 tests/Makefile.am create mode 120000 tests/bootp create mode 100644 tests/confs/bootp create mode 100644 tests/confs/leading0 create mode 100644 tests/confs/simple create mode 100644 tests/expected/bootp create mode 100644 tests/expected/leading0 create mode 100644 tests/expected/simple create mode 120000 tests/leading0 create mode 120000 tests/leases/bootp create mode 120000 tests/leases/leading0 create mode 100644 tests/leases/simple create mode 120000 tests/simple create mode 100755 tests/test.sh diff --git a/Makefile.am b/Makefile.am index 22158cb..9618448 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,4 +4,4 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = m4/gnulib-cache.m4 -SUBDIRS = lib src man contrib +SUBDIRS = lib src man tests contrib diff --git a/configure.ac b/configure.ac index 269889c..e75498e 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,7 @@ AC_CONFIG_FILES([ src/Makefile man/Makefile man/dhcpd-pools.1 + tests/Makefile contrib/Makefile ]) diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..c831351 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +/Makefile +/Makefile.in +/outputs diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..d51cec1 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,16 @@ +EXTRA_DIST = \ + bootp \ + confs \ + expected \ + leading0 \ + leases \ + simple \ + test.sh + +TESTS = simple bootp leading0 +check_SCRIPTS = test.sh + +check-local: $(SHELL) $(top_srcdir)/tests/test.sh + +clean-local: + rm -rf $(top_builddir)/tests/outputs diff --git a/tests/bootp b/tests/bootp new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/bootp @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/confs/bootp b/tests/confs/bootp new file mode 100644 index 0000000..7e4564e --- /dev/null +++ b/tests/confs/bootp @@ -0,0 +1,5 @@ +subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range dynamic-bootp 10.0.0.1 10.0.0.10; + } +} diff --git a/tests/confs/leading0 b/tests/confs/leading0 new file mode 100644 index 0000000..6d4deb8 --- /dev/null +++ b/tests/confs/leading0 @@ -0,0 +1,5 @@ +subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range dynamic-bootp 10.0.0.001 10.0.0.010; + } +} diff --git a/tests/confs/simple b/tests/confs/simple new file mode 100644 index 0000000..56881c6 --- /dev/null +++ b/tests/confs/simple @@ -0,0 +1,5 @@ +subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range 10.0.0.1 10.0.0.10; + } +} diff --git a/tests/expected/bootp b/tests/expected/bootp new file mode 100644 index 0000000..da14b05 --- /dev/null +++ b/tests/expected/bootp @@ -0,0 +1,10 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.0.0.1 - 10.0.0.10 10 10 100.000 0 10 100.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 10 10 100.000 0 10 100.000 diff --git a/tests/expected/leading0 b/tests/expected/leading0 new file mode 100644 index 0000000..46da8bf --- /dev/null +++ b/tests/expected/leading0 @@ -0,0 +1,10 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.0.0.1 - 10.0.0.8 8 8 100.000 0 8 100.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 8 8 100.000 0 8 100.000 diff --git a/tests/expected/simple b/tests/expected/simple new file mode 100644 index 0000000..da14b05 --- /dev/null +++ b/tests/expected/simple @@ -0,0 +1,10 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.0.0.1 - 10.0.0.10 10 10 100.000 0 10 100.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 10 10 100.000 0 10 100.000 diff --git a/tests/leading0 b/tests/leading0 new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/leading0 @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/leases/bootp b/tests/leases/bootp new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/leases/bootp @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/leases/leading0 b/tests/leases/leading0 new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/leases/leading0 @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/leases/simple b/tests/leases/simple new file mode 100644 index 0000000..9454b83 --- /dev/null +++ b/tests/leases/simple @@ -0,0 +1,48 @@ +lease 10.0.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.0.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.0.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.0.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.0.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.0.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.0.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.0.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.0.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} +lease 10.0.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} +lease 10.0.0.10 { + binding state active; + hardware ethernet 00:00:00:00:00:10; +} +lease 10.0.0.11 { + binding state active; + hardware ethernet 00:00:00:00:00:11; +} diff --git a/tests/simple b/tests/simple new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/simple @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..f1f1587 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# +# Minimal regression test suite. + +TEST_TOPDIR=$(cd $(dirname $0) && pwd) +IAM=$(basename $0) +DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools) + +if [ ! -d outputs ]; then + mkdir outputs +fi + +$DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM +diff -q expected/$IAM outputs/$IAM >/dev/null +exit $? From a57d399643cade9ddbfd71b129533c711101c51a Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Sun, 2 Dec 2012 19:38:26 +0000 Subject: [PATCH 004/313] IPv6: add DHCPv6 support The DHCP version is determined according to the first IP address that appears in the configuration file. Caveat; counters are of native long type. Since IPv6 address space has 2^128 addresses, they are subject to overflow. [Sami Kerola: This commit also fixed a percent sorting bug, which has been broken always. See changes ret_percent() for the fix.] CC: LI Zimu CC: Xing Li Reviewed-by: Sami Kerola Signed-off-by: Cheer Xiao --- src/analyze.c | 30 ++++-------- src/dhcpd-pools.c | 8 ++++ src/dhcpd-pools.h | 39 ++++++++++++++-- src/getdata.c | 63 +++++++++++++++++-------- src/hash.c | 21 +++++++-- src/other.c | 72 ++++++++++++++++++++++++++++ src/output.c | 116 +++++++++++++++++++++++----------------------- src/sort.c | 37 ++++++++++----- 8 files changed, 267 insertions(+), 119 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index d38db6b..f66b150 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -42,20 +42,10 @@ #include "dhcpd-pools.h" /* Clean up data */ -static int ip_sort(const struct leases_t *restrict a, - const struct leases_t *restrict b) -{ - if (a->ip < b->ip) - return -1; - if (a->ip > b->ip) - return 1; - return 0; -} - int prepare_data(void) { /* Sort leases */ - HASH_SORT(leases, ip_sort); + HASH_SORT(leases, leasecomp); /* Sort ranges */ qsort(ranges, (size_t)num_ranges, sizeof(struct range_t), &rangecomp); return 0; @@ -68,20 +58,18 @@ int do_counting(void) const struct leases_t *restrict l = leases; unsigned long i, k, block_size; - unsigned long r_end; range_p = ranges; /* Walk through ranges */ for (i = 0; i < num_ranges; i++) { - for (; l != NULL && range_p->first_ip < l->ip; l = l->hh.prev) + for (; l != NULL && ipcomp(&range_p->first_ip, &l->ip) < 0; + l = l->hh.prev) /* rewind */ ; if (l == NULL) l = leases; - /* last_ip + 1 make comparison to small bit quicker as it results to - * be 'smaller than' not 'smaller or equal to' */ - r_end = range_p->last_ip + 1; - for (; l != NULL && l->ip < r_end; l = l->hh.next) { - if (l->ip < range_p->first_ip) { + for (; l != NULL && ipcomp(&l->ip, &range_p->last_ip) <= 0; + l = l->hh.next) { + if (ipcomp(&l->ip, &range_p->first_ip) < 0) { /* should not be necessary */ continue; } @@ -114,8 +102,7 @@ int do_counting(void) } /* Size of range, shared net & all networks */ - block_size = - (unsigned int)(range_p->last_ip - range_p->first_ip + 1); + block_size = get_range_size(range_p); if (range_p->shared_net) { range_p->shared_net->available += block_size; } @@ -131,8 +118,7 @@ int do_counting(void) shared_networks->touched = 0; range_p = ranges; for (k = 0; k < num_ranges; k++) { - shared_networks->available += - range_p->last_ip - range_p->first_ip + 1; + shared_networks->available += get_range_size(range_p); shared_networks->used += range_p->count; shared_networks->touched += range_p->touched; shared_networks->backups += range_p->backups; diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 26a353b..91c518c 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -239,6 +239,14 @@ int main(int argc, char **argv) /* Global allocations, counter resets etc */ int prepare_memory(void) { + /* Fill in prefix length cache */ + int i, j; + for (i = 0; i < 2; i++) { + for (j = 0; j < NUM_OF_PREFIX; j++) { + prefix_length[i][j] = strlen(prefixes[i][j]); + } + } + dhcp_version = VERSION_UNKNOWN; RANGES = 64; num_ranges = num_shared_networks = 0; shared_networks = diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 0b98497..287c153 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -52,7 +52,26 @@ # endif /* Structures and unions */ +union ipaddr_t { + uint32_t v4; + unsigned char v6[16]; +}; +enum dhcp_version { + VERSION_4, + VERSION_6, + VERSION_UNKNOWN, +}; +enum prefix_t { + PREFIX_LEASE, + PREFIX_BINDING_STATE_FREE, + PREFIX_BINDING_STATE_ACTIVE, + PREFIX_BINDING_STATE_BACKUP, + PREFIX_HARDWARE_ETHERNET, + NUM_OF_PREFIX +}; + struct configuration_t { + char dhcpv6; char *dhcpdconf_file; char *dhcpdlease_file; char output_format[2]; @@ -72,8 +91,8 @@ struct shared_network_t { }; struct range_t { struct shared_network_t *shared_net; - uint32_t first_ip; - uint32_t last_ip; + union ipaddr_t first_ip; + union ipaddr_t last_ip; unsigned long int count; unsigned long int touched; unsigned long int backups; @@ -89,13 +108,16 @@ enum ltype { BACKUP }; struct leases_t { - uint32_t ip; /* ip as key */ + union ipaddr_t ip; /* ip as key */ enum ltype type; UT_hash_handle hh; }; /* Global variables */ +const char *prefixes[2][NUM_OF_PREFIX]; +int prefix_length[2][NUM_OF_PREFIX]; struct configuration_t config; +enum dhcp_version dhcp_version; static int const output_limit_bit_1 = 1; static int const output_limit_bit_2 = 2; static int const output_limit_bit_3 = 4; @@ -128,6 +150,11 @@ void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ +int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst); +void copy_ipaddr(union ipaddr_t *restrict dst, + const union ipaddr_t *restrict src); +const char *ntop_ipaddr(const union ipaddr_t *ip); +unsigned long get_range_size(const struct range_t *r); int xstrstr(const char *__restrict a, const char *__restrict b, int len) __attribute__ ((nonnull(1, 2))) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) @@ -142,6 +169,8 @@ void usage(int status) __attribute__ ((noreturn)); /* ...for ranges and... */ int intcomp(const void *__restrict x, const void *__restrict y) __attribute__ ((nonnull(1, 2))); +int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ @@ -170,8 +199,8 @@ int output_alarming(void); /* Memory release, file closing etc */ void clean_up(void); /* Hash functions */ -void add_lease(int ip, enum ltype type); -struct leases_t *find_lease(int ip); +void add_lease(union ipaddr_t *ip, enum ltype type); +struct leases_t *find_lease(union ipaddr_t *ip); void delete_lease(struct leases_t *lease); void delete_all_leases(); diff --git a/src/getdata.c b/src/getdata.c index 9270581..a792806 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -53,13 +53,34 @@ #include "dhcpd-pools.h" #include "xalloc.h" +/* The .indent.pro in use will mess formatting of array below. Please do + * not commit less readable indentation. */ +const char *prefixes[2][NUM_OF_PREFIX] = { + [VERSION_4] = { + [PREFIX_LEASE] = "lease ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + }, + [VERSION_6] = { + [PREFIX_LEASE] = " iaaddr ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + } +}; + +int prefix_length[2][NUM_OF_PREFIX] = { }; + /* Parse dhcpd.leases file. All performance boosts for this function are * welcome */ int parse_leases(void) { FILE *dhcpd_leases; char *line, *ipstring, *macstring = NULL; - struct in_addr inp; + union ipaddr_t addr; struct stat lease_file_stats; struct macaddr_t *macaddr_p = NULL; int sw_active_lease = 0; @@ -105,43 +126,46 @@ int parse_leases(void) macaddr_p->next = NULL; } + const char **p = prefixes[dhcp_version]; + int *l = prefix_length[dhcp_version]; +#define HAS_PREFIX(line, type) xstrstr((line), p[type], l[type]) + while (!feof(dhcpd_leases)) { if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) { err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); } /* It's a lease, save IP */ - if (xstrstr(line, "lease", 5)) { - memcpy(ipstring, line + 6, 16); - nth_field(ipstring, ipstring); - inet_aton(ipstring, &inp); + if (HAS_PREFIX(line, PREFIX_LEASE)) { + nth_field(ipstring, line + l[PREFIX_LEASE]); + parse_ipaddr(ipstring, &addr); sw_active_lease = 0; continue; } - if (xstrstr(line, " binding state free", 20)) { + if (HAS_PREFIX(line, PREFIX_BINDING_STATE_FREE)) { /* remove old entry, if exists */ - if ((lease = find_lease(ntohl(inp.s_addr))) != NULL) { + if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } - add_lease(ntohl(inp.s_addr), FREE); + add_lease(&addr, FREE); continue; } /* Copy IP to correct array */ - if (xstrstr(line, " binding state active", 22)) { + if (HAS_PREFIX(line, PREFIX_BINDING_STATE_ACTIVE)) { /* remove old entry, if exists */ - if ((lease = find_lease(ntohl(inp.s_addr))) != NULL) { + if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } - add_lease(ntohl(inp.s_addr), ACTIVE); + add_lease(&addr, ACTIVE); sw_active_lease = 1; continue; } - if (xstrstr(line, " binding state backup", 22)) { + if (HAS_PREFIX(line, PREFIX_BINDING_STATE_BACKUP)) { /* remove old entry, if exists */ - if ((lease = find_lease(ntohl(inp.s_addr))) != NULL) { + if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } - add_lease(ntohl(inp.s_addr), BACKUP); + add_lease(&addr, BACKUP); continue; } if ((macaddr != NULL) @@ -159,6 +183,7 @@ int parse_leases(void) } } } +#undef HAS_PREFIX free(line); free(ipstring); if (macaddr != NULL) { @@ -204,7 +229,7 @@ void parse_config(int is_include, const char *restrict config_file, size_t i = 0; char *word, c; int braces_shared = 1000; - struct in_addr inp; + union ipaddr_t addr; struct range_t *range_p; word = xmalloc(sizeof(char) * MAXLEN); @@ -356,9 +381,9 @@ void parse_config(int is_include, const char *restrict config_file, case 2: /* printf ("range 2nd ip: %s\n", word); */ range_p = ranges + num_ranges; - inet_aton(word, &inp); + parse_ipaddr(word, &addr); argument = 0; - range_p->last_ip = ntohl(inp.s_addr); + copy_ipaddr(&range_p->last_ip, &addr); range_p->count = 0; range_p->touched = 0; range_p->backups = 0; @@ -377,12 +402,12 @@ void parse_config(int is_include, const char *restrict config_file, case 3: /* printf ("range 1nd ip: %s\n", word); */ range_p = ranges + num_ranges; - if (!(inet_aton(word, &inp))) { + if (!(parse_ipaddr(word, &addr))) { /* word was not ip, try * again */ break; } - range_p->first_ip = ntohl(inp.s_addr); + copy_ipaddr(&range_p->first_ip, &addr); argument = 2; break; case 1: diff --git a/src/hash.c b/src/hash.c index 4978259..a9e41b8 100644 --- a/src/hash.c +++ b/src/hash.c @@ -36,20 +36,31 @@ #include "dhcpd-pools.h" #include "xalloc.h" -void add_lease(int ip, enum ltype type) +#define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out) +#define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add) + +void add_lease(union ipaddr_t *addr, enum ltype type) { struct leases_t *l; l = xmalloc(sizeof(struct leases_t)); - l->ip = ip; + copy_ipaddr(&l->ip, addr); l->type = type; - HASH_ADD_INT(leases, ip, l); + if (dhcp_version == VERSION_6) { + HASH_ADD_V6(leases, ip.v6, l); + } else { + HASH_ADD_INT(leases, ip.v4, l); + } } -struct leases_t *find_lease(int ip) +struct leases_t *find_lease(union ipaddr_t *addr) { struct leases_t *l; - HASH_FIND_INT(leases, &ip, l); + if (dhcp_version == VERSION_6) { + HASH_FIND_V6(leases, &addr->v6, l); + } else { + HASH_FIND_INT(leases, &addr->v4, l); + } return l; } diff --git a/src/other.c b/src/other.c index 7c34578..a970c0e 100644 --- a/src/other.c +++ b/src/other.c @@ -45,6 +45,78 @@ #include #include #include +#include + +int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) +{ + int rv; + if (dhcp_version == VERSION_UNKNOWN) { + struct in_addr addr; + struct in6_addr addr6; + if (inet_aton(src, &addr) == 1) { + dhcp_version = VERSION_4; + } else if (inet_pton(AF_INET6, src, &addr6) == 1) { + dhcp_version = VERSION_6; + } else { + return 0; + } + } + if (dhcp_version == VERSION_6) { + struct in6_addr addr; + rv = inet_pton(AF_INET6, src, &addr); + memcpy(&dst->v6, addr.s6_addr, sizeof(addr.s6_addr)); + } else { + struct in_addr addr; + rv = inet_aton(src, &addr); + dst->v4 = ntohl(addr.s_addr); + } + return rv == 1; +} + +void copy_ipaddr(union ipaddr_t *restrict dst, + const union ipaddr_t *restrict src) +{ + if (dhcp_version == VERSION_6) { + memcpy(&dst->v6, &src->v6, sizeof(src->v6)); + } else { + dst->v4 = src->v4; + } +} + +const char *ntop_ipaddr(const union ipaddr_t *ip) +{ + static char + buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; + if (dhcp_version == VERSION_6) { + struct in6_addr addr; + memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); + return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); + } else { + struct in_addr addr; + addr.s_addr = htonl(ip->v4); + return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)); + } +} + +unsigned long get_range_size(const struct range_t *r) +{ + if (dhcp_version == VERSION_6) { + unsigned long size = 0; + int i; + /* When calculating the size of an IPv6 range overflow may + * occur. In that case only the last LONG_BIT bits are + * preserved, thus we just skip the first (16 - LONG_BIT) + * bits... */ + for (i = LONG_BIT / 8 < 16 ? 16 - LONG_BIT / 8 : 0; i < 16; i++) { + size <<= 8; + size += (int)r->last_ip.v6[i] - (int)r->first_ip.v6[i]; + } + fprintf(stderr, "\n"); + return size + 1; + } else { + return r->last_ip.v4 - r->first_ip.v4 + 1; + } +} int #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) diff --git a/src/output.c b/src/output.c index 1eb3a65..78b54bb 100644 --- a/src/output.c +++ b/src/output.c @@ -53,11 +53,12 @@ int output_txt(void) { unsigned int i; - struct in_addr first, last; struct range_t *range_p; + unsigned long range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; + int max_ipaddr_length = dhcp_version == VERSION_6 ? 39 : 16; if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); @@ -69,13 +70,20 @@ int output_txt(void) } range_p = ranges; + range_size = get_range_size(range_p); shared_p = shared_networks; if (config.output_limit[0] & output_limit_bit_1) { fprintf(outfile, "Ranges:\n"); fprintf (outfile, - "shared net name first ip last ip max cur percent touch t+c t+c perc"); + "%-20s%-*s %-*s %5s %5s %10s %5s %5s %9s", + "shared net name", + max_ipaddr_length, + "first ip", + max_ipaddr_length, + "last ip", + "max", "cur", "percent", "touch", "t+c", "t+c perc"); if (0 < num_backups) { fprintf(outfile, " bu bu perc"); } @@ -83,40 +91,39 @@ int output_txt(void) } if (config.output_limit[1] & output_limit_bit_1) { for (i = 0; i < num_ranges; i++) { - first.s_addr = ntohl(range_p->first_ip); - last.s_addr = ntohl(range_p->last_ip); - if (range_p->shared_net) { fprintf(outfile, "%-20s", range_p->shared_net->name); } else { fprintf(outfile, "not_defined "); } - fprintf(outfile, "%-16s", inet_ntoa(first)); + /* Outputting of first_ip and last_ip need to be + * separate since ntop_ipaddr always returns the + * same buffer */ + fprintf(outfile, "%-*s", + max_ipaddr_length, + ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, - " - %-16s %5" PRIu32 - " %5lu %10.3f %5lu %5lu %9.3f", - inet_ntoa(last), - range_p->last_ip - range_p->first_ip + 1, + " - %-*s %5lu %5lu %10.3f %5lu %5lu %9.3f", + max_ipaddr_length, + ntop_ipaddr(&range_p->last_ip), + range_size, range_p->count, - (float)(100 * range_p->count) / - (range_p->last_ip - range_p->first_ip + 1), + (float)(100 * range_p->count) / range_size, range_p->touched, range_p->touched + range_p->count, (float)(100 * (range_p->touched + - range_p->count)) / (range_p->last_ip - - range_p->first_ip + - 1)); + range_p->count)) / range_size); if (0 < num_backups) { fprintf(outfile, "%7lu %8.3f", range_p->backups, (float)(100 * range_p->backups) / - (range_p->last_ip - - range_p->first_ip + 1)); + range_size); } fprintf(outfile, "\n"); range_p++; + range_size = get_range_size(range_p); } } if (config.output_limit[1] & output_limit_bit_1 @@ -210,8 +217,8 @@ int output_txt(void) int output_xml(void) { unsigned int i; - struct in_addr first, last; struct range_t *range_p; + unsigned long range_size; struct shared_network_t *shared_p; struct macaddr_t *macaddr_p; int ret; @@ -227,6 +234,7 @@ int output_xml(void) } range_p = ranges; + range_size = get_range_size(range_p); shared_p = shared_networks; fprintf(outfile, "\n"); @@ -242,8 +250,6 @@ int output_xml(void) if (config.output_limit[1] & output_limit_bit_1) { for (i = 0; i < num_ranges; i++) { - first.s_addr = ntohl(range_p->first_ip); - last.s_addr = ntohl(range_p->last_ip); fprintf(outfile, "\n"); if (range_p->shared_net) { fprintf(outfile, @@ -255,17 +261,19 @@ int output_xml(void) fprintf(outfile, "\t\n"); fprintf(outfile, "\t\n"); - fprintf(outfile, "\t%s ", inet_ntoa(first)); - fprintf(outfile, "- %s\n", inet_ntoa(last)); + fprintf(outfile, "\t%s ", + ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, "- %s\n", + ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\t\n"); - fprintf(outfile, "\t%" PRIu32 "\n", - range_p->last_ip - range_p->first_ip + 1); + fprintf(outfile, "\t%lu\n", + range_size); fprintf(outfile, "\t%lu\n", range_p->count); fprintf(outfile, "\t%lu\n", - range_p->last_ip - range_p->first_ip + 1 - - range_p->count); + range_size - range_p->count); range_p++; + range_size = get_range_size(range_p); fprintf(outfile, "\n"); } } @@ -456,8 +464,8 @@ static void newsection(FILE *restrict f, char const *restrict title) int output_html(void) { unsigned int i; - struct in_addr first, last; struct range_t *range_p; + unsigned long range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; @@ -472,6 +480,7 @@ int output_html(void) } range_p = ranges; + range_size = get_range_size(range_p); shared_p = shared_networks; if (fullhtml) { html_header(outfile); @@ -497,8 +506,6 @@ int output_html(void) } if (config.output_limit[1] & output_limit_bit_1) { for (i = 0; i < num_ranges; i++) { - first.s_addr = ntohl(range_p->first_ip); - last.s_addr = ntohl(range_p->last_ip); newrow(outfile); if (range_p->shared_net) { output_line(outfile, "td", "calign", @@ -507,34 +514,32 @@ int output_html(void) output_line(outfile, "td", "calign", "not_defined"); } - output_line(outfile, "td", "calign", inet_ntoa(first)); - output_line(outfile, "td", "calign", inet_ntoa(last)); - output_long(outfile, "td", - range_p->last_ip - range_p->first_ip + 1); + output_line(outfile, "td", "calign", + ntop_ipaddr(&range_p->first_ip)); + output_line(outfile, "td", "calign", + ntop_ipaddr(&range_p->last_ip)); + output_long(outfile, "td", range_size); output_long(outfile, "td", range_p->count); output_float(outfile, "td", (float)(100 * range_p->count) / - (range_p->last_ip - - range_p->first_ip + 1)); + range_size); output_long(outfile, "td", range_p->touched); output_long(outfile, "td", range_p->touched + range_p->count); output_float(outfile, "td", (float)(100 * (range_p->touched + - range_p->count)) / - (range_p->last_ip - - range_p->first_ip + 1)); + range_p->count)) / range_size); if (0 < num_backups) { output_long(outfile, "td", range_p->backups); output_float(outfile, "td", (float)(100 * range_p->backups) / - (range_p->last_ip - - range_p->first_ip + 1)); + range_size); } endrow(outfile); range_p++; + range_size = get_range_size(range_p); } } table_end(outfile); @@ -647,8 +652,8 @@ int output_html(void) int output_csv(void) { unsigned int i; - struct in_addr first, last; struct range_t *range_p; + unsigned long range_size; struct shared_network_t *shared_p; FILE *outfile; int ret; @@ -662,6 +667,7 @@ int output_csv(void) } range_p = ranges; + range_size = get_range_size(range_p); shared_p = shared_networks; if (config.output_limit[0] & output_limit_bit_1) { fprintf(outfile, "\"Ranges:\"\n"); @@ -675,40 +681,34 @@ int output_csv(void) } if (config.output_limit[1] & output_limit_bit_1) { for (i = 0; i < num_ranges; i++) { - first.s_addr = ntohl(range_p->first_ip); - last.s_addr = ntohl(range_p->last_ip); if (range_p->shared_net) { fprintf(outfile, "\"%s\",", range_p->shared_net->name); } else { fprintf(outfile, "\"not_defined\","); } - fprintf(outfile, "\"%s\",", inet_ntoa(first)); + fprintf(outfile, "\"%s\",", + ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, - "\"%s\",\"%" PRIu32 - "\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", - inet_ntoa(last), - range_p->last_ip - range_p->first_ip + 1, + "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", + ntop_ipaddr(&range_p->last_ip), range_size, range_p->count, - (float)(100 * range_p->count) / - (range_p->last_ip - range_p->first_ip + 1), + (float)(100 * range_p->count) / range_size, range_p->touched, range_p->touched + range_p->count, (float)(100 * (range_p->touched + - range_p->count)) / (range_p->last_ip - - range_p->first_ip + - 1)); + range_p->count)) / range_size); if (0 < num_backups) { fprintf(outfile, ",\"%lu\",\"%.3f\"", range_p->backups, (float)(100 * range_p->backups) / - (range_p->last_ip - - range_p->first_ip + 1)); + range_size); } fprintf(outfile, "\n"); range_p++; + range_size = get_range_size(range_p); } fprintf(outfile, "\n"); } @@ -796,6 +796,7 @@ int output_alarming(void) { FILE *outfile; struct range_t *range_p; + unsigned long range_size; struct shared_network_t *shared_p; unsigned int i; float perc; @@ -803,6 +804,7 @@ int output_alarming(void) int ret_val, ret; range_p = ranges; + range_size = get_range_size(range_p); shared_p = shared_networks; if (config.output_file[0]) { @@ -817,8 +819,7 @@ int output_alarming(void) if (config.output_limit[1] & output_limit_bit_1) { for (i = 0; i < num_ranges; i++) { - perc = (float)(100 * range_p->count) / - (range_p->last_ip - range_p->first_ip + 1); + perc = (float)(100 * range_p->count) / range_size; if (config.critical < perc) rc++; else if (config.warning < perc) @@ -826,6 +827,7 @@ int output_alarming(void) else ro++; range_p++; + range_size = get_range_size(range_p); } } if (config.output_limit[1] & output_limit_bit_2) { diff --git a/src/sort.c b/src/sort.c index c018e45..3d606fd 100644 --- a/src/sort.c +++ b/src/sort.c @@ -53,20 +53,35 @@ int intcomp(const void *restrict x, const void *restrict y) return 0; } +int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) +{ + if (dhcp_version == VERSION_6) { + return memcmp(&a->v6, &b->v6, sizeof(a->v6)); + } else { + if (a->v4 < b->v4) + return -1; + if (a->v4 > b->v4) + return 1; + return 0; + } +} + +int leasecomp(const void *restrict a, const void *restrict b) +{ + return ipcomp(&((const struct leases_t *)a)->ip, + &((const struct leases_t *)b)->ip); +} + int rangecomp(const void *restrict r1, const void *restrict r2) { - if ((((struct range_t *)r1)->first_ip) < - (((struct range_t *)r2)->first_ip)) - return -1; - if ((((struct range_t *)r2)->first_ip) < - (((struct range_t *)r1)->first_ip)) - return 1; - return 0; + return ipcomp(&((const struct range_t *)r1)->first_ip, + &((const struct range_t *)r2)->first_ip); } unsigned long int ret_ip(struct range_t r) { - return (r.first_ip); + /* FIXME: IPv6 */ + return (r.first_ip.v4); } unsigned long int ret_cur(struct range_t r) @@ -76,13 +91,13 @@ unsigned long int ret_cur(struct range_t r) unsigned long int ret_max(struct range_t r) { - return (r.last_ip - r.first_ip); + return get_range_size(&r); } unsigned long int ret_percent(struct range_t r) { float f; - f = (float)r.count / (r.last_ip - r.first_ip - 1); + f = (float)r.count / get_range_size(&r); return ((unsigned long int)(f * 100000)); } @@ -99,7 +114,7 @@ unsigned long int ret_tc(struct range_t r) unsigned long int ret_tcperc(struct range_t r) { float f; - f = (float)(r.count + r.touched) / (r.last_ip - r.first_ip - 1); + f = (float)(r.count + r.touched) / get_range_size(&r); return ((unsigned long int)(f * 10000)); } From 1424db94274d5ec4920d303004352d6fad48deb4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Dec 2012 20:41:06 +0000 Subject: [PATCH 005/313] build-sys: update .gitignore Signed-off-by: Sami Kerola --- lib/.gitignore | 66 ++++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 50 deletions(-) diff --git a/lib/.gitignore b/lib/.gitignore index 7676fcf..66f0e0d 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,36 +1,28 @@ +/*.o +/*.lo /.deps/ /.gitignore~ /.libs/ /Makefile -/Makefile.in /Makefile.am +/Makefile.in /_Exit.c /arg-nonnull.h /atexit.c /c++defs.h /c-ctype.c /c-ctype.h -/c-ctype.lo -/c-ctype.o /c-strcase.h /c-strcasecmp.c -/c-strcasecmp.lo -/c-strcasecmp.o /c-strcaseeq.h /c-strncasecmp.c -/c-strncasecmp.lo -/c-strncasecmp.o /calloc.c /charset.alias /close-stream.c /close-stream.h -/close-stream.lo -/close-stream.o /close.c /closeout.c /closeout.h -/closeout.lo -/closeout.o /config.charset /configmake.h /dosname.h @@ -39,36 +31,22 @@ /error.h /exitfail.c /exitfail.h -/exitfail.lo -/exitfail.o /fclose.c -/fclose.lo -/fclose.o +/fcntl.h +/fcntl.in.h /fd-hook.c /fd-hook.h -/fd-hook.lo -/fd-hook.o /fdopen.c /fflush.c -/fflush.lo -/fflush.o /fopen.c /fpending.c /fpending.h /fpurge.c -/fpurge.lo -/fpurge.o /freading.c /freading.h -/freading.lo -/freading.o /free.c /fseek.c -/fseek.lo -/fseek.o /fseeko.c -/fseeko.lo -/fseeko.o /fstat.c /ftell.c /ftello.c @@ -78,11 +56,11 @@ /getopt_int.h /gettext.h /intprops.h +/langinfo.h +/langinfo.in.h /libdhcpd_pools.la /localcharset.c /localcharset.h -/localcharset.lo -/localcharset.o /lseek.c /malloc.c /mbrtowc.c @@ -94,22 +72,24 @@ /msvc-inval.h /msvc-nothrow.c /msvc-nothrow.h +/netinet_in.in.h /pathmax.h /quote.h /quotearg.c /quotearg.h -/quotearg.lo -/quotearg.o /realloc.c /ref-add.sed /ref-add.sin /ref-del.sed /ref-del.sin /stat.c +/stdalign.h +/stdalign.in.h /stdarg.in.h /stdbool.in.h /stddef.in.h /stdio-impl.h +/stdio.c /stdio.h /stdio.in.h /stdlib.h @@ -122,18 +102,20 @@ /strerror.c /strftime.c /strftime.h -/strftime.lo -/strftime.o /string.h /string.in.h /strstr.c /strtod.c /sys/ +/sys_socket.c +/sys_socket.in.h /sys_stat.in.h /sys_types.in.h +/sys_uio.in.h /time.h /time.in.h /time_r.c +/unistd.c /unistd.h /unistd.in.h /unused-parameter.h @@ -141,30 +123,14 @@ /warn-on-use.h /wchar.h /wchar.in.h +/wctype-h.c /wctype.h /wctype.in.h /xalloc-die.c -/xalloc-die.lo -/xalloc-die.o /xalloc-oversized.h /xalloc.h /xmalloc.c -/xmalloc.lo -/xmalloc.o /xprintf.c /xprintf.h -/xprintf.lo -/xprintf.o /xstrtod.c /xstrtod.h -/xstrtod.lo -/xstrtod.o -/fcntl.in.h -/langinfo.in.h -/netinet_in.in.h -/stdalign.h -/stdalign.in.h -/sys_socket.in.h -/sys_uio.in.h -/fcntl.h -/langinfo.h From a2fa69a40383d88209953c0d438798caea0d806e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Dec 2012 21:33:07 +0000 Subject: [PATCH 006/313] tests: add v6 check The counting of total maximum address space seems to be broken at the moment, and the check is expected to fail until a counting fix is available. Signed-off-by: Sami Kerola --- tests/Makefile.am | 2 +- tests/confs/v6 | 10 ++++++ tests/expected/v6 | 11 +++++++ tests/leases/v6 | 78 +++++++++++++++++++++++++++++++++++++++++++++++ tests/v6 | 1 + 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/confs/v6 create mode 100644 tests/expected/v6 create mode 100644 tests/leases/v6 create mode 120000 tests/v6 diff --git a/tests/Makefile.am b/tests/Makefile.am index d51cec1..0a062c1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,7 +7,7 @@ EXTRA_DIST = \ simple \ test.sh -TESTS = simple bootp leading0 +TESTS = simple bootp leading0 v6 check_SCRIPTS = test.sh check-local: $(SHELL) $(top_srcdir)/tests/test.sh diff --git a/tests/confs/v6 b/tests/confs/v6 new file mode 100644 index 0000000..cf20676 --- /dev/null +++ b/tests/confs/v6 @@ -0,0 +1,10 @@ +subnet6 dead:abba:1000::/56 { + range6 dead:abba:1000::2 dead:abba:1000:00ff:ffff:ffff:ffff:ffff; + prefix6 dead:abba:1000:0100:: dead:abba:1000:ff00::/56; +} + +subnet6 dead:abba:40ff::/56 { + range6 dead:abba:4000::2 dead:abba:4000::00ff; + prefix6 dead:abba:4000:0100:: dead:abba:4000:ff00::/56; +} + diff --git a/tests/expected/v6 b/tests/expected/v6 new file mode 100644 index 0000000..969290c --- /dev/null +++ b/tests/expected/v6 @@ -0,0 +1,11 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks dead:abba:1000::2 - dead:abba:1000:ff:ffff:ffff:ffff:ffff 18446744073709551614 2 0.000 0 2 0.000 +All networks dead:abba:4000::2 - dead:abba:4000::ff 254 1 0.394 0 1 0.394 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 18446744073709551868 3 1.190 0 3 1.190 # FIXME: this line is mocked up diff --git a/tests/leases/v6 b/tests/leases/v6 new file mode 100644 index 0000000..8f2e62b --- /dev/null +++ b/tests/leases/v6 @@ -0,0 +1,78 @@ +ia-na "sample" { + iaaddr dead:abba:1000:b4:a4e4:7b7a:140a:9ab1 { + binding state active; + } +} + +ia-na "sample" { + iaaddr dead:abba:1000:c0:812a:6e4c:cc3:782d { + binding state active; + } +} + +ia-na "sample" { + iaaddr dead:abba:1000:ce:3507:ad74:2645:d041 { + binding state expired; + } +} + +ia-na "sample" { + iaaddr dead:abba:4000::68 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:1000:fe00::/56 { + binding state active; + } +} + +ia-pd "sample" { + iaprefix dead:abba:4000:ff00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:4000:fe00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:4000:ff00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:1000:ff00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:4000:ff00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:4000:fe00::/56 { + binding state expired; + } +} + +ia-pd "sample" { + iaprefix dead:abba:1000:fe00::/56 { + binding state active; + } +} + +ia-na "sample" { + iaaddr dead:abba:1000:b4:a4e4:7b7a:140a:9ab1 { + binding state active; + } +} + diff --git a/tests/v6 b/tests/v6 new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/v6 @@ -0,0 +1 @@ +test.sh \ No newline at end of file From 179e2ac1471d1e2791e969be43698282ab346b73 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Dec 2012 21:36:39 +0000 Subject: [PATCH 007/313] output: remove unnecessary new line printing Signed-off-by: Sami Kerola --- src/other.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/other.c b/src/other.c index a970c0e..35a6ebf 100644 --- a/src/other.c +++ b/src/other.c @@ -111,7 +111,6 @@ unsigned long get_range_size(const struct range_t *r) size <<= 8; size += (int)r->last_ip.v6[i] - (int)r->first_ip.v6[i]; } - fprintf(stderr, "\n"); return size + 1; } else { return r->last_ip.v4 - r->first_ip.v4 + 1; From a302bc68294424b3f47cf3acc7d37c81b2df4ef4 Mon Sep 17 00:00:00 2001 From: Gilles Bouthenot Date: Tue, 4 Dec 2012 17:17:14 +0100 Subject: [PATCH 008/313] output: add json format support Reviewed-by: Sami Kerola Signed-off-by: Gilles Bouthenot --- THANKS | 1 + man/dhcpd-pools.1.in | 8 ++- src/dhcpd-pools.c | 6 ++ src/dhcpd-pools.h | 1 + src/getdata.c | 2 +- src/other.c | 7 ++- src/output.c | 136 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 156 insertions(+), 5 deletions(-) diff --git a/THANKS b/THANKS index d38f285..142b8ed 100644 --- a/THANKS +++ b/THANKS @@ -24,3 +24,4 @@ Robert Viou Enno Gröper Ryan Malek Cheer Xiao +Gilles Bouthenot diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index efa8c33..ce1e6ce 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -62,7 +62,7 @@ are equal next one is used. The IP field is default sort key. \fB\-r\fR, \fB\-\-reverse\fR Sort results in reverse order. .TP -\fB\-f\fR, \fB\-\-format\fR=\fI[thHcxX]\fR +\fB\-f\fR, \fB\-\-format\fR=\fI[thHcxXjJ]\fR Output format. Text .RI ( t ). @@ -77,7 +77,11 @@ stands for comma-separated values. Output format xml .RI ( x ) is similar to the dhcpstatus Perl module output. The extended xml .RI ( X ) -format will print ethernet address details. +format will print ethernet address details. The +.RI ( j ) +will output in json format, which can be extended with +.RI ( J ) +to include ethernet address. .IP The default format is .IR @OUTPUT_FORMAT@ . diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 91c518c..9b90807 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -207,6 +207,12 @@ int main(int argc, char **argv) case 'X': output_analysis = output_xml; break; + case 'j': + output_analysis = output_json; + break; + case 'J': + output_analysis = output_json; + break; case 'c': output_analysis = output_csv; break; diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 287c153..b15eb30 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -194,6 +194,7 @@ int (*output_analysis) (void); int output_txt(void); int output_html(void); int output_xml(void); +int output_json(void); int output_csv(void); int output_alarming(void); /* Memory release, file closing etc */ diff --git a/src/getdata.c b/src/getdata.c index a792806..d5fe77e 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -119,7 +119,7 @@ int parse_leases(void) line = xmalloc(sizeof(char) * MAXLEN); ipstring = xmalloc(sizeof(char) * MAXLEN); - if (config.output_format[0] == 'X') { + if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { macstring = xmalloc(sizeof(char) * 18); macaddr = xmalloc(sizeof(struct macaddr_t)); macaddr_p = macaddr; diff --git a/src/other.c b/src/other.c index 35a6ebf..e378084 100644 --- a/src/other.c +++ b/src/other.c @@ -219,13 +219,16 @@ This is ISC dhcpd pools usage analyzer.\n\ \n", program_invocation_short_name); fprintf(out, "\ -c, --config=FILE path to the dhcpd.conf file\n\ - -l, --leases=FILE path to the dhcpd.leases file\n\ - -f, --format=[thHcxX] output format\n\ + -l, --leases=FILE path to the dhcpd.leases file\n"); + fprintf(out, "\ + -f, --format=[thHcxXjJ] output format\n\ t for text\n\ h for html table\n\ H for full html page\n\ x for xml\n\ X for xml with active lease details\n\ + j for json\n\ + J for json with active lease details\n\ c for comma separated values\n"); fprintf(out, "\ -s, --sort=[nimcptTe] sort ranges by\n\ diff --git a/src/output.c b/src/output.c index 78b54bb..639f866 100644 --- a/src/output.c +++ b/src/output.c @@ -322,6 +322,142 @@ int output_xml(void) return 0; } +int output_json(void) +{ + unsigned int i; + struct range_t *range_p; + unsigned long range_size; + struct shared_network_t *shared_p; + struct macaddr_t *macaddr_p; + int ret; + FILE *outfile; + char sep; + + if (config.output_file[0]) { + outfile = fopen(config.output_file, "w+"); + if (outfile == NULL) { + err(EXIT_FAILURE, "output_json: %s", + config.output_file); + } + } else { + outfile = stdout; + } + + range_p = ranges; + range_size = get_range_size(range_p); + shared_p = shared_networks; + sep = ' '; + + fprintf(outfile, "{\n"); + + if (macaddr != NULL) { + fprintf(outfile, " %c\"active_leases\": [\n", sep); + for (i = 0, macaddr_p = macaddr; macaddr_p->next != NULL; + macaddr_p = macaddr_p->next) { + if (0 != i) { + fprintf(outfile, ",\n "); + } else { + fprintf(outfile, "\n "); + } + fprintf(outfile, + "{ \"ip\":\"%s\", \"macaddress\":\"%s\" }", + macaddr_p->ip, macaddr_p->ethernet); + i++; + } + fprintf(outfile, "\n ]"); /* end of active_leases */ + sep = ','; + } + + if (config.output_limit[1] & output_limit_bit_1) { + if (sep == ',') + printf(",\n"); + fprintf(outfile, " \"subnets\": [\n"); + for (i = 0; i < num_ranges; i++) { + fprintf(outfile, " "); + fprintf(outfile, "{ "); + if (range_p->shared_net) { + fprintf(outfile, + "\"location\":\"%s\", ", + range_p->shared_net->name); + } else { + fprintf(outfile, "\"location\":\"\", "); + } + + fprintf(outfile, "\"network\":\"\", "); + fprintf(outfile, "\"netmask\":\"\", "); + fprintf(outfile, "\"range\":\"%s\", ", + ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, "\"gateway\":\"\", "); + fprintf(outfile, "\"defined\":%lu, ", range_size); + fprintf(outfile, "\"used\":%lu, ", range_p->count); + fprintf(outfile, "\"free\":%lu ", + range_size - range_p->count); + range_p++; + range_size = get_range_size(range_p); + if (i + 1 < num_ranges) + fprintf(outfile, "},\n"); + else + fprintf(outfile, "}\n"); + } + fprintf(outfile, " ]"); /* end of subnets */ + sep = ','; + } + + if (config.output_limit[1] & output_limit_bit_2) { + if (sep == ',') + printf(",\n"); + fprintf(outfile, " \"shared-networks\": [\n"); + for (i = 0; i < num_shared_networks; i++) { + fprintf(outfile, " "); + shared_p++; + fprintf(outfile, "{ "); + fprintf(outfile, "\"location\":\"%s\", ", + shared_p->name); + fprintf(outfile, "\"defined\":%lu, ", + shared_p->available); + fprintf(outfile, "\"used\":%lu, ", shared_p->used); + fprintf(outfile, "\"free\":%lu ", + shared_p->available - shared_p->used); + if (i + 1 < num_shared_networks) + fprintf(outfile, "},\n"); + else + fprintf(outfile, "}\n"); + } + fprintf(outfile, " ]"); /* end of shared-networks */ + sep = ','; + } + + if (config.output_limit[0] & output_limit_bit_3) { + if (sep == ',') + printf(",\n"); + fprintf(outfile, " \"summary\": {\n"); + fprintf(outfile, " \"location\":\"%s\",\n", + shared_networks->name); + fprintf(outfile, " \"defined\":%lu,\n", + shared_networks->available); + fprintf(outfile, " \"used\":%lu,\n", + shared_networks->used); + fprintf(outfile, " \"free\":%lu\n", + shared_networks->available - shared_networks->used); + fprintf(outfile, " }"); /* end of summary */ + } + + fprintf(outfile, "\n}"); + if (outfile == stdout) { + ret = fflush(stdout); + if (ret) { + warn("output_json: fflush"); + } + } else { + ret = close_stream(outfile); + if (ret) { + warn("output_json: fclose"); + } + } + + return 0; +} + static void html_header(FILE *restrict f) { char outstr[200]; From d34259092d0c56d364b48935dfefeca862ab3d4a Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 4 Dec 2012 22:08:15 +0000 Subject: [PATCH 009/313] build-sys: more clean ups The gnulib will set AC_GNU_SOURCE equivivelant if necessary. The awk is relevant only for contrib stuff, and compiler program was something I had not understood quite right some years ago when I added it. Signed-off-by: Sami Kerola --- configure.ac | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index e75498e..9286a86 100644 --- a/configure.ac +++ b/configure.ac @@ -13,14 +13,11 @@ AM_INIT_AUTOMAKE([-Wall foreign 1.10 tar-pax no-dist-gzip dist-xz -Wextra-portab AC_CONFIG_SRCDIR([src/dhcpd-pools.h]) AC_CONFIG_HEADERS([config.h]) -AC_GNU_SOURCE - # Checks for programs -AC_PROG_AWK gl_EARLY gl_INIT AC_C_RESTRICT -AC_PROG_CXX +AC_PROG_CC_C99 AC_PROG_MAKE_SET AC_PROG_LIBTOOL From 48a23c94e5f03c50f851cbca1c98912779a14cf8 Mon Sep 17 00:00:00 2001 From: Gilles Bouthenot Date: Wed, 5 Dec 2012 12:32:15 +0100 Subject: [PATCH 010/313] json output: add newline at end And remove extra empty lines where they are not needed. Reviewed-by: Sami Kerola Signed-off-by: Gilles Bouthenot --- src/output.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/output.c b/src/output.c index 639f866..0f2329f 100644 --- a/src/output.c +++ b/src/output.c @@ -331,7 +331,7 @@ int output_json(void) struct macaddr_t *macaddr_p; int ret; FILE *outfile; - char sep; + unsigned int sep; if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); @@ -346,12 +346,12 @@ int output_json(void) range_p = ranges; range_size = get_range_size(range_p); shared_p = shared_networks; - sep = ' '; + sep = 0; fprintf(outfile, "{\n"); if (macaddr != NULL) { - fprintf(outfile, " %c\"active_leases\": [\n", sep); + fprintf(outfile, " \"active_leases\": ["); for (i = 0, macaddr_p = macaddr; macaddr_p->next != NULL; macaddr_p = macaddr_p->next) { if (0 != i) { @@ -365,12 +365,13 @@ int output_json(void) i++; } fprintf(outfile, "\n ]"); /* end of active_leases */ - sep = ','; + sep++; } if (config.output_limit[1] & output_limit_bit_1) { - if (sep == ',') + if (sep) { printf(",\n"); + } fprintf(outfile, " \"subnets\": [\n"); for (i = 0; i < num_ranges; i++) { fprintf(outfile, " "); @@ -400,12 +401,13 @@ int output_json(void) fprintf(outfile, "}\n"); } fprintf(outfile, " ]"); /* end of subnets */ - sep = ','; + sep++; } if (config.output_limit[1] & output_limit_bit_2) { - if (sep == ',') + if (sep) { printf(",\n"); + } fprintf(outfile, " \"shared-networks\": [\n"); for (i = 0; i < num_shared_networks; i++) { fprintf(outfile, " "); @@ -424,12 +426,13 @@ int output_json(void) fprintf(outfile, "}\n"); } fprintf(outfile, " ]"); /* end of shared-networks */ - sep = ','; + sep++; } if (config.output_limit[0] & output_limit_bit_3) { - if (sep == ',') + if (sep) { printf(",\n"); + } fprintf(outfile, " \"summary\": {\n"); fprintf(outfile, " \"location\":\"%s\",\n", shared_networks->name); @@ -440,9 +443,10 @@ int output_json(void) fprintf(outfile, " \"free\":%lu\n", shared_networks->available - shared_networks->used); fprintf(outfile, " }"); /* end of summary */ + sep++; } - fprintf(outfile, "\n}"); + fprintf(outfile, "\n}\n"); if (outfile == stdout) { ret = fflush(stdout); if (ret) { From e9d196e81623fac2e5bccb08e045474beb3234bd Mon Sep 17 00:00:00 2001 From: Gilles Bouthenot Date: Wed, 5 Dec 2012 12:47:08 +0100 Subject: [PATCH 011/313] json output: remove useless, empty fields Reviewed-by: Sami Kerola Signed-off-by: Gilles Bouthenot --- src/output.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/output.c b/src/output.c index 0f2329f..eb99454 100644 --- a/src/output.c +++ b/src/output.c @@ -384,11 +384,8 @@ int output_json(void) fprintf(outfile, "\"location\":\"\", "); } - fprintf(outfile, "\"network\":\"\", "); - fprintf(outfile, "\"netmask\":\"\", "); fprintf(outfile, "\"range\":\"%s\", ", ntop_ipaddr(&range_p->first_ip)); - fprintf(outfile, "\"gateway\":\"\", "); fprintf(outfile, "\"defined\":%lu, ", range_size); fprintf(outfile, "\"used\":%lu, ", range_p->count); fprintf(outfile, "\"free\":%lu ", From bc654bcc683d23907e94cd2af31a73eb3ec73b81 Mon Sep 17 00:00:00 2001 From: Gilles Bouthenot Date: Wed, 5 Dec 2012 12:54:49 +0100 Subject: [PATCH 012/313] json output: bugfix: correct range specify only first ip Reviewed-by: Sami Kerola Signed-off-by: Gilles Bouthenot --- src/output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index eb99454..3a2a921 100644 --- a/src/output.c +++ b/src/output.c @@ -384,8 +384,10 @@ int output_json(void) fprintf(outfile, "\"location\":\"\", "); } - fprintf(outfile, "\"range\":\"%s\", ", + fprintf(outfile, "\"range\":\"%s", ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, " - %s\", ", + ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\"defined\":%lu, ", range_size); fprintf(outfile, "\"used\":%lu, ", range_p->count); fprintf(outfile, "\"free\":%lu ", From 443b19790106c95fe6443f9e27a085529cd108cc Mon Sep 17 00:00:00 2001 From: Gilles Bouthenot Date: Wed, 5 Dec 2012 14:33:01 +0100 Subject: [PATCH 013/313] contrib: add munin plugins Signed-off-by: Gilles Bouthenot --- contrib/Makefile.am | 2 +- contrib/munin_plugins/dhcpstats_abs.js | 44 ++++++++++++++++++ contrib/munin_plugins/dhcpstats_abs.php | 37 +++++++++++++++ contrib/munin_plugins/dhcpstats_percent.js | 49 ++++++++++++++++++++ contrib/munin_plugins/dhcpstats_percent.php | 42 +++++++++++++++++ contrib/munin_plugins/preview.png | Bin 0 -> 81531 bytes 6 files changed, 173 insertions(+), 1 deletion(-) create mode 100755 contrib/munin_plugins/dhcpstats_abs.js create mode 100755 contrib/munin_plugins/dhcpstats_abs.php create mode 100755 contrib/munin_plugins/dhcpstats_percent.js create mode 100755 contrib/munin_plugins/dhcpstats_percent.php create mode 100644 contrib/munin_plugins/preview.png diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 6de6b49..a3396bf 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,3 +1,3 @@ contribdir = $(datadir)/dhcpd-pools/ dist_contrib_SCRIPTS = dhcpd-pools.cgi snmptest.pl -EXTRA_DIST = nagios.conf +EXTRA_DIST = nagios.conf munin_plugins diff --git a/contrib/munin_plugins/dhcpstats_abs.js b/contrib/munin_plugins/dhcpstats_abs.js new file mode 100755 index 0000000..aa5409c --- /dev/null +++ b/contrib/munin_plugins/dhcpstats_abs.js @@ -0,0 +1,44 @@ +#!/usr/bin/env node + +var command = "dhcpd-pools" +var timeout = 5000; // (ms) if the command take longer, then kill it + +var execFile = require('child_process').execFile; +var echo = require('util').print; + +var arg = process.argv[2]; + +if ("autoconf" === arg) { + echo("yes\n"); + return 0; +} + +execFile(command, [ "--format=j", "--sort=n" ], { timeout: timeout }, function(error, stdout, stderr) { + if (error !== null) { + console.log('exec error: ' + error); + return 1; + } + + stdout = JSON.parse(stdout); + + if ("config" === arg) { + echo("graph_title dhcp usage (number of machines)\n"); + echo("graph_vlabel nb of machines\n"); + echo("graph_scale no\n"); + echo("graph_category network\n"); + + stdout["subnets"].forEach(function(subnet) { + var location = subnet["location"]; + var range = subnet["range"]; + echo(location + '.label ' + location + ' (' + range + ')\n'); + }); + } else { + stdout["shared-networks"].forEach(function(network) { + var location = network["location"]; + var used = network["used"]; + var defined = network["defined"]; + echo(location + '.value ' + used + '\n'); + }); + } + +}); diff --git a/contrib/munin_plugins/dhcpstats_abs.php b/contrib/munin_plugins/dhcpstats_abs.php new file mode 100755 index 0000000..3f8c553 --- /dev/null +++ b/contrib/munin_plugins/dhcpstats_abs.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +1 && $argv[1]=="autoconf") { + echo "yes\n"; + return; +} elseif ($argc>1 && $argv[1]=="config") { + $xml2 = $xml->xpath("subnet"); + echo "graph_title dhcp usage (number of machines)\n"; + echo "graph_vlabel nb of machines\n"; + echo "graph_scale no\n"; + echo "graph_category network\n"; + foreach ($xml2 as $xml3) { + $location = (string) $xml3->location; + $range = (string) $xml3->range; + echo "$location.label $location ($range)\n"; + } +} else { + $xml2 = $xml->xpath("shared-network"); + foreach ($xml2 as $xml3) { + $location = (string) $xml3->location; + $used = (int) $xml3->used; + $defined = (int) $xml3->defined; + $pourcent = ceil($used*10000/$defined)/100; + echo "$location.value $used\n"; + } +} + diff --git a/contrib/munin_plugins/dhcpstats_percent.js b/contrib/munin_plugins/dhcpstats_percent.js new file mode 100755 index 0000000..6cf2dbd --- /dev/null +++ b/contrib/munin_plugins/dhcpstats_percent.js @@ -0,0 +1,49 @@ +#!/usr/bin/env node + +var command = "dhcpd-pools" +var timeout = 5000; // (ms) if the command take longer, then kill it + +var execFile = require('child_process').execFile; +var echo = require('util').print; + +var arg = process.argv[2]; + +if ("autoconf" === arg) { + echo("yes\n"); + return 0; +} + +execFile(command, [ "--format=j", "--sort=n" ], { timeout: timeout }, function(error, stdout, stderr) { + if (error !== null) { + console.log('exec error: ' + error); + return 1; + } + + stdout = JSON.parse(stdout); + + if ("config" === arg) { + echo("graph_title dhcp usage (in percent)\n"); + echo("graph_args --upper-limit 100 -l 0 --rigid\n"); + echo("graph_vlabel %\n"); + echo("graph_scale no\n"); + echo("graph_category network\n"); + + stdout["subnets"].forEach(function(subnet) { + var location = subnet["location"]; + var range = subnet["range"]; + echo(location + '.label ' + location + ' (' + range + ')\n'); + echo(location + '.warning 75\n'); + echo(location + '.critical 90\n'); + }); + } else { + stdout["shared-networks"].forEach(function(network) { + var location = network["location"]; + var used = network["used"]; + var defined = network["defined"]; + // keep 1 digit after decimal point + var percent = Math.ceil(used * 100 / defined) / 10; + echo(location + '.value ' + percent + '\n'); + }); + } + +}); diff --git a/contrib/munin_plugins/dhcpstats_percent.php b/contrib/munin_plugins/dhcpstats_percent.php new file mode 100755 index 0000000..8a5ae32 --- /dev/null +++ b/contrib/munin_plugins/dhcpstats_percent.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +1 && $argv[1]=="autoconf") { + echo "yes\n"; + return; +} elseif ($argc>1 && $argv[1]=="config") { + $xml2 = $xml->xpath("subnet"); + echo "graph_title dhcp usage (in percent)\n"; + echo "graph_args --upper-limit 100 -l 0 --rigid\n"; + echo "graph_vlabel %\n"; + echo "graph_scale no\n"; + echo "graph_category network\n"; + foreach ($xml2 as $xml3) { + $location = (string) $xml3->location; + $range = (string) $xml3->range; + echo "$location.label $location ($range)\n"; + echo "$location.warning 75\n"; + echo "$location.critical 90\n"; + } +} else { + $xml2 = $xml->xpath("shared-network"); + foreach ($xml2 as $xml3) { + $location = (string) $xml3->location; + $used = (int) $xml3->used; + $defined = (int) $xml3->defined; + // keep 1 digit after decimal point + $pourcent = ceil($used*1000/$defined)/10; + echo "$location.value $pourcent\n"; + } +} + diff --git a/contrib/munin_plugins/preview.png b/contrib/munin_plugins/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..b621b6966d31153fe312c32995a0db1c96bed097 GIT binary patch literal 81531 zcmb5Wc|4SF`#ye6!%%2cvX!M&6tYJ4p`ujQkYp)ES(1Hc5LzwSQno^}%f1s?vhT7J zvKz)S#`?R4-tV60`F#KR&Fj^x8Row4>$>jqJdWc$&g=F6u zgKv?-lqmS$X;qb6_#c_E>`hq!zWP&b-Xn*f5!Px7av-hg_!RuG|LIk2YXA;blKvrT zEWSJd2x;1Dmt}7`^v-V4WFM^xA^7WKR9YFy9%A;NJ19S1b%KjQsM=ESNYIG5D)O~u z^<{UXr%@C~L*6mHVVXE&f`27`4snw%_Oj;-tuU^e$u)PVQPM<$JA9Ta=x7}$6l*5tvAP1tA1yzY)13<|k z`OgQ;5hk!bQ?^az@y}0y!@uv~{Qth^|N9op`1gJJ-?xDJ?|XLAvhBUFh#0!pJgPg= zt7v0dZ&>=g-Sy=>{<#1a!7j4BkWqLG_4Dt^v4?9w`Jc1E|Hf*-g0C;1 z6hCe0^1T(`x)`bZPm9Nf(0Zfxkp%Y%;tl~lJ#rm=Tz`Fm&16aCAy2?Kk|J%3a2nx7 zNHX?iWDm_>n{F~qMGPAZR{L$)=RA}9XB}dKQCN^qG5xW-h+@P81^mB#G#Z{`p4CDv z%zs;xjm7XvdfBB5R4%!sBZgyCJ-*5O85Z_%HF%1iL?2w$^|B(A4|b>S4CiPFt;k*n zCaBdYSyuwK_$^v zNX*J?sSs`1^2q4{q)WkIc&F&A{ZCu?RihCA{m&6#+#g|J02WvtQJgSi0Nw6kdQJ=P zUkVJXl}T2ufCaXWA{ww$`aNgNL-*gX5iUWLUr2U)O3TVG#3l~X4{mBX`WnCRu#dr& zY08{KVV)t%3pgkG=>M5jIS7bEu(#L_a<=H*q}#?aA~lfq_83f=heL!epr!%y)^2?V z{`od&Jd7OPK~?ReWaQVhK!~ehNH2|1@q5%K_@CnG$lF6zFyzrxiXT&1l$;jY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-77qz zg-dJJV1RJ)*@_`@^=&%~dtC=jTi)QIHr)E&G}+>?F_&Q-J;FjC4z;Ir4FKm9JS z3JGbAISDUeoPHbhcp%#iqPql>UfYYBTOip4*(2R7pJ*@SIQ?SM*4%vUK%b}%B0C3a zd}^|be2ajL=!5X?7<%;y%?9nOr&>SayPCVJ^@Jbu^pJHxS;R1i5*^Yz#!F!ZQNuc5 zZ~&ObHo<*ZpNShA(~rXcT&R-)ew-9mUtgc?kBQ%Uq`PT6iE30sIhcvkk1>_V4iMOP zsX&&Ltf}9h3wd%`UbXBAEx20kfg1IuuM!iU{4-zX#JO9(Oa3c0$HM>p31Bh|!kYg% zAJ#kveSYX#pN$}+!_K}i^*gNz!QcDy#mNf**eW{tD`%R5utKGG@$thl$?vgZ@%yG8i-it~)p>&(B8JPF~7ilKpH2K+|l0X4lTX7lTHVbEfHl yzInEiPQMBMdsecZe(S`v;PgfOX+k7dk74(m=>6pPN8(`MAE|rtck{#z{QnP)K(E38 literal 0 HcmV?d00001 From a768049f3ec36a20c57049d9556f0f80ff6e2e48 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 7 Dec 2012 20:12:34 +0000 Subject: [PATCH 014/313] json output: use defined output file for all printing Signed-off-by: Sami Kerola --- src/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/output.c b/src/output.c index 3a2a921..c3e6243 100644 --- a/src/output.c +++ b/src/output.c @@ -370,7 +370,7 @@ int output_json(void) if (config.output_limit[1] & output_limit_bit_1) { if (sep) { - printf(",\n"); + fprintf(outfile, ",\n"); } fprintf(outfile, " \"subnets\": [\n"); for (i = 0; i < num_ranges; i++) { @@ -405,7 +405,7 @@ int output_json(void) if (config.output_limit[1] & output_limit_bit_2) { if (sep) { - printf(",\n"); + fprintf(outfile, ",\n"); } fprintf(outfile, " \"shared-networks\": [\n"); for (i = 0; i < num_shared_networks; i++) { @@ -430,7 +430,7 @@ int output_json(void) if (config.output_limit[0] & output_limit_bit_3) { if (sep) { - printf(",\n"); + fprintf(outfile, ",\n"); } fprintf(outfile, " \"summary\": {\n"); fprintf(outfile, " \"location\":\"%s\",\n", From d8aae53968a0a2be66d8ae49db923e4d3f29287e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 7 Dec 2012 20:25:21 +0000 Subject: [PATCH 015/313] 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 Signed-off-by: Sami Kerola --- tests/Makefile.am | 14 ++++++++++---- tests/confs/same-twice | 1 + tests/expected/same-twice | 10 ++++++++++ tests/expected/same-twice-json | 16 ++++++++++++++++ tests/full-json | 14 ++++++++++++++ tests/leases/same-twice | 10 ++++++++++ tests/same-twice | 1 + tests/test.sh | 2 +- 8 files changed, 63 insertions(+), 5 deletions(-) create mode 120000 tests/confs/same-twice create mode 100644 tests/expected/same-twice create mode 100644 tests/expected/same-twice-json create mode 100755 tests/full-json create mode 100644 tests/leases/same-twice create mode 120000 tests/same-twice diff --git a/tests/Makefile.am b/tests/Makefile.am index 0a062c1..6aa921e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,14 +1,20 @@ EXTRA_DIST = \ bootp \ + full-json \ confs \ expected \ leading0 \ leases \ - simple \ - test.sh + same-twice \ + simple -TESTS = simple bootp leading0 v6 -check_SCRIPTS = test.sh +TESTS = \ + bootp \ + full-json \ + leading0 \ + same-twice \ + simple \ + v6 check-local: $(SHELL) $(top_srcdir)/tests/test.sh diff --git a/tests/confs/same-twice b/tests/confs/same-twice new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/confs/same-twice @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/expected/same-twice b/tests/expected/same-twice new file mode 100644 index 0000000..477fc7e --- /dev/null +++ b/tests/expected/same-twice @@ -0,0 +1,10 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.0.0.1 - 10.0.0.10 10 1 10.000 0 1 10.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 10 1 10.000 0 1 10.000 diff --git a/tests/expected/same-twice-json b/tests/expected/same-twice-json new file mode 100644 index 0000000..aa0c419 --- /dev/null +++ b/tests/expected/same-twice-json @@ -0,0 +1,16 @@ +{ + "active_leases": [ + { "ip":"10.0.0.5", "macaddress":"00:00:00:00:00:00" } + ], + "subnets": [ + { "location":"All networks", "range":"10.0.0.1 - 10.0.0.10", "defined":10, "used":1, "free":9 } + ], + "shared-networks": [ + ], + "summary": { + "location":"All networks", + "defined":10, + "used":1, + "free":9 + } +} diff --git a/tests/full-json b/tests/full-json new file mode 100755 index 0000000..93c4ffd --- /dev/null +++ b/tests/full-json @@ -0,0 +1,14 @@ +#!/bin/sh +# +# Minimal regression test suite. + +TEST_TOPDIR=$(cd $(dirname $0) && pwd) +DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools) + +if [ ! -d outputs ]; then + mkdir outputs +fi + +$DHCPD_POOLS -f J -c confs/same-twice -l leases/same-twice -o outputs/same-twice-json +diff -u expected/same-twice-json outputs/same-twice-json +exit $? diff --git a/tests/leases/same-twice b/tests/leases/same-twice new file mode 100644 index 0000000..1a5179a --- /dev/null +++ b/tests/leases/same-twice @@ -0,0 +1,10 @@ +lease 10.0.0.5 { + binding state active; + next binding state free; + hardware ethernet be:ef:00:00:co:de; +} +lease 10.0.0.5 { + binding state active; + next binding state free; + hardware ethernet 00:00:00:00:00:00; +} diff --git a/tests/same-twice b/tests/same-twice new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/same-twice @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh index f1f1587..3b06828 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -11,5 +11,5 @@ if [ ! -d outputs ]; then fi $DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM -diff -q expected/$IAM outputs/$IAM >/dev/null +diff -u expected/$IAM outputs/$IAM exit $? From fdc560bab93cb7ac25f3fa5529f6d662051ea1c8 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 7 Dec 2012 21:23:01 +0000 Subject: [PATCH 016/313] 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 ae7747db876a6c2aaaaa2f1815d9f41b89c28826, 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 Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 1 - src/dhcpd-pools.h | 7 +------ src/getdata.c | 30 +++++++----------------------- src/hash.c | 4 ++++ src/output.c | 46 ++++++++++++++++++++++++++-------------------- 5 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 9b90807..aa401e0 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -259,7 +259,6 @@ int prepare_memory(void) xmalloc(sizeof(struct shared_network_t) * SHARED_NETWORKS); ranges = xmalloc(sizeof(struct range_t) * RANGES); - macaddr = NULL; /* First shared network entry is all networks */ shared_networks->name = xstrdup("All networks"); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index b15eb30..6dd493a 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -97,11 +97,6 @@ struct range_t { unsigned long int touched; unsigned long int backups; }; -struct macaddr_t { - char *ethernet; - char *ip; - struct macaddr_t *next; -}; enum ltype { ACTIVE, FREE, @@ -110,6 +105,7 @@ enum ltype { struct leases_t { union ipaddr_t ip; /* ip as key */ enum ltype type; + char *ethernet; UT_hash_handle hh; }; @@ -130,7 +126,6 @@ struct leases_t *leases; unsigned long int num_leases; unsigned long int num_touches; unsigned long int num_backups; -struct macaddr_t *macaddr; /* Function prototypes */ int prepare_memory(void); diff --git a/src/getdata.c b/src/getdata.c index d5fe77e..1a57909 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -79,11 +79,10 @@ int prefix_length[2][NUM_OF_PREFIX] = { }; int parse_leases(void) { FILE *dhcpd_leases; - char *line, *ipstring, *macstring = NULL; + char *line, *ipstring, macstring[20]; union ipaddr_t addr; struct stat lease_file_stats; - struct macaddr_t *macaddr_p = NULL; - int sw_active_lease = 0; + int ethernets = false; struct leases_t *lease; num_touches = num_leases = num_backups = 0; @@ -120,10 +119,7 @@ int parse_leases(void) line = xmalloc(sizeof(char) * MAXLEN); ipstring = xmalloc(sizeof(char) * MAXLEN); if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { - macstring = xmalloc(sizeof(char) * 18); - macaddr = xmalloc(sizeof(struct macaddr_t)); - macaddr_p = macaddr; - macaddr_p->next = NULL; + ethernets = true; } const char **p = prefixes[dhcp_version]; @@ -139,7 +135,6 @@ int parse_leases(void) if (HAS_PREFIX(line, PREFIX_LEASE)) { nth_field(ipstring, line + l[PREFIX_LEASE]); parse_ipaddr(ipstring, &addr); - sw_active_lease = 0; continue; } if (HAS_PREFIX(line, PREFIX_BINDING_STATE_FREE)) { @@ -157,7 +152,6 @@ int parse_leases(void) delete_lease(lease); } add_lease(&addr, ACTIVE); - sw_active_lease = 1; continue; } if (HAS_PREFIX(line, PREFIX_BINDING_STATE_BACKUP)) { @@ -168,27 +162,17 @@ int parse_leases(void) add_lease(&addr, BACKUP); continue; } - if ((macaddr != NULL) - && (sw_active_lease == 1) - && (xstrstr(line, " hardware ethernet", 19))) { + if (ethernets && (xstrstr(line, " hardware ethernet", 19))) { nth_field(macstring, line + 20); - if (macstring) { - macstring[17] = '\0'; - macaddr_p->ethernet = xstrdup(macstring); - macaddr_p->ip = xstrdup(ipstring); - macaddr_p->next = - xmalloc(sizeof(struct macaddr_t)); - macaddr_p = macaddr_p->next; - macaddr_p->next = NULL; + macstring[17] = '\0'; + if ((lease = find_lease(&addr)) != NULL) { + lease->ethernet = xstrdup(macstring); } } } #undef HAS_PREFIX free(line); free(ipstring); - if (macaddr != NULL) { - free(macstring); - } fclose(dhcpd_leases); return 0; } diff --git a/src/hash.c b/src/hash.c index a9e41b8..d374860 100644 --- a/src/hash.c +++ b/src/hash.c @@ -50,6 +50,7 @@ void add_lease(union ipaddr_t *addr, enum ltype type) } else { HASH_ADD_INT(leases, ip.v4, l); } + l->ethernet = NULL; } struct leases_t *find_lease(union ipaddr_t *addr) @@ -66,6 +67,8 @@ struct leases_t *find_lease(union ipaddr_t *addr) void delete_lease(struct leases_t *lease) { + if (lease->ethernet != NULL) + free(lease->ethernet); HASH_DEL(leases, lease); free(lease); } @@ -86,6 +89,7 @@ void delete_all_leases() struct leases_t *l; while (leases) { l = leases; + free(l->ethernet); HASH_DEL(leases, l); /* leases advances to next on delete */ free(l); } diff --git a/src/output.c b/src/output.c index c3e6243..ae16421 100644 --- a/src/output.c +++ b/src/output.c @@ -220,7 +220,6 @@ int output_xml(void) struct range_t *range_p; unsigned long range_size; struct shared_network_t *shared_p; - struct macaddr_t *macaddr_p; int ret; FILE *outfile; @@ -239,12 +238,17 @@ int output_xml(void) fprintf(outfile, "\n"); - if (macaddr != NULL) { - for (macaddr_p = macaddr; macaddr_p->next != NULL; - macaddr_p = macaddr_p->next) { - fprintf(outfile, - "\n\t%s\n\t%s\n\n", - macaddr_p->ip, macaddr_p->ethernet); + if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { + struct leases_t *l; + for (l = leases; l != NULL; l = l->hh.next) { + if (l->type == ACTIVE) { + fputs("\n\t", outfile); + fputs(ntop_ipaddr(&l->ip), outfile); + fputs("\n\t", outfile); + fputs(l->ethernet, outfile); + fputs("\n\n", + outfile); + } } } @@ -324,11 +328,10 @@ int output_xml(void) int output_json(void) { - unsigned int i; + unsigned int i = 0; struct range_t *range_p; unsigned long range_size; struct shared_network_t *shared_p; - struct macaddr_t *macaddr_p; int ret; FILE *outfile; unsigned int sep; @@ -350,19 +353,22 @@ int output_json(void) fprintf(outfile, "{\n"); - if (macaddr != NULL) { + if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { + struct leases_t *l; fprintf(outfile, " \"active_leases\": ["); - for (i = 0, macaddr_p = macaddr; macaddr_p->next != NULL; - macaddr_p = macaddr_p->next) { - if (0 != i) { - fprintf(outfile, ",\n "); - } else { - fprintf(outfile, "\n "); + for (l = leases; l != NULL; l = l->hh.next) { + if (l->type == ACTIVE) { + if (i == 0) { + i = 1; + } else { + fputc(',', outfile); + } + fputs("\n { \"ip\":\"", outfile); + fputs(ntop_ipaddr(&l->ip), outfile); + fputs("\", \"macaddress\":\"", outfile); + fputs(l->ethernet, outfile); + fputs("\" }", outfile); } - fprintf(outfile, - "{ \"ip\":\"%s\", \"macaddress\":\"%s\" }", - macaddr_p->ip, macaddr_p->ethernet); - i++; } fprintf(outfile, "\n ]"); /* end of active_leases */ sep++; From aa7928b3abde861b62b67d45462bc0e2e34470b7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 7 Dec 2012 22:32:28 +0000 Subject: [PATCH 017/313] 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 --- src/output.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index ae16421..9181feb 100644 --- a/src/output.c +++ b/src/output.c @@ -245,7 +245,9 @@ int output_xml(void) fputs("\n\t", outfile); fputs(ntop_ipaddr(&l->ip), outfile); fputs("\n\t", outfile); - fputs(l->ethernet, outfile); + if (l->ethernet != NULL) { + fputs(l->ethernet, outfile); + } fputs("\n\n", outfile); } @@ -366,7 +368,9 @@ int output_json(void) fputs("\n { \"ip\":\"", outfile); fputs(ntop_ipaddr(&l->ip), outfile); fputs("\", \"macaddress\":\"", outfile); - fputs(l->ethernet, outfile); + if (l->ethernet != NULL) { + fputs(l->ethernet, outfile); + } fputs("\" }", outfile); } } From 3471c917961e7951f6448d690919df0c3391917b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 01:25:04 +0000 Subject: [PATCH 018/313] 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 --- Makefile.am | 4 + configure.ac | 20 + doc/.gitignore | 5 + doc/Makefile.am | 18 + doc/doxy.conf.in | 1808 ++++++++++++++++++++++++++++++++++++++++++ doc/introduction.dox | 49 ++ src/analyze.c | 21 +- src/defaults.h | 16 +- src/dhcpd-pools.c | 21 +- src/dhcpd-pools.h | 57 +- src/getdata.c | 44 +- src/hash.c | 19 + src/other.c | 54 +- src/output.c | 69 ++ src/sort.c | 75 +- 15 files changed, 2254 insertions(+), 26 deletions(-) create mode 100644 doc/.gitignore create mode 100644 doc/Makefile.am create mode 100644 doc/doxy.conf.in create mode 100644 doc/introduction.dox diff --git a/Makefile.am b/Makefile.am index 9618448..a265718 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,3 +5,7 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = m4/gnulib-cache.m4 SUBDIRS = lib src man tests contrib + +if ENABLE_DOXYGEN +SUBDIRS += doc +endif diff --git a/configure.ac b/configure.ac index 9286a86..82872ea 100644 --- a/configure.ac +++ b/configure.ac @@ -118,6 +118,26 @@ AC_ARG_WITH([critical], AC_DEFINE_UNQUOTED([ALARM_CRIT], [$critical_percent], [monitoring critical default]) AC_SUBST([ALARM_CRIT], [$critical_percent]) +AC_ARG_ENABLE([doxygen], + AC_HELP_STRING([--enable-doxygen], [build internal api documentation @<:@default=disabled@:>@]), + [], [enable_doxygen=no]) +AM_CONDITIONAL([ENABLE_DOXYGEN], [test "x$enable_doxygen" = "xyes"]) + +AS_IF([test x$enable_doxygen = xyes], [ + AC_CHECK_PROGS([DOXYGEN], [doxygen]) + AS_IF([test "x$DOXYGEN" = "x"], + AC_MSG_ERROR([doxygen not in path]), + AC_CONFIG_FILES([doc/Makefile doc/doxy.conf]) + ) + + AC_CHECK_PROGS([DOXYGEN_DOT], [dot]) + AS_IF([test "x$DOXYGEN" = "x"], + AC_MSG_WARN([dot not in path, internal documentation graphs are not generated]) + ) +]) +AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x"]) +AM_CONDITIONAL([HAVE_DOXYGEN_DOT], [test "x$DOXYGEN_DOT" != "x"]) + AC_CONFIG_FILES([ Makefile lib/Makefile diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..7167275 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,5 @@ +/Makefile +/Makefile.in +/doxy.conf +/doxyfile.stamp +/html diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..e990c92 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,18 @@ +EXTRA_DIST = doxy.conf.in introduction.dox + +if ENABLE_DOXYGEN + +doxyfile.stamp: + $(DOXYGEN) doxy.conf + date > doxyfile.stamp + +CLEANFILES = doxyfile.stamp + +all-local: doxyfile.stamp + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + -rm -rf html + +endif diff --git a/doc/doxy.conf.in b/doc/doxy.conf.in new file mode 100644 index 0000000..86e2d3b --- /dev/null +++ b/doc/doxy.conf.in @@ -0,0 +1,1808 @@ +# Doxyfile 1.8.2 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = @PACKAGE_NAME@ + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @PACKAGE_VERSION@ + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "ISC dhcpd lease usage analyser" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = @top_srcdir@/doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = src + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter and setter methods for a property. Setting this option to YES (the default) will make doxygen replace the get and set methods by a property in the documentation. This will only work if the methods are indeed getting or setting a simple type. If this is not the case, or you want to show the methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = YES + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = @top_srcdir@ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c *.h *.dox + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = build-aux contrib + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = *.c *.h + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/introduction.dox b/doc/introduction.dox new file mode 100644 index 0000000..d1fd997 --- /dev/null +++ b/doc/introduction.dox @@ -0,0 +1,49 @@ +/*! +@mainpage +@section introduction Introduction + +This is dhcpd-pools ISC dhcp shared network and pool range usage +analysis. Purpose of command is to count usage ratio of each IP range +and shared network pool which ISC dhcpd is in control of. Users of the +command are most likely ISPs and other organizations that have large IP +space. + +Program is written C. Design goal is to get analysis done quickly where +there is lots of data. On cheap laptop the speed of analysis is roughly +100k leases per second. Number of ranges, or shared networks, does not +make any significant difference in getting analysis done. + +@section main-copyright Copyright Policy + +The dhcpd-pools has BSD 2-clause license which also known as "Simplified +BSD License" or "FreeBSD License". + +Copyright 2006- Sami Kerola. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are +those of the authors and should not be interpreted as representing +official policies, either expressed or implied, of Sami Kerola. + +*/ diff --git a/src/analyze.c b/src/analyze.c index f66b150..dafcdd5 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file analyze.c + * \brief Data analysis functions. + */ + #include #include @@ -41,9 +45,10 @@ #include "dhcpd-pools.h" -/* Clean up data */ -int prepare_data(void) -{ +/*! \brief Prepare data for analysis. The function will sort leases and + * ranges. + * FIXME: This function should return void. */ +int prepare_data(void) { /* Sort leases */ HASH_SORT(leases, leasecomp); /* Sort ranges */ @@ -51,7 +56,8 @@ int prepare_data(void) return 0; } -/* Join leases and ranges into counter structs */ +/*! \brief Perform counting. Join leases with ranges, and update counters. + * FIXME: This function should return void. */ int do_counting(void) { struct range_t *restrict range_p; @@ -110,9 +116,10 @@ int do_counting(void) range_p++; } - /* FIXME: During count of other shared networks default network and - * all networks got mixed together semantically. This fixes the - * problem, but is not elegant. */ + + /* FIXME: During count of other shared networks default network + * and all networks got mixed together semantically. The below + * fixes the problem, but is not elegant. */ shared_networks->available = 0; shared_networks->used = 0; shared_networks->touched = 0; diff --git a/src/defaults.h b/src/defaults.h index 76e1ec5..1e671da 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -33,16 +33,26 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file defaults.h + * \brief Default settings which cannot be changed without recompiling + * the software. + */ + #ifndef DEFAULTS_H # define DEFAULTS_H 1 -/* Maximum line length in dhcpd.conf and dhcpd.leases */ +/*! \var MAXLEN + * \brief Maximum expected line length in dhcpd.conf and dhcpd.leases + * files. */ static const size_t MAXLEN = 1024; -/* Maximum number of shared networks */ +/*! \var SHARED_NETWORKS + * \brief Maximum number of different shared networks in dhcpd.conf file. */ static const unsigned int SHARED_NETWORKS = 8192; -/* Maximum number of ranges */ +/*! \var RANGES + * \brief Maximum number of ranges + * \xrefitem FIXME RANGES "Move this variable to dhcpd-pools.h"*/ unsigned int RANGES; #endif /* DEFAULTS_H */ diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index aa401e0..fc835c9 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file dhcpd-pools.c + * \brief The main(), and core initialization. + */ + #include #include #include @@ -49,6 +53,16 @@ #include "dhcpd-pools.h" #include "xalloc.h" +/*! \brief Start of execution. Parse options, and call other other + * functions one after another. At the moment adding threading support + * would be difficult, but there does not seem to be valid reason to + * consider that. Overall the analysis already quick enough even without + * making it parallel. + * + * \return Return value indicates success or fail or analysis, unless + * either --warning or --critical options are in use, which makes the + * return value in some cases to match with Nagios expectations about + * alarming. */ int main(int argc, char **argv) { int i, c, sorts = 0; @@ -79,7 +93,8 @@ int main(int argc, char **argv) atexit(close_stdout); - /* FIXME: make these allocations dynamic up on need. */ + /* FIXME: These allocations should be fully dynamic, e.g., grow + * if needed. */ config.dhcpdconf_file = xmalloc(sizeof(char) * MAXLEN); config.dhcpdlease_file = xmalloc(sizeof(char) * MAXLEN); config.output_file = xmalloc(sizeof(char) * MAXLEN); @@ -242,7 +257,9 @@ int main(int argc, char **argv) return (ret_val); } -/* Global allocations, counter resets etc */ +/*! \brief Run time initialization. Global allocations, counter + * initializations, etc are here. + * FIXME: This function should return void. */ int prepare_memory(void) { /* Fill in prefix length cache */ diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 6dd493a..65d5d06 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -33,6 +33,12 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file dhcpd-pools.h + * \brief Global definitions of structures, enums, and function prototypes. + * FIXME: The file has too many global variables. Most of them should be + * removed, if not all. + */ + #ifndef DHCPD_POOLS_H # define DHCPD_POOLS_H 1 @@ -43,6 +49,12 @@ # include # include +/*! \def likely(x) + * \brief Symbolic call to __builtin_expect'ed branch. + */ +/*! \def unlikely(x) + * \brief Symbolic call to not-__builtin_expect'ed branch. + */ # ifdef HAVE_BUILTIN_EXPECT # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) @@ -51,16 +63,24 @@ # define unlikely(x) (x) # endif -/* Structures and unions */ +/*! \union ipaddr_t + * \brief Memory space for a binary IP address saving. */ union ipaddr_t { uint32_t v4; unsigned char v6[16]; }; +/*! \enum dhcp_version + * \brief Indicator which IP version is in use. + */ enum dhcp_version { VERSION_4, VERSION_6, VERSION_UNKNOWN, }; +/*! \enum prefix_t + * \brief Enumeration of interesting data in dhcpd.leases file, that has + * to be further examined, and saved. + */ enum prefix_t { PREFIX_LEASE, PREFIX_BINDING_STATE_FREE, @@ -69,7 +89,9 @@ enum prefix_t { PREFIX_HARDWARE_ETHERNET, NUM_OF_PREFIX }; - +/*! \struct configuration_t + * \brief Runtime configuration. + */ struct configuration_t { char dhcpv6; char *dhcpdconf_file; @@ -82,6 +104,9 @@ struct configuration_t { double warning; double critical; }; +/*! \struct shared_network_t + * \brief Counters for an individual shared network. + */ struct shared_network_t { char *name; unsigned long int available; @@ -89,6 +114,9 @@ struct shared_network_t { unsigned long int touched; unsigned long int backups; }; +/*! \struct range_t + * \brief Counters for an individual range. + */ struct range_t { struct shared_network_t *shared_net; union ipaddr_t first_ip; @@ -97,11 +125,17 @@ struct range_t { unsigned long int touched; unsigned long int backups; }; +/*! \enum ltype + * \brief Lease state types. + */ enum ltype { ACTIVE, FREE, BACKUP }; +/*! \struct leases_t + * \brief An individual lease. The leaases are hashed. + */ struct leases_t { union ipaddr_t ip; /* ip as key */ enum ltype type; @@ -110,21 +144,40 @@ struct leases_t { }; /* Global variables */ +/* \var prefixes An array holding dhcpd.leases lines that are wanted to examine.*/ const char *prefixes[2][NUM_OF_PREFIX]; +/* \var prefix_length Length of each prefix. */ int prefix_length[2][NUM_OF_PREFIX]; +/* \var config Runtime configuration. */ struct configuration_t config; +/* \var dhcp_version Version of IP in use. + * FIXME: move to runtime configuration. */ enum dhcp_version dhcp_version; +/* \var output_limit_bit_1 Bit mask what is printed. + * FIXME: These should probably be enum with hex assignments. */ static int const output_limit_bit_1 = 1; +/* \var output_limit_bit_2 See output_limit_bit_1 */ static int const output_limit_bit_2 = 2; +/* \var output_limit_bit_3 see output_limit_bit_1 */ static int const output_limit_bit_3 = 4; +/* \var fullhtml Setting if full html is been requested by user. + * FIXME: move to config. */ unsigned int fullhtml; +/* \var shared_networks Pointer holding shared network count results. */ struct shared_network_t *shared_networks; +/* \var num_shared_networks Number of shared networks found. */ unsigned int num_shared_networks; +/* \var ranges Pointer holding range count results. */ struct range_t *ranges; +/* \var num_ranges Number of ranges found. */ unsigned int num_ranges; +/* \var leases Pointer holding all leases. */ struct leases_t *leases; +/* \var num_leases FIXME: not in use, remove */ unsigned long int num_leases; +/* \var num_touches FIXME: not in use, remove */ unsigned long int num_touches; +/* \var num_backups FIXME: not in use, remove */ unsigned long int num_backups; /* Function prototypes */ diff --git a/src/getdata.c b/src/getdata.c index 1a57909..661bdb7 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file getdata.c + * \brief Functions to read data from dhcpd.conf and dhcdp.leases files. + */ + #include #include @@ -53,8 +57,13 @@ #include "dhcpd-pools.h" #include "xalloc.h" -/* The .indent.pro in use will mess formatting of array below. Please do - * not commit less readable indentation. */ +/*! \var prefixes[2][NUM_OF_PREFIX] + * \brief ISC lease file formats for IPv4 and IPv6. + * + * The .indent.pro in use will mess formatting of array below. + * Please do not commit less readable indentation. + * + * FIXME: The prefixes should be moved to defaults.h */ const char *prefixes[2][NUM_OF_PREFIX] = { [VERSION_4] = { [PREFIX_LEASE] = "lease ", @@ -72,10 +81,15 @@ const char *prefixes[2][NUM_OF_PREFIX] = { } }; +/*! \var prefix_length[2][NUM_OF_PREFIX] + * \brief Expected configuration string length, that varies for IPv4 and + * IPv6. See also prefixes. + * + * FIXME: The prefix_length should be moved to dhcpd-pools.h */ int prefix_length[2][NUM_OF_PREFIX] = { }; -/* Parse dhcpd.leases file. All performance boosts for this function are - * welcome */ +/*! \brief Lease file parser. The parser can only read ISC DHCPD + * dhcpd.leases file format. */ int parse_leases(void) { FILE *dhcpd_leases; @@ -124,6 +138,12 @@ int parse_leases(void) const char **p = prefixes[dhcp_version]; int *l = prefix_length[dhcp_version]; + +/*! \def HAS_PREFIX(line, type) + * \brief A macro to match IPv4 and IPv6 lease lines. + * + * FIXME: This macro should have better name. The HAS_PREFIX sounds like + * some sort of prefix length test. */ #define HAS_PREFIX(line, type) xstrstr((line), p[type], l[type]) while (!feof(dhcpd_leases)) { @@ -177,7 +197,10 @@ int parse_leases(void) return 0; } -/* Like strcpy but for field which is separated by white spaces. */ +/*! \brief A version of strcpy, but for a white space separated field. + * \param dest String copy destination. + * \param src String copy source. + */ void nth_field(char *restrict dest, const char *restrict src) { size_t i, len; @@ -191,7 +214,11 @@ void nth_field(char *restrict dest, const char *restrict src) } } -/* dhcpd.conf interesting words */ +/*! \brief Keyword search in dhcpd.conf file. + * \param s A line from the dhcpd.conf file. + * \return Indicator what configuration was found. + * FIXME: This function should return enum type. + */ static int is_interesting_config_clause(char const *restrict s) { if (strstr(s, "range")) @@ -203,7 +230,10 @@ static int is_interesting_config_clause(char const *restrict s) return 0; } -/* FIXME: This spaghetti monster function need to be rewrote at least ones. */ +/*! \brief The dhcpd.conf file parser. + * FIXME: This spaghetti monster function need to be rewrote at least + * ones. + */ void parse_config(int is_include, const char *restrict config_file, struct shared_network_t *restrict shared_p) { diff --git a/src/hash.c b/src/hash.c index d374860..0f1d6d6 100644 --- a/src/hash.c +++ b/src/hash.c @@ -33,12 +33,20 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file hash.c + * \brief The leases hash functions. The hash sorting is key to make + * analysis happen as quick as possible.. + */ + #include "dhcpd-pools.h" #include "xalloc.h" #define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out) #define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add) +/*! \brief Add a lease to hash array. + * \param addr Binary IP to be added in leases hash. + * \param type Lease state of the IP. */ void add_lease(union ipaddr_t *addr, enum ltype type) { struct leases_t *l; @@ -53,6 +61,10 @@ void add_lease(union ipaddr_t *addr, enum ltype type) l->ethernet = NULL; } +/*! \brief Find pointer to lease from hash array. + * \param addr Binary IP searched from leases hash. + * \return A lease structure about requested IP, or NULL. + */ struct leases_t *find_lease(union ipaddr_t *addr) { struct leases_t *l; @@ -65,6 +77,8 @@ struct leases_t *find_lease(union ipaddr_t *addr) return l; } +/*! \brief Delete a lease from hash array. + * \param lease Pointer to lease hash. */ void delete_lease(struct leases_t *lease) { if (lease->ethernet != NULL) @@ -84,6 +98,11 @@ void delete_all_leases() } */ +/*! \brief Delete all leases from hash array. + * FIXME: The prototype should have (void) as an argument. + * FIXME: Take the HASH_ITER + HASH_DEL in use by if uthash version + * allows it. + */ void delete_all_leases() { struct leases_t *l; diff --git a/src/other.c b/src/other.c index e378084..5bb032a 100644 --- a/src/other.c +++ b/src/other.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file other.c + * \brief Collection of various functions. + */ + #include #include "dhcpd-pools.h" @@ -47,6 +51,11 @@ #include #include +/*! \brief Convert text string IP address from either IPv4 or IPv6 to an integer. + * \param src An IP string in either format. + * \param dst An union which will hold conversion result. + * \return Was parsing successful. + */ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) { int rv; @@ -73,6 +82,10 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) return rv == 1; } +/*! \brief Copy IP address to union. + * + * \param dst Destination for a binary IP address. + * \param src Sourse of an IP address. */ void copy_ipaddr(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) { @@ -83,6 +96,14 @@ void copy_ipaddr(union ipaddr_t *restrict dst, } } +/*! \brief Convert an address to string. This function will convert the + * IPv4 addresses to 123.45.65.78 format, and the IPv6 addresses to it's + * native format depending on which version of the addressing is found to + * be in use. + * + * \param ip Binary IP address. + * \return Printable address. + */ const char *ntop_ipaddr(const union ipaddr_t *ip) { static char @@ -98,6 +119,12 @@ const char *ntop_ipaddr(const union ipaddr_t *ip) } } +/*! \brief Calculate how many addresses there are in a range. + * + * \param r Pointer to range structure, which has information about first + * and last IP in the range. + * \return Size of a range. + */ unsigned long get_range_size(const struct range_t *r) { if (dhcp_version == VERSION_6) { @@ -117,6 +144,15 @@ unsigned long get_range_size(const struct range_t *r) } } +/*! \fn xstrstr(const char *restrict a, const char *restrict b, const int len) + * \brief Compare two strings. Similar to strcmp, but tuned to be + * quicker which is possible because input data is known to have certain + * structure. + * + * \param a String which is been compared, e.g., a haystack. + * \param b Constant string which is hoped to found, e.g., a needle. + * \param len Stop point in characters when comparison must be ended. + * \return Zero if strings differ, one if they are the same. */ int #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((hot)) @@ -143,7 +179,12 @@ int return true; } -/* Return percentage value */ +/*! \brief Return a double floating point value. + * + * \param str String to be converted to a double. + * \param errmesg Exit error message if conversion fails. + * \return Binary result of string to double conversion. + */ double strtod_or_err(const char *restrict str, const char *restrict errmesg) { double num; @@ -165,6 +206,13 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg) errx(EXIT_FAILURE, "%s: '%s'", errmesg, str); } +/*! \brief Reverse range. + * Used before output, if a caller has requested reverse sorting. + * FIXME: The temporary memory area handling should be internal to this + * function, not a parameter. + * + * \param flip_me The range that needs to be inverted. + * \param tmp_ranges Temporary memory area for the flip. */ void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ranges) { @@ -178,7 +226,7 @@ void flip_ranges(struct range_t *restrict flip_me, memcpy(flip_me, tmp_ranges, num_ranges * sizeof(struct range_t)); } -/* Free memory, flush buffers etc */ +/*! \brief Free memory, flush buffers etc. */ void clean_up(void) { unsigned int i; @@ -199,6 +247,7 @@ void clean_up(void) free(shared_networks); } +/*! \brief A version printing. */ void __attribute__ ((__noreturn__)) print_version(void) { fprintf(stdout, "%s\n" @@ -208,6 +257,7 @@ void __attribute__ ((__noreturn__)) print_version(void) exit(EXIT_SUCCESS); } +/*! \brief Command line help screen. */ void __attribute__ ((__noreturn__)) usage(int status) { FILE *out; diff --git a/src/output.c b/src/output.c index 9181feb..809ec23 100644 --- a/src/output.c +++ b/src/output.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file output.c + * \brief All about output formats. + */ + #include #include @@ -50,6 +54,8 @@ #include "dhcpd-pools.h" #include "strftime.h" +/*! \brief Text output format, which is the default. + * FIXME: This function should return void. */ int output_txt(void) { unsigned int i; @@ -214,6 +220,9 @@ int output_txt(void) return 0; } +/*! \brief The xml output formats. + * FIXME: This function should return void. + */ int output_xml(void) { unsigned int i; @@ -328,6 +337,9 @@ int output_xml(void) return 0; } +/*! \brief The json output formats. + * FIXME: This function should return void. + */ int output_json(void) { unsigned int i = 0; @@ -471,6 +483,10 @@ int output_json(void) return 0; } +/*! \brief Header for full html output format. + * + * \param f Output file descriptor. + */ static void html_header(FILE *restrict f) { char outstr[200]; @@ -545,6 +561,10 @@ static void html_header(FILE *restrict f) fprintf(f, "The lease file mtime: %s", outstr); } +/*! \brief Footer for full html output format. + * + * \param f Output file descriptor. + */ static void html_footer(FILE *restrict f) { fprintf(f, "


\n"); @@ -561,33 +581,64 @@ static void html_footer(FILE *restrict f) fprintf(f, "\n"); } +/*! \brief A new row for html output format. + * + * \param f Output file descriptor. + */ static void newrow(FILE *restrict f) { fprintf(f, "\n"); } +/*! \brief End a row for html output format. + * + * \param f Output file descriptor. + */ static void endrow(FILE *restrict f) { fprintf(f, "\n\n"); } +/*! \brief Line with text in html output format. + * + * \param f Output file descriptor. + * \param type HTML tag name. + * \param class How the data is aligned. + * \param text Actual payload of the printout. + */ static void output_line(FILE *restrict f, char const *restrict type, char const *restrict class, char const *restrict text) { fprintf(f, " <%s class=%s>%s\n", type, class, text, type); } +/*! \brief Line with digit in html output format. + * + * \param f Output file descriptor. + * \param type HMTL tag name. + * \param unlong Actual payload of the printout. + */ static void output_long(FILE *restrict f, char const *restrict type, unsigned long unlong) { fprintf(f, " <%s class=ralign>%lu\n", type, unlong, type); } +/*! \brief Line with float in html output format. + * + * \param f Output file descriptor. + * \param type HTML tag name. + * \param fl Actual payload of the printout. + */ static void output_float(FILE *f, char const *restrict type, float fl) { fprintf(f, " <%s class=ralign>%.3f\n", type, fl, type); } +/*! \brief Begin table in html output format. + * + * \param f Output file descriptor. + */ static void table_start(FILE *restrict f) { fprintf(f, "\n"); } +/*! \brief End table in html output format. + * + * \param f Output file descriptor. + */ static void table_end(FILE *restrict f) { fprintf(f, "
\n"); } +/*! \brief New section in html output format. + * + * \param f Output file descriptor. + * \param title Table title. + */ static void newsection(FILE *restrict f, char const *restrict title) { newrow(f); @@ -610,6 +670,9 @@ static void newsection(FILE *restrict f, char const *restrict title) endrow(f); } +/*! \brief Output html format. + * FIXME: This function should return void. + */ int output_html(void) { unsigned int i; @@ -798,6 +861,9 @@ int output_html(void) return 0; } +/*! \brief Output cvs format. + * FIXME: This function should return void. + */ int output_csv(void) { unsigned int i; @@ -941,6 +1007,9 @@ int output_csv(void) return 0; } +/*! \brief Output alarm text, and return program exit value. + * FIXME: This function should return void. + */ int output_alarming(void) { FILE *outfile; diff --git a/src/sort.c b/src/sort.c index 3d606fd..3bd1719 100644 --- a/src/sort.c +++ b/src/sort.c @@ -33,6 +33,10 @@ * official policies, either expressed or implied, of Sami Kerola. */ +/*! \file sort.c + * \brief Functions to sort output. + */ + #include #include @@ -43,7 +47,11 @@ #include "dhcpd-pools.h" -/* Sort functions for range sorting */ +/*! \brief Compare unsigned 32 bit integers. Suitable for IPv4 sorting. + * \param x Binary IPv4 address. + * \param y Binary IPv4 address. + * \return If x < y return -1, if y < x return 1, when they are equal return 0. + */ int intcomp(const void *restrict x, const void *restrict y) { if (*(uint32_t *) x < *(uint32_t *) y) @@ -53,6 +61,11 @@ int intcomp(const void *restrict x, const void *restrict y) return 0; } +/*! \brief Compare IP address, with IPv4/v6 determination. + * \param a Binary IP address. + * \param b Binary IP address. + * \return If a < b return -1, if a < b return 1, when they are equal return 0. + */ int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) { if (dhcp_version == VERSION_6) { @@ -66,34 +79,60 @@ int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) } } +/*! \brief Compare IP address in leases. Suitable for sorting leases. + * \param a A lease structure. + * \param b A lease structure. + * \return Return pas through from ipcomp. + */ int leasecomp(const void *restrict a, const void *restrict b) { return ipcomp(&((const struct leases_t *)a)->ip, &((const struct leases_t *)b)->ip); } +/*! \brief Compare IP address in leases. Suitable for sorting range table. + * \param r1 A range structure. + * \param r2 A range structure. + * \return Return pas through from ipcomp. + */ int rangecomp(const void *restrict r1, const void *restrict r2) { return ipcomp(&((const struct range_t *)r1)->first_ip, &((const struct range_t *)r2)->first_ip); } +/*! \brief Return IP. + * \param r A range structure. + * \return First IP in the range, perhaps?? maybe? + * FIXME: This function is not implemented, yet. + */ unsigned long int ret_ip(struct range_t r) { - /* FIXME: IPv6 */ return (r.first_ip.v4); } +/*! \brief In use in range. + * \param r A range structure. + * \return Number of addresses that are in use in the given range. + */ unsigned long int ret_cur(struct range_t r) { return (r.count); } +/*! \brief Range maximum. + * \param r A range structure. + * \return Maximum number of addresses that can be in the given range. + */ unsigned long int ret_max(struct range_t r) { return get_range_size(&r); } +/*! \brief Percentage in use in range. + * \param r A range structure. + * \return Usage percentage of the given range. + */ unsigned long int ret_percent(struct range_t r) { float f; @@ -101,16 +140,28 @@ unsigned long int ret_percent(struct range_t r) return ((unsigned long int)(f * 100000)); } +/*! \brief Touched in range. + * \param r A range structure. + * \return Number of touched addresses in the given range. + */ unsigned long int ret_touched(struct range_t r) { return (r.touched); } +/*! \brief Touched and in use in range + * \param r A range structure. + * \return Number of touched or in use addresses in the given range. + */ unsigned long int ret_tc(struct range_t r) { return (r.count + r.touched); } +/*! \brief Return percentage of addresses touched and in use in range. + * \param r A range structure. + * \return Percentage of touched or in use addresses in the given range. + */ unsigned long int ret_tcperc(struct range_t r) { float f; @@ -118,6 +169,12 @@ unsigned long int ret_tcperc(struct range_t r) return ((unsigned long int)(f * 10000)); } +/*! \brief Sort field selector. + * \param c Symbolic name of a sort by character. + * The sort algorithms are stabile, which means multiple sorts can be + * specified and they do not mess the result of previous sort. The sort + * algorithms are used via function pointer, that gets to be reassigned. + */ void field_selector(char c) { switch (c) { @@ -151,7 +208,13 @@ void field_selector(char c) } } -/* Needed to support multiple key sorting. */ +/*! \brief Perform requested sorting. + * \param left The left side of the merge sort. + * \param right The right side of the merge sort. + * FIXME: This function should be marked as static. + * FIXME: Really horribly named indirection about which function is in use. + * \return Relevant for merge sort decision. + */ int get_order(struct range_t *restrict left, struct range_t *restrict right) { int i, len, ret; @@ -189,6 +252,12 @@ int get_order(struct range_t *restrict left, struct range_t *restrict right) return (0); } +/*! \brief Mergesort for range table. + * \param orig Pointer to range that is requested to be sorted. + * \param size Number of ranges to be sorted. + * \param temp Temporary memory space, needed when a values has to be + * flipped. + */ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *restrict temp) { From f1411858cbf68b4bea01790c9a4615cbfc985caf Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 22:14:22 +0000 Subject: [PATCH 019/313] 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 --- src/dhcpd-pools.c | 1 + src/dhcpd-pools.h | 8 ++------ src/getdata.c | 3 +-- src/output.c | 37 +++++++++++++++++++------------------ 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index fc835c9..89070e2 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -120,6 +120,7 @@ int main(int argc, char **argv) /* Default sort order is by IPs small to big */ config.reverse_order = false; + config.backups_found = false; /* Parse command line options */ while (1) { diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 65d5d06..a429398 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -44,6 +44,7 @@ # include # include +# include # include # include # include @@ -101,6 +102,7 @@ struct configuration_t { int reverse_order; char *output_file; int output_limit[2]; + bool backups_found; double warning; double critical; }; @@ -173,12 +175,6 @@ struct range_t *ranges; unsigned int num_ranges; /* \var leases Pointer holding all leases. */ struct leases_t *leases; -/* \var num_leases FIXME: not in use, remove */ -unsigned long int num_leases; -/* \var num_touches FIXME: not in use, remove */ -unsigned long int num_touches; -/* \var num_backups FIXME: not in use, remove */ -unsigned long int num_backups; /* Function prototypes */ int prepare_memory(void); diff --git a/src/getdata.c b/src/getdata.c index 661bdb7..bbd17bf 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -99,8 +99,6 @@ int parse_leases(void) int ethernets = false; struct leases_t *lease; - num_touches = num_leases = num_backups = 0; - dhcpd_leases = fopen(config.dhcpdlease_file, "r"); if (dhcpd_leases == NULL) { err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); @@ -180,6 +178,7 @@ int parse_leases(void) delete_lease(lease); } add_lease(&addr, BACKUP); + config.backups_found = true; continue; } if (ethernets && (xstrstr(line, " hardware ethernet", 19))) { diff --git a/src/output.c b/src/output.c index 809ec23..36ba850 100644 --- a/src/output.c +++ b/src/output.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,7 @@ int output_txt(void) max_ipaddr_length, "last ip", "max", "cur", "percent", "touch", "t+c", "t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, " bu bu perc"); } fprintf(outfile, "\n"); @@ -121,7 +122,7 @@ int output_txt(void) (float)(100 * (range_p->touched + range_p->count)) / range_size); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, "%7lu %8.3f", range_p->backups, (float)(100 * range_p->backups) / @@ -140,7 +141,7 @@ int output_txt(void) fprintf(outfile, "Shared networks:\n"); fprintf(outfile, "name max cur percent touch t+c t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, " bu bu perc"); } fprintf(outfile, "\n"); @@ -159,7 +160,7 @@ int output_txt(void) (shared_p->touched + shared_p->used)) / shared_p->available); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, "%7lu %8.3f", shared_p->backups, (float)(100 * shared_p->backups) / @@ -178,7 +179,7 @@ int output_txt(void) fprintf(outfile, "name max cur percent touch t+c t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, " bu bu perc"); } fprintf(outfile, "\n"); @@ -197,7 +198,7 @@ int output_txt(void) shared_networks->used)) / shared_networks->available); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, "%7lu %8.3f", shared_networks->backups, (float)(100 * shared_networks->backups) / @@ -710,7 +711,7 @@ int output_html(void) output_line(outfile, "th", "ralign", "touch"); output_line(outfile, "th", "ralign", "t+c"); output_line(outfile, "th", "ralign", "t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { output_line(outfile, "th", "ralign", "bu"); output_line(outfile, "th", "ralign", "bu perc"); } @@ -742,7 +743,7 @@ int output_html(void) (float)(100 * (range_p->touched + range_p->count)) / range_size); - if (0 < num_backups) { + if (config.backups_found == true) { output_long(outfile, "td", range_p->backups); output_float(outfile, "td", (float)(100 * @@ -766,7 +767,7 @@ int output_html(void) output_line(outfile, "th", "ralign", "touch"); output_line(outfile, "th", "ralign", "t+c"); output_line(outfile, "th", "ralign", "t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { output_line(outfile, "th", "ralign", "bu"); output_line(outfile, "th", "ralign", "bu perc"); } @@ -790,7 +791,7 @@ int output_html(void) (shared_p->touched + shared_p->used)) / shared_p->available); - if (0 < num_backups) { + if (config.backups_found == true) { output_long(outfile, "td", shared_p->backups); output_float(outfile, "td", (float)(100 * @@ -811,7 +812,7 @@ int output_html(void) output_line(outfile, "th", "ralign", "touch"); output_line(outfile, "th", "ralign", "t+c"); output_line(outfile, "th", "ralign", "t+c perc"); - if (0 < num_backups) { + if (config.backups_found == true) { output_line(outfile, "th", "ralign", "bu"); output_line(outfile, "th", "ralign", "bu perc"); } @@ -834,7 +835,7 @@ int output_html(void) (shared_networks->touched + shared_networks->used)) / shared_networks->available); - if (0 < num_backups) { + if (config.backups_found == true) { output_long(outfile, "td", shared_networks->backups); output_float(outfile, "td", (float)(100 * @@ -889,7 +890,7 @@ int output_csv(void) fprintf (outfile, "\"shared net name\",\"first ip\",\"last ip\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\""); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, ",\"bu\",\"bu perc\""); } fprintf(outfile, "\n"); @@ -914,7 +915,7 @@ int output_csv(void) (float)(100 * (range_p->touched + range_p->count)) / range_size); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, ",\"%lu\",\"%.3f\"", range_p->backups, (float)(100 * range_p->backups) / @@ -931,7 +932,7 @@ int output_csv(void) fprintf(outfile, "\"Shared networks:\"\n"); fprintf(outfile, "\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\""); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, ",\"bu\",\"bu perc\""); } fprintf(outfile, "\n"); @@ -951,7 +952,7 @@ int output_csv(void) (shared_p->touched + shared_p->used)) / shared_p->available); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, ",\"%lu\",\"%.3f\"", shared_p->backups, (float)(100 * shared_p->backups) / @@ -966,7 +967,7 @@ int output_csv(void) fprintf(outfile, "\"Sum of all ranges:\"\n"); fprintf(outfile, "\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\""); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, ",\"bu\",\"bu perc\""); } fprintf(outfile, "\n"); @@ -985,7 +986,7 @@ int output_csv(void) (shared_networks->touched + shared_networks->used)) / shared_networks->available); - if (0 < num_backups) { + if (config.backups_found == true) { fprintf(outfile, "%7lu %8.3f", shared_networks->backups, (float)(100 * shared_networks->backups) / From 2008e1a047049e57edc16bcb28891e8562b0dcd0 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 22:27:58 +0000 Subject: [PATCH 020/313] clean up: remove unused functions Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 3 --- src/sort.c | 14 -------------- 2 files changed, 17 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index a429398..f7c3ab6 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -211,14 +211,11 @@ void print_version(void) __attribute__ ((noreturn)); void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ -int intcomp(const void *__restrict x, const void *__restrict y) - __attribute__ ((nonnull(1, 2))); int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ -int sort_name(void); unsigned long int (*returner) (struct range_t r); unsigned long int ret_ip(struct range_t r); unsigned long int ret_cur(struct range_t r); diff --git a/src/sort.c b/src/sort.c index 3bd1719..cd0ed81 100644 --- a/src/sort.c +++ b/src/sort.c @@ -47,20 +47,6 @@ #include "dhcpd-pools.h" -/*! \brief Compare unsigned 32 bit integers. Suitable for IPv4 sorting. - * \param x Binary IPv4 address. - * \param y Binary IPv4 address. - * \return If x < y return -1, if y < x return 1, when they are equal return 0. - */ -int intcomp(const void *restrict x, const void *restrict y) -{ - if (*(uint32_t *) x < *(uint32_t *) y) - return -1; - if (*(uint32_t *) y < *(uint32_t *) x) - return 1; - return 0; -} - /*! \brief Compare IP address, with IPv4/v6 determination. * \param a Binary IP address. * \param b Binary IP address. From a9d2d9c82f5575edb61a140530d3c2eed6c251df Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 22:40:00 +0000 Subject: [PATCH 021/313] clean up: move code to more proper location Signed-off-by: Sami Kerola --- src/defaults.h | 27 +++++++++++++++++++++++---- src/dhcpd-pools.h | 4 ++-- src/getdata.c | 31 ------------------------------- 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/defaults.h b/src/defaults.h index 1e671da..7b643ad 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -41,6 +41,8 @@ #ifndef DEFAULTS_H # define DEFAULTS_H 1 +#include "dhcpd-pools.h" + /*! \var MAXLEN * \brief Maximum expected line length in dhcpd.conf and dhcpd.leases * files. */ @@ -50,9 +52,26 @@ static const size_t MAXLEN = 1024; * \brief Maximum number of different shared networks in dhcpd.conf file. */ static const unsigned int SHARED_NETWORKS = 8192; -/*! \var RANGES - * \brief Maximum number of ranges - * \xrefitem FIXME RANGES "Move this variable to dhcpd-pools.h"*/ -unsigned int RANGES; +/*! \var prefixes[2][NUM_OF_PREFIX] + * \brief ISC lease file formats for IPv4 and IPv6. + * + * The .indent.pro in use will mess formatting of array below. + * Please do not commit less readable indentation. */ +static const char *prefixes[2][NUM_OF_PREFIX] = { + [VERSION_4] = { + [PREFIX_LEASE] = "lease ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + }, + [VERSION_6] = { + [PREFIX_LEASE] = " iaaddr ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + } +}; #endif /* DEFAULTS_H */ diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index f7c3ab6..3a91e3c 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -146,8 +146,6 @@ struct leases_t { }; /* Global variables */ -/* \var prefixes An array holding dhcpd.leases lines that are wanted to examine.*/ -const char *prefixes[2][NUM_OF_PREFIX]; /* \var prefix_length Length of each prefix. */ int prefix_length[2][NUM_OF_PREFIX]; /* \var config Runtime configuration. */ @@ -175,6 +173,8 @@ struct range_t *ranges; unsigned int num_ranges; /* \var leases Pointer holding all leases. */ struct leases_t *leases; +/*! \var RANGES Maximum number of ranges. */ +unsigned int RANGES; /* Function prototypes */ int prepare_memory(void); diff --git a/src/getdata.c b/src/getdata.c index bbd17bf..4df4945 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -57,37 +57,6 @@ #include "dhcpd-pools.h" #include "xalloc.h" -/*! \var prefixes[2][NUM_OF_PREFIX] - * \brief ISC lease file formats for IPv4 and IPv6. - * - * The .indent.pro in use will mess formatting of array below. - * Please do not commit less readable indentation. - * - * FIXME: The prefixes should be moved to defaults.h */ -const char *prefixes[2][NUM_OF_PREFIX] = { - [VERSION_4] = { - [PREFIX_LEASE] = "lease ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" - }, - [VERSION_6] = { - [PREFIX_LEASE] = " iaaddr ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" - } -}; - -/*! \var prefix_length[2][NUM_OF_PREFIX] - * \brief Expected configuration string length, that varies for IPv4 and - * IPv6. See also prefixes. - * - * FIXME: The prefix_length should be moved to dhcpd-pools.h */ -int prefix_length[2][NUM_OF_PREFIX] = { }; - /*! \brief Lease file parser. The parser can only read ISC DHCPD * dhcpd.leases file format. */ int parse_leases(void) From b59e980cabef4f153c188b9537f24c3a8f9a19b8 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 22:43:32 +0000 Subject: [PATCH 022/313] 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 --- src/dhcpd-pools.h | 2 +- src/hash.c | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 3a91e3c..9ebf9b6 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -244,6 +244,6 @@ void clean_up(void); void add_lease(union ipaddr_t *ip, enum ltype type); struct leases_t *find_lease(union ipaddr_t *ip); void delete_lease(struct leases_t *lease); -void delete_all_leases(); +void delete_all_leases(void); #endif /* DHCPD_POOLS_H */ diff --git a/src/hash.c b/src/hash.c index 0f1d6d6..f8c46e1 100644 --- a/src/hash.c +++ b/src/hash.c @@ -87,8 +87,9 @@ void delete_lease(struct leases_t *lease) free(lease); } -/* uthash >= 1.9.2 -void delete_all_leases() +/*! \brief Delete all leases from hash array. */ +#ifdef HASH_ITER +void delete_all_leases(void) { struct leases_t *l, *tmp; HASH_ITER(hh, leases, l, tmp) { @@ -96,14 +97,8 @@ void delete_all_leases() free(l); } } -*/ - -/*! \brief Delete all leases from hash array. - * FIXME: The prototype should have (void) as an argument. - * FIXME: Take the HASH_ITER + HASH_DEL in use by if uthash version - * allows it. - */ -void delete_all_leases() +#else +void delete_all_leases(void) { struct leases_t *l; while (leases) { @@ -113,3 +108,4 @@ void delete_all_leases() free(l); } } +#endif From d3ee104a59aa4b1a716597bb17d91470e938e973 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 22:56:07 +0000 Subject: [PATCH 023/313] clean up: move global variables to config structure Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 6 +++--- src/dhcpd-pools.h | 10 +++------- src/getdata.c | 4 ++-- src/hash.c | 4 ++-- src/other.c | 14 +++++++------- src/output.c | 6 +++--- src/sort.c | 2 +- 7 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 89070e2..21256fd 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) config.output_limit[0] = (*tmp - '0'); tmp++; config.output_limit[1] = (*tmp - '0'); - fullhtml = false; + config.fullhtml = false; /* Make sure some output format is selected by default */ strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1); @@ -215,7 +215,7 @@ int main(int argc, char **argv) break; case 'H': output_analysis = output_html; - fullhtml = true; + config.fullhtml = true; break; case 'x': output_analysis = output_xml; @@ -270,7 +270,7 @@ int prepare_memory(void) prefix_length[i][j] = strlen(prefixes[i][j]); } } - dhcp_version = VERSION_UNKNOWN; + config.dhcp_version = VERSION_UNKNOWN; RANGES = 64; num_ranges = num_shared_networks = 0; shared_networks = diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 9ebf9b6..aadf988 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -95,11 +95,13 @@ enum prefix_t { */ struct configuration_t { char dhcpv6; + enum dhcp_version dhcp_version; char *dhcpdconf_file; char *dhcpdlease_file; char output_format[2]; + bool fullhtml; char sort[6]; - int reverse_order; + bool reverse_order; char *output_file; int output_limit[2]; bool backups_found; @@ -150,9 +152,6 @@ struct leases_t { int prefix_length[2][NUM_OF_PREFIX]; /* \var config Runtime configuration. */ struct configuration_t config; -/* \var dhcp_version Version of IP in use. - * FIXME: move to runtime configuration. */ -enum dhcp_version dhcp_version; /* \var output_limit_bit_1 Bit mask what is printed. * FIXME: These should probably be enum with hex assignments. */ static int const output_limit_bit_1 = 1; @@ -160,9 +159,6 @@ static int const output_limit_bit_1 = 1; static int const output_limit_bit_2 = 2; /* \var output_limit_bit_3 see output_limit_bit_1 */ static int const output_limit_bit_3 = 4; -/* \var fullhtml Setting if full html is been requested by user. - * FIXME: move to config. */ -unsigned int fullhtml; /* \var shared_networks Pointer holding shared network count results. */ struct shared_network_t *shared_networks; /* \var num_shared_networks Number of shared networks found. */ diff --git a/src/getdata.c b/src/getdata.c index 4df4945..4c86311 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -103,8 +103,8 @@ int parse_leases(void) ethernets = true; } - const char **p = prefixes[dhcp_version]; - int *l = prefix_length[dhcp_version]; + const char **p = prefixes[config.dhcp_version]; + int *l = prefix_length[config.dhcp_version]; /*! \def HAS_PREFIX(line, type) * \brief A macro to match IPv4 and IPv6 lease lines. diff --git a/src/hash.c b/src/hash.c index f8c46e1..d56d082 100644 --- a/src/hash.c +++ b/src/hash.c @@ -53,7 +53,7 @@ void add_lease(union ipaddr_t *addr, enum ltype type) l = xmalloc(sizeof(struct leases_t)); copy_ipaddr(&l->ip, addr); l->type = type; - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { HASH_ADD_V6(leases, ip.v6, l); } else { HASH_ADD_INT(leases, ip.v4, l); @@ -69,7 +69,7 @@ struct leases_t *find_lease(union ipaddr_t *addr) { struct leases_t *l; - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { HASH_FIND_V6(leases, &addr->v6, l); } else { HASH_FIND_INT(leases, &addr->v4, l); diff --git a/src/other.c b/src/other.c index 5bb032a..70b29e2 100644 --- a/src/other.c +++ b/src/other.c @@ -59,18 +59,18 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) { int rv; - if (dhcp_version == VERSION_UNKNOWN) { + if (config.dhcp_version == VERSION_UNKNOWN) { struct in_addr addr; struct in6_addr addr6; if (inet_aton(src, &addr) == 1) { - dhcp_version = VERSION_4; + config.dhcp_version = VERSION_4; } else if (inet_pton(AF_INET6, src, &addr6) == 1) { - dhcp_version = VERSION_6; + config.dhcp_version = VERSION_6; } else { return 0; } } - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { struct in6_addr addr; rv = inet_pton(AF_INET6, src, &addr); memcpy(&dst->v6, addr.s6_addr, sizeof(addr.s6_addr)); @@ -89,7 +89,7 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) void copy_ipaddr(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) { - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { memcpy(&dst->v6, &src->v6, sizeof(src->v6)); } else { dst->v4 = src->v4; @@ -108,7 +108,7 @@ const char *ntop_ipaddr(const union ipaddr_t *ip) { static char buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { struct in6_addr addr; memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); @@ -127,7 +127,7 @@ const char *ntop_ipaddr(const union ipaddr_t *ip) */ unsigned long get_range_size(const struct range_t *r) { - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { unsigned long size = 0; int i; /* When calculating the size of an IPv6 range overflow may diff --git a/src/output.c b/src/output.c index 36ba850..1dc9526 100644 --- a/src/output.c +++ b/src/output.c @@ -65,7 +65,7 @@ int output_txt(void) struct shared_network_t *shared_p; int ret; FILE *outfile; - int max_ipaddr_length = dhcp_version == VERSION_6 ? 39 : 16; + int max_ipaddr_length = config.dhcp_version == VERSION_6 ? 39 : 16; if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); @@ -695,7 +695,7 @@ int output_html(void) range_p = ranges; range_size = get_range_size(range_p); shared_p = shared_networks; - if (fullhtml) { + if (config.fullhtml) { html_header(outfile); } table_start(outfile); @@ -845,7 +845,7 @@ int output_html(void) endrow(outfile); } table_end(outfile); - if (fullhtml) { + if (config.fullhtml) { html_footer(outfile); } if (outfile == stdout) { diff --git a/src/sort.c b/src/sort.c index cd0ed81..480fec5 100644 --- a/src/sort.c +++ b/src/sort.c @@ -54,7 +54,7 @@ */ int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) { - if (dhcp_version == VERSION_6) { + if (config.dhcp_version == VERSION_6) { return memcmp(&a->v6, &b->v6, sizeof(a->v6)); } else { if (a->v4 < b->v4) From 4b014eba1c66a39340a2742e7e654b6baebea3f2 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:02:01 +0000 Subject: [PATCH 024/313] clean up: use enum as symbolic bit masks Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 15 ++++++------ src/output.c | 62 +++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index aadf988..098b4c1 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -146,19 +146,20 @@ struct leases_t { char *ethernet; UT_hash_handle hh; }; +/*! \enum limbits + * \brief Output limit bits + */ +enum limbits { + BIT1 = 0x1, + BIT2 = 0x2, + BIT3 = 0x4 +}; /* Global variables */ /* \var prefix_length Length of each prefix. */ int prefix_length[2][NUM_OF_PREFIX]; /* \var config Runtime configuration. */ struct configuration_t config; -/* \var output_limit_bit_1 Bit mask what is printed. - * FIXME: These should probably be enum with hex assignments. */ -static int const output_limit_bit_1 = 1; -/* \var output_limit_bit_2 See output_limit_bit_1 */ -static int const output_limit_bit_2 = 2; -/* \var output_limit_bit_3 see output_limit_bit_1 */ -static int const output_limit_bit_3 = 4; /* \var shared_networks Pointer holding shared network count results. */ struct shared_network_t *shared_networks; /* \var num_shared_networks Number of shared networks found. */ diff --git a/src/output.c b/src/output.c index 1dc9526..43cd5d9 100644 --- a/src/output.c +++ b/src/output.c @@ -80,7 +80,7 @@ int output_txt(void) range_size = get_range_size(range_p); shared_p = shared_networks; - if (config.output_limit[0] & output_limit_bit_1) { + if (config.output_limit[0] & BIT1) { fprintf(outfile, "Ranges:\n"); fprintf (outfile, @@ -96,7 +96,7 @@ int output_txt(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { if (range_p->shared_net) { fprintf(outfile, "%-20s", @@ -133,11 +133,10 @@ int output_txt(void) range_size = get_range_size(range_p); } } - if (config.output_limit[1] & output_limit_bit_1 - && config.output_limit[0] & output_limit_bit_2) { + if (config.output_limit[1] & BIT1 && config.output_limit[0] & BIT2) { fprintf(outfile, "\n"); } - if (config.output_limit[0] & output_limit_bit_2) { + if (config.output_limit[0] & BIT2) { fprintf(outfile, "Shared networks:\n"); fprintf(outfile, "name max cur percent touch t+c t+c perc"); @@ -146,7 +145,7 @@ int output_txt(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { shared_p++; fprintf(outfile, @@ -170,11 +169,10 @@ int output_txt(void) fprintf(outfile, "\n"); } } - if (config.output_limit[1] & output_limit_bit_2 - && config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[1] & BIT2 && config.output_limit[0] & BIT3) { fprintf(outfile, "\n"); } - if (config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[0] & BIT3) { fprintf(outfile, "Sum of all ranges:\n"); fprintf(outfile, "name max cur percent touch t+c t+c perc"); @@ -184,7 +182,7 @@ int output_txt(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_3) { + if (config.output_limit[1] & BIT3) { fprintf(outfile, "%-20s %5lu %5lu %10.3f %7lu %6lu %9.3f", shared_networks->name, shared_networks->available, @@ -264,7 +262,7 @@ int output_xml(void) } } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { fprintf(outfile, "\n"); if (range_p->shared_net) { @@ -294,7 +292,7 @@ int output_xml(void) } } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { shared_p++; fprintf(outfile, "\n"); @@ -310,7 +308,7 @@ int output_xml(void) } } - if (config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[0] & BIT3) { fprintf(outfile, "\n"); fprintf(outfile, "\t%s\n", shared_networks->name); @@ -391,7 +389,7 @@ int output_json(void) sep++; } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { if (sep) { fprintf(outfile, ",\n"); } @@ -426,7 +424,7 @@ int output_json(void) sep++; } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { if (sep) { fprintf(outfile, ",\n"); } @@ -451,7 +449,7 @@ int output_json(void) sep++; } - if (config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[0] & BIT3) { if (sep) { fprintf(outfile, ",\n"); } @@ -699,7 +697,7 @@ int output_html(void) html_header(outfile); } table_start(outfile); - if (config.output_limit[0] & output_limit_bit_1) { + if (config.output_limit[0] & BIT1) { newsection(outfile, "Ranges:"); newrow(outfile); output_line(outfile, "th", "calign", "shared net name"); @@ -717,7 +715,7 @@ int output_html(void) } endrow(outfile); } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { newrow(outfile); if (range_p->shared_net) { @@ -757,7 +755,7 @@ int output_html(void) } table_end(outfile); table_start(outfile); - if (config.output_limit[0] & output_limit_bit_2) { + if (config.output_limit[0] & BIT2) { newsection(outfile, "Shared networks:"); newrow(outfile); output_line(outfile, "th", "calign", "name"); @@ -773,7 +771,7 @@ int output_html(void) } endrow(outfile); } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { shared_p++; newrow(outfile); @@ -802,7 +800,7 @@ int output_html(void) endrow(outfile); } } - if (config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[0] & BIT3) { newsection(outfile, "Sum of all ranges:"); newrow(outfile); output_line(outfile, "th", "calign", "name"); @@ -819,7 +817,7 @@ int output_html(void) endrow(outfile); } - if (config.output_limit[1] & output_limit_bit_3) { + if (config.output_limit[1] & BIT3) { newrow(outfile); output_line(outfile, "td", "calign", shared_networks->name); output_long(outfile, "td", shared_networks->available); @@ -885,7 +883,7 @@ int output_csv(void) range_p = ranges; range_size = get_range_size(range_p); shared_p = shared_networks; - if (config.output_limit[0] & output_limit_bit_1) { + if (config.output_limit[0] & BIT1) { fprintf(outfile, "\"Ranges:\"\n"); fprintf (outfile, @@ -895,7 +893,7 @@ int output_csv(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { if (range_p->shared_net) { fprintf(outfile, "\"%s\",", @@ -928,7 +926,7 @@ int output_csv(void) } fprintf(outfile, "\n"); } - if (config.output_limit[0] & output_limit_bit_2) { + if (config.output_limit[0] & BIT2) { fprintf(outfile, "\"Shared networks:\"\n"); fprintf(outfile, "\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\""); @@ -937,7 +935,7 @@ int output_csv(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { shared_p++; @@ -963,7 +961,7 @@ int output_csv(void) } fprintf(outfile, "\n"); } - if (config.output_limit[0] & output_limit_bit_3) { + if (config.output_limit[0] & BIT3) { fprintf(outfile, "\"Sum of all ranges:\"\n"); fprintf(outfile, "\"name\",\"max\",\"cur\",\"percent\",\"touch\",\"t+c\",\"t+c perc\""); @@ -972,7 +970,7 @@ int output_csv(void) } fprintf(outfile, "\n"); } - if (config.output_limit[1] & output_limit_bit_3) { + if (config.output_limit[1] & BIT3) { fprintf(outfile, "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", @@ -1036,7 +1034,7 @@ int output_alarming(void) outfile = stdout; } - if (config.output_limit[1] & output_limit_bit_1) { + if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { perc = (float)(100 * range_p->count) / range_size; if (config.critical < perc) @@ -1049,7 +1047,7 @@ int output_alarming(void) range_size = get_range_size(range_p); } } - if (config.output_limit[1] & output_limit_bit_2) { + if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { perc = (float)(100 * shared_p->used) / shared_p->available; @@ -1074,11 +1072,11 @@ int output_alarming(void) ret_val = 0; fprintf(outfile, "OK: "); } - if (config.output_limit[0] & output_limit_bit_1) { + if (config.output_limit[0] & BIT1) { fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw, ro); } - if (config.output_limit[0] & output_limit_bit_2) { + if (config.output_limit[0] & BIT2) { fprintf(outfile, "Shared nets; crit: %d warn: %d ok: %d", sc, sw, so); } From bd5ee58a3f7d880f20013957fb2b79d74e1e866f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:12:37 +0000 Subject: [PATCH 025/313] clean up: convert parsing magic numbers to symbolic values Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 10 ++++++++++ src/getdata.c | 51 +++++++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 098b4c1..ec95e18 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -129,6 +129,16 @@ struct range_t { unsigned long int touched; unsigned long int backups; }; +/*! \enum isc_conf_parser + * \brief Configuration file parsing state flags. + */ +enum isc_conf_parser { + ITS_NOTHING_INTERESTING, + ITS_A_RANGE_FIRST_IP, + ITS_A_RANGE_SECOND_IP, + ITS_A_SHAREDNET, + ITS_AN_INCLUCE +}; /*! \enum ltype * \brief Lease state types. */ diff --git a/src/getdata.c b/src/getdata.c index 4c86311..b74c5d1 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -184,18 +184,16 @@ void nth_field(char *restrict dest, const char *restrict src) /*! \brief Keyword search in dhcpd.conf file. * \param s A line from the dhcpd.conf file. - * \return Indicator what configuration was found. - * FIXME: This function should return enum type. - */ + * \return Indicator what configuration was found. */ static int is_interesting_config_clause(char const *restrict s) { if (strstr(s, "range")) - return 3; + return ITS_A_RANGE_FIRST_IP; if (strstr(s, "shared-network")) - return 1; + return ITS_A_SHAREDNET; if (strstr(s, "include")) - return 4; - return 0; + return ITS_AN_INCLUCE; + return ITS_NOTHING_INTERESTING; } /*! \brief The dhcpd.conf file parser. @@ -207,7 +205,7 @@ void parse_config(int is_include, const char *restrict config_file, { FILE *dhcpd_config; bool newclause = true, comment = false; - int quote = 0, braces = 0, argument = 0; + int quote = 0, braces = 0, argument = ITS_NOTHING_INTERESTING; size_t i = 0; char *word, c; int braces_shared = 1000; @@ -269,10 +267,12 @@ void parse_config(int is_include, const char *restrict config_file, if (0 < quote) { break; } - if (comment == false && argument != 2 && argument != 4) { + if (comment == false + && argument != ITS_A_RANGE_SECOND_IP + && argument != 4) { newclause = true; i = 0; - } else if (argument == 2) { + } else if (argument == ITS_A_RANGE_SECOND_IP) { /* Range ends to ; and this hair in code * make two ranges wrote together like... * @@ -321,16 +321,19 @@ void parse_config(int is_include, const char *restrict config_file, } /* Either inside comment or Nth word of clause. */ - if (comment == true || (newclause == false && argument == 0)) { + if (comment == true + || (newclause == false + && argument == ITS_NOTHING_INTERESTING)) { continue; } /* Strip white spaces before new clause word. */ - if ((newclause == true || argument != 0) && isspace(c) + if ((newclause == true || argument != ITS_NOTHING_INTERESTING) + && isspace(c) && i == 0) { continue; } /* Save to word which clause this is. */ - if ((newclause == true || argument != 0) + if ((newclause == true || argument != ITS_NOTHING_INTERESTING) && (!isspace(c) || 0 < quote)) { word[i] = c; i++; @@ -354,17 +357,17 @@ void parse_config(int is_include, const char *restrict config_file, argument = is_interesting_config_clause(word); } /* words after range, shared-network or include */ - else if (argument != 0) { + else if (argument != ITS_NOTHING_INTERESTING) { word[i] = '\0'; newclause = false; i = 0; switch (argument) { - case 2: + case ITS_A_RANGE_SECOND_IP: /* printf ("range 2nd ip: %s\n", word); */ range_p = ranges + num_ranges; parse_ipaddr(word, &addr); - argument = 0; + argument = ITS_NOTHING_INTERESTING; copy_ipaddr(&range_p->last_ip, &addr); range_p->count = 0; range_p->touched = 0; @@ -381,7 +384,7 @@ void parse_config(int is_include, const char *restrict config_file, } newclause = true; break; - case 3: + case ITS_A_RANGE_FIRST_IP: /* printf ("range 1nd ip: %s\n", word); */ range_p = ranges + num_ranges; if (!(parse_ipaddr(word, &addr))) { @@ -390,9 +393,9 @@ void parse_config(int is_include, const char *restrict config_file, break; } copy_ipaddr(&range_p->first_ip, &addr); - argument = 2; + argument = ITS_A_RANGE_SECOND_IP; break; - case 1: + case ITS_A_SHAREDNET: /* printf ("shared-network named: %s\n", word); */ num_shared_networks++; shared_p = @@ -409,18 +412,18 @@ void parse_config(int is_include, const char *restrict config_file, errx(EXIT_FAILURE, "parse_config: increase default.h SHARED_NETWORKS and recompile"); } - argument = 0; + argument = ITS_NOTHING_INTERESTING; braces_shared = braces; break; - case 4: + case ITS_AN_INCLUCE: /* printf ("include file: %s\n", word); */ - argument = 0; + argument = ITS_NOTHING_INTERESTING; parse_config(false, word, shared_p); newclause = true; break; - case 0: + case ITS_NOTHING_INTERESTING: /* printf ("nothing interesting: %s\n", word); */ - argument = 0; + argument = ITS_NOTHING_INTERESTING; break; default: warnx("impossible occurred, report a bug"); From 82df7c98d4268ff7cdc9bad60fc576201767dfe9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:20:46 +0000 Subject: [PATCH 026/313] 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 --- src/dhcpd-pools.h | 2 -- src/sort.c | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index ec95e18..dda625f 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -232,8 +232,6 @@ unsigned long int ret_touched(struct range_t r); unsigned long int ret_tc(struct range_t r); unsigned long int ret_tcperc(struct range_t r); void field_selector(char c); -int get_order(struct range_t *__restrict left, struct range_t *__restrict right) - __attribute__ ((nonnull(1, 2))); void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); diff --git a/src/sort.c b/src/sort.c index 480fec5..30a4267 100644 --- a/src/sort.c +++ b/src/sort.c @@ -197,11 +197,9 @@ void field_selector(char c) /*! \brief Perform requested sorting. * \param left The left side of the merge sort. * \param right The right side of the merge sort. - * FIXME: This function should be marked as static. - * FIXME: Really horribly named indirection about which function is in use. * \return Relevant for merge sort decision. */ -int get_order(struct range_t *restrict left, struct range_t *restrict right) +static int merge(struct range_t *restrict left, struct range_t *restrict right) { int i, len, ret; unsigned long int lint, rint; @@ -256,7 +254,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, for (left = 0; left < size; left++) { hold = *(orig + left); for (right = left - 1; 0 <= right; right--) { - if (get_order((orig + right), &hold)) { + if (merge((orig + right), &hold)) { break; } *(orig + right + 1) = *(orig + right); @@ -274,7 +272,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, i = 0; while (left < size / 2 && right < size) { - if (get_order((orig + left), (orig + right))) { + if (merge((orig + left), (orig + right))) { *(temp + i) = *(orig + left); left++; } else { From 51143b6b3c35b8ec28e355f433ba3c5c4a51cd52 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:28:58 +0000 Subject: [PATCH 027/313] clean up: fix few indentation slips Signed-off-by: Sami Kerola --- src/analyze.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index dafcdd5..0b0939e 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -48,7 +48,8 @@ /*! \brief Prepare data for analysis. The function will sort leases and * ranges. * FIXME: This function should return void. */ -int prepare_data(void) { +int prepare_data(void) +{ /* Sort leases */ HASH_SORT(leases, leasecomp); /* Sort ranges */ @@ -116,7 +117,6 @@ int do_counting(void) range_p++; } - /* FIXME: During count of other shared networks default network * and all networks got mixed together semantically. The below * fixes the problem, but is not elegant. */ From 70c65f4d593c539b2a216672a9564136c2a2bb79 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Dec 2012 23:38:37 +0000 Subject: [PATCH 028/313] 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 --- src/getdata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/getdata.c b/src/getdata.c index b74c5d1..39061d3 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -65,7 +65,7 @@ int parse_leases(void) char *line, *ipstring, macstring[20]; union ipaddr_t addr; struct stat lease_file_stats; - int ethernets = false; + bool ethernets = false; struct leases_t *lease; dhcpd_leases = fopen(config.dhcpdlease_file, "r"); @@ -244,7 +244,7 @@ void parse_config(int is_include, const char *restrict config_file, switch (c) { /* Handle comments if they are not quoted */ case '#': - if (quote == false) { + if (quote == 0) { comment = true; } continue; @@ -258,7 +258,7 @@ void parse_config(int is_include, const char *restrict config_file, case '\n': /* New line resets comment section, but * not if quoted */ - if (quote == false) { + if (quote == 0) { comment = false; } break; @@ -269,7 +269,7 @@ void parse_config(int is_include, const char *restrict config_file, } if (comment == false && argument != ITS_A_RANGE_SECOND_IP - && argument != 4) { + && argument != ITS_AN_INCLUCE) { newclause = true; i = 0; } else if (argument == ITS_A_RANGE_SECOND_IP) { From 4051a953bd903444dd4ff72c29cd459e6d7b9d53 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 20 Dec 2012 20:04:06 +0000 Subject: [PATCH 029/313] 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 --- src/dhcpd-pools.h | 2 +- src/hash.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index dda625f..f4c591f 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -76,7 +76,7 @@ union ipaddr_t { enum dhcp_version { VERSION_4, VERSION_6, - VERSION_UNKNOWN, + VERSION_UNKNOWN }; /*! \enum prefix_t * \brief Enumeration of interesting data in dhcpd.leases file, that has diff --git a/src/hash.c b/src/hash.c index d56d082..7b3f359 100644 --- a/src/hash.c +++ b/src/hash.c @@ -81,8 +81,7 @@ struct leases_t *find_lease(union ipaddr_t *addr) * \param lease Pointer to lease hash. */ void delete_lease(struct leases_t *lease) { - if (lease->ethernet != NULL) - free(lease->ethernet); + free(lease->ethernet); HASH_DEL(leases, lease); free(lease); } From 137c1d37c2096792e0ffecc0cb1efa23282508f0 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Sat, 5 Jan 2013 23:08:03 +0800 Subject: [PATCH 030/313] sort: Use a comparer instead of returner This resolves the FIXME of sorting ranges according to first_ip in IPv6 mode. --- src/dhcpd-pools.h | 6 +-- src/sort.c | 113 ++++++++++++++++++++++++++++++---------------- 2 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index f4c591f..6b175ac 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -223,12 +223,8 @@ int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ -unsigned long int (*returner) (struct range_t r); -unsigned long int ret_ip(struct range_t r); -unsigned long int ret_cur(struct range_t r); -unsigned long int ret_max(struct range_t r); +int (*comparer) (struct range_t *r1, struct range_t *r2); unsigned long int ret_percent(struct range_t r); -unsigned long int ret_touched(struct range_t r); unsigned long int ret_tc(struct range_t r); unsigned long int ret_tcperc(struct range_t r); void field_selector(char c); diff --git a/src/sort.c b/src/sort.c index 30a4267..5415359 100644 --- a/src/sort.c +++ b/src/sort.c @@ -3,6 +3,7 @@ * BSD License" or "FreeBSD License". * * Copyright 2006- Sami Kerola. All rights reserved. + * Copyright 2012 Cheer Xiao. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -87,32 +88,76 @@ int rangecomp(const void *restrict r1, const void *restrict r2) &((const struct range_t *)r2)->first_ip); } -/*! \brief Return IP. - * \param r A range structure. - * \return First IP in the range, perhaps?? maybe? - * FIXME: This function is not implemented, yet. +/*! \brief Compare two unsigned long. + * \param u1,u2 Data to compare. + * \return Like strcmp. */ -unsigned long int ret_ip(struct range_t r) +int comp_ulong(unsigned long u1, unsigned long u2) { - return (r.first_ip.v4); + return u1 < u2 ? -1 : u1 > u2 ? 1 : 0; } -/*! \brief In use in range. - * \param r A range structure. - * \return Number of addresses that are in use in the given range. +/*! \brief Compare two range_t by their first_ip. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. */ -unsigned long int ret_cur(struct range_t r) +int comp_ip(struct range_t *r1, struct range_t *r2) { - return (r.count); + return ipcomp(&r1->first_ip, &r2->first_ip); } -/*! \brief Range maximum. - * \param r A range structure. - * \return Maximum number of addresses that can be in the given range. +/*! \brief Compare two range_t by their capacity. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. */ -unsigned long int ret_max(struct range_t r) +int comp_max(struct range_t *r1, struct range_t *r2) { - return get_range_size(&r); + return comp_ulong(get_range_size(r1), get_range_size(r2)); +} + +/*! \brief Compare two range_t by their current usage. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. + */ +int comp_cur(struct range_t *r1, struct range_t *r2) +{ + return comp_ulong(r1->count, r2->count); +} + +/*! \brief Compare two range_t by their current usage percentage. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. + */ +int comp_percent(struct range_t *r1, struct range_t *r2) +{ + return comp_ulong(ret_percent(*r1), ret_percent(*r2)); +} + +/*! \brief Compare two range_t by their touched addresses. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. + */ +int comp_touched(struct range_t *r1, struct range_t *r2) +{ + return comp_ulong(r1->touched, r2->touched); +} + +/*! \brief Compare two range_t by their touched and in use addresses. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. + */ +int comp_tc(struct range_t *r1, struct range_t *r2) +{ + return comp_ulong(ret_tc(*r1), ret_tc(*r2)); +} + +/*! \brief Compare two range_t by their touched and in use percentage. + * \param r1,r2 Pointers to data to compare. + * \return Like strcmp. + */ +int comp_tcperc(struct range_t *r1, struct range_t *r2) +{ + return comp_ulong(ret_tcperc(*r1), ret_tcperc(*r2)); } /*! \brief Percentage in use in range. @@ -126,15 +171,6 @@ unsigned long int ret_percent(struct range_t r) return ((unsigned long int)(f * 100000)); } -/*! \brief Touched in range. - * \param r A range structure. - * \return Number of touched addresses in the given range. - */ -unsigned long int ret_touched(struct range_t r) -{ - return (r.touched); -} - /*! \brief Touched and in use in range * \param r A range structure. * \return Number of touched or in use addresses in the given range. @@ -167,25 +203,25 @@ void field_selector(char c) case 'n': break; case 'i': - returner = ret_ip; + comparer = comp_ip; break; case 'm': - returner = ret_max; + comparer = comp_max; break; case 'c': - returner = ret_cur; + comparer = comp_cur; break; case 'p': - returner = ret_percent; + comparer = comp_percent; break; case 't': - returner = ret_touched; + comparer = comp_touched; break; case 'T': - returner = ret_tc; + comparer = comp_tc; break; case 'e': - returner = ret_tcperc; + comparer = comp_tcperc; break; default: warnx("field_selector: unknown sort order `%c'", c); @@ -202,7 +238,7 @@ void field_selector(char c) static int merge(struct range_t *restrict left, struct range_t *restrict right) { int i, len, ret; - unsigned long int lint, rint; + int cmp; len = strlen(config.sort); for (i = 0; i < len; i++) { @@ -218,21 +254,20 @@ static int merge(struct range_t *restrict left, struct range_t *restrict right) continue; } - /* Select which function is pointed by returner */ + /* Select which function is pointed by comparer */ field_selector(config.sort[i]); - lint = returner(*left); - rint = returner(*right); + cmp = comparer(left, right); /* If fields are equal use next sort method */ - if (lint == rint) { + if (cmp == 0) { continue; } - if (lint < rint) { + if (cmp < 0) { return (1); } return (0); } - /* If all returners where equal */ + /* If all comparers where equal */ return (0); } From 39e1fb9e5a5b11ee3e11e3fa0329a6053a870eac Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:40:28 +0800 Subject: [PATCH 031/313] sort: Get rid of global comparer --- src/dhcpd-pools.h | 3 +-- src/sort.c | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 6b175ac..0aa9210 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -223,11 +223,10 @@ int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ -int (*comparer) (struct range_t *r1, struct range_t *r2); +typedef int (*comparer_t) (struct range_t *r1, struct range_t *r2); unsigned long int ret_percent(struct range_t r); unsigned long int ret_tc(struct range_t r); unsigned long int ret_tcperc(struct range_t r); -void field_selector(char c); void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); diff --git a/src/sort.c b/src/sort.c index 5415359..cdf3d9f 100644 --- a/src/sort.c +++ b/src/sort.c @@ -196,33 +196,27 @@ unsigned long int ret_tcperc(struct range_t r) * The sort algorithms are stabile, which means multiple sorts can be * specified and they do not mess the result of previous sort. The sort * algorithms are used via function pointer, that gets to be reassigned. + * \return Return the selected compare function. */ -void field_selector(char c) +comparer_t field_selector(char c) { switch (c) { case 'n': break; case 'i': - comparer = comp_ip; - break; + return comp_ip; case 'm': - comparer = comp_max; - break; + return comp_max; case 'c': - comparer = comp_cur; - break; + return comp_cur; case 'p': - comparer = comp_percent; - break; + return comp_percent; case 't': - comparer = comp_touched; - break; + return comp_touched; case 'T': - comparer = comp_tc; - break; + return comp_tc; case 'e': - comparer = comp_tcperc; - break; + return comp_tcperc; default: warnx("field_selector: unknown sort order `%c'", c); errx(EXIT_FAILURE, "Try `%s --help' for more information.", @@ -238,6 +232,7 @@ void field_selector(char c) static int merge(struct range_t *restrict left, struct range_t *restrict right) { int i, len, ret; + comparer_t comparer; int cmp; len = strlen(config.sort); @@ -255,7 +250,7 @@ static int merge(struct range_t *restrict left, struct range_t *restrict right) } /* Select which function is pointed by comparer */ - field_selector(config.sort[i]); + comparer = field_selector(config.sort[i]); cmp = comparer(left, right); /* If fields are equal use next sort method */ if (cmp == 0) { From 6642335c8a3b1567acad678ded4b89aaa79ef3a9 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:47:50 +0800 Subject: [PATCH 032/313] counting & output: Convert all counters to double --- src/dhcpd-pools.h | 20 ++++----- src/output.c | 108 +++++++++++++++++++++++----------------------- src/sort.c | 14 +++--- 3 files changed, 69 insertions(+), 73 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 0aa9210..c0183b8 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -113,10 +113,10 @@ struct configuration_t { */ struct shared_network_t { char *name; - unsigned long int available; - unsigned long int used; - unsigned long int touched; - unsigned long int backups; + double available; + double used; + double touched; + double backups; }; /*! \struct range_t * \brief Counters for an individual range. @@ -125,9 +125,9 @@ struct range_t { struct shared_network_t *shared_net; union ipaddr_t first_ip; union ipaddr_t last_ip; - unsigned long int count; - unsigned long int touched; - unsigned long int backups; + double count; + double touched; + double backups; }; /*! \enum isc_conf_parser * \brief Configuration file parsing state flags. @@ -224,9 +224,9 @@ int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ typedef int (*comparer_t) (struct range_t *r1, struct range_t *r2); -unsigned long int ret_percent(struct range_t r); -unsigned long int ret_tc(struct range_t r); -unsigned long int ret_tcperc(struct range_t r); +double ret_percent(struct range_t r); +double ret_tc(struct range_t r); +double ret_tcperc(struct range_t r); void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); diff --git a/src/output.c b/src/output.c index 43cd5d9..d8e1456 100644 --- a/src/output.c +++ b/src/output.c @@ -61,7 +61,7 @@ int output_txt(void) { unsigned int i; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; @@ -111,7 +111,7 @@ int output_txt(void) max_ipaddr_length, ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, - " - %-*s %5lu %5lu %10.3f %5lu %5lu %9.3f", + " - %-*s %5g %5g %10.3f %5g %5g %9.3f", max_ipaddr_length, ntop_ipaddr(&range_p->last_ip), range_size, @@ -123,7 +123,7 @@ int output_txt(void) (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { - fprintf(outfile, "%7lu %8.3f", + fprintf(outfile, "%7g %8.3f", range_p->backups, (float)(100 * range_p->backups) / range_size); @@ -149,7 +149,7 @@ int output_txt(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; fprintf(outfile, - "%-20s %5lu %5lu %10.3f %7lu %6lu %9.3f", + "%-20s %5g %5g %10.3f %7g %6g %9.3f", shared_p->name, shared_p->available, shared_p->used, (float)(100 * shared_p->used) / @@ -160,7 +160,7 @@ int output_txt(void) shared_p->used)) / shared_p->available); if (config.backups_found == true) { - fprintf(outfile, "%7lu %8.3f", + fprintf(outfile, "%7g %8.3f", shared_p->backups, (float)(100 * shared_p->backups) / shared_p->available); @@ -183,7 +183,7 @@ int output_txt(void) fprintf(outfile, "\n"); } if (config.output_limit[1] & BIT3) { - fprintf(outfile, "%-20s %5lu %5lu %10.3f %7lu %6lu %9.3f", + fprintf(outfile, "%-20s %5g %5g %10.3f %7g %6g %9.3f", shared_networks->name, shared_networks->available, shared_networks->used, @@ -197,7 +197,7 @@ int output_txt(void) shared_networks->available); if (config.backups_found == true) { - fprintf(outfile, "%7lu %8.3f", + fprintf(outfile, "%7g %8.3f", shared_networks->backups, (float)(100 * shared_networks->backups) / shared_networks->available); @@ -226,7 +226,7 @@ int output_xml(void) { unsigned int i; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; @@ -280,11 +280,11 @@ int output_xml(void) fprintf(outfile, "- %s\n", ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\t\n"); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", range_size); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", range_p->count); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); @@ -298,11 +298,11 @@ int output_xml(void) fprintf(outfile, "\n"); fprintf(outfile, "\t%s\n", shared_p->name); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", shared_p->available); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", shared_p->used); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", shared_p->available - shared_p->used); fprintf(outfile, "\n"); } @@ -312,10 +312,10 @@ int output_xml(void) fprintf(outfile, "\n"); fprintf(outfile, "\t%s\n", shared_networks->name); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", shared_networks->available); - fprintf(outfile, "\t%lu\n", shared_networks->used); - fprintf(outfile, "\t%lu\n", + fprintf(outfile, "\t%g\n", shared_networks->used); + fprintf(outfile, "\t%g\n", shared_networks->available - shared_networks->used); fprintf(outfile, "\n"); } @@ -343,7 +343,7 @@ int output_json(void) { unsigned int i = 0; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; @@ -409,9 +409,9 @@ int output_json(void) ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, " - %s\", ", ntop_ipaddr(&range_p->last_ip)); - fprintf(outfile, "\"defined\":%lu, ", range_size); - fprintf(outfile, "\"used\":%lu, ", range_p->count); - fprintf(outfile, "\"free\":%lu ", + fprintf(outfile, "\"defined\":%g, ", range_size); + fprintf(outfile, "\"used\":%g, ", range_p->count); + fprintf(outfile, "\"free\":%g ", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); @@ -435,10 +435,10 @@ int output_json(void) fprintf(outfile, "{ "); fprintf(outfile, "\"location\":\"%s\", ", shared_p->name); - fprintf(outfile, "\"defined\":%lu, ", + fprintf(outfile, "\"defined\":%g, ", shared_p->available); - fprintf(outfile, "\"used\":%lu, ", shared_p->used); - fprintf(outfile, "\"free\":%lu ", + fprintf(outfile, "\"used\":%g, ", shared_p->used); + fprintf(outfile, "\"free\":%g ", shared_p->available - shared_p->used); if (i + 1 < num_shared_networks) fprintf(outfile, "},\n"); @@ -456,11 +456,11 @@ int output_json(void) fprintf(outfile, " \"summary\": {\n"); fprintf(outfile, " \"location\":\"%s\",\n", shared_networks->name); - fprintf(outfile, " \"defined\":%lu,\n", + fprintf(outfile, " \"defined\":%g,\n", shared_networks->available); - fprintf(outfile, " \"used\":%lu,\n", + fprintf(outfile, " \"used\":%g,\n", shared_networks->used); - fprintf(outfile, " \"free\":%lu\n", + fprintf(outfile, " \"free\":%g\n", shared_networks->available - shared_networks->used); fprintf(outfile, " }"); /* end of summary */ sep++; @@ -617,10 +617,10 @@ static void output_line(FILE *restrict f, char const *restrict type, * \param type HMTL tag name. * \param unlong Actual payload of the printout. */ -static void output_long(FILE *restrict f, char const *restrict type, - unsigned long unlong) +static void output_double(FILE *restrict f, char const *restrict type, + double d) { - fprintf(f, " <%s class=ralign>%lu\n", type, unlong, type); + fprintf(f, " <%s class=ralign>%g\n", type, d, type); } /*! \brief Line with float in html output format. @@ -676,7 +676,7 @@ int output_html(void) { unsigned int i; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; int ret; FILE *outfile; @@ -729,20 +729,20 @@ int output_html(void) ntop_ipaddr(&range_p->first_ip)); output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->last_ip)); - output_long(outfile, "td", range_size); - output_long(outfile, "td", range_p->count); + output_double(outfile, "td", range_size); + output_double(outfile, "td", range_p->count); output_float(outfile, "td", (float)(100 * range_p->count) / range_size); - output_long(outfile, "td", range_p->touched); - output_long(outfile, "td", + output_double(outfile, "td", range_p->touched); + output_double(outfile, "td", range_p->touched + range_p->count); output_float(outfile, "td", (float)(100 * (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { - output_long(outfile, "td", range_p->backups); + output_double(outfile, "td", range_p->backups); output_float(outfile, "td", (float)(100 * range_p->backups) / @@ -776,13 +776,13 @@ int output_html(void) shared_p++; newrow(outfile); output_line(outfile, "td", "calign", shared_p->name); - output_long(outfile, "td", shared_p->available); - output_long(outfile, "td", shared_p->used); + output_double(outfile, "td", shared_p->available); + output_double(outfile, "td", shared_p->used); output_float(outfile, "td", (float)(100 * shared_p->used) / shared_p->available); - output_long(outfile, "td", shared_p->touched); - output_long(outfile, "td", + output_double(outfile, "td", shared_p->touched); + output_double(outfile, "td", shared_p->touched + shared_p->used); output_float(outfile, "td", (float)(100 * @@ -790,7 +790,7 @@ int output_html(void) shared_p->used)) / shared_p->available); if (config.backups_found == true) { - output_long(outfile, "td", shared_p->backups); + output_double(outfile, "td", shared_p->backups); output_float(outfile, "td", (float)(100 * shared_p->backups) / @@ -820,13 +820,13 @@ int output_html(void) if (config.output_limit[1] & BIT3) { newrow(outfile); output_line(outfile, "td", "calign", shared_networks->name); - output_long(outfile, "td", shared_networks->available); - output_long(outfile, "td", shared_networks->used); + output_double(outfile, "td", shared_networks->available); + output_double(outfile, "td", shared_networks->used); output_float(outfile, "td", (float)(100 * shared_networks->used) / shared_networks->available); - output_long(outfile, "td", shared_networks->touched); - output_long(outfile, "td", + output_double(outfile, "td", shared_networks->touched); + output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_float(outfile, "td", (float)(100 * @@ -834,7 +834,7 @@ int output_html(void) shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { - output_long(outfile, "td", shared_networks->backups); + output_double(outfile, "td", shared_networks->backups); output_float(outfile, "td", (float)(100 * shared_networks->backups) / @@ -867,7 +867,7 @@ int output_csv(void) { unsigned int i; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; FILE *outfile; int ret; @@ -904,7 +904,7 @@ int output_csv(void) fprintf(outfile, "\"%s\",", ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, - "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", + "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", ntop_ipaddr(&range_p->last_ip), range_size, range_p->count, (float)(100 * range_p->count) / range_size, @@ -914,7 +914,7 @@ int output_csv(void) (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { - fprintf(outfile, ",\"%lu\",\"%.3f\"", + fprintf(outfile, ",\"%g\",\"%.3f\"", range_p->backups, (float)(100 * range_p->backups) / range_size); @@ -940,7 +940,7 @@ int output_csv(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; fprintf(outfile, - "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", + "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", shared_p->name, shared_p->available, shared_p->used, (float)(100 * shared_p->used) / @@ -951,7 +951,7 @@ int output_csv(void) shared_p->used)) / shared_p->available); if (config.backups_found == true) { - fprintf(outfile, ",\"%lu\",\"%.3f\"", + fprintf(outfile, ",\"%g\",\"%.3f\"", shared_p->backups, (float)(100 * shared_p->backups) / shared_p->available); @@ -973,7 +973,7 @@ int output_csv(void) if (config.output_limit[1] & BIT3) { fprintf(outfile, - "\"%s\",\"%lu\",\"%lu\",\"%.3f\",\"%lu\",\"%lu\",\"%.3f\"", + "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", shared_networks->name, shared_networks->available, shared_networks->used, (float)(100 * shared_networks->used) / @@ -985,7 +985,7 @@ int output_csv(void) shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { - fprintf(outfile, "%7lu %8.3f", + fprintf(outfile, "%7g %8.3f", shared_networks->backups, (float)(100 * shared_networks->backups) / shared_networks->available); @@ -1013,7 +1013,7 @@ int output_alarming(void) { FILE *outfile; struct range_t *range_p; - unsigned long range_size; + double range_size; struct shared_network_t *shared_p; unsigned int i; float perc; diff --git a/src/sort.c b/src/sort.c index cdf3d9f..54e4790 100644 --- a/src/sort.c +++ b/src/sort.c @@ -164,18 +164,16 @@ int comp_tcperc(struct range_t *r1, struct range_t *r2) * \param r A range structure. * \return Usage percentage of the given range. */ -unsigned long int ret_percent(struct range_t r) +double ret_percent(struct range_t r) { - float f; - f = (float)r.count / get_range_size(&r); - return ((unsigned long int)(f * 100000)); + return r.count / get_range_size(&r); } /*! \brief Touched and in use in range * \param r A range structure. * \return Number of touched or in use addresses in the given range. */ -unsigned long int ret_tc(struct range_t r) +double ret_tc(struct range_t r) { return (r.count + r.touched); } @@ -184,11 +182,9 @@ unsigned long int ret_tc(struct range_t r) * \param r A range structure. * \return Percentage of touched or in use addresses in the given range. */ -unsigned long int ret_tcperc(struct range_t r) +double ret_tcperc(struct range_t r) { - float f; - f = (float)(r.count + r.touched) / get_range_size(&r); - return ((unsigned long int)(f * 10000)); + return ret_tc(r) / get_range_size(&r); } /*! \brief Sort field selector. From 6820c9fc0995a497b962df8a5ba46f6474064d87 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:52:54 +0800 Subject: [PATCH 033/313] fix: Put prototype of field_selector back to dhcpd-pools.h It's needed in main to check unknown field selectors. --- src/dhcpd-pools.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index c0183b8..793172d 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -224,6 +224,7 @@ int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ typedef int (*comparer_t) (struct range_t *r1, struct range_t *r2); +comparer_t field_selector(char c); double ret_percent(struct range_t r); double ret_tc(struct range_t r); double ret_tcperc(struct range_t r); From afd9f77051fb44bc92ed1d7e7dbd5297f7b99f21 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:57:07 +0800 Subject: [PATCH 034/313] sort: let field_selector return NULL at the end --- src/sort.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sort.c b/src/sort.c index 54e4790..4e15895 100644 --- a/src/sort.c +++ b/src/sort.c @@ -218,6 +218,7 @@ comparer_t field_selector(char c) errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_invocation_short_name); } + return NULL; } /*! \brief Perform requested sorting. From 9c4184bd9afad994bf6eab32099d06865e57314c Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:57:33 +0800 Subject: [PATCH 035/313] counting: Let get_range_size return double --- src/dhcpd-pools.h | 2 +- src/other.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 793172d..5568711 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -205,7 +205,7 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst); void copy_ipaddr(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); const char *ntop_ipaddr(const union ipaddr_t *ip); -unsigned long get_range_size(const struct range_t *r); +double get_range_size(const struct range_t *r); int xstrstr(const char *__restrict a, const char *__restrict b, int len) __attribute__ ((nonnull(1, 2))) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) diff --git a/src/other.c b/src/other.c index 70b29e2..7b8ec99 100644 --- a/src/other.c +++ b/src/other.c @@ -125,17 +125,17 @@ const char *ntop_ipaddr(const union ipaddr_t *ip) * and last IP in the range. * \return Size of a range. */ -unsigned long get_range_size(const struct range_t *r) +double get_range_size(const struct range_t *r) { if (config.dhcp_version == VERSION_6) { - unsigned long size = 0; + double size = 0; int i; /* When calculating the size of an IPv6 range overflow may * occur. In that case only the last LONG_BIT bits are * preserved, thus we just skip the first (16 - LONG_BIT) * bits... */ - for (i = LONG_BIT / 8 < 16 ? 16 - LONG_BIT / 8 : 0; i < 16; i++) { - size <<= 8; + for (i = 0; i < 16; i++) { + size *= 256; size += (int)r->last_ip.v6[i] - (int)r->first_ip.v6[i]; } return size + 1; From 75d979bb001ae2d0b73c2910735a57e15769f919 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 22:59:35 +0800 Subject: [PATCH 036/313] sort: let comp_* functions compare double --- src/sort.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sort.c b/src/sort.c index 4e15895..b276bc7 100644 --- a/src/sort.c +++ b/src/sort.c @@ -88,13 +88,13 @@ int rangecomp(const void *restrict r1, const void *restrict r2) &((const struct range_t *)r2)->first_ip); } -/*! \brief Compare two unsigned long. - * \param u1,u2 Data to compare. +/*! \brief Compare two doubles. + * \param f1,f2 Data to compare. * \return Like strcmp. */ -int comp_ulong(unsigned long u1, unsigned long u2) +int comp_double(double f1, double f2) { - return u1 < u2 ? -1 : u1 > u2 ? 1 : 0; + return f1 < f2 ? -1 : f1 > f2 ? 1 : 0; } /*! \brief Compare two range_t by their first_ip. @@ -112,7 +112,7 @@ int comp_ip(struct range_t *r1, struct range_t *r2) */ int comp_max(struct range_t *r1, struct range_t *r2) { - return comp_ulong(get_range_size(r1), get_range_size(r2)); + return comp_double(get_range_size(r1), get_range_size(r2)); } /*! \brief Compare two range_t by their current usage. @@ -121,7 +121,7 @@ int comp_max(struct range_t *r1, struct range_t *r2) */ int comp_cur(struct range_t *r1, struct range_t *r2) { - return comp_ulong(r1->count, r2->count); + return comp_double(r1->count, r2->count); } /*! \brief Compare two range_t by their current usage percentage. @@ -130,7 +130,7 @@ int comp_cur(struct range_t *r1, struct range_t *r2) */ int comp_percent(struct range_t *r1, struct range_t *r2) { - return comp_ulong(ret_percent(*r1), ret_percent(*r2)); + return comp_double(ret_percent(*r1), ret_percent(*r2)); } /*! \brief Compare two range_t by their touched addresses. @@ -139,7 +139,7 @@ int comp_percent(struct range_t *r1, struct range_t *r2) */ int comp_touched(struct range_t *r1, struct range_t *r2) { - return comp_ulong(r1->touched, r2->touched); + return comp_double(r1->touched, r2->touched); } /*! \brief Compare two range_t by their touched and in use addresses. @@ -148,7 +148,7 @@ int comp_touched(struct range_t *r1, struct range_t *r2) */ int comp_tc(struct range_t *r1, struct range_t *r2) { - return comp_ulong(ret_tc(*r1), ret_tc(*r2)); + return comp_double(ret_tc(*r1), ret_tc(*r2)); } /*! \brief Compare two range_t by their touched and in use percentage. @@ -157,7 +157,7 @@ int comp_tc(struct range_t *r1, struct range_t *r2) */ int comp_tcperc(struct range_t *r1, struct range_t *r2) { - return comp_ulong(ret_tcperc(*r1), ret_tcperc(*r2)); + return comp_double(ret_tcperc(*r1), ret_tcperc(*r2)); } /*! \brief Percentage in use in range. From ff7ca8c4197c74652416b553b3146de4b38a8005 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Tue, 8 Jan 2013 23:00:57 +0800 Subject: [PATCH 037/313] tests: update expected/v6 The range size in the old file was also incorrect. --- tests/expected/v6 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/expected/v6 b/tests/expected/v6 index 969290c..b3fe5b4 100644 --- a/tests/expected/v6 +++ b/tests/expected/v6 @@ -1,6 +1,6 @@ Ranges: shared net name first ip last ip max cur percent touch t+c t+c perc -All networks dead:abba:1000::2 - dead:abba:1000:ff:ffff:ffff:ffff:ffff 18446744073709551614 2 0.000 0 2 0.000 +All networks dead:abba:1000::2 - dead:abba:1000:ff:ffff:ffff:ffff:ffff 4.72237e+21 2 0.000 0 2 0.000 All networks dead:abba:4000::2 - dead:abba:4000::ff 254 1 0.394 0 1 0.394 Shared networks: @@ -8,4 +8,4 @@ name max cur percent touch t+c t+c perc Sum of all ranges: name max cur percent touch t+c t+c perc -All networks 18446744073709551868 3 1.190 0 3 1.190 # FIXME: this line is mocked up +All networks 4.72237e+21 3 0.000 0 3 0.000 From 478bbe1b449150a74a47aa4085fc65b15fcccf13 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Wed, 9 Jan 2013 10:19:06 +0800 Subject: [PATCH 038/313] output: fix doc of output_double --- src/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index d8e1456..d06276f 100644 --- a/src/output.c +++ b/src/output.c @@ -615,7 +615,7 @@ static void output_line(FILE *restrict f, char const *restrict type, * * \param f Output file descriptor. * \param type HMTL tag name. - * \param unlong Actual payload of the printout. + * \param d Actual payload of the printout. */ static void output_double(FILE *restrict f, char const *restrict type, double d) From 3be3f34bd4d6b2d5167077cad5247671d542fd01 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 17:27:50 +0000 Subject: [PATCH 039/313] build-sys: allow tests run parallel Signed-off-by: Sami Kerola --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 82872ea..ad241f2 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,8 @@ AC_INIT([dhcpd-pools], PACKAGE_MAINTAINER="Sami Kerola" AC_SUBST([PACKAGE_MAINTAINER]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([-Wall foreign 1.10 tar-pax no-dist-gzip dist-xz -Wextra-portability]) +AM_INIT_AUTOMAKE([-Wall -Wextra-portability foreign 1.10 tar-pax no-dist-gzip dist-xz + parallel-tests]) AC_CONFIG_SRCDIR([src/dhcpd-pools.h]) AC_CONFIG_HEADERS([config.h]) From 632e97834be86fefc5149bffa920aced737ca59f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 17:29:04 +0000 Subject: [PATCH 040/313] build-sys: update .gitignore files Signed-off-by: Sami Kerola --- build-aux/.gitignore | 1 + tests/.gitignore | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build-aux/.gitignore b/build-aux/.gitignore index 06cb16c..7b4c263 100644 --- a/build-aux/.gitignore +++ b/build-aux/.gitignore @@ -5,4 +5,5 @@ /ltmain.sh /mdate-sh /missing +/test-driver /texinfo.tex diff --git a/tests/.gitignore b/tests/.gitignore index c831351..0d52223 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,5 @@ /Makefile /Makefile.in /outputs +/*.log +/*.trs From 34f73dbae1af064c03692eeb76d5dce2212f9c13 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 17:36:52 +0000 Subject: [PATCH 041/313] 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 CC: LI Zimu CC: Cheer Xiao Signed-off-by: Sami Kerola --- TODO | 4 +--- man/dhcpd-pools.1.in | 6 ++++-- src/other.c | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index d45c3c6..fe04930 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,6 @@ Reported-by: Huangyu: I found dhcpd-pools didn't consider if the ### Feature requests -o IPv6 support (Frank) o Assigned IPs count (Nelson) o Subnet counting class (Henryk) o When time stamps are part of lease situation evaluation (see @@ -33,8 +32,7 @@ o Add lease time histogram support. dhcpd-pool servers. 9 Nice http view interface on super server, much can be copied from http://piwik.org/ -10 IPv6 support. -11 And some other things perhaps... +10 And some other things perhaps... When items 1-7 are done v3 can be released. To support rewrite there should be a design document with nice blue print, which is diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index ce1e6ce..7c365c7 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -181,10 +181,12 @@ ISC dhcpd configuration file. .TP @DHCPDLEASE_FILE@ ISC dhcpd lease file. -.SH AUTHOR -Written by Sami Kerola. +.SH AUTHORS +Original design by Sami Kerola. .br XML support by Dominic Germain, Sogetel inc. +.br +IPv6 support by Cheer Xiao. .PP The software has FreeBSD License. .SH "REPORTING BUGS" diff --git a/src/other.c b/src/other.c index 7b8ec99..226fe30 100644 --- a/src/other.c +++ b/src/other.c @@ -251,8 +251,9 @@ void clean_up(void) void __attribute__ ((__noreturn__)) print_version(void) { fprintf(stdout, "%s\n" - "Written by Sami Kerola.\n" - "XML support by Dominic Germain, Sogetel inc.\n\n" + "Original design by Sami Kerola.\n" + "XML support by Dominic Germain, Sogetel inc.\n" + "IPv6 support by Cheer Xiao.\n\n" "The software has FreeBSD License.\n", PACKAGE_STRING); exit(EXIT_SUCCESS); } From e50d0a7d387bffdd3c6f50a7bc973ba63b902fc4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 20:23:32 +0000 Subject: [PATCH 042/313] 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 --- tests/Makefile.am | 18 ++++++++---------- tests/full-json | 9 ++++----- tests/test.sh | 7 +++---- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6aa921e..ff036b3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,13 +1,3 @@ -EXTRA_DIST = \ - bootp \ - full-json \ - confs \ - expected \ - leading0 \ - leases \ - same-twice \ - simple - TESTS = \ bootp \ full-json \ @@ -16,6 +6,14 @@ TESTS = \ simple \ v6 +EXTRA_DIST = \ + confs \ + expected \ + leases \ + $(TESTS) + +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=../src$(PATH_SEPARATOR)$$PATH + check-local: $(SHELL) $(top_srcdir)/tests/test.sh clean-local: diff --git a/tests/full-json b/tests/full-json index 93c4ffd..b9ebb55 100755 --- a/tests/full-json +++ b/tests/full-json @@ -2,13 +2,12 @@ # # Minimal regression test suite. -TEST_TOPDIR=$(cd $(dirname $0) && pwd) -DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools) - if [ ! -d outputs ]; then mkdir outputs fi -$DHCPD_POOLS -f J -c confs/same-twice -l leases/same-twice -o outputs/same-twice-json -diff -u expected/same-twice-json outputs/same-twice-json +dhcpd-pools -f J -c $top_srcdir/tests/confs/same-twice \ + -l $top_srcdir/tests/leases/same-twice \ + -o outputs/same-twice-json +diff -u $top_srcdir/tests/expected/same-twice-json outputs/same-twice-json exit $? diff --git a/tests/test.sh b/tests/test.sh index 3b06828..a8746c8 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -2,14 +2,13 @@ # # Minimal regression test suite. -TEST_TOPDIR=$(cd $(dirname $0) && pwd) IAM=$(basename $0) -DHCPD_POOLS=$(readlink -f $TEST_TOPDIR/../src/dhcpd-pools) if [ ! -d outputs ]; then mkdir outputs fi -$DHCPD_POOLS -c confs/$IAM -l leases/$IAM -o outputs/$IAM -diff -u expected/$IAM outputs/$IAM +dhcpd-pools -c $top_srcdir/tests/confs/$IAM \ + -l $top_srcdir/tests/leases/$IAM -o outputs/$IAM +diff -u $top_srcdir/tests/expected/$IAM outputs/$IAM exit $? From 625c54d83479309a691666c0a3c449cc06f8a634 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 20:24:58 +0000 Subject: [PATCH 043/313] 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 --- Makefile.am | 6 +----- configure.ac | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index a265718..f6ddef6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,4 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = m4/gnulib-cache.m4 -SUBDIRS = lib src man tests contrib - -if ENABLE_DOXYGEN -SUBDIRS += doc -endif +SUBDIRS = doc lib src man tests contrib diff --git a/configure.ac b/configure.ac index ad241f2..1623ba2 100644 --- a/configure.ac +++ b/configure.ac @@ -128,7 +128,7 @@ AS_IF([test x$enable_doxygen = xyes], [ AC_CHECK_PROGS([DOXYGEN], [doxygen]) AS_IF([test "x$DOXYGEN" = "x"], AC_MSG_ERROR([doxygen not in path]), - AC_CONFIG_FILES([doc/Makefile doc/doxy.conf]) + AC_CONFIG_FILES([doc/doxy.conf]) ) AC_CHECK_PROGS([DOXYGEN_DOT], [dot]) @@ -146,6 +146,7 @@ AC_CONFIG_FILES([ man/Makefile man/dhcpd-pools.1 tests/Makefile + doc/Makefile contrib/Makefile ]) From f3a476ba52a2bc0b77536a2ff5acd206f96c2b47 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 15 Jan 2013 20:29:40 +0000 Subject: [PATCH 044/313] release: 2.21 Signed-off-by: Sami Kerola --- NEWS | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/NEWS b/NEWS index aa5a0fe..5e5a0f5 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,58 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. + +Version 2.21 +$ git shortlog v2.20..v2.21 +Cheer Xiao (10): + IPv6: add DHCPv6 support + sort: Use a comparer instead of returner + sort: Get rid of global comparer + counting & output: Convert all counters to double + fix: Put prototype of field_selector back to dhcpd-pools.h + sort: let field_selector return NULL at the end + counting: Let get_range_size return double + sort: let comp_* functions compare double + tests: update expected/v6 + output: fix doc of output_double + +Gilles Bouthenot (5): + output: add json format support + json output: add newline at end + json output: remove useless, empty fields + json output: bugfix: correct range specify only first ip + contrib: add munin plugins + +Sami Kerola (29): + build-sys: remove c++ compiler check + tools: add indent command configuration file + tests: add basic tests + build-sys: update .gitignore + tests: add v6 check + output: remove unnecessary new line printing + build-sys: more clean ups + json output: use defined output file for all printing + tests: add json tests, and make fail output loud + ouput format: fix active lease printing + output ethernet: do not crash if ethernet is missing + docs: add doxygen tags, configuration file, and autotooling + backup counting: fix output regression + clean up: remove unused functions + clean up: move code to more proper location + hash: make delete to use HASH_ITER if it is available + clean up: move global variables to config structure + clean up: use enum as symbolic bit masks + clean up: convert parsing magic numbers to symbolic values + clean up: rename get_order() to merge() and mark static + clean up: fix few indentation slips + getdata: be consistant with symbolic numbers + smatch scan: fix few warnings + build-sys: allow tests run parallel + build-sys: update .gitignore files + docs: thanks to Cheer Xiao this software has IPv6 support + tests: fix make distcheck + docs: fix doxygen make distcheck breakage + release: 2.21 Version 2.20 $ git shortlog v2.19..v2.20 From 8e2da89c88e23e3e26c21a70eafa2bb000c6afbc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 16 Jan 2013 12:56:22 +0000 Subject: [PATCH 045/313] tests: add complete check including multiple ranges and shared networks Signed-off-by: Sami Kerola --- tests/Makefile.am | 1 + tests/complete | 1 + tests/confs/complete | 31 +++++++ tests/expected/complete | 16 ++++ tests/leases/complete | 198 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 247 insertions(+) create mode 120000 tests/complete create mode 100644 tests/confs/complete create mode 100644 tests/expected/complete create mode 100644 tests/leases/complete diff --git a/tests/Makefile.am b/tests/Makefile.am index ff036b3..eb1c088 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,6 @@ TESTS = \ bootp \ + complete \ full-json \ leading0 \ same-twice \ diff --git a/tests/complete b/tests/complete new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/complete @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/confs/complete b/tests/confs/complete new file mode 100644 index 0000000..0ef9eb0 --- /dev/null +++ b/tests/confs/complete @@ -0,0 +1,31 @@ +shared-network example1 { + subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range 10.0.0.1 10.0.0.20; + } + } + subnet 10.1.0.0 netmask 255.255.255.0 { + pool { + range 10.1.0.1 10.1.0.20; + } + } +} + +shared-network example2 { + subnet 10.2.0.0 netmask 255.255.255.0 { + pool { + range 10.2.0.1 10.2.0.20; + } + } + subnet 10.3.0.0 netmask 255.255.255.0 { + pool { + range 10.3.0.1 10.3.0.20; + } + } +} + +subnet 10.4.0.0 netmask 255.255.255.0 { + pool { + range 10.4.0.1 10.4.0.20; + } +} diff --git a/tests/expected/complete b/tests/expected/complete new file mode 100644 index 0000000..452bab8 --- /dev/null +++ b/tests/expected/complete @@ -0,0 +1,16 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +example1 10.0.0.1 - 10.0.0.20 20 11 55.000 0 11 55.000 +example1 10.1.0.1 - 10.1.0.20 20 10 50.000 0 10 50.000 +example2 10.2.0.1 - 10.2.0.20 20 8 40.000 0 8 40.000 +example2 10.3.0.1 - 10.3.0.20 20 9 45.000 0 9 45.000 +All networks 10.4.0.1 - 10.4.0.20 20 5 25.000 0 5 25.000 + +Shared networks: +name max cur percent touch t+c t+c perc +example1 40 21 52.500 0 21 52.500 +example2 40 17 42.500 0 17 42.500 + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 100 43 43.000 0 43 43.000 diff --git a/tests/leases/complete b/tests/leases/complete new file mode 100644 index 0000000..d186f0e --- /dev/null +++ b/tests/leases/complete @@ -0,0 +1,198 @@ +lease 10.0.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.0.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.0.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.0.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.0.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.0.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.0.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.0.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.0.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} +lease 10.0.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} +lease 10.0.0.10 { + binding state active; + hardware ethernet 00:00:00:00:00:10; +} +lease 10.0.0.11 { + binding state active; + hardware ethernet 00:00:00:00:00:11; +} + + +lease 10.1.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.1.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.1.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.1.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.1.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.1.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.1.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.1.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.1.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} +lease 10.1.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} +lease 10.1.0.10 { + binding state active; + hardware ethernet 00:00:00:00:00:10; +} + + +lease 10.2.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.2.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.2.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.2.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.2.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.2.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.2.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.2.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.2.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} + +lease 10.3.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.3.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.3.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.3.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.3.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.3.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.3.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.3.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.3.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} +lease 10.3.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} + +lease 10.4.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.4.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.4.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.4.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.4.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.4.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} From 23aae87356626f1b6b03c387d6cfb7a411e2dcb7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Mar 2013 23:38:25 +0000 Subject: [PATCH 046/313] 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 --- src/dhcpd-pools.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 5568711..123b8db 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -219,6 +219,14 @@ void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int comp_cur(struct range_t *r1, struct range_t *r2); +int comp_double(double f1, double f2); +int comp_ip(struct range_t *r1, struct range_t *r2); +int comp_max(struct range_t *r1, struct range_t *r2); +int comp_percent(struct range_t *r1, struct range_t *r2); +int comp_tc(struct range_t *r1, struct range_t *r2); +int comp_tcperc(struct range_t *r1, struct range_t *r2); +int comp_touched(struct range_t *r1, struct range_t *r2); int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); From c3e492165c2eeef977ff62dd61a51d3cb9abc1a3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 5 Apr 2013 23:13:10 +0100 Subject: [PATCH 047/313] 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 --- src/dhcpd-pools.c | 3 ++- src/getdata.c | 3 ++- src/hash.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 21256fd..19b9d15 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -65,7 +65,7 @@ * alarming. */ int main(int argc, char **argv) { - int i, c, sorts = 0; + int i, sorts = 0; int option_index = 0; char const *tmp; struct range_t *tmp_ranges; @@ -124,6 +124,7 @@ int main(int argc, char **argv) /* Parse command line options */ while (1) { + int c; c = getopt_long(argc, argv, "c:l:f:o:s:rL:vh", long_options, &option_index); diff --git a/src/getdata.c b/src/getdata.c index 39061d3..1e081f9 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -207,7 +207,7 @@ void parse_config(int is_include, const char *restrict config_file, bool newclause = true, comment = false; int quote = 0, braces = 0, argument = ITS_NOTHING_INTERESTING; size_t i = 0; - char *word, c; + char *word; int braces_shared = 1000; union ipaddr_t addr; struct range_t *range_p; @@ -239,6 +239,7 @@ void parse_config(int is_include, const char *restrict config_file, /* Very hairy stuff begins. */ while (unlikely(!feof(dhcpd_config))) { + char c; c = fgetc(dhcpd_config); /* Certain characters are magical */ switch (c) { diff --git a/src/hash.c b/src/hash.c index 7b3f359..d9a1d77 100644 --- a/src/hash.c +++ b/src/hash.c @@ -99,8 +99,8 @@ void delete_all_leases(void) #else void delete_all_leases(void) { - struct leases_t *l; while (leases) { + struct leases_t *l; l = leases; free(l->ethernet); HASH_DEL(leases, l); /* leases advances to next on delete */ From cdf2c81f31e49c9e96e28027b19ac090a34780ea Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 5 Apr 2013 23:21:49 +0100 Subject: [PATCH 048/313] build-sys: update .gitignore Signed-off-by: Sami Kerola --- build-aux/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/build-aux/.gitignore b/build-aux/.gitignore index 7b4c263..a7f0fb2 100644 --- a/build-aux/.gitignore +++ b/build-aux/.gitignore @@ -1,3 +1,4 @@ +/compile /config.guess /config.sub /depcomp From b858a4778b855c6aa6ce03370ca0d3671273bd85 Mon Sep 17 00:00:00 2001 From: Cheer Xiao Date: Sun, 7 Apr 2013 20:16:44 +0800 Subject: [PATCH 049/313] getdata: treat binding states abandoned, expired and release like free --- src/defaults.h | 26 ++++++++++++++++---------- src/dhcpd-pools.h | 3 +++ src/getdata.c | 5 ++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/defaults.h b/src/defaults.h index 7b643ad..a865cf0 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -59,18 +59,24 @@ static const unsigned int SHARED_NETWORKS = 8192; * Please do not commit less readable indentation. */ static const char *prefixes[2][NUM_OF_PREFIX] = { [VERSION_4] = { - [PREFIX_LEASE] = "lease ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + [PREFIX_LEASE] = "lease ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned", + [PREFIX_BINDING_STATE_EXPIRED] = " binding state expired", + [PREFIX_BINDING_STATE_RELEASED] = " binding state released", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" }, [VERSION_6] = { - [PREFIX_LEASE] = " iaaddr ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" + [PREFIX_LEASE] = " iaaddr ", + [PREFIX_BINDING_STATE_FREE] = " binding state free", + [PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned", + [PREFIX_BINDING_STATE_EXPIRED] = " binding state expired", + [PREFIX_BINDING_STATE_RELEASED] = " binding state released", + [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", + [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", + [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" } }; diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 123b8db..0fb295c 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -85,6 +85,9 @@ enum dhcp_version { enum prefix_t { PREFIX_LEASE, PREFIX_BINDING_STATE_FREE, + PREFIX_BINDING_STATE_ABANDONED, + PREFIX_BINDING_STATE_EXPIRED, + PREFIX_BINDING_STATE_RELEASED, PREFIX_BINDING_STATE_ACTIVE, PREFIX_BINDING_STATE_BACKUP, PREFIX_HARDWARE_ETHERNET, diff --git a/src/getdata.c b/src/getdata.c index 1e081f9..ba50c3d 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -124,7 +124,10 @@ int parse_leases(void) parse_ipaddr(ipstring, &addr); continue; } - if (HAS_PREFIX(line, PREFIX_BINDING_STATE_FREE)) { + if (HAS_PREFIX(line, PREFIX_BINDING_STATE_FREE) || + HAS_PREFIX(line, PREFIX_BINDING_STATE_ABANDONED) || + HAS_PREFIX(line, PREFIX_BINDING_STATE_EXPIRED) || + HAS_PREFIX(line, PREFIX_BINDING_STATE_RELEASED)) { /* remove old entry, if exists */ if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); From 5ee1aca2b9172b7defc04dedbe64b0c3cea33186 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 20:00:51 +0100 Subject: [PATCH 050/313] 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 Signed-off-by: Sami Kerola --- Makefile.am | 6 +++++- THANKS | 1 + tests/Makefile.am | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f6ddef6..dc1ed7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,5 +3,9 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = m4/gnulib-cache.m4 +EXTRA_DIST = \ + .tarball-version \ + build-aux/git-version-gen \ + m4/gnulib-cache.m4 + SUBDIRS = doc lib src man tests contrib diff --git a/THANKS b/THANKS index 142b8ed..f5f6554 100644 --- a/THANKS +++ b/THANKS @@ -25,3 +25,4 @@ Enno Gr Ryan Malek Cheer Xiao Gilles Bouthenot +Helmut Grohne diff --git a/tests/Makefile.am b/tests/Makefile.am index eb1c088..61d1891 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,7 @@ EXTRA_DIST = \ confs \ expected \ leases \ + test.sh \ $(TESTS) TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=../src$(PATH_SEPARATOR)$$PATH From 327b601ea4459cb024310ea50e330d89c018b16b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 20:02:39 +0100 Subject: [PATCH 051/313] docs: fix spelling mistakes in manual page Also quote dashes used in EXAMPLEs section. Reported-by: Helmut Grohne Signed-off-by: Sami Kerola --- man/dhcpd-pools.1.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index 7c365c7..b3858a3 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -68,7 +68,7 @@ Text .RI ( t ). Standard html .RI ( h ) -outputs only the HTML tables, and is useful for embeding more complex web +outputs only the HTML tables, and is useful for embedding more complex web pages. Full-html .RI ( H ) provides complete HTML headers, etc., including in-line CSS. The @@ -138,7 +138,7 @@ for example .IR \-L10 . To monitor shared network only the limit would be .IR \-L20 . -If warning percentage is not speficied it defaults to +If warning percentage is not specified it defaults to .BR @ALARM_WARN@ . The .I percent @@ -159,19 +159,19 @@ Print help to standard output and exit successfully. .SH EXAMPLES .TP Print ranges header, and analysis. -$ dhcpd-pools -L 11 -c dhcpd.conf -l dhcpd.leases +$ dhcpd-pools \-L 11 \-c dhcpd.conf \-l dhcpd.leases .br Ranges: .br shared net name [...] .TP Print shared networks and totals, both headers and results -$ dhcpd-pools -L 66 -c dhcpd.conf -l dhcpd.leases shared net name +$ dhcpd-pools \-L 66 \-c dhcpd.conf \-l dhcpd.leases shared net name .br [...] .TP Alarming -$ dhcpd-pools -c dhcpd.conf -l dhcpd.leases --critical 80.1 --warning 75 +$ dhcpd-pools \-c dhcpd.conf \-l dhcpd.leases \-\-critical 80.1 \-\-warning 75 .br CRITICAL: dhcpd-pools: Ranges; crit: 14 warn: 22 ok: 220 Shared nets; crit: 1 warn: 0 ok: 4 .SH FILES From d2b7d10dbc3c33a0ccfb1e2f9f665aa69d7df411 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 20:09:12 +0100 Subject: [PATCH 052/313] build-sys: ensure distribution has version file Signed-off-by: Sami Kerola --- .gitignore | 2 ++ Makefile.am | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9f44606..59ef307 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/.tarball-version +/.version /aclocal.m4 /autom4te.cache/ /autoscan.log diff --git a/Makefile.am b/Makefile.am index dc1ed7e..4e1eeae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,8 +4,14 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = \ - .tarball-version \ + .version \ build-aux/git-version-gen \ m4/gnulib-cache.m4 SUBDIRS = doc lib src man tests contrib + +BUILT_SOURCES = $(top_srcdir)/.version +$(top_srcdir)/.version: + echo $(VERSION) > $@-t && mv $@-t $@ +dist-hook: + echo $(VERSION) > $(distdir)/.tarball-version From 7c34231004f48236a73ea68f090ac916c082ab49 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 20:47:11 +0100 Subject: [PATCH 053/313] build-sys: update git-version-gen from gnulib Signed-off-by: Sami Kerola --- build-aux/git-version-gen | 97 ++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 0b7655e..3468247 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,8 +1,8 @@ #!/bin/sh # Print a version string. -scriptversion=2011-02-19.19; # UTC +scriptversion=2012-12-31.23; # UTC -# Copyright (C) 2007-2011 Free Software Foundation, Inc. +# Copyright (C) 2007-2013 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,8 +44,10 @@ scriptversion=2011-02-19.19; # UTC # files to pick up a version string change; and leave it stale to # minimize rebuild time after unrelated changes to configure sources. # -# It is probably wise to add these two files to .gitignore, so that you -# don't accidentally commit either generated file. +# As with any generated file in a VC'd directory, you should add +# /.version to .gitignore, so that you don't accidentally commit it. +# .tarball-version is never generated in a VC'd directory, so needn't +# be listed there. # # Use the following line in your configure.ac, so that $(VERSION) will # automatically be up-to-date each time configure is run (and note that @@ -57,24 +59,73 @@ scriptversion=2011-02-19.19; # UTC # [bug-project@example]) # # Then use the following lines in your Makefile.am, so that .version -# will be present for dependencies, and so that .tarball-version will -# exist in distribution tarballs. +# will be present for dependencies, and so that .version and +# .tarball-version will exist in distribution tarballs. # +# EXTRA_DIST = $(top_srcdir)/.version # BUILT_SOURCES = $(top_srcdir)/.version # $(top_srcdir)/.version: # echo $(VERSION) > $@-t && mv $@-t $@ # dist-hook: # echo $(VERSION) > $(distdir)/.tarball-version -case $# in - 1|2) ;; - *) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version" \ - '[TAG-NORMALIZATION-SED-SCRIPT]' - exit 1;; -esac -tarball_version_file=$1 -tag_sed_script="${2:-s/x/x/}" +me=$0 + +version="git-version-gen $scriptversion + +Copyright 2011 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + +usage="\ +Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] +Print a version string. + +Options: + + --prefix prefix of git tags (default 'v') + --fallback fallback version to use if \"git --version\" fails + + --help display this help and exit + --version output version information and exit + +Running without arguments will suffice in most cases." + +prefix=v +fallback= + +while test $# -gt 0; do + case $1 in + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + --prefix) shift; prefix="$1";; + --fallback) shift; fallback="$1";; + -*) + echo "$0: Unknown option '$1'." >&2 + echo "$0: Try '--help' for more information." >&2 + exit 1;; + *) + if test "x$tarball_version_file" = x; then + tarball_version_file="$1" + elif test "x$tag_sed_script" = x; then + tag_sed_script="$1" + else + echo "$0: extra non-option argument '$1'." >&2 + exit 1 + fi;; + esac + shift +done + +if test "x$tarball_version_file" = x; then + echo "$usage" + exit 1 +fi + +tag_sed_script="${tag_sed_script:-s/x/x/}" + nl=' ' @@ -92,22 +143,22 @@ then [0-9]*) ;; *) v= ;; esac - test -z "$v" \ + test "x$v" = x \ && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2 fi -if test -n "$v" +if test "x$v" != x then : # use $v # Otherwise, if there is at least one git commit involving the working # directory, and "git describe" output looks sensible, use that to # derive a version string. elif test "`git log -1 --pretty=format:x . 2>&1`" = x \ - && v=`git describe --tags --abbrev=4 --match='v*' HEAD 2>/dev/null \ - || git describe --tags --abbrev=4 HEAD 2>/dev/null` \ + && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \ + || git describe --abbrev=4 HEAD 2>/dev/null` \ && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ && case $v in - v[0-9]*) ;; + $prefix[0-9]*) ;; *) (exit 1) ;; esac then @@ -136,16 +187,18 @@ then # Remove the "g" in git describe's output string, to save a byte. v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`; v_from_git=1 -else +elif test "x$fallback" = x || git --version >/dev/null 2>&1; then v=UNKNOWN +else + v=$fallback fi -v=`echo "$v" |sed 's/^v//'` +v=`echo "$v" |sed "s/^$prefix//"` # Test whether to append the "-dirty" suffix only if the version # string we're using came from git. I.e., skip the test if it's "UNKNOWN" # or if it came from .tarball-version. -if test -n "$v_from_git"; then +if test "x$v_from_git" != x; then # Don't declare a version "dirty" merely because a time stamp has changed. git update-index --refresh > /dev/null 2>&1 From 3e677d8a2460664e4959e733f9911308ba79fe31 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 20:26:43 +0100 Subject: [PATCH 054/313] tests: binding states commit needs to be reflected in expected results The commit b858a4778b855c6aa6ce03370ca0d3671273bd85 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 --- tests/expected/v6 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/expected/v6 b/tests/expected/v6 index b3fe5b4..92b0413 100644 --- a/tests/expected/v6 +++ b/tests/expected/v6 @@ -1,6 +1,6 @@ Ranges: shared net name first ip last ip max cur percent touch t+c t+c perc -All networks dead:abba:1000::2 - dead:abba:1000:ff:ffff:ffff:ffff:ffff 4.72237e+21 2 0.000 0 2 0.000 +All networks dead:abba:1000::2 - dead:abba:1000:ff:ffff:ffff:ffff:ffff 4.72237e+21 2 0.000 1 3 0.000 All networks dead:abba:4000::2 - dead:abba:4000::ff 254 1 0.394 0 1 0.394 Shared networks: @@ -8,4 +8,4 @@ name max cur percent touch t+c t+c perc Sum of all ranges: name max cur percent touch t+c t+c perc -All networks 4.72237e+21 3 0.000 0 3 0.000 +All networks 4.72237e+21 3 0.000 1 4 0.000 From 90c1a4e4c5e649269a80b16b3d8082c10654b13d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 9 Apr 2013 21:10:10 +0100 Subject: [PATCH 055/313] 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 --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1623ba2..2e9b6fa 100644 --- a/configure.ac +++ b/configure.ac @@ -15,10 +15,11 @@ AC_CONFIG_SRCDIR([src/dhcpd-pools.h]) AC_CONFIG_HEADERS([config.h]) # Checks for programs -gl_EARLY +AC_USE_SYSTEM_EXTENSIONS gl_INIT AC_C_RESTRICT AC_PROG_CC_C99 +gl_EARLY AC_PROG_MAKE_SET AC_PROG_LIBTOOL From 5966360f124c1d534426afcae8e7e0c25d9558c4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 21 Apr 2013 14:05:59 +0100 Subject: [PATCH 056/313] 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 Signed-off-by: Sami Kerola --- src/getdata.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/getdata.c b/src/getdata.c index ba50c3d..1a2e882 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -74,15 +74,13 @@ int parse_leases(void) } #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_WILLNEED - posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_WILLNEED); - if (errno) { + if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_WILLNEED) != 0) { err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); } # endif /* POSIX_FADV_WILLNEED */ # ifdef POSIX_FADV_SEQUENTIAL - posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL); - if (errno) { + if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); } @@ -228,14 +226,12 @@ void parse_config(int is_include, const char *restrict config_file, err(EXIT_FAILURE, "parse_config: %s", config_file); } #ifdef POSIX_FADV_WILLNEED - posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_WILLNEED); - if (errno) { + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_WILLNEED) != 0) { err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); } #endif /* POSIX_FADV_WILLNEED */ #ifdef POSIX_FADV_SEQUENTIAL - posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL); - if (errno) { + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); } #endif /* POSIX_FADV_SEQUENTIAL */ From 805d353584a74e874df3f077dbe1d6239bb50d3f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 21 Apr 2013 14:30:21 +0100 Subject: [PATCH 057/313] 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. Signed-off-by: Sami Kerola --- THANKS | 1 + src/other.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/THANKS b/THANKS index f5f6554..fb9f030 100644 --- a/THANKS +++ b/THANKS @@ -26,3 +26,4 @@ Ryan Malek Cheer Xiao Gilles Bouthenot Helmut Grohne +Joey D. diff --git a/src/other.c b/src/other.c index 226fe30..fbdb3c0 100644 --- a/src/other.c +++ b/src/other.c @@ -160,6 +160,10 @@ int xstrstr(const char *restrict a, const char *restrict b, const int len) { int i; + /* Skip when config.dhcp_version == VERSION_UNKNOWN -> len is zero. */ + if (len == 0) { + return false; + } /* two spaces are very common in lease file, after them * nearly everything differs */ if (likely(a[2] != b[2])) { From 1a7649beb3c5180aa300adb0e67df6690ac47151 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 21 Apr 2013 14:37:34 +0100 Subject: [PATCH 058/313] 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 --- tests/Makefile.am | 1 + tests/confs/empty | 0 tests/empty | 1 + tests/expected/empty | 9 +++++++++ tests/leases/empty | 0 5 files changed, 11 insertions(+) create mode 100644 tests/confs/empty create mode 120000 tests/empty create mode 100644 tests/expected/empty create mode 100644 tests/leases/empty diff --git a/tests/Makefile.am b/tests/Makefile.am index 61d1891..d2a1eeb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,7 @@ TESTS = \ bootp \ complete \ + empty \ full-json \ leading0 \ same-twice \ diff --git a/tests/confs/empty b/tests/confs/empty new file mode 100644 index 0000000..e69de29 diff --git a/tests/empty b/tests/empty new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/empty @@ -0,0 +1 @@ +test.sh \ No newline at end of file diff --git a/tests/expected/empty b/tests/expected/empty new file mode 100644 index 0000000..96e71d1 --- /dev/null +++ b/tests/expected/empty @@ -0,0 +1,9 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 0 0 -nan 0 0 -nan diff --git a/tests/leases/empty b/tests/leases/empty new file mode 100644 index 0000000..e69de29 From b24fc42ec875246820fc191e1d4e40e1231548d7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 22 Apr 2013 22:28:49 +0100 Subject: [PATCH 059/313] getdata: make a lease address detection more robust The commit 805d353584a74e874df3f077dbe1d6239bb50d3f did not fix all possible problem cases. This commit attempts to address remaining issues. Reported-by: Joey D. Signed-off-by: Sami Kerola --- src/other.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/other.c b/src/other.c index fbdb3c0..45229cf 100644 --- a/src/other.c +++ b/src/other.c @@ -40,6 +40,7 @@ #include #include "dhcpd-pools.h" +#include "defaults.h" #include #include @@ -160,10 +161,20 @@ int xstrstr(const char *restrict a, const char *restrict b, const int len) { int i; - /* Skip when config.dhcp_version == VERSION_UNKNOWN -> len is zero. */ - if (len == 0) { + + /* Needed when dhcpd.conf has zero range definitions. */ + if (config.dhcp_version == VERSION_UNKNOWN) { + if (!strcmp(prefixes[VERSION_4][PREFIX_LEASE], a)) { + config.dhcp_version = VERSION_4; + return true; + } + if (!strcmp(prefixes[VERSION_6][PREFIX_LEASE], a)) { + config.dhcp_version = VERSION_6; + return true; + } return false; } + /* two spaces are very common in lease file, after them * nearly everything differs */ if (likely(a[2] != b[2])) { From ffffbc96cc86a139407683f2f92c90f6ccc6b5cc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 22 Apr 2013 23:08:21 +0100 Subject: [PATCH 060/313] 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. Signed-off-by: Sami Kerola --- src/getdata.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/getdata.c b/src/getdata.c index 1a2e882..38d9e74 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -205,7 +205,7 @@ void parse_config(int is_include, const char *restrict config_file, struct shared_network_t *restrict shared_p) { FILE *dhcpd_config; - bool newclause = true, comment = false; + bool newclause = true, comment = false, one_ip_range = false; int quote = 0, braces = 0, argument = ITS_NOTHING_INTERESTING; size_t i = 0; char *word; @@ -268,10 +268,15 @@ void parse_config(int is_include, const char *restrict config_file, break; } if (comment == false + && argument != ITS_A_RANGE_FIRST_IP && argument != ITS_A_RANGE_SECOND_IP && argument != ITS_AN_INCLUCE) { newclause = true; i = 0; + } else if (argument == ITS_A_RANGE_FIRST_IP) { + one_ip_range = true; + argument = ITS_A_RANGE_SECOND_IP; + c = ' '; } else if (argument == ITS_A_RANGE_SECOND_IP) { /* Range ends to ; and this hair in code * make two ranges wrote together like... @@ -368,6 +373,10 @@ void parse_config(int is_include, const char *restrict config_file, range_p = ranges + num_ranges; parse_ipaddr(word, &addr); argument = ITS_NOTHING_INTERESTING; + if (one_ip_range == true) { + one_ip_range = false; + copy_ipaddr(&range_p->first_ip, &addr); + } copy_ipaddr(&range_p->last_ip, &addr); range_p->count = 0; range_p->touched = 0; From ab535d8ab1b21ad45b972f5f00a696c90078d429 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 22 Apr 2013 23:16:18 +0100 Subject: [PATCH 061/313] tests: add a test for one ip range A regression test for commit ffffbc9 fix. Signed-off-by: Sami Kerola --- tests/Makefile.am | 1 + tests/confs/one-ip | 1 + tests/expected/one-ip | 10 ++++++++++ tests/leases/one-ip | 4 ++++ tests/one-ip | 1 + 5 files changed, 17 insertions(+) create mode 100644 tests/confs/one-ip create mode 100644 tests/expected/one-ip create mode 100644 tests/leases/one-ip create mode 120000 tests/one-ip diff --git a/tests/Makefile.am b/tests/Makefile.am index d2a1eeb..30b3cef 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,6 +4,7 @@ TESTS = \ empty \ full-json \ leading0 \ + one-ip \ same-twice \ simple \ v6 diff --git a/tests/confs/one-ip b/tests/confs/one-ip new file mode 100644 index 0000000..60a2e3f --- /dev/null +++ b/tests/confs/one-ip @@ -0,0 +1 @@ +range 10.20.30.40; diff --git a/tests/expected/one-ip b/tests/expected/one-ip new file mode 100644 index 0000000..977a9b9 --- /dev/null +++ b/tests/expected/one-ip @@ -0,0 +1,10 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.20.30.40 - 10.20.30.40 1 1 100.000 0 1 100.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 1 1 100.000 0 1 100.000 diff --git a/tests/leases/one-ip b/tests/leases/one-ip new file mode 100644 index 0000000..43df364 --- /dev/null +++ b/tests/leases/one-ip @@ -0,0 +1,4 @@ +lease 10.20.30.40 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} diff --git a/tests/one-ip b/tests/one-ip new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/one-ip @@ -0,0 +1 @@ +test.sh \ No newline at end of file From 0495ea4edfe12509f3ff3f545af14e92d2c936d0 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 24 Apr 2013 21:12:37 +0100 Subject: [PATCH 062/313] 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 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2e9b6fa..b873bd1 100644 --- a/configure.ac +++ b/configure.ac @@ -16,10 +16,10 @@ AC_CONFIG_HEADERS([config.h]) # Checks for programs AC_USE_SYSTEM_EXTENSIONS -gl_INIT AC_C_RESTRICT AC_PROG_CC_C99 gl_EARLY +gl_INIT AC_PROG_MAKE_SET AC_PROG_LIBTOOL From 30238e9d1c08b6ebaabf91f61077c8245070a0da Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 24 Apr 2013 21:36:16 +0100 Subject: [PATCH 063/313] 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 --- .gitignore | 38 +++++++++++++++--------------- Makefile.am | 13 +++++++++- configure.ac | 9 ++----- contrib/Makefile.am | 3 --- contrib/Makemodule.am | 3 +++ doc/.gitignore | 5 ---- doc/Makefile.am | 18 -------------- doc/Makemodule.am | 20 ++++++++++++++++ man/.gitignore | 1 - man/Makefile.am | 3 --- man/Makemodule.am | 3 +++ src/.gitignore | 12 ---------- src/{Makefile.am => Makemodule.am} | 18 +++++++------- tests/.gitignore | 5 ---- tests/Makefile.am | 24 ------------------- tests/Makemodule.am | 26 ++++++++++++++++++++ tests/full-json | 8 +++---- tests/test.sh | 8 +++---- 18 files changed, 102 insertions(+), 115 deletions(-) delete mode 100644 contrib/Makefile.am create mode 100644 contrib/Makemodule.am delete mode 100644 doc/.gitignore delete mode 100644 doc/Makefile.am create mode 100644 doc/Makemodule.am delete mode 100644 man/.gitignore delete mode 100644 man/Makefile.am create mode 100644 man/Makemodule.am delete mode 100644 src/.gitignore rename src/{Makefile.am => Makemodule.am} (65%) delete mode 100644 tests/.gitignore delete mode 100644 tests/Makefile.am create mode 100644 tests/Makemodule.am diff --git a/.gitignore b/.gitignore index 59ef307..24f1410 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,30 @@ -/.tarball-version +# Wildcard + in any subdir. +*.o + +# Exact filename in any subdir. +.deps +.dirstamp +Makefile +Makefile.in + +# Exact wildcard, e.g., not in subdirs. +/tests/*.log +/tests/*.trs + +# Exact match, if a directory then everything in directory. /.version /aclocal.m4 /autom4te.cache/ -/autoscan.log -/config.guess /config.h /config.h.in -/config.h.in~ /config.log /config.status -/config.sub /configure -/configure.scan -/contrib/Makefile -/contrib/Makefile.in -/depcomp -/gnulib/ +/dhcpd-pools /INSTALL -/install-sh /libtool -/ltmain.sh -/m4 -/Makefile -/Makefile.in -/man/Makefile -/man/Makefile.in -/missing +/m4/ +/man/dhcpd-pools.1 /stamp-h1 -/tags +/test-suite.log +/tests/outputs/ diff --git a/Makefile.am b/Makefile.am index 4e1eeae..b2beaca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,10 +8,21 @@ EXTRA_DIST = \ build-aux/git-version-gen \ m4/gnulib-cache.m4 -SUBDIRS = doc lib src man tests contrib +SUBDIRS = lib BUILT_SOURCES = $(top_srcdir)/.version $(top_srcdir)/.version: echo $(VERSION) > $@-t && mv $@-t $@ dist-hook: echo $(VERSION) > $(distdir)/.tarball-version + +CLEANFILES = +CLEAN_LOCALS = + +include contrib/Makemodule.am +include doc/Makemodule.am +include man/Makemodule.am +include src/Makemodule.am +include tests/Makemodule.am + +clean-local: $(CLEAN_LOCALS) diff --git a/configure.ac b/configure.ac index b873bd1..9c9ddc6 100644 --- a/configure.ac +++ b/configure.ac @@ -9,8 +9,8 @@ AC_INIT([dhcpd-pools], PACKAGE_MAINTAINER="Sami Kerola" AC_SUBST([PACKAGE_MAINTAINER]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([-Wall -Wextra-portability foreign 1.10 tar-pax no-dist-gzip dist-xz - parallel-tests]) +AM_INIT_AUTOMAKE([-Wall -Wextra-portability foreign 1.10 tar-pax + no-dist-gzip dist-xz parallel-tests subdir-objects]) AC_CONFIG_SRCDIR([src/dhcpd-pools.h]) AC_CONFIG_HEADERS([config.h]) @@ -143,12 +143,7 @@ AM_CONDITIONAL([HAVE_DOXYGEN_DOT], [test "x$DOXYGEN_DOT" != "x"]) AC_CONFIG_FILES([ Makefile lib/Makefile - src/Makefile - man/Makefile man/dhcpd-pools.1 - tests/Makefile - doc/Makefile - contrib/Makefile ]) AC_OUTPUT diff --git a/contrib/Makefile.am b/contrib/Makefile.am deleted file mode 100644 index a3396bf..0000000 --- a/contrib/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -contribdir = $(datadir)/dhcpd-pools/ -dist_contrib_SCRIPTS = dhcpd-pools.cgi snmptest.pl -EXTRA_DIST = nagios.conf munin_plugins diff --git a/contrib/Makemodule.am b/contrib/Makemodule.am new file mode 100644 index 0000000..f6aee1f --- /dev/null +++ b/contrib/Makemodule.am @@ -0,0 +1,3 @@ +contribdir = $(datadir)/dhcpd-pools/ +dist_contrib_SCRIPTS = contrib/dhcpd-pools.cgi contrib/snmptest.pl +EXTRA_DIST += contrib/nagios.conf contrib/munin_plugins diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index 7167275..0000000 --- a/doc/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/Makefile -/Makefile.in -/doxy.conf -/doxyfile.stamp -/html diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index e990c92..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -EXTRA_DIST = doxy.conf.in introduction.dox - -if ENABLE_DOXYGEN - -doxyfile.stamp: - $(DOXYGEN) doxy.conf - date > doxyfile.stamp - -CLEANFILES = doxyfile.stamp - -all-local: doxyfile.stamp - -clean-local: clean-local-check -.PHONY: clean-local-check -clean-local-check: - -rm -rf html - -endif diff --git a/doc/Makemodule.am b/doc/Makemodule.am new file mode 100644 index 0000000..5a5686d --- /dev/null +++ b/doc/Makemodule.am @@ -0,0 +1,20 @@ +EXTRA_DIST += \ + doc/doxy.conf.in \ + doc/introduction.dox + +if ENABLE_DOXYGEN + +doxyfile.stamp: + $(DOXYGEN) doc/doxy.conf + date > doc/doxyfile.stamp + +CLEANFILES += doc/doxyfile.stamp + +all-local: doc/doxyfile.stamp + +clean-local-doc: + -rm -rf doc/*html + +CLEAN_LOCALS += clean-local-doc + +endif diff --git a/man/.gitignore b/man/.gitignore deleted file mode 100644 index a6c61aa..0000000 --- a/man/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/dhcpd-pools.1 diff --git a/man/Makefile.am b/man/Makefile.am deleted file mode 100644 index 8c4d072..0000000 --- a/man/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -man_MANS = dhcpd-pools.1 -EXTRA_DIST = dhcpd-pools.1.in -CLEANFILES = dhcpd-pools.1 diff --git a/man/Makemodule.am b/man/Makemodule.am new file mode 100644 index 0000000..102705a --- /dev/null +++ b/man/Makemodule.am @@ -0,0 +1,3 @@ +man_MANS = man/dhcpd-pools.1 +EXTRA_DIST += man/dhcpd-pools.1.in +CLEANFILES += man/dhcpd-pools.1 diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 759c2c3..0000000 --- a/src/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -gmon.out -gmon.sum -*.c.gcov -*.gcda -*.gcno -*~ -*.o -.deps/ -dhcpd-pools -Makefile -Makefile.in -tags diff --git a/src/Makefile.am b/src/Makemodule.am similarity index 65% rename from src/Makefile.am rename to src/Makemodule.am index ee0dd88..45e62b5 100644 --- a/src/Makefile.am +++ b/src/Makemodule.am @@ -7,12 +7,12 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_builddir)/lib dhcpd_pools_LDADD = $(top_builddir)/lib/libdhcpd_pools.la dhcpd_pools_SOURCES = \ - analyze.c \ - defaults.h \ - dhcpd-pools.c \ - dhcpd-pools.h \ - getdata.c \ - hash.c \ - other.c \ - output.c \ - sort.c + src/analyze.c \ + src/defaults.h \ + src/dhcpd-pools.c \ + src/dhcpd-pools.h \ + src/getdata.c \ + src/hash.c \ + src/other.c \ + src/output.c \ + src/sort.c diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index 0d52223..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/Makefile -/Makefile.in -/outputs -/*.log -/*.trs diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 30b3cef..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -TESTS = \ - bootp \ - complete \ - empty \ - full-json \ - leading0 \ - one-ip \ - same-twice \ - simple \ - v6 - -EXTRA_DIST = \ - confs \ - expected \ - leases \ - test.sh \ - $(TESTS) - -TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=../src$(PATH_SEPARATOR)$$PATH - -check-local: $(SHELL) $(top_srcdir)/tests/test.sh - -clean-local: - rm -rf $(top_builddir)/tests/outputs diff --git a/tests/Makemodule.am b/tests/Makemodule.am new file mode 100644 index 0000000..3213ad7 --- /dev/null +++ b/tests/Makemodule.am @@ -0,0 +1,26 @@ +TESTS = \ + tests/bootp \ + tests/complete \ + tests/empty \ + tests/full-json \ + tests/leading0 \ + tests/one-ip \ + tests/same-twice \ + tests/simple \ + tests/v6 + +EXTRA_DIST += \ + tests/confs \ + tests/expected \ + tests/leases \ + tests/test.sh \ + $(TESTS) + +TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) PATH=$(top_builddir)$(PATH_SEPARATOR)$$PATH + +check-local: $(SHELL) $(top_srcdir)/tests/test.sh + +clean-local-tests: + rm -rf $(top_builddir)/tests/outputs + +CLEAN_LOCALS += clean-local-tests diff --git a/tests/full-json b/tests/full-json index b9ebb55..31b0c93 100755 --- a/tests/full-json +++ b/tests/full-json @@ -2,12 +2,12 @@ # # Minimal regression test suite. -if [ ! -d outputs ]; then - mkdir outputs +if [ ! -d tests/outputs ]; then + mkdir tests/outputs fi dhcpd-pools -f J -c $top_srcdir/tests/confs/same-twice \ -l $top_srcdir/tests/leases/same-twice \ - -o outputs/same-twice-json -diff -u $top_srcdir/tests/expected/same-twice-json outputs/same-twice-json + -o tests/outputs/same-twice-json +diff -u $top_srcdir/tests/expected/same-twice-json tests/outputs/same-twice-json exit $? diff --git a/tests/test.sh b/tests/test.sh index a8746c8..6694344 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -4,11 +4,11 @@ IAM=$(basename $0) -if [ ! -d outputs ]; then - mkdir outputs +if [ ! -d tests/outputs ]; then + mkdir tests/outputs fi dhcpd-pools -c $top_srcdir/tests/confs/$IAM \ - -l $top_srcdir/tests/leases/$IAM -o outputs/$IAM -diff -u $top_srcdir/tests/expected/$IAM outputs/$IAM + -l $top_srcdir/tests/leases/$IAM -o tests/outputs/$IAM +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM exit $? From 0002aa57e6baed37523d41298dc1ff1654a1c3f0 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 24 Apr 2013 22:06:31 +0100 Subject: [PATCH 064/313] release: 2.22 Signed-off-by: Sami Kerola --- NEWS | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/NEWS b/NEWS index 5e5a0f5..ba69766 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,32 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. + +Version 2.21 +$ git shortlog v2.21..v2.22 +Cheer Xiao (1): + getdata: treat binding states abandoned, expired and release like free + +Sami Kerola (19): + tests: add complete check including multiple ranges and shared networks + include: add missing declarations to dhcpd-pool.h + cppcheck: fix variable scoping + build-sys: update .gitignore + build-sys: add git-version-gen and test.sh to release package + docs: fix spelling mistakes in manual page + build-sys: ensure distribution has version file + build-sys: update git-version-gen from gnulib + tests: binding states commit needs to be reflected in expected results + build-sys: reorder gnulib macro in relation to C standard + getdata: posix_fadvise() error checking + getdata: certain input files caused SIGSEGV + tests: check how command works with invalid input + getdata: make a lease address detection more robust + getdata: make single address ranges work + tests: add a test for one ip range + build-sys: fix gnulib function order + build-sys: use non-recursive build + release: 2.22 Version 2.21 $ git shortlog v2.20..v2.21 From 8dba1c749d338528d2e36b58740e8790b8e9a4dd Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 10 May 2013 23:50:02 +0100 Subject: [PATCH 065/313] gnulib: add gnulib modules Some systems, such as freebsd, does not have program_invocation_short_name available. There are also problems finding AF_INET{,6} definitions. CC: Peter Fraser Reported-by: Ryan Steinmetz Signed-off-by: Sami Kerola --- THANKS | 1 + bootstrap.conf | 2 ++ lib/.gitignore | 5 +++++ src/dhcpd-pools.c | 4 +++- src/other.c | 5 ++++- src/output.c | 5 +++-- src/sort.c | 3 ++- 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/THANKS b/THANKS index fb9f030..2c48a08 100644 --- a/THANKS +++ b/THANKS @@ -27,3 +27,4 @@ Cheer Xiao Gilles Bouthenot Helmut Grohne Joey D. +Ryan Steinmetz diff --git a/bootstrap.conf b/bootstrap.conf index d0d2c01..dcb0617 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -27,8 +27,10 @@ gnulib_modules=" fopen free getopt-gnu + inet_pton langinfo netinet_in + progname realloc-gnu stat stddef diff --git a/lib/.gitignore b/lib/.gitignore index 66f0e0d..3ce8e00 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -3,11 +3,13 @@ /.deps/ /.gitignore~ /.libs/ +/arpa/ /Makefile /Makefile.am /Makefile.in /_Exit.c /arg-nonnull.h +/arpa_inet.in.h /atexit.c /c++defs.h /c-ctype.c @@ -55,6 +57,7 @@ /getopt1.c /getopt_int.h /gettext.h +/inet_pton.c /intprops.h /langinfo.h /langinfo.in.h @@ -74,6 +77,8 @@ /msvc-nothrow.h /netinet_in.in.h /pathmax.h +/progname.c +/progname.h /quote.h /quotearg.c /quotearg.h diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 19b9d15..754f6fc 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -51,6 +51,7 @@ #include "closeout.h" #include "defaults.h" #include "dhcpd-pools.h" +#include "progname.h" #include "xalloc.h" /*! \brief Start of execution. Parse options, and call other other @@ -92,6 +93,7 @@ int main(int argc, char **argv) }; atexit(close_stdout); + set_program_name(argv[0]); /* FIXME: These allocations should be fully dynamic, e.g., grow * if needed. */ @@ -199,7 +201,7 @@ int main(int argc, char **argv) default: errx(EXIT_FAILURE, "Try `%s --help' for more information.", - program_invocation_short_name); + program_name); } } diff --git a/src/other.c b/src/other.c index 45229cf..397c697 100644 --- a/src/other.c +++ b/src/other.c @@ -41,9 +41,12 @@ #include "dhcpd-pools.h" #include "defaults.h" +#include "progname.h" +#include #include #include +#include #include #include #include @@ -282,7 +285,7 @@ void __attribute__ ((__noreturn__)) usage(int status) fprintf(out, "\ Usage: %s [OPTIONS]\n\n\ This is ISC dhcpd pools usage analyzer.\n\ -\n", program_invocation_short_name); +\n", program_name); fprintf(out, "\ -c, --config=FILE path to the dhcpd.conf file\n\ -l, --leases=FILE path to the dhcpd.leases file\n"); diff --git a/src/output.c b/src/output.c index d06276f..cb80ba7 100644 --- a/src/output.c +++ b/src/output.c @@ -53,6 +53,7 @@ #include "close-stream.h" #include "dhcpd-pools.h" +#include "progname.h" #include "strftime.h" /*! \brief Text output format, which is the default. @@ -1063,11 +1064,11 @@ int output_alarming(void) if (0 < rc || 0 < sc) { ret_val = 2; fprintf(outfile, "CRITICAL: %s: ", - program_invocation_short_name); + program_name); } else if (0 < rw || 0 < sw) { ret_val = 1; fprintf(outfile, "WARNING: %s: ", - program_invocation_short_name); + program_name); } else { ret_val = 0; fprintf(outfile, "OK: "); diff --git a/src/sort.c b/src/sort.c index b276bc7..5a2a4e1 100644 --- a/src/sort.c +++ b/src/sort.c @@ -47,6 +47,7 @@ #include #include "dhcpd-pools.h" +#include "progname.h" /*! \brief Compare IP address, with IPv4/v6 determination. * \param a Binary IP address. @@ -216,7 +217,7 @@ comparer_t field_selector(char c) default: warnx("field_selector: unknown sort order `%c'", c); errx(EXIT_FAILURE, "Try `%s --help' for more information.", - program_invocation_short_name); + program_name); } return NULL; } From 824a6aec7350ce2bf2ba285302ed05794b41a9c5 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 11 May 2013 17:35:38 +0100 Subject: [PATCH 066/313] build-sys: update bootstrap from gnulib Signed-off-by: Sami Kerola --- bootstrap | 88 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/bootstrap b/bootstrap index 6df39df..c69b99f 100755 --- a/bootstrap +++ b/bootstrap @@ -1,10 +1,10 @@ #! /bin/sh # Print a version string. -scriptversion=2012-07-19.14; # UTC +scriptversion=2013-05-08.20; # UTC # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2012 Free Software Foundation, Inc. +# Copyright (C) 2003-2013 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -140,21 +140,22 @@ po_download_command_format2=\ "wget --mirror -nd -q -np -A.po -P '%s' \ http://translationproject.org/latest/%s/" +# Prefer a non-empty tarname (4th argument of AC_INIT if given), else +# fall back to the package name (1st argument with munging) extract_package_name=' - /^AC_INIT(/{ - /.*,.*,.*, */{ - s/// - s/[][]//g - s/)$// + /^AC_INIT(\[*/{ + s/// + /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{ + s//\1/ + s/[],)].*// p q } - s/AC_INIT(\[*// - s/]*,.*// + s/[],)].*// s/^GNU // - y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ - s/[^A-Za-z0-9_]/-/g s/-/_/g + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g p } ' @@ -183,8 +184,8 @@ XGETTEXT_OPTIONS='\\\ ' # Package bug report address and copyright holder for gettext files -COPYRIGHT_HOLDER='Sami Kerola' -MSGID_BUGS_ADDRESS=kerolasa@iki.fi +COPYRIGHT_HOLDER='Free Software Foundation, Inc.' +MSGID_BUGS_ADDRESS=bug-$package@gnu.org # Files we don't want to import. excluded_files= @@ -307,34 +308,34 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then die "Bootstrapping from a non-checked-out distribution is risky." fi -# Ensure that lines starting with ! sort last, per gitignore conventions -# for whitelisting exceptions after a more generic blacklist pattern. -sort_patterns() { - sort -u "$@" | sed '/^!/ { - H - d - } - $ { - P - x - s/^\n// - }' | sed '/^$/d' +# Strip blank and comment lines to leave significant entries. +gitignore_entries() { + sed '/^#/d; /^$/d' "$@" } -# If $STR is not already on a line by itself in $FILE, insert it, -# sorting the new contents of the file and replacing $FILE with the result. -insert_sorted_if_absent() { +# If $STR is not already on a line by itself in $FILE, insert it at the start. +# Entries are inserted at the start of the ignore list to ensure existing +# entries starting with ! are not overridden. Such entries support +# whitelisting exceptions after a more generic blacklist pattern. +insert_if_absent() { file=$1 str=$2 test -f $file || touch $file - echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \ - || { echo "$str" | sort_patterns - $file > $file.bak \ - && mv $file.bak $file; } \ - || die "insert_sorted_if_absent $file $str: failed" + test -r $file || die "Error: failed to read ignore file: $file" + duplicate_entries=$(gitignore_entries $file | sort | uniq -d) + if [ "$duplicate_entries" ] ; then + die "Error: Duplicate entries in $file: " $duplicate_entries + fi + linesold=$(gitignore_entries $file | wc -l) + linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l) + if [ $linesold != $linesnew ] ; then + { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ + || die "insert_if_absent $file $str: failed" + fi } # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with -# insert_sorted_if_absent. +# insert_if_absent. insert_vc_ignore() { vc_ignore_file="$1" pattern="$2" @@ -345,7 +346,7 @@ insert_vc_ignore() { # .gitignore entry. pattern=$(echo "$pattern" | sed s,^,/,);; esac - insert_sorted_if_absent "$vc_ignore_file" "$pattern" + insert_if_absent "$vc_ignore_file" "$pattern" } # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. @@ -631,9 +632,13 @@ esac if $bootstrap_sync; then cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { echo "$0: updating bootstrap and restarting..." + case $(sh -c 'echo "$1"' -- a) in + a) ignored=--;; + *) ignored=ignored;; + esac exec sh -c \ 'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ - -- "$GNULIB_SRCDIR/build-aux/bootstrap" \ + $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \ "$0" "$@" --no-bootstrap-sync } fi @@ -890,20 +895,21 @@ find "$m4_base" "$source_base" \ -depth \( -name '*.m4' -o -name '*.[ch]' \) \ -type l -xtype l -delete > /dev/null 2>&1 +# Invoke autoreconf with --force --install to ensure upgrades of tools +# such as ylwrap. +AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS" + # Some systems (RHEL 5) are using ancient autotools, for which the # --no-recursive option had not been invented. Detect that lack and # omit the option when it's not supported. FIXME in 2017: remove this # hack when RHEL 5 autotools are updated, or when they become irrelevant. -no_recursive= case $($AUTORECONF --help) in - *--no-recursive*) no_recursive=--no-recursive;; + *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";; esac # Tell autoreconf not to invoke autopoint or libtoolize; they were run above. -echo "running: AUTOPOINT=true LIBTOOLIZE=true " \ - "$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS" -AUTOPOINT=true LIBTOOLIZE=true \ - $AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \ +echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS" +AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \ || die "autoreconf failed" # Get some extra files from gnulib, overriding existing files. From 3f3d447ad8aaca13c5e3bfaf10e9fdb8f071477d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 11 May 2013 17:39:34 +0100 Subject: [PATCH 067/313] release: 2.23 Signed-off-by: Sami Kerola --- NEWS | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ba69766..22a7fb0 100644 --- a/NEWS +++ b/NEWS @@ -6,7 +6,14 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. -Version 2.21 +Version 2.23 +$ git shortlog v2.22..v2.23 +Sami Kerola (3): + gnulib: add gnulib modules + build-sys: update bootstrap from gnulib + release: 2.23 + +Version 2.22 $ git shortlog v2.21..v2.22 Cheer Xiao (1): getdata: treat binding states abandoned, expired and release like free From 7de719a80c30d85c58877986c651c5e58ada51e1 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 23 Jun 2013 12:42:32 +0100 Subject: [PATCH 068/313] build-sys: update configure.ac Run autoupdate, and fix few items manually such as prefer AS_CASE rather than shell case clause. Signed-off-by: Sami Kerola --- configure.ac | 66 ++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/configure.ac b/configure.ac index 9c9ddc6..8f71ab4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,16 +1,26 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.64) +AC_PREREQ([2.69]) AC_CONFIG_MACRO_DIR([m4]) AC_INIT([dhcpd-pools], - m4_esyscmd([build-aux/git-version-gen .tarball-version]), - [kerolasa@iki.fi],,[http://dhcpd-pools.sourceforge.net/]) + [m4_esyscmd([build-aux/git-version-gen .tarball-version])], + [kerolasa@iki.fi],[], + [http://dhcpd-pools.sourceforge.net/]) PACKAGE_MAINTAINER="Sami Kerola" AC_SUBST([PACKAGE_MAINTAINER]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([-Wall -Wextra-portability foreign 1.10 tar-pax - no-dist-gzip dist-xz parallel-tests subdir-objects]) +AM_INIT_AUTOMAKE([ + -Wall + -Wextra-portability + 1.10 + foreign + dist-xz + no-dist-gzip + parallel-tests + subdir-objects + tar-pax +]) AC_CONFIG_SRCDIR([src/dhcpd-pools.h]) AC_CONFIG_HEADERS([config.h]) @@ -21,7 +31,7 @@ AC_PROG_CC_C99 gl_EARLY gl_INIT AC_PROG_MAKE_SET -AC_PROG_LIBTOOL +LT_INIT # Checks for libraries. LT_INIT @@ -35,20 +45,16 @@ AC_CHECK_HEADERS([\ sys/socket.h \ ]) -AC_ARG_WITH(uthash, -AC_HELP_STRING([--with-uthash=DIR], [Use uthash from [DIR]/uthash.h)]), [ - case "$with_uthash" in - yes) - ;; - no) - AC_MSG_ERROR([the uthash.h is required]) - ;; - *) - CPPFLAGS="$CPPFLAGS -I$with_uthash" - ;; - esac -]) -AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Unable to find uthash.h])]) +AC_ARG_WITH( + [uthash], + [AS_HELP_STRING([--with-uthash=DIR], [Use uthash from [DIR]/uthash.h)])], + [AS_CASE([$with_uthash], + [yes], [], + [no], [AC_MSG_ERROR([the uthash is required])], + [CPPFLAGS="$CPPFLAGS -I$with_uthash"] + )] +) +AC_CHECK_HEADER([uthash.h], [], [AC_MSG_ERROR([Unable to find uthash.h])]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE @@ -64,12 +70,12 @@ AC_CHECK_FUNCS([\ ]) AC_MSG_CHECKING([if the compiler supports __builtin_expect]) -AC_TRY_COMPILE(, [ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ return __builtin_expect(1, 1) ? 1 : 0 -], [ +]])],[ have_builtin_expect=yes AC_MSG_RESULT([yes]) -], [ +],[ have_builtin_expect=no AC_MSG_RESULT([no]) ]) @@ -79,49 +85,49 @@ AS_IF([test x$have_builtin_expect = xyes], [ ]) AC_ARG_WITH([dhcpd-conf], - [AC_HELP_STRING([--with-dhcpd-conf=FILE], [default path of dhcpd.conf])], + [AS_HELP_STRING([--with-dhcpd-conf=FILE],[default path of dhcpd.conf])], [dhcpd_conf_path="$withval"], [dhcpd_conf_path="/etc/dhcpd.conf"]) AC_DEFINE_UNQUOTED([DHCPDCONF_FILE], ["$dhcpd_conf_path"], [default path of dhcpd.conf]) AC_SUBST([DHCPDCONF_FILE], [$dhcpd_conf_path]) AC_ARG_WITH([dhcpd-leases], - [AC_HELP_STRING([--with-dhcpd-leases=FILE], [default path of dhcpd.leases])], + [AS_HELP_STRING([--with-dhcpd-leases=FILE],[default path of dhcpd.leases])], [dhcpd_leases_path="$withval"], [dhcpd_leases_path="/var/lib/dhcp/dhcpd.leases"]) AC_DEFINE_UNQUOTED([DHCPDLEASE_FILE], ["$dhcpd_leases_path"], [default path of dhcpd.leases]) AC_SUBST([DHCPDLEASE_FILE], [$dhcpd_leases_path]) AC_ARG_WITH([output-format], - [AC_HELP_STRING([--with-output-format=FORMAT], [default output format])], + [AS_HELP_STRING([--with-output-format=FORMAT],[default output format])], [output_format="$withval"], [output_format="text"]) AC_DEFINE_UNQUOTED([OUTPUT_FORMAT], ["$output_format"], [default output format]) AC_SUBST([OUTPUT_FORMAT], [$output_format]) AC_ARG_WITH([output-limit], - [AC_HELP_STRING([--with-output-limit=MASK], [default output limit])], + [AS_HELP_STRING([--with-output-limit=MASK],[default output limit])], [output_limit="$withval"], [output_limit="77"]) AC_DEFINE_UNQUOTED([OUTPUT_LIMIT], ["$output_limit"], [default output limit]) AC_SUBST([OUTPUT_LIMIT], [$output_limit]) AC_ARG_WITH([warning], - [AC_HELP_STRING([--with-warning=NUM], [monitoring warning default])], + [AS_HELP_STRING([--with-warning=NUM],[monitoring warning default])], [warning_percent="$withval"], [warning_percent="80"]) AC_DEFINE_UNQUOTED([ALARM_WARN], [$warning_percent], [monitoring warning default]) AC_SUBST([ALARM_WARN], [$warning_percent]) AC_ARG_WITH([critical], - [AC_HELP_STRING([--with-critical=NUM], [monitoring critical default])], + [AS_HELP_STRING([--with-critical=NUM],[monitoring critical default])], [critical_percent="$withval"], [critical_percent="90"]) AC_DEFINE_UNQUOTED([ALARM_CRIT], [$critical_percent], [monitoring critical default]) AC_SUBST([ALARM_CRIT], [$critical_percent]) AC_ARG_ENABLE([doxygen], - AC_HELP_STRING([--enable-doxygen], [build internal api documentation @<:@default=disabled@:>@]), + AS_HELP_STRING([--enable-doxygen],[build internal api documentation @<:@default=disabled@:>@]), [], [enable_doxygen=no]) AM_CONDITIONAL([ENABLE_DOXYGEN], [test "x$enable_doxygen" = "xyes"]) From 08c9bcc502a8a499b805fdc10c7198d6ab6fbf36 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 10 Jul 2013 22:34:47 +0100 Subject: [PATCH 069/313] output: make output limits to apply to alarm return values The earlier behavior made alarming nearly impossible to use for shared networks only, as they often are expected to be whole lot less full than ranges. Unfortunately if a alarm level was exceeded either by range or shared network the exit value changed. In most of the cases that lead alarms to be sent, without sensible message. Reported-by: Dan Pritts Signed-off-by: Sami Kerola --- src/output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index cb80ba7..08cdfdf 100644 --- a/src/output.c +++ b/src/output.c @@ -1061,11 +1061,11 @@ int output_alarming(void) shared_p++; } } - if (0 < rc || 0 < sc) { + if ((0 < rc && config.output_limit[1] & BIT1) || (0 < sc && config.output_limit[1] & BIT2)) { ret_val = 2; fprintf(outfile, "CRITICAL: %s: ", program_name); - } else if (0 < rw || 0 < sw) { + } else if ((0 < rw && config.output_limit[1] & BIT1) || (0 < sw && config.output_limit[1] & BIT2)) { ret_val = 1; fprintf(outfile, "WARNING: %s: ", program_name); From c0e7b50bd3ab3b437df23d1099fee142a9b8569d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 10 Jul 2013 22:42:25 +0100 Subject: [PATCH 070/313] tests: add alarming tests Signed-off-by: Sami Kerola --- tests/Makemodule.am | 8 ++++++++ tests/alarm-critical | 16 ++++++++++++++++ tests/alarm-critical-ranges | 16 ++++++++++++++++ tests/alarm-critical-snets | 16 ++++++++++++++++ tests/alarm-ok | 16 ++++++++++++++++ tests/alarm-shared-ok | 16 ++++++++++++++++ tests/alarm-warning | 16 ++++++++++++++++ tests/alarm-warning-ranges | 16 ++++++++++++++++ tests/alarm-warning-snets | 16 ++++++++++++++++ tests/expected/alarm-critical | 2 ++ tests/expected/alarm-critical-ranges | 2 ++ tests/expected/alarm-critical-snets | 2 ++ tests/expected/alarm-ok | 2 ++ tests/expected/alarm-shared-ok | 2 ++ tests/expected/alarm-warning | 2 ++ tests/expected/alarm-warning-ranges | 2 ++ tests/expected/alarm-warning-snets | 2 ++ 17 files changed, 152 insertions(+) create mode 100755 tests/alarm-critical create mode 100755 tests/alarm-critical-ranges create mode 100755 tests/alarm-critical-snets create mode 100755 tests/alarm-ok create mode 100755 tests/alarm-shared-ok create mode 100755 tests/alarm-warning create mode 100755 tests/alarm-warning-ranges create mode 100755 tests/alarm-warning-snets create mode 100644 tests/expected/alarm-critical create mode 100644 tests/expected/alarm-critical-ranges create mode 100644 tests/expected/alarm-critical-snets create mode 100644 tests/expected/alarm-ok create mode 100644 tests/expected/alarm-shared-ok create mode 100644 tests/expected/alarm-warning create mode 100644 tests/expected/alarm-warning-ranges create mode 100644 tests/expected/alarm-warning-snets diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 3213ad7..70ed8df 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -1,4 +1,12 @@ TESTS = \ + tests/alarm-critical \ + tests/alarm-critical-ranges \ + tests/alarm-critical-snets \ + tests/alarm-ok \ + tests/alarm-shared-ok \ + tests/alarm-warning \ + tests/alarm-warning-ranges \ + tests/alarm-warning-snets \ tests/bootp \ tests/complete \ tests/empty \ diff --git a/tests/alarm-critical b/tests/alarm-critical new file mode 100755 index 0000000..ee20865 --- /dev/null +++ b/tests/alarm-critical @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm critical both ranges & shared nets. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools --critical=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-critical-ranges b/tests/alarm-critical-ranges new file mode 100755 index 0000000..0356c42 --- /dev/null +++ b/tests/alarm-critical-ranges @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm critical ranges only. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -L 11 --critical=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-critical-snets b/tests/alarm-critical-snets new file mode 100755 index 0000000..7cacbdd --- /dev/null +++ b/tests/alarm-critical-snets @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm critical shared networks only. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -L 22 --critical=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-ok b/tests/alarm-ok new file mode 100755 index 0000000..4b526e1 --- /dev/null +++ b/tests/alarm-ok @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm warning both ranges and shared networks. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools --critical=100 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-shared-ok b/tests/alarm-shared-ok new file mode 100755 index 0000000..cc78e9e --- /dev/null +++ b/tests/alarm-shared-ok @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Shared network should be OK, and critical range ignored. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -L 22 --critical=54 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-warning b/tests/alarm-warning new file mode 100755 index 0000000..fcddd3e --- /dev/null +++ b/tests/alarm-warning @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm warning both ranges and shared networks. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools --warning=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-warning-ranges b/tests/alarm-warning-ranges new file mode 100755 index 0000000..e5867f4 --- /dev/null +++ b/tests/alarm-warning-ranges @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm warning ranges only. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -L 11 --warning=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/alarm-warning-snets b/tests/alarm-warning-snets new file mode 100755 index 0000000..7fa52b1 --- /dev/null +++ b/tests/alarm-warning-snets @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm warning shared networks only. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -L 22 --warning=50 -c $top_srcdir/tests/confs/complete \ + -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/expected/alarm-critical b/tests/expected/alarm-critical new file mode 100644 index 0000000..fe0b242 --- /dev/null +++ b/tests/expected/alarm-critical @@ -0,0 +1,2 @@ +CRITICAL: dhcpd-pools: Ranges; crit: 1 warn: 0 ok: 4 Shared nets; crit: 1 warn: 0 ok: 1 +2 diff --git a/tests/expected/alarm-critical-ranges b/tests/expected/alarm-critical-ranges new file mode 100644 index 0000000..fcb1833 --- /dev/null +++ b/tests/expected/alarm-critical-ranges @@ -0,0 +1,2 @@ +CRITICAL: dhcpd-pools: Ranges; crit: 1 warn: 0 ok: 4 +2 diff --git a/tests/expected/alarm-critical-snets b/tests/expected/alarm-critical-snets new file mode 100644 index 0000000..8f2c02b --- /dev/null +++ b/tests/expected/alarm-critical-snets @@ -0,0 +1,2 @@ +CRITICAL: dhcpd-pools: Shared nets; crit: 1 warn: 0 ok: 1 +2 diff --git a/tests/expected/alarm-ok b/tests/expected/alarm-ok new file mode 100644 index 0000000..7137c5b --- /dev/null +++ b/tests/expected/alarm-ok @@ -0,0 +1,2 @@ +OK: Ranges; crit: 0 warn: 0 ok: 5 Shared nets; crit: 0 warn: 0 ok: 2 +0 diff --git a/tests/expected/alarm-shared-ok b/tests/expected/alarm-shared-ok new file mode 100644 index 0000000..fb71df9 --- /dev/null +++ b/tests/expected/alarm-shared-ok @@ -0,0 +1,2 @@ +OK: Shared nets; crit: 0 warn: 0 ok: 2 +0 diff --git a/tests/expected/alarm-warning b/tests/expected/alarm-warning new file mode 100644 index 0000000..1471296 --- /dev/null +++ b/tests/expected/alarm-warning @@ -0,0 +1,2 @@ +WARNING: dhcpd-pools: Ranges; crit: 0 warn: 1 ok: 4 Shared nets; crit: 0 warn: 1 ok: 1 +1 diff --git a/tests/expected/alarm-warning-ranges b/tests/expected/alarm-warning-ranges new file mode 100644 index 0000000..82d97d9 --- /dev/null +++ b/tests/expected/alarm-warning-ranges @@ -0,0 +1,2 @@ +WARNING: dhcpd-pools: Ranges; crit: 0 warn: 1 ok: 4 +1 diff --git a/tests/expected/alarm-warning-snets b/tests/expected/alarm-warning-snets new file mode 100644 index 0000000..636d947 --- /dev/null +++ b/tests/expected/alarm-warning-snets @@ -0,0 +1,2 @@ +WARNING: dhcpd-pools: Shared nets; crit: 0 warn: 1 ok: 1 +1 From 9f676f527622461be2d7355afb53fbefab051039 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 11 Jul 2013 20:29:06 +0100 Subject: [PATCH 071/313] output: allow alarming, in case of success, be silent This will allow runnign dhcpd with cron, and when nothing is wrong emails will not be sent. Proposed-by: Dan Pritts Signed-off-by: Sami Kerola --- src/output.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index 08cdfdf..e45acaf 100644 --- a/src/output.c +++ b/src/output.c @@ -1071,7 +1071,10 @@ int output_alarming(void) program_name); } else { ret_val = 0; - fprintf(outfile, "OK: "); + if (config.output_limit[1] & BIT3) + fprintf(outfile, "OK: "); + else + return ret_val; } if (config.output_limit[0] & BIT1) { fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw, From 978ddeddebdffdfc8f9640545c58c5455306a34b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 11 Jul 2013 20:37:55 +0100 Subject: [PATCH 072/313] tests: fix tests to use the new OK printing limit Signed-off-by: Sami Kerola --- tests/alarm-shared-ok | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/alarm-shared-ok b/tests/alarm-shared-ok index cc78e9e..3357908 100755 --- a/tests/alarm-shared-ok +++ b/tests/alarm-shared-ok @@ -8,7 +8,7 @@ if [ ! -d tests/outputs ]; then mkdir tests/outputs fi -dhcpd-pools -L 22 --critical=54 -c $top_srcdir/tests/confs/complete \ +dhcpd-pools -L 66 --critical=54 -c $top_srcdir/tests/confs/complete \ -l $top_srcdir/tests/leases/complete -o tests/outputs/$IAM echo $? >> tests/outputs/$IAM From 4becf97fb3ae18d87d812bd99c9a791be9de4eed Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 11 Jul 2013 20:47:09 +0100 Subject: [PATCH 073/313] docs: inform how the limits affect to printing when alarming is in use Proposed-by: Dan Pritts Signed-off-by: Sami Kerola --- man/dhcpd-pools.1.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index b3858a3..d75d81f 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -127,6 +127,14 @@ Print shared network header Print total summary header .PD .RE +.IP +The output limit for total summary has special meaning in +.B \-\-warning +and +.B \-\-critical +alarming context. When the alarming is in use, and total is not wanted +to be seen then in the case of alarming returning success nothing is +printed. .TP \fB\-\-warning\fR=\fIpercent\fR Turn on alarm output format, and specify percentage number which will From 28f1e8c54cf554e9e1ebcaa2346fbb70991aecc7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 12 Jul 2013 19:18:24 +0100 Subject: [PATCH 074/313] output: allow user to ignore small ranges and shared networks Some have configuration which combines small ranges such as one host, and greater address ranges that are important to monitor. Especially the one host ranges tend to cause a lot of false-positive alarms, as they are immediately 100% full when a machine requests an address. Signed-off-by: Sami Kerola --- man/dhcpd-pools.1.in | 6 ++++++ src/dhcpd-pools.c | 8 +++++++- src/dhcpd-pools.h | 1 + src/other.c | 3 ++- src/output.c | 48 +++++++++++++++++++++++++++++--------------- 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index d75d81f..eeb7e99 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -159,6 +159,12 @@ is If critical percentage is not specified it defaults to .BR @ALARM_CRIT@ . .TP +\fB\-\-minsize\fR=\fIsize\f +Ignore ranges and shared networks that are smaller or equal to the +defined size. This option is meaningful only in context of alarming, and +will intented to supress for example single host ranges. By default this +option is not in use. +.TP \fB\-v\fR, \fB\-\-version\fR Print version information to standard output and exit successfully. .TP diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 754f6fc..06641d6 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -72,7 +72,8 @@ int main(int argc, char **argv) struct range_t *tmp_ranges; enum { OPT_WARN = CHAR_MAX + 1, - OPT_CRIT + OPT_CRIT, + OPT_MINSIZE }; int ret_val; @@ -89,6 +90,7 @@ int main(int argc, char **argv) {"help", no_argument, NULL, 'h'}, {"warning", required_argument, NULL, OPT_WARN}, {"critical", required_argument, NULL, OPT_CRIT}, + {"minsize", required_argument, NULL, OPT_MINSIZE}, {NULL, 0, NULL, 0} }; @@ -192,6 +194,10 @@ int main(int argc, char **argv) config.critical = strtod_or_err(optarg, "illegal argument"); break; + case OPT_MINSIZE: + config.minsize = + strtod_or_err(optarg, "illegal argument"); + break; case 'v': /* Print version */ print_version(); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 0fb295c..3578319 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -110,6 +110,7 @@ struct configuration_t { bool backups_found; double warning; double critical; + double minsize; }; /*! \struct shared_network_t * \brief Counters for an individual shared network. diff --git a/src/other.c b/src/other.c index 397c697..e31b3bb 100644 --- a/src/other.c +++ b/src/other.c @@ -314,7 +314,8 @@ This is ISC dhcpd pools usage analyzer.\n\ -L, --limit=NR output limit mask 77 - 00\n"); fprintf(out, "\ --warning=PERC set warning alarming limit\n\ - --critical=PERC set critical alarming limit\n"); + --critical=PERC set critical alarming limit\n\ + --minsize=size disable alarms for small ranges and shared-nets\n"); fprintf(out, "\ -v, --version version information\n\ -h, --help this screen\n\ diff --git a/src/output.c b/src/output.c index e45acaf..bc94b74 100644 --- a/src/output.c +++ b/src/output.c @@ -1018,7 +1018,7 @@ int output_alarming(void) struct shared_network_t *shared_p; unsigned int i; float perc; - int rw = 0, rc = 0, ro = 0, sw = 0, sc = 0, so = 0; + int rw = 0, rc = 0, ro = 0, ri = 0, sw = 0, sc = 0, so = 0, si = 0; int ret_val, ret; range_p = ranges; @@ -1037,27 +1037,36 @@ int output_alarming(void) if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { - perc = (float)(100 * range_p->count) / range_size; - if (config.critical < perc) - rc++; - else if (config.warning < perc) - rw++; - else - ro++; + if (config.minsize < range_size) { + perc = + (float)(100 * range_p->count) / range_size; + if (config.critical < perc) + rc++; + else if (config.warning < perc) + rw++; + else + ro++; + } else { + ri++; + } range_p++; range_size = get_range_size(range_p); } } if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { - perc = (float)(100 * shared_p->used) / - shared_p->available; - if (config.critical < perc) - sc++; - else if (config.warning < perc) - sw++; - else - so++; + if (config.minsize < shared_p->available) { + perc = (float)(100 * shared_p->used) / + shared_p->available; + if (config.critical < perc) + sc++; + else if (config.warning < perc) + sw++; + else + so++; + } else { + si++; + } shared_p++; } } @@ -1079,10 +1088,17 @@ int output_alarming(void) if (config.output_limit[0] & BIT1) { fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw, ro); + if (ri != 0) { + fprintf(outfile, "ignored: %d ", ri); + } + } if (config.output_limit[0] & BIT2) { fprintf(outfile, "Shared nets; crit: %d warn: %d ok: %d", sc, sw, so); + if (si != 0) { + fprintf(outfile, "ignored: %d ", si); + } } fprintf(outfile, "\n"); if (outfile == stdout) { From 57ddd4f7851d6687682253702dd87b34daba1589 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 12 Jul 2013 19:32:27 +0100 Subject: [PATCH 075/313] tests: test small network alarm ignoring Signed-off-by: Sami Kerola --- tests/Makemodule.am | 1 + tests/alarm-ignore | 15 +++++++++++++++ tests/expected/alarm-ignore | 1 + 3 files changed, 17 insertions(+) create mode 100755 tests/alarm-ignore create mode 100644 tests/expected/alarm-ignore diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 70ed8df..d309b9b 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -2,6 +2,7 @@ TESTS = \ tests/alarm-critical \ tests/alarm-critical-ranges \ tests/alarm-critical-snets \ + tests/alarm-ignore \ tests/alarm-ok \ tests/alarm-shared-ok \ tests/alarm-warning \ diff --git a/tests/alarm-ignore b/tests/alarm-ignore new file mode 100755 index 0000000..95bcf85 --- /dev/null +++ b/tests/alarm-ignore @@ -0,0 +1,15 @@ +#!/bin/sh +# +# Minimal regression test suite. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools --warning 1 --critical 101 --min 2 \ + -c $top_srcdir/tests/confs/one-ip \ + -l $top_srcdir/tests/leases/one-ip -o tests/outputs/$IAM +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? diff --git a/tests/expected/alarm-ignore b/tests/expected/alarm-ignore new file mode 100644 index 0000000..18ca9c6 --- /dev/null +++ b/tests/expected/alarm-ignore @@ -0,0 +1 @@ +OK: Ranges; crit: 0 warn: 0 ok: 0 ignored: 1 Shared nets; crit: 0 warn: 0 ok: 0 From 3944e289c83dba167231ea95a1718e9ed5e0d54b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 12 Jul 2013 19:59:50 +0100 Subject: [PATCH 076/313] docs: add an example how to use limits with alarming Proposed-by: Dan Pritts Signed-off-by: Sami Kerola --- man/dhcpd-pools.1.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index eeb7e99..144eebb 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -188,6 +188,13 @@ Alarming $ dhcpd-pools \-c dhcpd.conf \-l dhcpd.leases \-\-critical 80.1 \-\-warning 75 .br CRITICAL: dhcpd-pools: Ranges; crit: 14 warn: 22 ok: 220 Shared nets; crit: 1 warn: 0 ok: 4 +.IP +$ dhcpd-pools \-c dhcpd.conf \-l dhcpd.leases \-L 22 \-\-critical 70 \-\-warning 50 +.br +[no-output] +.br +Supress printing OK, and make alarm only to go off if shared networks +exceed critial or warning levels. .SH FILES .TP @DHCPDCONF_FILE@ From d70b08244fe0d28c6a16d6c3ab9f52fe928b4a34 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 12 Jul 2013 20:01:20 +0100 Subject: [PATCH 077/313] thanks: Dan Pritts For good ideas how to improve alarming. Signed-off-by: Sami Kerola --- THANKS | 1 + 1 file changed, 1 insertion(+) diff --git a/THANKS b/THANKS index 2c48a08..64c70f5 100644 --- a/THANKS +++ b/THANKS @@ -28,3 +28,4 @@ Gilles Bouthenot Helmut Grohne Joey D. Ryan Steinmetz +Dan Pritts From 06ffa5ed04a7083711cd78cbffaab5d71e56c930 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 31 Aug 2013 00:30:28 +0100 Subject: [PATCH 078/313] xstrstr: speed up analysis by avoiding string comparisons With large input one should see cut 15% for overall run time. Signed-off-by: Sami Kerola --- src/defaults.h | 28 ------------ src/dhcpd-pools.c | 7 --- src/dhcpd-pools.h | 3 +- src/getdata.c | 48 ++++++++----------- src/other.c | 114 +++++++++++++++++++++++++++++++++------------- 5 files changed, 102 insertions(+), 98 deletions(-) diff --git a/src/defaults.h b/src/defaults.h index a865cf0..3b4f882 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -52,32 +52,4 @@ static const size_t MAXLEN = 1024; * \brief Maximum number of different shared networks in dhcpd.conf file. */ static const unsigned int SHARED_NETWORKS = 8192; -/*! \var prefixes[2][NUM_OF_PREFIX] - * \brief ISC lease file formats for IPv4 and IPv6. - * - * The .indent.pro in use will mess formatting of array below. - * Please do not commit less readable indentation. */ -static const char *prefixes[2][NUM_OF_PREFIX] = { - [VERSION_4] = { - [PREFIX_LEASE] = "lease ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned", - [PREFIX_BINDING_STATE_EXPIRED] = " binding state expired", - [PREFIX_BINDING_STATE_RELEASED] = " binding state released", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" - }, - [VERSION_6] = { - [PREFIX_LEASE] = " iaaddr ", - [PREFIX_BINDING_STATE_FREE] = " binding state free", - [PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned", - [PREFIX_BINDING_STATE_EXPIRED] = " binding state expired", - [PREFIX_BINDING_STATE_RELEASED] = " binding state released", - [PREFIX_BINDING_STATE_ACTIVE] = " binding state active", - [PREFIX_BINDING_STATE_BACKUP] = " binding state backup", - [PREFIX_HARDWARE_ETHERNET] = " hardware ethernet" - } -}; - #endif /* DEFAULTS_H */ diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 06641d6..d37d0d0 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -272,13 +272,6 @@ int main(int argc, char **argv) * FIXME: This function should return void. */ int prepare_memory(void) { - /* Fill in prefix length cache */ - int i, j; - for (i = 0; i < 2; i++) { - for (j = 0; j < NUM_OF_PREFIX; j++) { - prefix_length[i][j] = strlen(prefixes[i][j]); - } - } config.dhcp_version = VERSION_UNKNOWN; RANGES = 64; num_ranges = num_shared_networks = 0; diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 3578319..7157a4f 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -210,8 +210,7 @@ void copy_ipaddr(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); const char *ntop_ipaddr(const union ipaddr_t *ip); double get_range_size(const struct range_t *r); -int xstrstr(const char *__restrict a, const char *__restrict b, int len) - __attribute__ ((nonnull(1, 2))) +int xstrstr(const char *__restrict str) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((__hot__)) # endif diff --git a/src/getdata.c b/src/getdata.c index 38d9e74..8b411f4 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -101,62 +101,52 @@ int parse_leases(void) ethernets = true; } - const char **p = prefixes[config.dhcp_version]; - int *l = prefix_length[config.dhcp_version]; - -/*! \def HAS_PREFIX(line, type) - * \brief A macro to match IPv4 and IPv6 lease lines. - * - * FIXME: This macro should have better name. The HAS_PREFIX sounds like - * some sort of prefix length test. */ -#define HAS_PREFIX(line, type) xstrstr((line), p[type], l[type]) - while (!feof(dhcpd_leases)) { if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) { err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); } + switch(xstrstr(line)) { /* It's a lease, save IP */ - if (HAS_PREFIX(line, PREFIX_LEASE)) { - nth_field(ipstring, line + l[PREFIX_LEASE]); + case PREFIX_LEASE: + nth_field(ipstring, line + (config.dhcp_version == VERSION_4 ? 6 : 9)); parse_ipaddr(ipstring, &addr); - continue; - } - if (HAS_PREFIX(line, PREFIX_BINDING_STATE_FREE) || - HAS_PREFIX(line, PREFIX_BINDING_STATE_ABANDONED) || - HAS_PREFIX(line, PREFIX_BINDING_STATE_EXPIRED) || - HAS_PREFIX(line, PREFIX_BINDING_STATE_RELEASED)) { - /* remove old entry, if exists */ + break; + case PREFIX_BINDING_STATE_FREE: + case PREFIX_BINDING_STATE_ABANDONED: + case PREFIX_BINDING_STATE_EXPIRED: + case PREFIX_BINDING_STATE_RELEASED: if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } add_lease(&addr, FREE); - continue; - } - /* Copy IP to correct array */ - if (HAS_PREFIX(line, PREFIX_BINDING_STATE_ACTIVE)) { + break; + case PREFIX_BINDING_STATE_ACTIVE: /* remove old entry, if exists */ if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } add_lease(&addr, ACTIVE); - continue; - } - if (HAS_PREFIX(line, PREFIX_BINDING_STATE_BACKUP)) { + break; + case PREFIX_BINDING_STATE_BACKUP: /* remove old entry, if exists */ if ((lease = find_lease(&addr)) != NULL) { delete_lease(lease); } add_lease(&addr, BACKUP); config.backups_found = true; - continue; - } - if (ethernets && (xstrstr(line, " hardware ethernet", 19))) { + break; + case PREFIX_HARDWARE_ETHERNET: + if (ethernets == false) + break; nth_field(macstring, line + 20); macstring[17] = '\0'; if ((lease = find_lease(&addr)) != NULL) { lease->ethernet = xstrdup(macstring); } + break; + default: + /* do nothing */; } } #undef HAS_PREFIX diff --git a/src/other.c b/src/other.c index e31b3bb..a45352c 100644 --- a/src/other.c +++ b/src/other.c @@ -148,53 +148,103 @@ double get_range_size(const struct range_t *r) } } -/*! \fn xstrstr(const char *restrict a, const char *restrict b, const int len) - * \brief Compare two strings. Similar to strcmp, but tuned to be - * quicker which is possible because input data is known to have certain - * structure. +/*! \fn xstrstr(const char *restrict str) + * \brief Categorize dhcpd.leases line. * - * \param a String which is been compared, e.g., a haystack. - * \param b Constant string which is hoped to found, e.g., a needle. - * \param len Stop point in characters when comparison must be ended. - * \return Zero if strings differ, one if they are the same. */ + * \param str A line from dhcpd.conf + * \return prefix_t enum value + */ int #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((hot)) #endif - xstrstr(const char *restrict a, const char *restrict b, const int len) + xstrstr(const char *restrict str) { - int i; - + size_t len; /* Needed when dhcpd.conf has zero range definitions. */ if (config.dhcp_version == VERSION_UNKNOWN) { - if (!strcmp(prefixes[VERSION_4][PREFIX_LEASE], a)) { + if (strncmp("lease ", str, 6)) { config.dhcp_version = VERSION_4; - return true; - } - if (!strcmp(prefixes[VERSION_6][PREFIX_LEASE], a)) { + return PREFIX_LEASE; + } else if (strncmp(" iaaddr ", str, 9)) { config.dhcp_version = VERSION_6; - return true; + return PREFIX_LEASE; } - return false; + return NUM_OF_PREFIX; } - - /* two spaces are very common in lease file, after them - * nearly everything differs */ - if (likely(a[2] != b[2])) { - return false; + if ((config.dhcp_version == VERSION_4 && str[2] == 'b') + || (config.dhcp_version == VERSION_6 && str[4] == 'b') + || str[2] == 'h') { + len = strlen(str); + } else { + len = 0; } - /* " binding state " == 16 chars, this will skip right - * to first differing line. */ - if (17 < len && a[17] != b[17]) { - return false; - } - /* looking good, double check the whole thing... */ - for (i = 0; a[i] != '\0' && b[i] != '\0'; i++) { - if (a[i] != b[i]) { - return false; + if (15 < len && config.dhcp_version == VERSION_4) { + switch (str[16]) { + case 'f': + if (!strncmp(" binding state free;", str, 21)) + return PREFIX_BINDING_STATE_FREE; + break; + case 'a': + if (!strncmp(" binding state active;", str, 23)) + return PREFIX_BINDING_STATE_ACTIVE; + if (!strncmp(" binding state abandoned;", str, 25)) + return PREFIX_BINDING_STATE_ABANDONED; + break; + case 'e': + if (!strncmp(" binding state expired;", str, 24)) + return PREFIX_BINDING_STATE_EXPIRED; + break; + case 'r': + if (!strncmp(" binding state released;", str, 25)) + return PREFIX_BINDING_STATE_RELEASED; + break; + case 'b': + if (!strncmp(" binding state backup;", str, 23)) + return PREFIX_BINDING_STATE_BACKUP; + break; + case 'n': + if (!strncmp(" hardware ethernet", str, 19)) + return PREFIX_HARDWARE_ETHERNET; + break; + } + } else if (17 < len /* && config.dhcp_version == VERSION_6 */ ) { + switch (str[18]) { + case 'f': + if (!strncmp(" binding state free;", str, 23)) + return PREFIX_BINDING_STATE_FREE; + break; + case 'a': + if (!strncmp(" binding state active;", str, 25)) + return PREFIX_BINDING_STATE_ACTIVE; + if (!strncmp(" binding state abandoned;", str, 27)) + return PREFIX_BINDING_STATE_ABANDONED; + break; + case 'e': + if (!strncmp(" binding state expired;", str, 26)) + return PREFIX_BINDING_STATE_EXPIRED; + break; + case 'r': + if (!strncmp(" binding state released;", str, 27)) + return PREFIX_BINDING_STATE_RELEASED; + break; + case 'b': + if (!strncmp(" binding state backup;", str, 25)) + return PREFIX_BINDING_STATE_BACKUP; + break; + case 'n': + if (!strncmp(" hardware ethernet", str, 19)) + return PREFIX_HARDWARE_ETHERNET; + break; } } - return true; + if (config.dhcp_version == VERSION_4 && !strncmp("lease ", str, 6)) { + return PREFIX_LEASE; + } else if (config.dhcp_version == VERSION_6 + && !strncmp(" iaaddr ", str, 9)) { + return PREFIX_LEASE; + } + return NUM_OF_PREFIX; } /*! \brief Return a double floating point value. From 47582ed8d8715704d82faa7ddb15d54764d047b3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 2 Sep 2013 22:21:32 +0100 Subject: [PATCH 079/313] other: memcmp() is tiny bit quicker than strncmp() With the large input samples I have use of memcmp makes run to take about 2-3% less time. Signed-off-by: Sami Kerola --- src/other.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/other.c b/src/other.c index a45352c..76571e0 100644 --- a/src/other.c +++ b/src/other.c @@ -163,10 +163,10 @@ int size_t len; /* Needed when dhcpd.conf has zero range definitions. */ if (config.dhcp_version == VERSION_UNKNOWN) { - if (strncmp("lease ", str, 6)) { + if (memcmp("lease ", str, 6)) { config.dhcp_version = VERSION_4; return PREFIX_LEASE; - } else if (strncmp(" iaaddr ", str, 9)) { + } else if (memcmp(" iaaddr ", str, 9)) { config.dhcp_version = VERSION_6; return PREFIX_LEASE; } @@ -182,66 +182,66 @@ int if (15 < len && config.dhcp_version == VERSION_4) { switch (str[16]) { case 'f': - if (!strncmp(" binding state free;", str, 21)) + if (!memcmp(" binding state free;", str, 21)) return PREFIX_BINDING_STATE_FREE; break; case 'a': - if (!strncmp(" binding state active;", str, 23)) + if (!memcmp(" binding state active;", str, 23)) return PREFIX_BINDING_STATE_ACTIVE; - if (!strncmp(" binding state abandoned;", str, 25)) + if (!memcmp(" binding state abandoned;", str, 25)) return PREFIX_BINDING_STATE_ABANDONED; break; case 'e': - if (!strncmp(" binding state expired;", str, 24)) + if (!memcmp(" binding state expired;", str, 24)) return PREFIX_BINDING_STATE_EXPIRED; break; case 'r': - if (!strncmp(" binding state released;", str, 25)) + if (!memcmp(" binding state released;", str, 25)) return PREFIX_BINDING_STATE_RELEASED; break; case 'b': - if (!strncmp(" binding state backup;", str, 23)) + if (!memcmp(" binding state backup;", str, 23)) return PREFIX_BINDING_STATE_BACKUP; break; case 'n': - if (!strncmp(" hardware ethernet", str, 19)) + if (!memcmp(" hardware ethernet", str, 19)) return PREFIX_HARDWARE_ETHERNET; break; } } else if (17 < len /* && config.dhcp_version == VERSION_6 */ ) { switch (str[18]) { case 'f': - if (!strncmp(" binding state free;", str, 23)) + if (!memcmp(" binding state free;", str, 23)) return PREFIX_BINDING_STATE_FREE; break; case 'a': - if (!strncmp(" binding state active;", str, 25)) + if (!memcmp(" binding state active;", str, 25)) return PREFIX_BINDING_STATE_ACTIVE; - if (!strncmp(" binding state abandoned;", str, 27)) + if (!memcmp(" binding state abandoned;", str, 27)) return PREFIX_BINDING_STATE_ABANDONED; break; case 'e': - if (!strncmp(" binding state expired;", str, 26)) + if (!memcmp(" binding state expired;", str, 26)) return PREFIX_BINDING_STATE_EXPIRED; break; case 'r': - if (!strncmp(" binding state released;", str, 27)) + if (!memcmp(" binding state released;", str, 27)) return PREFIX_BINDING_STATE_RELEASED; break; case 'b': - if (!strncmp(" binding state backup;", str, 25)) + if (!memcmp(" binding state backup;", str, 25)) return PREFIX_BINDING_STATE_BACKUP; break; case 'n': - if (!strncmp(" hardware ethernet", str, 19)) + if (!memcmp(" hardware ethernet", str, 19)) return PREFIX_HARDWARE_ETHERNET; break; } } - if (config.dhcp_version == VERSION_4 && !strncmp("lease ", str, 6)) { + if (config.dhcp_version == VERSION_4 && !memcmp("lease ", str, 6)) { return PREFIX_LEASE; } else if (config.dhcp_version == VERSION_6 - && !strncmp(" iaaddr ", str, 9)) { + && !memcmp(" iaaddr ", str, 9)) { return PREFIX_LEASE; } return NUM_OF_PREFIX; From e8f8c0497924718b28c55b23cfa2389b71017441 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 7 Sep 2013 16:39:23 +0100 Subject: [PATCH 080/313] build-sys: update gnulib modules Signed-off-by: Sami Kerola --- bootstrap.conf | 2 +- lib/.gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index dcb0617..bb1840d 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -25,7 +25,6 @@ gnulib_modules=" fdopen fflush fopen - free getopt-gnu inet_pton langinfo @@ -36,6 +35,7 @@ gnulib_modules=" stddef stdio stdlib + stpncpy strdup-posix strftime strstr diff --git a/lib/.gitignore b/lib/.gitignore index 3ce8e00..f22ede0 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -139,3 +139,4 @@ /xprintf.h /xstrtod.c /xstrtod.h +/stpncpy.c From 7c872ef8d79edbb97b904148ff37b205857f70e6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 7 Sep 2013 16:56:46 +0100 Subject: [PATCH 081/313] build-sys: AC_PROG_CC_C99 is obsolete; use AC_PROG_CC Reference: http://lists.gnu.org/archive/html/autoconf-commit/2012-10/msg00001.html Signed-off-by: Sami Kerola --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8f71ab4..ae5bd63 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ AC_CONFIG_HEADERS([config.h]) # Checks for programs AC_USE_SYSTEM_EXTENSIONS AC_C_RESTRICT -AC_PROG_CC_C99 +AC_PROG_CC gl_EARLY gl_INIT AC_PROG_MAKE_SET From 20ec1c2b42dbef01e4a996e9b450274518564bf3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 10 Sep 2013 21:36:46 +0100 Subject: [PATCH 082/313] getdata: use correct file caching advice The POSIX_FADV_NOREUSE is more appropriate considering dhcpd-pools may need cache, but not necessarily. Reference: http://lwn.net/Articles/449420/ Signed-off-by: Sami Kerola --- src/getdata.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/getdata.c b/src/getdata.c index 8b411f4..b4a6763 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -73,12 +73,12 @@ int parse_leases(void) err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); } #ifdef HAVE_POSIX_FADVISE -# ifdef POSIX_FADV_WILLNEED - if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_WILLNEED) != 0) { +# ifdef POSIX_FADV_NOREUSE + if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) { err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); } -# endif /* POSIX_FADV_WILLNEED */ +# endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { err(EXIT_FAILURE, "parse_leases: fadvise %s", @@ -215,11 +215,11 @@ void parse_config(int is_include, const char *restrict config_file, if (dhcpd_config == NULL) { err(EXIT_FAILURE, "parse_config: %s", config_file); } -#ifdef POSIX_FADV_WILLNEED - if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_WILLNEED) != 0) { +#ifdef POSIX_FADV_NOREUSE + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); } -#endif /* POSIX_FADV_WILLNEED */ +#endif /* POSIX_FADV_NOREUSE */ #ifdef POSIX_FADV_SEQUENTIAL if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); From 5189333c956bbb27fed6f13b262afa3116b6ac3d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 17 Sep 2013 22:58:53 +0100 Subject: [PATCH 083/313] analyze: remove unnecessary function Signed-off-by: Sami Kerola --- src/analyze.c | 2 +- src/dhcpd-pools.h | 1 - src/sort.c | 11 ----------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/analyze.c b/src/analyze.c index 0b0939e..71c48d0 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -51,7 +51,7 @@ int prepare_data(void) { /* Sort leases */ - HASH_SORT(leases, leasecomp); + HASH_SORT(leases, ipcomp); /* Sort ranges */ qsort(ranges, (size_t)num_ranges, sizeof(struct range_t), &rangecomp); return 0; diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 7157a4f..288f3c3 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -230,7 +230,6 @@ int comp_percent(struct range_t *r1, struct range_t *r2); int comp_tc(struct range_t *r1, struct range_t *r2); int comp_tcperc(struct range_t *r1, struct range_t *r2); int comp_touched(struct range_t *r1, struct range_t *r2); -int leasecomp(const void *restrict a, const void *restrict b); int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ diff --git a/src/sort.c b/src/sort.c index 5a2a4e1..badb2ab 100644 --- a/src/sort.c +++ b/src/sort.c @@ -67,17 +67,6 @@ int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) } } -/*! \brief Compare IP address in leases. Suitable for sorting leases. - * \param a A lease structure. - * \param b A lease structure. - * \return Return pas through from ipcomp. - */ -int leasecomp(const void *restrict a, const void *restrict b) -{ - return ipcomp(&((const struct leases_t *)a)->ip, - &((const struct leases_t *)b)->ip); -} - /*! \brief Compare IP address in leases. Suitable for sorting range table. * \param r1 A range structure. * \param r2 A range structure. From 5b8ad97611bd4b47d5f5dcaa13cfe4eb5f57b1f6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 18 Sep 2013 00:05:16 +0100 Subject: [PATCH 084/313] getdata: memccpy() is better than own similar function The memccpy() is maintained in libc so there is no reason to reimplement similar functionality within this software. Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 6 ------ src/getdata.c | 27 +++++++-------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 288f3c3..8d90caf 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -193,12 +193,6 @@ int parse_leases(void); void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) __attribute__ ((nonnull(2, 3))); -void nth_field(char *__restrict dest, const char *__restrict src) - __attribute__ ((nonnull(1, 2))) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) - __attribute__ ((__hot__)) -# endif - ; int prepare_data(void); int do_counting(void); void flip_ranges(struct range_t *__restrict ranges, diff --git a/src/getdata.c b/src/getdata.c index b4a6763..89c2d5b 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -62,7 +62,7 @@ int parse_leases(void) { FILE *dhcpd_leases; - char *line, *ipstring, macstring[20]; + char *line, *ipstring, macstring[20], *stop; union ipaddr_t addr; struct stat lease_file_stats; bool ethernets = false; @@ -109,7 +109,11 @@ int parse_leases(void) switch(xstrstr(line)) { /* It's a lease, save IP */ case PREFIX_LEASE: - nth_field(ipstring, line + (config.dhcp_version == VERSION_4 ? 6 : 9)); + stop = memccpy(ipstring, line + (config.dhcp_version == VERSION_4 ? 6 : 9), ' ', strlen(line)); + if (stop != NULL) { + --stop; + *stop = '\0'; + } parse_ipaddr(ipstring, &addr); break; case PREFIX_BINDING_STATE_FREE: @@ -139,7 +143,7 @@ int parse_leases(void) case PREFIX_HARDWARE_ETHERNET: if (ethernets == false) break; - nth_field(macstring, line + 20); + memcpy(macstring, line + 20, 17); macstring[17] = '\0'; if ((lease = find_lease(&addr)) != NULL) { lease->ethernet = xstrdup(macstring); @@ -156,23 +160,6 @@ int parse_leases(void) return 0; } -/*! \brief A version of strcpy, but for a white space separated field. - * \param dest String copy destination. - * \param src String copy source. - */ -void nth_field(char *restrict dest, const char *restrict src) -{ - size_t i, len; - len = strlen(src); - for (i = 0; i < len; i++) { - dest[i] = src[i]; - if (unlikely(src[i] == ' ')) { - dest[i] = '\0'; - break; - } - } -} - /*! \brief Keyword search in dhcpd.conf file. * \param s A line from the dhcpd.conf file. * \return Indicator what configuration was found. */ From 97c6f0292f8ae37e7fe3ac38aeb1ef502dd097f4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 18 Sep 2013 00:35:33 +0100 Subject: [PATCH 085/313] getdata: split busy function to segments used via function pointer When it is known IPv4 is in use there is no need to spend time with if statements checking whether IPv6 is in use. Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 1 + src/dhcpd-pools.h | 14 +++++++- src/other.c | 82 ++++++++++++++++++++++++++++++++++------------- 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index d37d0d0..692c4ff 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -248,6 +248,7 @@ int main(int argc, char **argv) /* Do the job */ prepare_memory(); + xstrstr = xstrstr_init; parse_config(true, config.dhcpdconf_file, shared_networks); parse_leases(); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 8d90caf..5068380 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -204,11 +204,23 @@ void copy_ipaddr(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); const char *ntop_ipaddr(const union ipaddr_t *ip); double get_range_size(const struct range_t *r); -int xstrstr(const char *__restrict str) +int (*xstrstr)(const char *__restrict str); +int xstrstr_init(const char *__restrict str) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((__hot__)) # endif ; +int xstrstr_v4(const char *__restrict str) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) + __attribute__ ((__hot__)) +# endif + ; +int xstrstr_v6(const char *__restrict str) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) + __attribute__ ((__hot__)) +# endif + ; + double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); void print_version(void) __attribute__ ((noreturn)); diff --git a/src/other.c b/src/other.c index 76571e0..4e56e86 100644 --- a/src/other.c +++ b/src/other.c @@ -68,8 +68,10 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) struct in6_addr addr6; if (inet_aton(src, &addr) == 1) { config.dhcp_version = VERSION_4; + xstrstr = xstrstr_v4; } else if (inet_pton(AF_INET6, src, &addr6) == 1) { config.dhcp_version = VERSION_6; + xstrstr = xstrstr_v6; } else { return 0; } @@ -148,8 +150,9 @@ double get_range_size(const struct range_t *r) } } -/*! \fn xstrstr(const char *restrict str) - * \brief Categorize dhcpd.leases line. +/*! \fn xstrstr_init(const char *restrict str) + * \brief Determine if the dhcpd is in IPv4 or IPv6 mode. This function + * may be needed when dhcpd.conf file has zero IP version hints. * * \param str A line from dhcpd.conf * \return prefix_t enum value @@ -158,28 +161,39 @@ int #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) __attribute__ ((hot)) #endif - xstrstr(const char *restrict str) + xstrstr_init(const char *restrict str) +{ + if (memcmp("lease ", str, 6)) { + config.dhcp_version = VERSION_4; + xstrstr = xstrstr_v4; + return PREFIX_LEASE; + } else if (memcmp(" iaaddr ", str, 9)) { + config.dhcp_version = VERSION_6; + xstrstr = xstrstr_v6; + return PREFIX_LEASE; + } + return NUM_OF_PREFIX; +} + +/*! \fn xstrstr_v4(const char *restrict str) + * \brief parse lease file in IPv4 mode + * + * \param str A line from dhcpd.conf + * \return prefix_t enum value + */ +int +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) + __attribute__ ((hot)) +#endif + xstrstr_v4(const char *restrict str) { size_t len; - /* Needed when dhcpd.conf has zero range definitions. */ - if (config.dhcp_version == VERSION_UNKNOWN) { - if (memcmp("lease ", str, 6)) { - config.dhcp_version = VERSION_4; - return PREFIX_LEASE; - } else if (memcmp(" iaaddr ", str, 9)) { - config.dhcp_version = VERSION_6; - return PREFIX_LEASE; - } - return NUM_OF_PREFIX; - } - if ((config.dhcp_version == VERSION_4 && str[2] == 'b') - || (config.dhcp_version == VERSION_6 && str[4] == 'b') - || str[2] == 'h') { + if (str[2] == 'b' || str[2] == 'h') { len = strlen(str); } else { len = 0; } - if (15 < len && config.dhcp_version == VERSION_4) { + if (15 < len) { switch (str[16]) { case 'f': if (!memcmp(" binding state free;", str, 21)) @@ -208,7 +222,32 @@ int return PREFIX_HARDWARE_ETHERNET; break; } - } else if (17 < len /* && config.dhcp_version == VERSION_6 */ ) { + } + if (!memcmp("lease ", str, 6)) { + return PREFIX_LEASE; + } + return NUM_OF_PREFIX; +} + +/*! \fn xstrstr_v4(const char *restrict str) + * \brief parse lease file in IPv6 mode + * + * \param str A line from dhcpd.conf + * \return prefix_t enum value + */ +int +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) + __attribute__ ((hot)) +#endif + xstrstr_v6(const char *restrict str) +{ + size_t len; + if (str[4] == 'b' || str[2] == 'h') { + len = strlen(str); + } else { + len = 0; + } + if (17 < len) { switch (str[18]) { case 'f': if (!memcmp(" binding state free;", str, 23)) @@ -238,10 +277,7 @@ int break; } } - if (config.dhcp_version == VERSION_4 && !memcmp("lease ", str, 6)) { - return PREFIX_LEASE; - } else if (config.dhcp_version == VERSION_6 - && !memcmp(" iaaddr ", str, 9)) { + if (!memcmp(" iaaddr ", str, 9)) { return PREFIX_LEASE; } return NUM_OF_PREFIX; From 8da98bbc89494a5069f2b9c9051b3904df095ac7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 21 Sep 2013 11:38:24 +0100 Subject: [PATCH 086/313] various: split functions to IPv4 and IPv6 versions The code selection will be set with function pointer, which avoids numerous IP version checks. As a result with some inputs the analysis runs quicker. Most users will not notice much of difference. Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 2 +- src/dhcpd-pools.h | 44 +++++++++-- src/hash.c | 41 +++++++--- src/other.c | 188 ++++++++++++++++++++++++++++++++-------------- src/sort.c | 29 ++++--- 5 files changed, 215 insertions(+), 89 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 692c4ff..c50fcfb 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -248,7 +248,7 @@ int main(int argc, char **argv) /* Do the job */ prepare_memory(); - xstrstr = xstrstr_init; + set_ipv_functions(VERSION_UNKNOWN); parse_config(true, config.dhcpdconf_file, shared_networks); parse_leases(); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 5068380..29d5e4c 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -189,6 +189,7 @@ unsigned int RANGES; /* Function prototypes */ int prepare_memory(void); +void set_ipv_functions(int version); int parse_leases(void); void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) @@ -199,11 +200,26 @@ void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ -int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst); -void copy_ipaddr(union ipaddr_t *restrict dst, - const union ipaddr_t *restrict src); -const char *ntop_ipaddr(const union ipaddr_t *ip); -double get_range_size(const struct range_t *r); +int (*parse_ipaddr)(const char *restrict src, union ipaddr_t *restrict dst); +int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst); +int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst); +int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst); + +void (*copy_ipaddr)(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +void copy_ipaddr_init(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); + +const char *(*ntop_ipaddr)(const union ipaddr_t *ip); +const char *ntop_ipaddr_init(const union ipaddr_t *ip); +const char *ntop_ipaddr_v4(const union ipaddr_t *ip); +const char *ntop_ipaddr_v6(const union ipaddr_t *ip); + +double (*get_range_size)(const struct range_t *r); +double get_range_size_init(const struct range_t *r); +double get_range_size_v4(const struct range_t *r); +double get_range_size_v6(const struct range_t *r); + int (*xstrstr)(const char *__restrict str); int xstrstr_init(const char *__restrict str) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) @@ -227,7 +243,11 @@ void print_version(void) __attribute__ ((noreturn)); void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ -int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int (*ipcomp)(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int ipcomp_init(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); + int comp_cur(struct range_t *r1, struct range_t *r2); int comp_double(double f1, double f2); int comp_ip(struct range_t *r1, struct range_t *r2); @@ -258,8 +278,16 @@ int output_alarming(void); /* Memory release, file closing etc */ void clean_up(void); /* Hash functions */ -void add_lease(union ipaddr_t *ip, enum ltype type); -struct leases_t *find_lease(union ipaddr_t *ip); +void (*add_lease)(union ipaddr_t *ip, enum ltype type); +void add_lease_init(union ipaddr_t *ip, enum ltype type); +void add_lease_v4(union ipaddr_t *ip, enum ltype type); +void add_lease_v6(union ipaddr_t *ip, enum ltype type); + +struct leases_t *(*find_lease)(union ipaddr_t *ip); +struct leases_t *find_lease_init(union ipaddr_t *ip); +struct leases_t *find_lease_v4(union ipaddr_t *ip); +struct leases_t *find_lease_v6(union ipaddr_t *ip); + void delete_lease(struct leases_t *lease); void delete_all_leases(void); diff --git a/src/hash.c b/src/hash.c index d9a1d77..d598b74 100644 --- a/src/hash.c +++ b/src/hash.c @@ -47,17 +47,27 @@ /*! \brief Add a lease to hash array. * \param addr Binary IP to be added in leases hash. * \param type Lease state of the IP. */ -void add_lease(union ipaddr_t *addr, enum ltype type) +void add_lease_init(union ipaddr_t *addr __attribute__((unused)), enum ltype type __attribute__((unused))) +{ +} + +void add_lease_v4(union ipaddr_t *addr, enum ltype type) { struct leases_t *l; l = xmalloc(sizeof(struct leases_t)); copy_ipaddr(&l->ip, addr); l->type = type; - if (config.dhcp_version == VERSION_6) { - HASH_ADD_V6(leases, ip.v6, l); - } else { - HASH_ADD_INT(leases, ip.v4, l); - } + HASH_ADD_INT(leases, ip.v4, l); + l->ethernet = NULL; +} + +void add_lease_v6(union ipaddr_t *addr, enum ltype type) +{ + struct leases_t *l; + l = xmalloc(sizeof(struct leases_t)); + copy_ipaddr(&l->ip, addr); + l->type = type; + HASH_ADD_V6(leases, ip.v6, l); l->ethernet = NULL; } @@ -65,15 +75,22 @@ void add_lease(union ipaddr_t *addr, enum ltype type) * \param addr Binary IP searched from leases hash. * \return A lease structure about requested IP, or NULL. */ -struct leases_t *find_lease(union ipaddr_t *addr) +struct leases_t *find_lease_init(union ipaddr_t *addr __attribute__((unused))) +{ + return NULL; +} + +struct leases_t *find_lease_v4(union ipaddr_t *addr) { struct leases_t *l; + HASH_FIND_INT(leases, &addr->v4, l); + return l; +} - if (config.dhcp_version == VERSION_6) { - HASH_FIND_V6(leases, &addr->v6, l); - } else { - HASH_FIND_INT(leases, &addr->v4, l); - } +struct leases_t *find_lease_v6(union ipaddr_t *addr) +{ + struct leases_t *l; + HASH_FIND_V6(leases, &addr->v4, l); return l; } diff --git a/src/other.c b/src/other.c index 4e56e86..75158a0 100644 --- a/src/other.c +++ b/src/other.c @@ -55,36 +55,90 @@ #include #include +/*! \brief Set function pointers depending on IP version. + * \param ip IP version. + */ +void set_ipv_functions(int version) +{ + switch (version) { + + case VERSION_4: + config.dhcp_version = version; + add_lease = add_lease_v4; + copy_ipaddr = copy_ipaddr_v4; + find_lease = find_lease_v4; + get_range_size = get_range_size_v4; + ipcomp = ipcomp_v4; + ntop_ipaddr = ntop_ipaddr_v4; + parse_ipaddr = parse_ipaddr_v4; + xstrstr = xstrstr_v4; + break; + + case VERSION_6: + config.dhcp_version = version; + add_lease = add_lease_v6; + copy_ipaddr = copy_ipaddr_v6; + find_lease = find_lease_v6; + get_range_size = get_range_size_v6; + ipcomp = ipcomp_v6; + ntop_ipaddr = ntop_ipaddr_v6; + parse_ipaddr = parse_ipaddr_v6; + xstrstr = xstrstr_v6; + break; + + case VERSION_UNKNOWN: + config.dhcp_version = version; + add_lease = add_lease_init; + copy_ipaddr = copy_ipaddr_init; + find_lease = find_lease_init; + get_range_size = get_range_size_init; + ipcomp = ipcomp_init; + ntop_ipaddr = ntop_ipaddr_init; + parse_ipaddr = parse_ipaddr_init; + xstrstr = xstrstr_init; + break; + + default: + abort(); + + } + return; +} + /*! \brief Convert text string IP address from either IPv4 or IPv6 to an integer. * \param src An IP string in either format. * \param dst An union which will hold conversion result. * \return Was parsing successful. */ -int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) +int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst) +{ + struct in_addr addr; + struct in6_addr addr6; + if (inet_aton(src, &addr) == 1) { + set_ipv_functions(VERSION_4); + } else if (inet_pton(AF_INET6, src, &addr6) == 1) { + set_ipv_functions(VERSION_6); + } else { + return 0; + } + return parse_ipaddr(src, dst); +} + +int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst) { int rv; - if (config.dhcp_version == VERSION_UNKNOWN) { - struct in_addr addr; - struct in6_addr addr6; - if (inet_aton(src, &addr) == 1) { - config.dhcp_version = VERSION_4; - xstrstr = xstrstr_v4; - } else if (inet_pton(AF_INET6, src, &addr6) == 1) { - config.dhcp_version = VERSION_6; - xstrstr = xstrstr_v6; - } else { - return 0; - } - } - if (config.dhcp_version == VERSION_6) { - struct in6_addr addr; - rv = inet_pton(AF_INET6, src, &addr); - memcpy(&dst->v6, addr.s6_addr, sizeof(addr.s6_addr)); - } else { - struct in_addr addr; - rv = inet_aton(src, &addr); - dst->v4 = ntohl(addr.s_addr); - } + struct in_addr addr; + rv = inet_aton(src, &addr); + dst->v4 = ntohl(addr.s_addr); + return rv == 1; +} + +int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst) +{ + int rv; + struct in6_addr addr; + rv = inet_pton(AF_INET6, src, &addr); + memcpy(&dst->v6, addr.s6_addr, sizeof(addr.s6_addr)); return rv == 1; } @@ -92,14 +146,21 @@ int parse_ipaddr(const char *restrict src, union ipaddr_t *restrict dst) * * \param dst Destination for a binary IP address. * \param src Sourse of an IP address. */ -void copy_ipaddr(union ipaddr_t *restrict dst, +void copy_ipaddr_init(union ipaddr_t *restrict dst __attribute__((unused)), + const union ipaddr_t *restrict src __attribute__((unused))) +{ +} + +void copy_ipaddr_v4(union ipaddr_t *restrict dst, + const union ipaddr_t *restrict src) +{ + dst->v4 = src->v4; +} + +void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) { - if (config.dhcp_version == VERSION_6) { - memcpy(&dst->v6, &src->v6, sizeof(src->v6)); - } else { - dst->v4 = src->v4; - } + memcpy(&dst->v6, &src->v6, sizeof(src->v6)); } /*! \brief Convert an address to string. This function will convert the @@ -110,19 +171,27 @@ void copy_ipaddr(union ipaddr_t *restrict dst, * \param ip Binary IP address. * \return Printable address. */ -const char *ntop_ipaddr(const union ipaddr_t *ip) +const char *ntop_ipaddr_init(const union ipaddr_t *ip __attribute__((unused))) +{ + static char buffer = '\0'; + return &buffer; +} + +const char *ntop_ipaddr_v4(const union ipaddr_t *ip) +{ + static char buffer[sizeof("255.255.255.255")]; + struct in_addr addr; + addr.s_addr = htonl(ip->v4); + return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)); +} + +const char *ntop_ipaddr_v6(const union ipaddr_t *ip) { static char buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; - if (config.dhcp_version == VERSION_6) { - struct in6_addr addr; - memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); - return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); - } else { - struct in_addr addr; - addr.s_addr = htonl(ip->v4); - return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)); - } + struct in6_addr addr; + memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); + return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); } /*! \brief Calculate how many addresses there are in a range. @@ -131,23 +200,28 @@ const char *ntop_ipaddr(const union ipaddr_t *ip) * and last IP in the range. * \return Size of a range. */ -double get_range_size(const struct range_t *r) +double get_range_size_init(const struct range_t *r __attribute__((unused))) { - if (config.dhcp_version == VERSION_6) { - double size = 0; - int i; - /* When calculating the size of an IPv6 range overflow may - * occur. In that case only the last LONG_BIT bits are - * preserved, thus we just skip the first (16 - LONG_BIT) - * bits... */ - for (i = 0; i < 16; i++) { - size *= 256; - size += (int)r->last_ip.v6[i] - (int)r->first_ip.v6[i]; - } - return size + 1; - } else { - return r->last_ip.v4 - r->first_ip.v4 + 1; + return 0; +} + +double get_range_size_v4(const struct range_t *r) +{ + return r->last_ip.v4 - r->first_ip.v4 + 1; +} + +double get_range_size_v6(const struct range_t *r) +{ + double size = 0; + int i; + /* When calculating the size of an IPv6 range overflow may occur. + * In that case only the last LONG_BIT bits are preserved, thus + * we just skip the first (16 - LONG_BIT) bits... */ + for (i = 0; i < 16; i++) { + size *= 256; + size += (int)r->last_ip.v6[i] - (int)r->first_ip.v6[i]; } + return size + 1; } /*! \fn xstrstr_init(const char *restrict str) @@ -164,12 +238,10 @@ int xstrstr_init(const char *restrict str) { if (memcmp("lease ", str, 6)) { - config.dhcp_version = VERSION_4; - xstrstr = xstrstr_v4; + set_ipv_functions(VERSION_4); return PREFIX_LEASE; } else if (memcmp(" iaaddr ", str, 9)) { - config.dhcp_version = VERSION_6; - xstrstr = xstrstr_v6; + set_ipv_functions(VERSION_6); return PREFIX_LEASE; } return NUM_OF_PREFIX; diff --git a/src/sort.c b/src/sort.c index badb2ab..a2eaa18 100644 --- a/src/sort.c +++ b/src/sort.c @@ -54,17 +54,26 @@ * \param b Binary IP address. * \return If a < b return -1, if a < b return 1, when they are equal return 0. */ -int ipcomp(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) +int ipcomp_init(const union ipaddr_t *restrict a __attribute__((unused)), + const union ipaddr_t *restrict b __attribute__((unused))) { - if (config.dhcp_version == VERSION_6) { - return memcmp(&a->v6, &b->v6, sizeof(a->v6)); - } else { - if (a->v4 < b->v4) - return -1; - if (a->v4 > b->v4) - return 1; - return 0; - } + return 0; +} + +int ipcomp_v4(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) +{ + if (a->v4 < b->v4) + return -1; + if (a->v4 > b->v4) + return 1; + return 0; +} + +int ipcomp_v6(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) +{ + return memcmp(&a->v6, &b->v6, sizeof(a->v6)); } /*! \brief Compare IP address in leases. Suitable for sorting range table. From d2d8abd66012c4d046a3c116996d4d8d690f3ff3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 3 Nov 2013 14:28:42 +0000 Subject: [PATCH 087/313] various: fix memory leaks Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 2 ++ src/hash.c | 1 + src/other.c | 12 +++++++----- src/sort.c | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index c50fcfb..12c26ae 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -178,6 +178,7 @@ int main(int argc, char **argv) config.output_limit[i] = optarg[i] - '0'; } else { + clean_up(); errx(EXIT_FAILURE, "main: output mask `%s' is illegal", optarg); @@ -242,6 +243,7 @@ int main(int argc, char **argv) output_analysis = output_csv; break; default: + clean_up(); errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); } diff --git a/src/hash.c b/src/hash.c index d598b74..2f38550 100644 --- a/src/hash.c +++ b/src/hash.c @@ -109,6 +109,7 @@ void delete_all_leases(void) { struct leases_t *l, *tmp; HASH_ITER(hh, leases, l, tmp) { + free(l->ethernet); HASH_DEL(leases, l); free(l); } diff --git a/src/other.c b/src/other.c index 75158a0..b59e5fd 100644 --- a/src/other.c +++ b/src/other.c @@ -411,16 +411,18 @@ void clean_up(void) if (fflush(NULL)) { warn("clean_up: fflush"); } - num_shared_networks++; - for (i = 0; i < num_shared_networks; i++) { - free((shared_networks + i)->name); - } free(config.dhcpdconf_file); free(config.dhcpdlease_file); free(config.output_file); free(ranges); delete_all_leases(); - free(shared_networks); + if (shared_networks) { + num_shared_networks++; + for (i = 0; i < num_shared_networks; i++) { + free((shared_networks + i)->name); + } + free(shared_networks); + } } /*! \brief A version printing. */ diff --git a/src/sort.c b/src/sort.c index a2eaa18..a48b905 100644 --- a/src/sort.c +++ b/src/sort.c @@ -213,6 +213,7 @@ comparer_t field_selector(char c) case 'e': return comp_tcperc; default: + clean_up(); warnx("field_selector: unknown sort order `%c'", c); errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); From 6379ace9c71863e4008a930175d30502067df6d4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 3 Nov 2013 15:56:09 +0000 Subject: [PATCH 088/313] getdata: fix one ip ranges when they have trailing spaces in definition Ranges that defined single IP and followed each other, for example range 10.20.30.40 ; range 10.20.30.41 ; range 10.20.30.42 ; were misinterpreted, and every second (the .41 in example) were skipped. Signed-off-by: Sami Kerola --- src/getdata.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/getdata.c b/src/getdata.c index 89c2d5b..f9fa61f 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -250,11 +250,10 @@ void parse_config(int is_include, const char *restrict config_file, && argument != ITS_AN_INCLUCE) { newclause = true; i = 0; - } else if (argument == ITS_A_RANGE_FIRST_IP) { - one_ip_range = true; + } else if (argument == ITS_A_RANGE_FIRST_IP && one_ip_range == true) { argument = ITS_A_RANGE_SECOND_IP; c = ' '; - } else if (argument == ITS_A_RANGE_SECOND_IP) { + } else if (argument == ITS_A_RANGE_SECOND_IP && 0 < i) { /* Range ends to ; and this hair in code * make two ranges wrote together like... * @@ -262,6 +261,9 @@ void parse_config(int is_include, const char *restrict config_file, * * ...to be interpreted correctly. */ c = ' '; + } else if (argument == ITS_A_RANGE_SECOND_IP && i == 0) { + range_p->last_ip = range_p->first_ip; + goto newrange; } continue; case '{': @@ -310,8 +312,7 @@ void parse_config(int is_include, const char *restrict config_file, } /* Strip white spaces before new clause word. */ if ((newclause == true || argument != ITS_NOTHING_INTERESTING) - && isspace(c) - && i == 0) { + && isspace(c) && i == 0 && one_ip_range == false) { continue; } /* Save to word which clause this is. */ @@ -337,6 +338,9 @@ void parse_config(int is_include, const char *restrict config_file, } i = 0; argument = is_interesting_config_clause(word); + if (argument == ITS_A_RANGE_FIRST_IP) { + one_ip_range = true; + } } /* words after range, shared-network or include */ else if (argument != ITS_NOTHING_INTERESTING) { @@ -348,13 +352,14 @@ void parse_config(int is_include, const char *restrict config_file, case ITS_A_RANGE_SECOND_IP: /* printf ("range 2nd ip: %s\n", word); */ range_p = ranges + num_ranges; - parse_ipaddr(word, &addr); argument = ITS_NOTHING_INTERESTING; + parse_ipaddr(word, &addr); if (one_ip_range == true) { one_ip_range = false; copy_ipaddr(&range_p->first_ip, &addr); } copy_ipaddr(&range_p->last_ip, &addr); + newrange: range_p->count = 0; range_p->touched = 0; range_p->backups = 0; @@ -379,6 +384,7 @@ void parse_config(int is_include, const char *restrict config_file, break; } copy_ipaddr(&range_p->first_ip, &addr); + one_ip_range = false; argument = ITS_A_RANGE_SECOND_IP; break; case ITS_A_SHAREDNET: From 1eca3471963d5e0a94c58889493dbcd0c724c617 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 3 Nov 2013 16:53:49 +0000 Subject: [PATCH 089/313] release: 2.24 Signed-off-by: Sami Kerola --- NEWS | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/NEWS b/NEWS index 22a7fb0..b30ab7b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,32 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. + +Version 2.24 +$ git shortlog v2.23..v2.24 +Sami Kerola (22): + build-sys: update configure.ac + output: make output limits to apply to alarm return values + tests: add alarming tests + output: allow alarming, in case of success, be silent + tests: fix tests to use the new OK printing limit + docs: inform how the limits affect to printing when alarming is in use + output: allow user to ignore small ranges and shared networks + tests: test small network alarm ignoring + docs: add an example how to use limits with alarming + thanks: Dan Pritts + xstrstr: speed up analysis by avoiding string comparisons + other: memcmp() is tiny bit quicker than strncmp() + build-sys: update gnulib modules + build-sys: AC_PROG_CC_C99 is obsolete; use AC_PROG_CC + getdata: use correct file caching advice + analyze: remove unnecessary function + getdata: memccpy() is better than own similar function + getdata: split busy function to segments used via function pointer + various: split functions to IPv4 and IPv6 versions + various: fix memory leaks + getdata: fix one ip ranges when they have trailing spaces in definition + release: 2.24 Version 2.23 $ git shortlog v2.22..v2.23 From 631bf0bf7cb3af35f532ff124138a414c22ae610 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Nov 2013 19:19:27 +0000 Subject: [PATCH 090/313] build-sys: use more strict method to check __builtin_expect The problem with the detection of gcc's __builtin_expect, the autoconf set up uses EX_COMPILE_IFELSE which only compiles the test code with gcc -c, it does not link so a missing __builtin_expect is treated as a missing symbol and is not detected. Reported-by: Conor McCarthy Signed-off-by: Sami Kerola --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ae5bd63..e062c58 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ AC_CHECK_FUNCS([\ ]) AC_MSG_CHECKING([if the compiler supports __builtin_expect]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return __builtin_expect(1, 1) ? 1 : 0 ]])],[ have_builtin_expect=yes From 48caf5fb42385916be29efe67764577d0ec0bb6f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Nov 2013 19:21:19 +0000 Subject: [PATCH 091/313] getdata: add missing HAVE_POSIX_FADVISE protection Reported-by: Conor McCarthy Signed-off-by: Sami Kerola --- src/getdata.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/getdata.c b/src/getdata.c index f9fa61f..e93bbad 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -202,16 +202,18 @@ void parse_config(int is_include, const char *restrict config_file, if (dhcpd_config == NULL) { err(EXIT_FAILURE, "parse_config: %s", config_file); } -#ifdef POSIX_FADV_NOREUSE - if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); - } -#endif /* POSIX_FADV_NOREUSE */ -#ifdef POSIX_FADV_SEQUENTIAL - if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); - } -#endif /* POSIX_FADV_SEQUENTIAL */ +#ifdef HAVE_POSIX_FADVISE +# ifdef POSIX_FADV_NOREUSE +if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { + err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); +} +# endif /* POSIX_FADV_NOREUSE */ +# ifdef POSIX_FADV_SEQUENTIAL +if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { + err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); +} +# endif /* POSIX_FADV_SEQUENTIAL */ +#endif /* HAVE_POSIX_FADVISE */ /* Very hairy stuff begins. */ while (unlikely(!feof(dhcpd_config))) { From 7fc354827a4598adb008bc94f94d40fff111cd61 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Nov 2013 19:33:13 +0000 Subject: [PATCH 092/313] getdata: fix consecutive range definition regression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The added test demonstrates the issue. If a did not end with whitespace it was skipped. Reported-by: Fredrik Lysén Signed-off-by: Sami Kerola --- src/getdata.c | 1 + tests/Makemodule.am | 1 + tests/confs/one-line | 1 + tests/expected/one-line | 1 + tests/expected/simple | 3 ++- tests/leases/one-line | 1 + tests/one-line | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/confs/one-line create mode 120000 tests/expected/one-line create mode 120000 tests/leases/one-line create mode 120000 tests/one-line diff --git a/src/getdata.c b/src/getdata.c index e93bbad..cd99013 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -263,6 +263,7 @@ if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { * * ...to be interpreted correctly. */ c = ' '; + break; } else if (argument == ITS_A_RANGE_SECOND_IP && i == 0) { range_p->last_ip = range_p->first_ip; goto newrange; diff --git a/tests/Makemodule.am b/tests/Makemodule.am index d309b9b..f58a38f 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -14,6 +14,7 @@ TESTS = \ tests/full-json \ tests/leading0 \ tests/one-ip \ + tests/one-line \ tests/same-twice \ tests/simple \ tests/v6 diff --git a/tests/confs/one-line b/tests/confs/one-line new file mode 100644 index 0000000..2e25692 --- /dev/null +++ b/tests/confs/one-line @@ -0,0 +1 @@ +pool {range 10.0.0.1 10.0.0.5;range 10.0.0.6 10.0.0.10;} diff --git a/tests/expected/one-line b/tests/expected/one-line new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/expected/one-line @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/expected/simple b/tests/expected/simple index da14b05..f1af1ed 100644 --- a/tests/expected/simple +++ b/tests/expected/simple @@ -1,6 +1,7 @@ Ranges: shared net name first ip last ip max cur percent touch t+c t+c perc -All networks 10.0.0.1 - 10.0.0.10 10 10 100.000 0 10 100.000 +All networks 10.0.0.1 - 10.0.0.5 5 5 100.000 0 5 100.000 +All networks 10.0.0.6 - 10.0.0.10 5 5 100.000 0 5 100.000 Shared networks: name max cur percent touch t+c t+c perc diff --git a/tests/leases/one-line b/tests/leases/one-line new file mode 120000 index 0000000..8fd3246 --- /dev/null +++ b/tests/leases/one-line @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/one-line b/tests/one-line new file mode 120000 index 0000000..61a58b0 --- /dev/null +++ b/tests/one-line @@ -0,0 +1 @@ +test.sh \ No newline at end of file From 6b88e8d872f718c7932acfa3d8b225499205237b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Nov 2013 20:50:26 +0000 Subject: [PATCH 093/313] man: add tip analysis of include files can be useful MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: Fredrik Lysén Signed-off-by: Sami Kerola --- man/dhcpd-pools.1.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index 144eebb..28b2fc5 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -49,7 +49,9 @@ only if there is failover configuration. .SH OPTIONS .TP \fB\-c\fR, \fB\-\-config\fR=\fIFILE\fR -Path to the dhcpd.conf file. +Path to the dhcpd.conf file. If the dhcpd.conf has include files they +can be analysed separately, that can be useful when trying to understand +or monitor subset of data. .TP \fB\-l\fR, \fB\-\-leases\fR=\fIFILE\fR Path to the dhcpd.leases file. From affb3d70a3b13e23d85697340c91800e279bdcb9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 8 Nov 2013 21:01:21 +0000 Subject: [PATCH 094/313] =?UTF-8?q?thanks:=20add=20Fredrik=20Lys=C3=A9n=20?= =?UTF-8?q?&=20Conor=20McCarthy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sami Kerola --- THANKS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/THANKS b/THANKS index 64c70f5..8c18c15 100644 --- a/THANKS +++ b/THANKS @@ -29,3 +29,5 @@ Helmut Grohne Joey D. Ryan Steinmetz Dan Pritts +Fredrik Lysén +Conor McCarthy From d089a19fb52e8c598ea5c316fa9be08b7758e3f4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 17 Nov 2013 18:11:28 +0000 Subject: [PATCH 095/313] generic: use pure and const function attributes when possible Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 76 +++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 29d5e4c..b27b85b 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -64,6 +64,28 @@ # define unlikely(x) (x) # endif +/* The __attribute__ feature is available in gcc versions 2.5 and later. + * The attribute __pure__ was added in gcc 2.96. */ +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _DP_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _DP_ATTRIBUTE_PURE /* empty */ +# endif + +/* The __const__ attribute was added in gcc 2.95. */ +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +# define _DP_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _DP_ATTRIBUTE_CONST /* empty */ +# endif + +/* The attribute __hot__ was added in gcc 4.3. */ +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# define _DP_ATTRIBUTE_HOT __attribute__ ((__hot__)) +# else +# define _DP_ATTRIBUTE_HOT /* empty */ +# endif + /*! \union ipaddr_t * \brief Memory space for a binary IP address saving. */ union ipaddr_t { @@ -201,41 +223,29 @@ void flip_ranges(struct range_t *__restrict ranges, __attribute__ ((nonnull(1, 2))); /* support functions */ int (*parse_ipaddr)(const char *restrict src, union ipaddr_t *restrict dst); -int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst); +int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst) _DP_ATTRIBUTE_CONST; int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst); int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst); void (*copy_ipaddr)(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -void copy_ipaddr_init(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +void copy_ipaddr_init(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) _DP_ATTRIBUTE_CONST; void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); const char *(*ntop_ipaddr)(const union ipaddr_t *ip); -const char *ntop_ipaddr_init(const union ipaddr_t *ip); +const char *ntop_ipaddr_init(const union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; const char *ntop_ipaddr_v4(const union ipaddr_t *ip); const char *ntop_ipaddr_v6(const union ipaddr_t *ip); double (*get_range_size)(const struct range_t *r); -double get_range_size_init(const struct range_t *r); -double get_range_size_v4(const struct range_t *r); -double get_range_size_v6(const struct range_t *r); +double get_range_size_init(const struct range_t *r) _DP_ATTRIBUTE_CONST; +double get_range_size_v4(const struct range_t *r) _DP_ATTRIBUTE_PURE; +double get_range_size_v6(const struct range_t *r) _DP_ATTRIBUTE_PURE; int (*xstrstr)(const char *__restrict str); -int xstrstr_init(const char *__restrict str) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) - __attribute__ ((__hot__)) -# endif - ; -int xstrstr_v4(const char *__restrict str) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) - __attribute__ ((__hot__)) -# endif - ; -int xstrstr_v6(const char *__restrict str) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) - __attribute__ ((__hot__)) -# endif - ; +int xstrstr_init(const char *__restrict str) _DP_ATTRIBUTE_CONST; +int xstrstr_v4(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; +int xstrstr_v6(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); @@ -244,25 +254,25 @@ void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ int (*ipcomp)(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); -int ipcomp_init(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); -int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); -int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int ipcomp_init(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_CONST; +int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; -int comp_cur(struct range_t *r1, struct range_t *r2); -int comp_double(double f1, double f2); +int comp_cur(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; +int comp_double(double f1, double f2) _DP_ATTRIBUTE_CONST; int comp_ip(struct range_t *r1, struct range_t *r2); int comp_max(struct range_t *r1, struct range_t *r2); int comp_percent(struct range_t *r1, struct range_t *r2); -int comp_tc(struct range_t *r1, struct range_t *r2); +int comp_tc(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; int comp_tcperc(struct range_t *r1, struct range_t *r2); -int comp_touched(struct range_t *r1, struct range_t *r2); +int comp_touched(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ typedef int (*comparer_t) (struct range_t *r1, struct range_t *r2); comparer_t field_selector(char c); double ret_percent(struct range_t r); -double ret_tc(struct range_t r); +double ret_tc(struct range_t r) _DP_ATTRIBUTE_CONST; double ret_tcperc(struct range_t r); void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) @@ -279,14 +289,14 @@ int output_alarming(void); void clean_up(void); /* Hash functions */ void (*add_lease)(union ipaddr_t *ip, enum ltype type); -void add_lease_init(union ipaddr_t *ip, enum ltype type); +void add_lease_init(union ipaddr_t *ip, enum ltype type) _DP_ATTRIBUTE_CONST; void add_lease_v4(union ipaddr_t *ip, enum ltype type); void add_lease_v6(union ipaddr_t *ip, enum ltype type); struct leases_t *(*find_lease)(union ipaddr_t *ip); -struct leases_t *find_lease_init(union ipaddr_t *ip); -struct leases_t *find_lease_v4(union ipaddr_t *ip); -struct leases_t *find_lease_v6(union ipaddr_t *ip); +struct leases_t *find_lease_init(union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; +struct leases_t *find_lease_v4(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; +struct leases_t *find_lease_v6(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; void delete_lease(struct leases_t *lease); void delete_all_leases(void); From ca0b1c326246fc609390b6390ff4cc0e5d8caabc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 17 Nov 2013 18:39:47 +0000 Subject: [PATCH 096/313] tests: fix testing error The commit 7fc354827a4598adb008bc94f94d40fff111cd61 introduced an symlink that end up to update simple test causing it to break. Signed-off-by: Sami Kerola --- tests/expected/one-line | 12 +++++++++++- tests/expected/simple | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) mode change 120000 => 100644 tests/expected/one-line diff --git a/tests/expected/one-line b/tests/expected/one-line deleted file mode 120000 index 8fd3246..0000000 --- a/tests/expected/one-line +++ /dev/null @@ -1 +0,0 @@ -simple \ No newline at end of file diff --git a/tests/expected/one-line b/tests/expected/one-line new file mode 100644 index 0000000..f1af1ed --- /dev/null +++ b/tests/expected/one-line @@ -0,0 +1,11 @@ +Ranges: +shared net name first ip last ip max cur percent touch t+c t+c perc +All networks 10.0.0.1 - 10.0.0.5 5 5 100.000 0 5 100.000 +All networks 10.0.0.6 - 10.0.0.10 5 5 100.000 0 5 100.000 + +Shared networks: +name max cur percent touch t+c t+c perc + +Sum of all ranges: +name max cur percent touch t+c t+c perc +All networks 10 10 100.000 0 10 100.000 diff --git a/tests/expected/simple b/tests/expected/simple index f1af1ed..da14b05 100644 --- a/tests/expected/simple +++ b/tests/expected/simple @@ -1,7 +1,6 @@ Ranges: shared net name first ip last ip max cur percent touch t+c t+c perc -All networks 10.0.0.1 - 10.0.0.5 5 5 100.000 0 5 100.000 -All networks 10.0.0.6 - 10.0.0.10 5 5 100.000 0 5 100.000 +All networks 10.0.0.1 - 10.0.0.10 10 10 100.000 0 10 100.000 Shared networks: name max cur percent touch t+c t+c perc From f3e282f12296728cfc2d174b9d67713294976417 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 24 Mar 2014 21:07:55 +0000 Subject: [PATCH 097/313] output: make nagios output have performance data Just in case someone wants to graph what is going on. Reference: http://nagios.sourceforge.net/docs/3_0/pluginapi.html Signed-off-by: Sami Kerola --- src/output.c | 28 ++++++++++++++++++++-------- tests/expected/alarm-critical | 3 ++- tests/expected/alarm-critical-ranges | 3 ++- tests/expected/alarm-critical-snets | 2 +- tests/expected/alarm-ignore | 3 ++- tests/expected/alarm-ok | 3 ++- tests/expected/alarm-shared-ok | 2 +- tests/expected/alarm-warning | 3 ++- tests/expected/alarm-warning-ranges | 3 ++- tests/expected/alarm-warning-snets | 2 +- 10 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/output.c b/src/output.c index bc94b74..112819d 100644 --- a/src/output.c +++ b/src/output.c @@ -1072,32 +1072,44 @@ int output_alarming(void) } if ((0 < rc && config.output_limit[1] & BIT1) || (0 < sc && config.output_limit[1] & BIT2)) { ret_val = 2; - fprintf(outfile, "CRITICAL: %s: ", + fprintf(outfile, "CRITICAL: %s:", program_name); } else if ((0 < rw && config.output_limit[1] & BIT1) || (0 < sw && config.output_limit[1] & BIT2)) { ret_val = 1; - fprintf(outfile, "WARNING: %s: ", + fprintf(outfile, "WARNING: %s:", program_name); } else { ret_val = 0; if (config.output_limit[1] & BIT3) - fprintf(outfile, "OK: "); + fprintf(outfile, "OK:"); else return ret_val; } if (config.output_limit[0] & BIT1) { - fprintf(outfile, "Ranges; crit: %d warn: %d ok: %d ", rc, rw, + fprintf(outfile, " Ranges - crit: %d warn: %d ok: %d", rc, rw, ro); if (ri != 0) { - fprintf(outfile, "ignored: %d ", ri); + fprintf(outfile, " ignored: %d", ri); } - + fprintf(outfile, "; | range_crit=%d range_warn=%d range_ok=%d", rc, rw, + ro); + if (ri != 0) { + fprintf(outfile, " range_ignored=%d", ri); + } + fprintf(outfile, "\n"); + } else { + fprintf(outfile, " "); } if (config.output_limit[0] & BIT2) { - fprintf(outfile, "Shared nets; crit: %d warn: %d ok: %d", sc, + fprintf(outfile, "Shared nets - crit: %d warn: %d ok: %d", sc, sw, so); if (si != 0) { - fprintf(outfile, "ignored: %d ", si); + fprintf(outfile, " ignored: %d", si); + } + fprintf(outfile, "; | snet_crit=%d snet_warn=%d snet_ok=%d", sc, + sw, so); + if (si != 0) { + fprintf(outfile, " snet_ignored=%d\n", si); } } fprintf(outfile, "\n"); diff --git a/tests/expected/alarm-critical b/tests/expected/alarm-critical index fe0b242..1a26624 100644 --- a/tests/expected/alarm-critical +++ b/tests/expected/alarm-critical @@ -1,2 +1,3 @@ -CRITICAL: dhcpd-pools: Ranges; crit: 1 warn: 0 ok: 4 Shared nets; crit: 1 warn: 0 ok: 1 +CRITICAL: dhcpd-pools: Ranges - crit: 1 warn: 0 ok: 4; | range_crit=1 range_warn=0 range_ok=4 +Shared nets - crit: 1 warn: 0 ok: 1; | snet_crit=1 snet_warn=0 snet_ok=1 2 diff --git a/tests/expected/alarm-critical-ranges b/tests/expected/alarm-critical-ranges index fcb1833..ce1ca4d 100644 --- a/tests/expected/alarm-critical-ranges +++ b/tests/expected/alarm-critical-ranges @@ -1,2 +1,3 @@ -CRITICAL: dhcpd-pools: Ranges; crit: 1 warn: 0 ok: 4 +CRITICAL: dhcpd-pools: Ranges - crit: 1 warn: 0 ok: 4; | range_crit=1 range_warn=0 range_ok=4 + 2 diff --git a/tests/expected/alarm-critical-snets b/tests/expected/alarm-critical-snets index 8f2c02b..b85e2ee 100644 --- a/tests/expected/alarm-critical-snets +++ b/tests/expected/alarm-critical-snets @@ -1,2 +1,2 @@ -CRITICAL: dhcpd-pools: Shared nets; crit: 1 warn: 0 ok: 1 +CRITICAL: dhcpd-pools: Shared nets - crit: 1 warn: 0 ok: 1; | snet_crit=1 snet_warn=0 snet_ok=1 2 diff --git a/tests/expected/alarm-ignore b/tests/expected/alarm-ignore index 18ca9c6..6a20168 100644 --- a/tests/expected/alarm-ignore +++ b/tests/expected/alarm-ignore @@ -1 +1,2 @@ -OK: Ranges; crit: 0 warn: 0 ok: 0 ignored: 1 Shared nets; crit: 0 warn: 0 ok: 0 +OK: Ranges - crit: 0 warn: 0 ok: 0 ignored: 1; | range_crit=0 range_warn=0 range_ok=0 range_ignored=1 +Shared nets - crit: 0 warn: 0 ok: 0; | snet_crit=0 snet_warn=0 snet_ok=0 diff --git a/tests/expected/alarm-ok b/tests/expected/alarm-ok index 7137c5b..2c48043 100644 --- a/tests/expected/alarm-ok +++ b/tests/expected/alarm-ok @@ -1,2 +1,3 @@ -OK: Ranges; crit: 0 warn: 0 ok: 5 Shared nets; crit: 0 warn: 0 ok: 2 +OK: Ranges - crit: 0 warn: 0 ok: 5; | range_crit=0 range_warn=0 range_ok=5 +Shared nets - crit: 0 warn: 0 ok: 2; | snet_crit=0 snet_warn=0 snet_ok=2 0 diff --git a/tests/expected/alarm-shared-ok b/tests/expected/alarm-shared-ok index fb71df9..d34ec23 100644 --- a/tests/expected/alarm-shared-ok +++ b/tests/expected/alarm-shared-ok @@ -1,2 +1,2 @@ -OK: Shared nets; crit: 0 warn: 0 ok: 2 +OK: Shared nets - crit: 0 warn: 0 ok: 2; | snet_crit=0 snet_warn=0 snet_ok=2 0 diff --git a/tests/expected/alarm-warning b/tests/expected/alarm-warning index 1471296..0c597c1 100644 --- a/tests/expected/alarm-warning +++ b/tests/expected/alarm-warning @@ -1,2 +1,3 @@ -WARNING: dhcpd-pools: Ranges; crit: 0 warn: 1 ok: 4 Shared nets; crit: 0 warn: 1 ok: 1 +WARNING: dhcpd-pools: Ranges - crit: 0 warn: 1 ok: 4; | range_crit=0 range_warn=1 range_ok=4 +Shared nets - crit: 0 warn: 1 ok: 1; | snet_crit=0 snet_warn=1 snet_ok=1 1 diff --git a/tests/expected/alarm-warning-ranges b/tests/expected/alarm-warning-ranges index 82d97d9..94b1b98 100644 --- a/tests/expected/alarm-warning-ranges +++ b/tests/expected/alarm-warning-ranges @@ -1,2 +1,3 @@ -WARNING: dhcpd-pools: Ranges; crit: 0 warn: 1 ok: 4 +WARNING: dhcpd-pools: Ranges - crit: 0 warn: 1 ok: 4; | range_crit=0 range_warn=1 range_ok=4 + 1 diff --git a/tests/expected/alarm-warning-snets b/tests/expected/alarm-warning-snets index 636d947..39ad2f0 100644 --- a/tests/expected/alarm-warning-snets +++ b/tests/expected/alarm-warning-snets @@ -1,2 +1,2 @@ -WARNING: dhcpd-pools: Shared nets; crit: 0 warn: 1 ok: 1 +WARNING: dhcpd-pools: Shared nets - crit: 0 warn: 1 ok: 1; | snet_crit=0 snet_warn=1 snet_ok=1 1 From 5454ab70869cb1483a8f76a1a676ec844e655e93 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 24 Mar 2014 21:38:10 +0000 Subject: [PATCH 098/313] build-sys: update gitinore file Signed-off-by: Sami Kerola --- lib/.gitignore | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/.gitignore b/lib/.gitignore index f22ede0..8208f92 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,14 +1,14 @@ -/*.o /*.lo +/*.o /.deps/ /.gitignore~ /.libs/ -/arpa/ /Makefile /Makefile.am /Makefile.in /_Exit.c /arg-nonnull.h +/arpa/ /arpa_inet.in.h /atexit.c /c++defs.h @@ -57,6 +57,7 @@ /getopt1.c /getopt_int.h /gettext.h +/gettimeofday.c /inet_pton.c /intprops.h /langinfo.h @@ -99,6 +100,7 @@ /stdio.in.h /stdlib.h /stdlib.in.h +/stpncpy.c /str-two-way.h /strdup.c /streq.h @@ -115,6 +117,7 @@ /sys_socket.c /sys_socket.in.h /sys_stat.in.h +/sys_time.in.h /sys_types.in.h /sys_uio.in.h /time.h @@ -139,4 +142,3 @@ /xprintf.h /xstrtod.c /xstrtod.h -/stpncpy.c From eb559465952e3369a48bd1c8fab7a10b94f39848 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 24 Mar 2014 21:56:34 +0000 Subject: [PATCH 099/313] output: use symbolic exit values for nagios commands And ensure the exit values are set no matter how user will limit output. Signed-off-by: Sami Kerola --- src/dhcpd-pools.h | 7 +++++++ src/output.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index b27b85b..90582b5 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -191,6 +191,13 @@ enum limbits { BIT3 = 0x4 }; +/*! \def STATE_OK + * \brief Nagios alarm exit value. + */ +#define STATE_OK 0 +#define STATE_WARNING 1 +#define STATE_CRITICAL 2 + /* Global variables */ /* \var prefix_length Length of each prefix. */ int prefix_length[2][NUM_OF_PREFIX]; diff --git a/src/output.c b/src/output.c index 112819d..6720e13 100644 --- a/src/output.c +++ b/src/output.c @@ -1070,16 +1070,21 @@ int output_alarming(void) shared_p++; } } + + if (sc || rc) + ret_val = STATE_CRITICAL; + else if (sw || rw) + ret_val = STATE_WARNING; + else + ret_val = STATE_OK; + if ((0 < rc && config.output_limit[1] & BIT1) || (0 < sc && config.output_limit[1] & BIT2)) { - ret_val = 2; fprintf(outfile, "CRITICAL: %s:", program_name); } else if ((0 < rw && config.output_limit[1] & BIT1) || (0 < sw && config.output_limit[1] & BIT2)) { - ret_val = 1; fprintf(outfile, "WARNING: %s:", program_name); } else { - ret_val = 0; if (config.output_limit[1] & BIT3) fprintf(outfile, "OK:"); else From 0f66becd571e14abea140a55ec7f30481330a963 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 13 Apr 2014 20:55:34 +0100 Subject: [PATCH 100/313] build-sys: update bootstrap script Signed-off-by: Sami Kerola --- bootstrap | 93 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/bootstrap b/bootstrap index c69b99f..8c68fea 100755 --- a/bootstrap +++ b/bootstrap @@ -1,10 +1,10 @@ #! /bin/sh # Print a version string. -scriptversion=2013-05-08.20; # UTC +scriptversion=2013-12-05.23; # UTC # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -210,12 +210,16 @@ bootstrap_sync=false # Use git to update gnulib sources use_git=true +check_exists() { + ($1 --version /dev/null 2>&1 + test $? -lt 126 +} + # find_tool ENVVAR NAMES... # ------------------------- # Search for a required program. Use the value of ENVVAR, if set, -# otherwise find the first of the NAMES that can be run (i.e., -# supports --version). If found, set ENVVAR to the program name, -# die otherwise. +# otherwise find the first of the NAMES that can be run. +# If found, set ENVVAR to the program name, die otherwise. # # FIXME: code duplication, see also gnu-web-doc-update. find_tool () @@ -225,27 +229,21 @@ find_tool () find_tool_names=$@ eval "find_tool_res=\$$find_tool_envvar" if test x"$find_tool_res" = x; then - for i - do - if ($i --version /dev/null 2>&1; then - find_tool_res=$i - break + for i; do + if check_exists $i; then + find_tool_res=$i + break fi done - else - find_tool_error_prefix="\$$find_tool_envvar: " fi - test x"$find_tool_res" != x \ - || die "one of these is required: $find_tool_names" - ($find_tool_res --version /dev/null 2>&1 \ - || die "${find_tool_error_prefix}cannot run $find_tool_res --version" + if test x"$find_tool_res" = x; then + warn_ "one of these is required: $find_tool_names;" + die "alternatively set $find_tool_envvar to a compatible tool" + fi eval "$find_tool_envvar=\$find_tool_res" eval "export $find_tool_envvar" } -# Find sha1sum, named gsha1sum on MacPorts, and shasum on Mac OS X 10.6. -find_tool SHA1SUM sha1sum gsha1sum shasum - # Override the default configuration, if necessary. # Make sure that bootstrap.conf is sourced from the current directory # if we were invoked as "sh bootstrap". @@ -257,12 +255,12 @@ esac # Extra files from gnulib, which override files from other sources. test -z "${gnulib_extra_files}" && \ gnulib_extra_files=" - $build_aux/install-sh - $build_aux/mdate-sh - $build_aux/texinfo.tex - $build_aux/depcomp - $build_aux/config.guess - $build_aux/config.sub + build-aux/install-sh + build-aux/mdate-sh + build-aux/texinfo.tex + build-aux/depcomp + build-aux/config.guess + build-aux/config.sub doc/INSTALL " @@ -327,7 +325,7 @@ insert_if_absent() { die "Error: Duplicate entries in $file: " $duplicate_entries fi linesold=$(gitignore_entries $file | wc -l) - linesnew=$(echo "$str" | gitignore_entries - $file | sort -u | wc -l) + linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) if [ $linesold != $linesnew ] ; then { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ || die "insert_if_absent $file $str: failed" @@ -470,8 +468,7 @@ check_versions() { if [ "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved # so we have to rely on $? rather than get_version. - $app --version >/dev/null 2>&1 - if [ 126 -le $? ]; then + if ! check_exists $app; then warn_ "Error: '$app' not found" ret=1 fi @@ -504,6 +501,12 @@ print_versions() { # can't depend on column -t } +# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. +# Also find the compatible sha1 utility on the BSDs +if test x"$SKIP_PO" = x; then + find_tool SHA1SUM sha1sum gsha1sum shasum sha1 +fi + use_libtool=0 # We'd like to use grep -E, to see if any of LT_INIT, # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac, @@ -549,13 +552,21 @@ if ! printf "$buildreq" | check_versions; then fi fi +# Warn the user if autom4te appears to be broken; this causes known +# issues with at least gettext 0.18.3. +probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -) +if test "x$probe" != xhi; then + warn_ "WARNING: your autom4te wrapper eats stdin;" + warn_ "if bootstrap fails, consider upgrading your autotools" +fi + echo "$0: Bootstrapping from checked-out $package sources..." # See if we can use gnulib's git-merge-changelog merge driver. -if test -d .git && (git --version) >/dev/null 2>/dev/null ; then +if $use_git && test -d .git && check_exists git; then if git config merge.merge-changelog.driver >/dev/null ; then : - elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then + elif check_exists git-merge-changelog; then echo "$0: initializing git-merge-changelog driver" git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' @@ -575,13 +586,17 @@ git_modules_config () { test -f .gitmodules && git config --file .gitmodules "$@" } -gnulib_path=$(git_modules_config submodule.gnulib.path) -test -z "$gnulib_path" && gnulib_path=gnulib +if $use_git; then + gnulib_path=$(git_modules_config submodule.gnulib.path) + test -z "$gnulib_path" && gnulib_path=gnulib +fi -# Get gnulib files. +# Get gnulib files. Populate $GNULIB_SRCDIR, possibly updating a +# submodule, for use in the rest of the script. case ${GNULIB_SRCDIR--} in -) + # Note that $use_git is necessarily true in this case. if git_modules_config submodule.gnulib.url >/dev/null; then echo "$0: getting gnulib files..." git submodule init || exit $? @@ -602,8 +617,8 @@ case ${GNULIB_SRCDIR--} in GNULIB_SRCDIR=$gnulib_path ;; *) - # Use GNULIB_SRCDIR as a reference. - if test -d "$GNULIB_SRCDIR"/.git && \ + # Use GNULIB_SRCDIR directly or as a reference. + if $use_git && test -d "$GNULIB_SRCDIR"/.git && \ git_modules_config submodule.gnulib.url >/dev/null; then echo "$0: getting gnulib files..." if git submodule -h|grep -- --reference > /dev/null; then @@ -629,6 +644,9 @@ case ${GNULIB_SRCDIR--} in ;; esac +# $GNULIB_SRCDIR now points to the version of gnulib to use, and +# we no longer need to use git or $gnulib_path below here. + if $bootstrap_sync; then cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || { echo "$0: updating bootstrap and restarting..." @@ -686,11 +704,10 @@ update_po_files() { cksum_file="$ref_po_dir/$po.s1" if ! test -f "$cksum_file" || ! test -f "$po_dir/$po.po" || - ! $SHA1SUM -c --status "$cksum_file" \ - < "$new_po" > /dev/null; then + ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then echo "$me: updated $po_dir/$po.po..." cp "$new_po" "$po_dir/$po.po" \ - && $SHA1SUM < "$new_po" > "$cksum_file" + && $SHA1SUM < "$new_po" > "$cksum_file" || return fi done } From 502daf83065596aad3d48c29e3150783e7302d82 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 13 Apr 2014 21:07:54 +0100 Subject: [PATCH 101/313] build-sys: require automake 1.12 to get working test-driver With older automake versions one can end up after ./bootstrap with situation where test-driver script is missing, and subsequent compilation fails. Requiring automake 1.12 should usually help, but unfortunately the case Dennis reported is different. Something goes wrong with 1.13 and autoconf 2.69, in 32 bit RHEL system. That sort of system seems to require AM_PROG_CC_C_O, and even when that is added following error happens. It is yet unknown to me why this is the case. parallel-tests: error: required file 'build-aux/test-driver' not found Reference: http://git.savannah.gnu.org/cgit/automake.git/tree/NEWS?id=v1.12#n113 Reported-by: Dennis Ortsen Signed-off-by: Sami Kerola --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e062c58..cfa9271 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([ -Wall -Wextra-portability - 1.10 + 1.12 foreign dist-xz no-dist-gzip From 6e680ee04fa84472695f7eabc8ea1ae90433d314 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 31 May 2014 18:13:21 +0100 Subject: [PATCH 102/313] contrib: add release siging key to contrib/ Signed-off-by: Sami Kerola --- contrib/kerolasa.gpg | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 contrib/kerolasa.gpg diff --git a/contrib/kerolasa.gpg b/contrib/kerolasa.gpg new file mode 100644 index 0000000..47d1ed6 --- /dev/null +++ b/contrib/kerolasa.gpg @@ -0,0 +1,52 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MLlzAExOftLPkwyWS8ePs7rJVLSA42N3diUYx5TO3NzmU8ifn4hGxb +F9J/sIYQUfCxH9V+DBe2vhVSZ/bQKpVUZTE8KxINL32JvTR3HbEwHKIe0xIFnDOM +GrWP7icPEsaSKj/0vEq/Is/R2nJWfD0Vzs7vil9zYU16vHQtZrv/5SzavzDRFGxL +m7/jDfrzMuNRdQARAQABiQIlBBgBAgAPBQJSx/43AhsMBQkJZgGAAAoJEKlVMkX9 +6bc5cYEQAI8xVRdoza/MY9KFJCRiobii4GjxAJqIXXvbY8mM7rvmiLnzfr5msLzS +op7Epse6tkI8QvYXbY+EjXke27J8rM/zqXyqdKJfcqKVzq6fIQyVVsz9o0hwvuSj +kcSgCV2b8XHKbNygSnNh2VJ5YY/zL2x5tsySa3tLukh46ydKWRQqOSMIxMT0TnCO +iTMr5INwGnX68rB0kEuCSUdkzDuyulW2T0oN7Yx4ASgrJixwSu/UNMO/fXvkG0NY +IWeXQcnn0C8zQv/PAfzJ9O+24Md4m6tzVuDpblSRB6E8xQhusysRc4BEHB/G3Ege +3JR/tumT6solJD7pfFDYkC9rAKhTKK9h1b2VpEGxN9o8qwwjtNljLakEYXuWNpCm +ZxKAR4Agg3UY8CGmgsTKyjsfB9iO2+LXCS9uQMAtIHbnr++mPASBEKD6rP8QIyf1 +2fbI9JRNGWcXQVZBGXWmu4UaKOrXBTVzooj2yG7kZmKO0FoIaCqqTUs2/KhnFj2E +Fvym2j1OMrYxOM/pT6w3cv3CwGb1ILOX0qrTQiEpOExSMa21Mi4678jXt6F6NPWG +/lwlgE1WM9i9jIcua+NU5ZJiqQ/rjuSRMB/WFrQy66/jb9wWNp/G6DXrANgdgoC9 +Dq5oviB+dqSXlU5b0atG4ru506mXCHKmOC+wu0oRlGQ/X6iuuDfS +=U+eW +-----END PGP PUBLIC KEY BLOCK----- From 6b267387ccb380ceb452353d1e277f1345186e36 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 31 May 2014 18:06:33 +0100 Subject: [PATCH 103/313] release: 2.25 Signed-off-by: Sami Kerola --- NEWS | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NEWS b/NEWS index b30ab7b..2f6e6ee 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,24 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. + +Version 2.25 +$ git shortlog v2.24..v2.25 +Sami Kerola (14): + build-sys: use more strict method to check __builtin_expect + getdata: add missing HAVE_POSIX_FADVISE protection + getdata: fix consecutive range definition regression + man: add tip analysis of include files can be useful + thanks: add Fredrik Lysén & Conor McCarthy + generic: use pure and const function attributes when possible + tests: fix testing error + output: make nagios output have performance data + build-sys: update gitinore file + output: use symbolic exit values for nagios commands + build-sys: update bootstrap script + build-sys: require automake 1.12 to get working test-driver + contrib: add release siging key to contrib/ + release: 2.25 Version 2.24 $ git shortlog v2.23..v2.24 From 9090cfb1d7faf51f832c4fde2285a80223d09603 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 31 May 2014 18:54:01 +0100 Subject: [PATCH 104/313] news: add the note about .sig pgp key id Signed-off-by: Sami Kerola --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 2f6e6ee..905dc0e 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ See the end for copying conditions. Please send dhcpd-pools bug reports to kerolasa@iki.fi. +gpg: Signature is crated using RSA key ID FDE9B739. Version 2.25 $ git shortlog v2.24..v2.25 From 4392a5b917ba8813971bcfb21dc5431386b796c1 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 20 Jul 2014 18:05:00 +0100 Subject: [PATCH 105/313] reindent all files And update the indent.pro to match with the style I like. Signed-off-by: Sami Kerola --- src/.indent.pro | 12 ++- src/analyze.c | 6 +- src/defaults.h | 2 +- src/dhcpd-pools.c | 31 +++---- src/dhcpd-pools.h | 52 ++++++------ src/getdata.c | 47 +++++------ src/hash.c | 5 +- src/other.c | 20 ++--- src/output.c | 202 ++++++++++++++++------------------------------ src/sort.c | 20 ++--- 10 files changed, 156 insertions(+), 241 deletions(-) diff --git a/src/.indent.pro b/src/.indent.pro index 34e832f..fb2aa48 100644 --- a/src/.indent.pro +++ b/src/.indent.pro @@ -1,2 +1,10 @@ --linux -Tuintmax_t -TFILE -Tsize_t -Toff_t -Ttime_t -ppi1 - +-linux +-TFILE +-Tipaddr_t +-Toff_t +-Trange_t +-Tsize_t +-Ttime_t +-Tuintmax_t +-l100 +-ppi1 diff --git a/src/analyze.c b/src/analyze.c index 71c48d0..2ec8626 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -69,13 +69,11 @@ int do_counting(void) /* Walk through ranges */ for (i = 0; i < num_ranges; i++) { - for (; l != NULL && ipcomp(&range_p->first_ip, &l->ip) < 0; - l = l->hh.prev) + for (; l != NULL && ipcomp(&range_p->first_ip, &l->ip) < 0; l = l->hh.prev) /* rewind */ ; if (l == NULL) l = leases; - for (; l != NULL && ipcomp(&l->ip, &range_p->last_ip) <= 0; - l = l->hh.next) { + for (; l != NULL && ipcomp(&l->ip, &range_p->last_ip) <= 0; l = l->hh.next) { if (ipcomp(&l->ip, &range_p->first_ip) < 0) { /* should not be necessary */ continue; diff --git a/src/defaults.h b/src/defaults.h index 3b4f882..c39149a 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -41,7 +41,7 @@ #ifndef DEFAULTS_H # define DEFAULTS_H 1 -#include "dhcpd-pools.h" +# include "dhcpd-pools.h" /*! \var MAXLEN * \brief Maximum expected line length in dhcpd.conf and dhcpd.leases diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 12c26ae..5c7a48a 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -129,8 +129,7 @@ int main(int argc, char **argv) /* Parse command line options */ while (1) { int c; - c = getopt_long(argc, argv, "c:l:f:o:s:rL:vh", - long_options, &option_index); + c = getopt_long(argc, argv, "c:l:f:o:s:rL:vh", long_options, &option_index); if (c == EOF) break; @@ -152,8 +151,7 @@ int main(int argc, char **argv) /* Output sorting option */ sorts = strlen(optarg); if (5 < sorts) { - warnx - ("main: only first 5 sort orders will be used"); + warnx("main: only first 5 sort orders will be used"); strncpy(config.sort, optarg, (size_t)5); sorts = 5; } else { @@ -175,29 +173,24 @@ int main(int argc, char **argv) /* Specification what will be printed */ for (i = 0; i < 2; i++) { if (optarg[i] >= '0' && optarg[i] < '8') { - config.output_limit[i] = - optarg[i] - '0'; + config.output_limit[i] = optarg[i] - '0'; } else { clean_up(); errx(EXIT_FAILURE, - "main: output mask `%s' is illegal", - optarg); + "main: output mask `%s' is illegal", optarg); } } break; case OPT_WARN: strcpy(config.output_format, "a"); - config.warning = - strtod_or_err(optarg, "illegal argument"); + config.warning = strtod_or_err(optarg, "illegal argument"); break; case OPT_CRIT: strcpy(config.output_format, "a"); - config.critical = - strtod_or_err(optarg, "illegal argument"); + config.critical = strtod_or_err(optarg, "illegal argument"); break; case OPT_MINSIZE: - config.minsize = - strtod_or_err(optarg, "illegal argument"); + config.minsize = strtod_or_err(optarg, "illegal argument"); break; case 'v': /* Print version */ @@ -206,9 +199,7 @@ int main(int argc, char **argv) /* Print help */ usage(EXIT_SUCCESS); default: - errx(EXIT_FAILURE, - "Try `%s --help' for more information.", - program_name); + errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); } } @@ -244,8 +235,7 @@ int main(int argc, char **argv) break; default: clean_up(); - errx(EXIT_FAILURE, "main: unknown output format `%c'", - config.output_format[0]); + errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); } /* Do the job */ @@ -278,8 +268,7 @@ int prepare_memory(void) config.dhcp_version = VERSION_UNKNOWN; RANGES = 64; num_ranges = num_shared_networks = 0; - shared_networks = - xmalloc(sizeof(struct shared_network_t) * SHARED_NETWORKS); + shared_networks = xmalloc(sizeof(struct shared_network_t) * SHARED_NETWORKS); ranges = xmalloc(sizeof(struct range_t) * RANGES); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index 90582b5..e7ccc97 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -194,9 +194,9 @@ enum limbits { /*! \def STATE_OK * \brief Nagios alarm exit value. */ -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 +# define STATE_OK 0 +# define STATE_WARNING 1 +# define STATE_CRITICAL 2 /* Global variables */ /* \var prefix_length Length of each prefix. */ @@ -220,50 +220,53 @@ unsigned int RANGES; int prepare_memory(void); void set_ipv_functions(int version); int parse_leases(void); -void parse_config(int, const char *__restrict, - struct shared_network_t *__restrict) +void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) __attribute__ ((nonnull(2, 3))); int prepare_data(void); int do_counting(void); -void flip_ranges(struct range_t *__restrict ranges, - struct range_t *__restrict tmp_ranges) +void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ -int (*parse_ipaddr)(const char *restrict src, union ipaddr_t *restrict dst); +int (*parse_ipaddr) (const char *restrict src, union ipaddr_t *restrict dst); int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst) _DP_ATTRIBUTE_CONST; int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst); int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst); -void (*copy_ipaddr)(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -void copy_ipaddr_init(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) _DP_ATTRIBUTE_CONST; +void (*copy_ipaddr) (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +void copy_ipaddr_init(union ipaddr_t *restrict dst, + const union ipaddr_t *restrict src) _DP_ATTRIBUTE_CONST; void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -const char *(*ntop_ipaddr)(const union ipaddr_t *ip); +const char *(*ntop_ipaddr) (const union ipaddr_t *ip); const char *ntop_ipaddr_init(const union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; const char *ntop_ipaddr_v4(const union ipaddr_t *ip); const char *ntop_ipaddr_v6(const union ipaddr_t *ip); -double (*get_range_size)(const struct range_t *r); +double (*get_range_size) (const struct range_t *r); double get_range_size_init(const struct range_t *r) _DP_ATTRIBUTE_CONST; double get_range_size_v4(const struct range_t *r) _DP_ATTRIBUTE_PURE; double get_range_size_v6(const struct range_t *r) _DP_ATTRIBUTE_PURE; -int (*xstrstr)(const char *__restrict str); +int (*xstrstr) (const char *__restrict str); int xstrstr_init(const char *__restrict str) _DP_ATTRIBUTE_CONST; -int xstrstr_v4(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; -int xstrstr_v6(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; +int xstrstr_v4(const char *__restrict str) +_DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; +int xstrstr_v6(const char *__restrict str) +_DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; -double strtod_or_err(const char *__restrict str, - const char *__restrict errmesg); +double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); void print_version(void) __attribute__ ((noreturn)); void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ -int (*ipcomp)(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); -int ipcomp_init(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_CONST; -int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; -int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +int (*ipcomp) (const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int ipcomp_init(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_CONST; +int ipcomp_v4(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +int ipcomp_v6(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; int comp_cur(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; int comp_double(double f1, double f2) _DP_ATTRIBUTE_CONST; @@ -281,8 +284,7 @@ comparer_t field_selector(char c); double ret_percent(struct range_t r); double ret_tc(struct range_t r) _DP_ATTRIBUTE_CONST; double ret_tcperc(struct range_t r); -void mergesort_ranges(struct range_t *__restrict orig, int size, - struct range_t *__restrict temp) +void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); /* output function pointer and functions */ int (*output_analysis) (void); @@ -295,12 +297,12 @@ int output_alarming(void); /* Memory release, file closing etc */ void clean_up(void); /* Hash functions */ -void (*add_lease)(union ipaddr_t *ip, enum ltype type); +void (*add_lease) (union ipaddr_t *ip, enum ltype type); void add_lease_init(union ipaddr_t *ip, enum ltype type) _DP_ATTRIBUTE_CONST; void add_lease_v4(union ipaddr_t *ip, enum ltype type); void add_lease_v6(union ipaddr_t *ip, enum ltype type); -struct leases_t *(*find_lease)(union ipaddr_t *ip); +struct leases_t *(*find_lease) (union ipaddr_t *ip); struct leases_t *find_lease_init(union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; struct leases_t *find_lease_v4(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; struct leases_t *find_lease_v6(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; diff --git a/src/getdata.c b/src/getdata.c index cd99013..56d5088 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -75,14 +75,12 @@ int parse_leases(void) #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) { - err(EXIT_FAILURE, "parse_leases: fadvise %s", - config.dhcpdlease_file); + err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); } # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { - err(EXIT_FAILURE, "parse_leases: fadvise %s", - config.dhcpdlease_file); + err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); } # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ @@ -103,13 +101,15 @@ int parse_leases(void) while (!feof(dhcpd_leases)) { if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) { - err(EXIT_FAILURE, "parse_leases: %s", - config.dhcpdlease_file); + err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); } - switch(xstrstr(line)) { - /* It's a lease, save IP */ + switch (xstrstr(line)) { + /* It's a lease, save IP */ case PREFIX_LEASE: - stop = memccpy(ipstring, line + (config.dhcp_version == VERSION_4 ? 6 : 9), ' ', strlen(line)); + stop = + memccpy(ipstring, + line + (config.dhcp_version == + VERSION_4 ? 6 : 9), ' ', strlen(line)); if (stop != NULL) { --stop; *stop = '\0'; @@ -150,7 +150,7 @@ int parse_leases(void) } break; default: - /* do nothing */; + /* do nothing */ ; } } #undef HAS_PREFIX @@ -204,14 +204,14 @@ void parse_config(int is_include, const char *restrict config_file, } #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE -if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); -} + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { + err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); + } # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL -if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); -} + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { + err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); + } # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ @@ -248,8 +248,7 @@ if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { } if (comment == false && argument != ITS_A_RANGE_FIRST_IP - && argument != ITS_A_RANGE_SECOND_IP - && argument != ITS_AN_INCLUCE) { + && argument != ITS_A_RANGE_SECOND_IP && argument != ITS_AN_INCLUCE) { newclause = true; i = 0; } else if (argument == ITS_A_RANGE_FIRST_IP && one_ip_range == true) { @@ -308,9 +307,7 @@ if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { } /* Either inside comment or Nth word of clause. */ - if (comment == true - || (newclause == false - && argument == ITS_NOTHING_INTERESTING)) { + if (comment == true || (newclause == false && argument == ITS_NOTHING_INTERESTING)) { continue; } /* Strip white spaces before new clause word. */ @@ -370,10 +367,7 @@ if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { num_ranges++; if (RANGES < num_ranges + 1) { RANGES *= 2; - ranges = - xrealloc(ranges, - sizeof(struct - range_t) * RANGES); + ranges = xrealloc(ranges, sizeof(struct range_t) * RANGES); range_p = ranges + num_ranges; } newclause = true; @@ -393,8 +387,7 @@ if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { case ITS_A_SHAREDNET: /* printf ("shared-network named: %s\n", word); */ num_shared_networks++; - shared_p = - shared_networks + num_shared_networks; + shared_p = shared_networks + num_shared_networks; shared_p->name = xstrdup(word); shared_p->available = 0; shared_p->used = 0; diff --git a/src/hash.c b/src/hash.c index 2f38550..4b42610 100644 --- a/src/hash.c +++ b/src/hash.c @@ -47,7 +47,8 @@ /*! \brief Add a lease to hash array. * \param addr Binary IP to be added in leases hash. * \param type Lease state of the IP. */ -void add_lease_init(union ipaddr_t *addr __attribute__((unused)), enum ltype type __attribute__((unused))) +void add_lease_init(union ipaddr_t *addr + __attribute__ ((unused)), enum ltype type __attribute__ ((unused))) { } @@ -75,7 +76,7 @@ void add_lease_v6(union ipaddr_t *addr, enum ltype type) * \param addr Binary IP searched from leases hash. * \return A lease structure about requested IP, or NULL. */ -struct leases_t *find_lease_init(union ipaddr_t *addr __attribute__((unused))) +struct leases_t *find_lease_init(union ipaddr_t *addr __attribute__ ((unused))) { return NULL; } diff --git a/src/other.c b/src/other.c index b59e5fd..fabb6d8 100644 --- a/src/other.c +++ b/src/other.c @@ -146,19 +146,17 @@ int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst) * * \param dst Destination for a binary IP address. * \param src Sourse of an IP address. */ -void copy_ipaddr_init(union ipaddr_t *restrict dst __attribute__((unused)), - const union ipaddr_t *restrict src __attribute__((unused))) +void copy_ipaddr_init(union ipaddr_t *restrict dst __attribute__ ((unused)), + const union ipaddr_t *restrict src __attribute__ ((unused))) { } -void copy_ipaddr_v4(union ipaddr_t *restrict dst, - const union ipaddr_t *restrict src) +void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) { dst->v4 = src->v4; } -void copy_ipaddr_v6(union ipaddr_t *restrict dst, - const union ipaddr_t *restrict src) +void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src) { memcpy(&dst->v6, &src->v6, sizeof(src->v6)); } @@ -171,7 +169,7 @@ void copy_ipaddr_v6(union ipaddr_t *restrict dst, * \param ip Binary IP address. * \return Printable address. */ -const char *ntop_ipaddr_init(const union ipaddr_t *ip __attribute__((unused))) +const char *ntop_ipaddr_init(const union ipaddr_t *ip __attribute__ ((unused))) { static char buffer = '\0'; return &buffer; @@ -187,8 +185,7 @@ const char *ntop_ipaddr_v4(const union ipaddr_t *ip) const char *ntop_ipaddr_v6(const union ipaddr_t *ip) { - static char - buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; + static char buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; struct in6_addr addr; memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); @@ -200,7 +197,7 @@ const char *ntop_ipaddr_v6(const union ipaddr_t *ip) * and last IP in the range. * \return Size of a range. */ -double get_range_size_init(const struct range_t *r __attribute__((unused))) +double get_range_size_init(const struct range_t *r __attribute__ ((unused))) { return 0; } @@ -389,8 +386,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg) * * \param flip_me The range that needs to be inverted. * \param tmp_ranges Temporary memory area for the flip. */ -void flip_ranges(struct range_t *restrict flip_me, - struct range_t *restrict tmp_ranges) +void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ranges) { unsigned int i = num_ranges - 1, j; diff --git a/src/output.c b/src/output.c index 6720e13..e713056 100644 --- a/src/output.c +++ b/src/output.c @@ -90,8 +90,7 @@ int output_txt(void) max_ipaddr_length, "first ip", max_ipaddr_length, - "last ip", - "max", "cur", "percent", "touch", "t+c", "t+c perc"); + "last ip", "max", "cur", "percent", "touch", "t+c", "t+c perc"); if (config.backups_found == true) { fprintf(outfile, " bu bu perc"); } @@ -100,8 +99,7 @@ int output_txt(void) if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { if (range_p->shared_net) { - fprintf(outfile, "%-20s", - range_p->shared_net->name); + fprintf(outfile, "%-20s", range_p->shared_net->name); } else { fprintf(outfile, "not_defined "); } @@ -109,8 +107,7 @@ int output_txt(void) * separate since ntop_ipaddr always returns the * same buffer */ fprintf(outfile, "%-*s", - max_ipaddr_length, - ntop_ipaddr(&range_p->first_ip)); + max_ipaddr_length, ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, " - %-*s %5g %5g %10.3f %5g %5g %9.3f", max_ipaddr_length, @@ -120,14 +117,11 @@ int output_txt(void) (float)(100 * range_p->count) / range_size, range_p->touched, range_p->touched + range_p->count, - (float)(100 * - (range_p->touched + - range_p->count)) / range_size); + (float)(100 * (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", range_p->backups, - (float)(100 * range_p->backups) / - range_size); + (float)(100 * range_p->backups) / range_size); } fprintf(outfile, "\n"); range_p++; @@ -158,13 +152,11 @@ int output_txt(void) shared_p->touched + shared_p->used, (float)(100 * (shared_p->touched + - shared_p->used)) / - shared_p->available); + shared_p->used)) / shared_p->available); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", shared_p->backups, - (float)(100 * shared_p->backups) / - shared_p->available); + (float)(100 * shared_p->backups) / shared_p->available); } fprintf(outfile, "\n"); @@ -194,8 +186,7 @@ int output_txt(void) shared_networks->touched + shared_networks->used, (float)(100 * (shared_networks->touched + - shared_networks->used)) / - shared_networks->available); + shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", @@ -257,8 +248,7 @@ int output_xml(void) if (l->ethernet != NULL) { fputs(l->ethernet, outfile); } - fputs("\n\n", - outfile); + fputs("\n\n", outfile); } } } @@ -268,25 +258,19 @@ int output_xml(void) fprintf(outfile, "\n"); if (range_p->shared_net) { fprintf(outfile, - "\t%s\n", - range_p->shared_net->name); + "\t%s\n", range_p->shared_net->name); } else { fprintf(outfile, "\t\n"); } fprintf(outfile, "\t\n"); fprintf(outfile, "\t\n"); - fprintf(outfile, "\t%s ", - ntop_ipaddr(&range_p->first_ip)); - fprintf(outfile, "- %s\n", - ntop_ipaddr(&range_p->last_ip)); + fprintf(outfile, "\t%s ", ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, "- %s\n", ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\t\n"); - fprintf(outfile, "\t%g\n", - range_size); - fprintf(outfile, "\t%g\n", - range_p->count); - fprintf(outfile, "\t%g\n", - range_size - range_p->count); + fprintf(outfile, "\t%g\n", range_size); + fprintf(outfile, "\t%g\n", range_p->count); + fprintf(outfile, "\t%g\n", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); fprintf(outfile, "\n"); @@ -297,12 +281,9 @@ int output_xml(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; fprintf(outfile, "\n"); - fprintf(outfile, "\t%s\n", - shared_p->name); - fprintf(outfile, "\t%g\n", - shared_p->available); - fprintf(outfile, "\t%g\n", - shared_p->used); + fprintf(outfile, "\t%s\n", shared_p->name); + fprintf(outfile, "\t%g\n", shared_p->available); + fprintf(outfile, "\t%g\n", shared_p->used); fprintf(outfile, "\t%g\n", shared_p->available - shared_p->used); fprintf(outfile, "\n"); @@ -311,10 +292,8 @@ int output_xml(void) if (config.output_limit[0] & BIT3) { fprintf(outfile, "\n"); - fprintf(outfile, "\t%s\n", - shared_networks->name); - fprintf(outfile, "\t%g\n", - shared_networks->available); + fprintf(outfile, "\t%s\n", shared_networks->name); + fprintf(outfile, "\t%g\n", shared_networks->available); fprintf(outfile, "\t%g\n", shared_networks->used); fprintf(outfile, "\t%g\n", shared_networks->available - shared_networks->used); @@ -353,8 +332,7 @@ int output_json(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_json: %s", - config.output_file); + err(EXIT_FAILURE, "output_json: %s", config.output_file); } } else { outfile = stdout; @@ -400,20 +378,16 @@ int output_json(void) fprintf(outfile, "{ "); if (range_p->shared_net) { fprintf(outfile, - "\"location\":\"%s\", ", - range_p->shared_net->name); + "\"location\":\"%s\", ", range_p->shared_net->name); } else { fprintf(outfile, "\"location\":\"\", "); } - fprintf(outfile, "\"range\":\"%s", - ntop_ipaddr(&range_p->first_ip)); - fprintf(outfile, " - %s\", ", - ntop_ipaddr(&range_p->last_ip)); + fprintf(outfile, "\"range\":\"%s", ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, " - %s\", ", ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\"defined\":%g, ", range_size); fprintf(outfile, "\"used\":%g, ", range_p->count); - fprintf(outfile, "\"free\":%g ", - range_size - range_p->count); + fprintf(outfile, "\"free\":%g ", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); if (i + 1 < num_ranges) @@ -434,13 +408,10 @@ int output_json(void) fprintf(outfile, " "); shared_p++; fprintf(outfile, "{ "); - fprintf(outfile, "\"location\":\"%s\", ", - shared_p->name); - fprintf(outfile, "\"defined\":%g, ", - shared_p->available); + fprintf(outfile, "\"location\":\"%s\", ", shared_p->name); + fprintf(outfile, "\"defined\":%g, ", shared_p->available); fprintf(outfile, "\"used\":%g, ", shared_p->used); - fprintf(outfile, "\"free\":%g ", - shared_p->available - shared_p->used); + fprintf(outfile, "\"free\":%g ", shared_p->available - shared_p->used); if (i + 1 < num_shared_networks) fprintf(outfile, "},\n"); else @@ -455,12 +426,9 @@ int output_json(void) fprintf(outfile, ",\n"); } fprintf(outfile, " \"summary\": {\n"); - fprintf(outfile, " \"location\":\"%s\",\n", - shared_networks->name); - fprintf(outfile, " \"defined\":%g,\n", - shared_networks->available); - fprintf(outfile, " \"used\":%g,\n", - shared_networks->used); + fprintf(outfile, " \"location\":\"%s\",\n", shared_networks->name); + fprintf(outfile, " \"defined\":%g,\n", shared_networks->available); + fprintf(outfile, " \"used\":%g,\n", shared_networks->used); fprintf(outfile, " \"free\":%g\n", shared_networks->available - shared_networks->used); fprintf(outfile, " }"); /* end of summary */ @@ -618,8 +586,7 @@ static void output_line(FILE *restrict f, char const *restrict type, * \param type HMTL tag name. * \param d Actual payload of the printout. */ -static void output_double(FILE *restrict f, char const *restrict type, - double d) +static void output_double(FILE *restrict f, char const *restrict type, double d) { fprintf(f, " <%s class=ralign>%g\n", type, d, type); } @@ -684,8 +651,7 @@ int output_html(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_html: %s", - config.output_file); + err(EXIT_FAILURE, "output_html: %s", config.output_file); } } else { outfile = stdout; @@ -720,34 +686,24 @@ int output_html(void) for (i = 0; i < num_ranges; i++) { newrow(outfile); if (range_p->shared_net) { - output_line(outfile, "td", "calign", - range_p->shared_net->name); + output_line(outfile, "td", "calign", range_p->shared_net->name); } else { - output_line(outfile, "td", "calign", - "not_defined"); + output_line(outfile, "td", "calign", "not_defined"); } - output_line(outfile, "td", "calign", - ntop_ipaddr(&range_p->first_ip)); - output_line(outfile, "td", "calign", - ntop_ipaddr(&range_p->last_ip)); + output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->first_ip)); + output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->last_ip)); output_double(outfile, "td", range_size); output_double(outfile, "td", range_p->count); - output_float(outfile, "td", - (float)(100 * range_p->count) / - range_size); + output_float(outfile, "td", (float)(100 * range_p->count) / range_size); output_double(outfile, "td", range_p->touched); - output_double(outfile, "td", - range_p->touched + range_p->count); + output_double(outfile, "td", range_p->touched + range_p->count); output_float(outfile, "td", (float)(100 * - (range_p->touched + - range_p->count)) / range_size); + (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { output_double(outfile, "td", range_p->backups); output_float(outfile, "td", - (float)(100 * - range_p->backups) / - range_size); + (float)(100 * range_p->backups) / range_size); } endrow(outfile); range_p++; @@ -780,22 +736,18 @@ int output_html(void) output_double(outfile, "td", shared_p->available); output_double(outfile, "td", shared_p->used); output_float(outfile, "td", - (float)(100 * shared_p->used) / - shared_p->available); + (float)(100 * shared_p->used) / shared_p->available); output_double(outfile, "td", shared_p->touched); - output_double(outfile, "td", - shared_p->touched + shared_p->used); + output_double(outfile, "td", shared_p->touched + shared_p->used); output_float(outfile, "td", (float)(100 * (shared_p->touched + - shared_p->used)) / - shared_p->available); + shared_p->used)) / shared_p->available); if (config.backups_found == true) { output_double(outfile, "td", shared_p->backups); output_float(outfile, "td", (float)(100 * - shared_p->backups) / - shared_p->available); + shared_p->backups) / shared_p->available); } endrow(outfile); @@ -824,16 +776,13 @@ int output_html(void) output_double(outfile, "td", shared_networks->available); output_double(outfile, "td", shared_networks->used); output_float(outfile, "td", - (float)(100 * shared_networks->used) / - shared_networks->available); + (float)(100 * shared_networks->used) / shared_networks->available); output_double(outfile, "td", shared_networks->touched); - output_double(outfile, "td", - shared_networks->touched + shared_networks->used); + output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_float(outfile, "td", (float)(100 * (shared_networks->touched + - shared_networks->used)) / - shared_networks->available); + shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { output_double(outfile, "td", shared_networks->backups); output_float(outfile, "td", @@ -897,13 +846,11 @@ int output_csv(void) if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { if (range_p->shared_net) { - fprintf(outfile, "\"%s\",", - range_p->shared_net->name); + fprintf(outfile, "\"%s\",", range_p->shared_net->name); } else { fprintf(outfile, "\"not_defined\","); } - fprintf(outfile, "\"%s\",", - ntop_ipaddr(&range_p->first_ip)); + fprintf(outfile, "\"%s\",", ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", ntop_ipaddr(&range_p->last_ip), range_size, @@ -911,14 +858,11 @@ int output_csv(void) (float)(100 * range_p->count) / range_size, range_p->touched, range_p->touched + range_p->count, - (float)(100 * - (range_p->touched + - range_p->count)) / range_size); + (float)(100 * (range_p->touched + range_p->count)) / range_size); if (config.backups_found == true) { fprintf(outfile, ",\"%g\",\"%.3f\"", range_p->backups, - (float)(100 * range_p->backups) / - range_size); + (float)(100 * range_p->backups) / range_size); } fprintf(outfile, "\n"); @@ -949,13 +893,11 @@ int output_csv(void) shared_p->touched + shared_p->used, (float)(100 * (shared_p->touched + - shared_p->used)) / - shared_p->available); + shared_p->used)) / shared_p->available); if (config.backups_found == true) { fprintf(outfile, ",\"%g\",\"%.3f\"", shared_p->backups, - (float)(100 * shared_p->backups) / - shared_p->available); + (float)(100 * shared_p->backups) / shared_p->available); } fprintf(outfile, "\n"); @@ -983,8 +925,7 @@ int output_csv(void) shared_networks->touched + shared_networks->used, (float)(100 * (shared_networks->touched + - shared_networks->used)) / - shared_networks->available); + shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", shared_networks->backups, @@ -1028,8 +969,7 @@ int output_alarming(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_alarming: %s", - config.output_file); + err(EXIT_FAILURE, "output_alarming: %s", config.output_file); } } else { outfile = stdout; @@ -1038,8 +978,7 @@ int output_alarming(void) if (config.output_limit[1] & BIT1) { for (i = 0; i < num_ranges; i++) { if (config.minsize < range_size) { - perc = - (float)(100 * range_p->count) / range_size; + perc = (float)(100 * range_p->count) / range_size; if (config.critical < perc) rc++; else if (config.warning < perc) @@ -1056,8 +995,7 @@ int output_alarming(void) if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { if (config.minsize < shared_p->available) { - perc = (float)(100 * shared_p->used) / - shared_p->available; + perc = (float)(100 * shared_p->used) / shared_p->available; if (config.critical < perc) sc++; else if (config.warning < perc) @@ -1078,12 +1016,12 @@ int output_alarming(void) else ret_val = STATE_OK; - if ((0 < rc && config.output_limit[1] & BIT1) || (0 < sc && config.output_limit[1] & BIT2)) { - fprintf(outfile, "CRITICAL: %s:", - program_name); - } else if ((0 < rw && config.output_limit[1] & BIT1) || (0 < sw && config.output_limit[1] & BIT2)) { - fprintf(outfile, "WARNING: %s:", - program_name); + if ((0 < rc && config.output_limit[1] & BIT1) + || (0 < sc && config.output_limit[1] & BIT2)) { + fprintf(outfile, "CRITICAL: %s:", program_name); + } else if ((0 < rw && config.output_limit[1] & BIT1) + || (0 < sw && config.output_limit[1] & BIT2)) { + fprintf(outfile, "WARNING: %s:", program_name); } else { if (config.output_limit[1] & BIT3) fprintf(outfile, "OK:"); @@ -1091,13 +1029,11 @@ int output_alarming(void) return ret_val; } if (config.output_limit[0] & BIT1) { - fprintf(outfile, " Ranges - crit: %d warn: %d ok: %d", rc, rw, - ro); + fprintf(outfile, " Ranges - crit: %d warn: %d ok: %d", rc, rw, ro); if (ri != 0) { fprintf(outfile, " ignored: %d", ri); } - fprintf(outfile, "; | range_crit=%d range_warn=%d range_ok=%d", rc, rw, - ro); + fprintf(outfile, "; | range_crit=%d range_warn=%d range_ok=%d", rc, rw, ro); if (ri != 0) { fprintf(outfile, " range_ignored=%d", ri); } @@ -1106,13 +1042,11 @@ int output_alarming(void) fprintf(outfile, " "); } if (config.output_limit[0] & BIT2) { - fprintf(outfile, "Shared nets - crit: %d warn: %d ok: %d", sc, - sw, so); + fprintf(outfile, "Shared nets - crit: %d warn: %d ok: %d", sc, sw, so); if (si != 0) { fprintf(outfile, " ignored: %d", si); } - fprintf(outfile, "; | snet_crit=%d snet_warn=%d snet_ok=%d", sc, - sw, so); + fprintf(outfile, "; | snet_crit=%d snet_warn=%d snet_ok=%d", sc, sw, so); if (si != 0) { fprintf(outfile, " snet_ignored=%d\n", si); } diff --git a/src/sort.c b/src/sort.c index a48b905..bafc290 100644 --- a/src/sort.c +++ b/src/sort.c @@ -54,14 +54,13 @@ * \param b Binary IP address. * \return If a < b return -1, if a < b return 1, when they are equal return 0. */ -int ipcomp_init(const union ipaddr_t *restrict a __attribute__((unused)), - const union ipaddr_t *restrict b __attribute__((unused))) +int ipcomp_init(const union ipaddr_t *restrict a __attribute__ ((unused)), + const union ipaddr_t *restrict b __attribute__ ((unused))) { return 0; } -int ipcomp_v4(const union ipaddr_t *restrict a, - const union ipaddr_t *restrict b) +int ipcomp_v4(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) { if (a->v4 < b->v4) return -1; @@ -70,8 +69,7 @@ int ipcomp_v4(const union ipaddr_t *restrict a, return 0; } -int ipcomp_v6(const union ipaddr_t *restrict a, - const union ipaddr_t *restrict b) +int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) { return memcmp(&a->v6, &b->v6, sizeof(a->v6)); } @@ -215,8 +213,7 @@ comparer_t field_selector(char c) default: clean_up(); warnx("field_selector: unknown sort order `%c'", c); - errx(EXIT_FAILURE, "Try `%s --help' for more information.", - program_name); + errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); } return NULL; } @@ -236,9 +233,7 @@ static int merge(struct range_t *restrict left, struct range_t *restrict right) for (i = 0; i < len; i++) { /* Handling strings is case of it's own */ if (config.sort[i] == 'n') { - ret = - strcmp(left->shared_net->name, - right->shared_net->name); + ret = strcmp(left->shared_net->name, right->shared_net->name); if (0 < ret) return (0); if (ret < 0) @@ -269,8 +264,7 @@ static int merge(struct range_t *restrict left, struct range_t *restrict right) * \param temp Temporary memory space, needed when a values has to be * flipped. */ -void mergesort_ranges(struct range_t *restrict orig, int size, - struct range_t *restrict temp) +void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *restrict temp) { int left, right, i; struct range_t hold; From 965875d20b01d467e6352863a9788112a488ec4c Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 9 Aug 2014 18:58:25 +0100 Subject: [PATCH 106/313] declare global variables only once Global variable declarations belong near main, and the header has to have extern reference to them. Signed-off-by: Sami Kerola --- src/dhcpd-pools.c | 21 ++++++ src/dhcpd-pools.h | 158 +++++++++++++++++++++++----------------------- 2 files changed, 101 insertions(+), 78 deletions(-) diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 5c7a48a..279db9a 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -54,6 +54,27 @@ #include "progname.h" #include "xalloc.h" +/* Global variables */ +int prefix_length[2][NUM_OF_PREFIX]; +struct configuration_t config; +struct shared_network_t *shared_networks; +unsigned int num_shared_networks; +struct range_t *ranges; +unsigned int num_ranges; +struct leases_t *leases; +unsigned int RANGES; + +/* Function pointers */ +int (*parse_ipaddr) (const char *restrict src, union ipaddr_t *restrict dst); +void (*copy_ipaddr) (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +const char *(*ntop_ipaddr) (const union ipaddr_t *ip); +double (*get_range_size) (const struct range_t *r); +int (*xstrstr) (const char *__restrict str); +int (*ipcomp) (const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int (*output_analysis) (void); +void (*add_lease) (union ipaddr_t *ip, enum ltype type); +struct leases_t *(*find_lease) (union ipaddr_t *ip); + /*! \brief Start of execution. Parse options, and call other other * functions one after another. At the moment adding threading support * would be difficult, but there does not seem to be valid reason to diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index e7ccc97..f6dfd95 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -200,114 +200,116 @@ enum limbits { /* Global variables */ /* \var prefix_length Length of each prefix. */ -int prefix_length[2][NUM_OF_PREFIX]; +extern int prefix_length[2][NUM_OF_PREFIX]; /* \var config Runtime configuration. */ -struct configuration_t config; +extern struct configuration_t config; /* \var shared_networks Pointer holding shared network count results. */ -struct shared_network_t *shared_networks; +extern struct shared_network_t *shared_networks; /* \var num_shared_networks Number of shared networks found. */ -unsigned int num_shared_networks; +extern unsigned int num_shared_networks; /* \var ranges Pointer holding range count results. */ -struct range_t *ranges; +extern struct range_t *ranges; /* \var num_ranges Number of ranges found. */ -unsigned int num_ranges; +extern unsigned int num_ranges; /* \var leases Pointer holding all leases. */ -struct leases_t *leases; +extern struct leases_t *leases; /*! \var RANGES Maximum number of ranges. */ -unsigned int RANGES; +extern unsigned int RANGES; /* Function prototypes */ -int prepare_memory(void); -void set_ipv_functions(int version); -int parse_leases(void); -void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) +extern int prepare_memory(void); +extern void set_ipv_functions(int version); +extern int parse_leases(void); +extern void parse_config(int, const char *__restrict, struct shared_network_t *__restrict) __attribute__ ((nonnull(2, 3))); -int prepare_data(void); -int do_counting(void); -void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) +extern int prepare_data(void); +extern int do_counting(void); +extern void flip_ranges(struct range_t *__restrict ranges, struct range_t *__restrict tmp_ranges) __attribute__ ((nonnull(1, 2))); /* support functions */ -int (*parse_ipaddr) (const char *restrict src, union ipaddr_t *restrict dst); -int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst) _DP_ATTRIBUTE_CONST; -int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst); -int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst); +extern int (*parse_ipaddr) (const char *restrict src, union ipaddr_t *restrict dst); +extern int parse_ipaddr_init(const char *restrict src, + union ipaddr_t *restrict dst) _DP_ATTRIBUTE_CONST; +extern int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst); +extern int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst); -void (*copy_ipaddr) (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -void copy_ipaddr_init(union ipaddr_t *restrict dst, - const union ipaddr_t *restrict src) _DP_ATTRIBUTE_CONST; -void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +extern void (*copy_ipaddr) (union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +extern void copy_ipaddr_init(union ipaddr_t *restrict dst, + const union ipaddr_t *restrict src) _DP_ATTRIBUTE_CONST; +extern void copy_ipaddr_v4(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); +extern void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict src); -const char *(*ntop_ipaddr) (const union ipaddr_t *ip); -const char *ntop_ipaddr_init(const union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; -const char *ntop_ipaddr_v4(const union ipaddr_t *ip); -const char *ntop_ipaddr_v6(const union ipaddr_t *ip); +extern const char *(*ntop_ipaddr) (const union ipaddr_t *ip); +extern const char *ntop_ipaddr_init(const union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; +extern const char *ntop_ipaddr_v4(const union ipaddr_t *ip); +extern const char *ntop_ipaddr_v6(const union ipaddr_t *ip); -double (*get_range_size) (const struct range_t *r); -double get_range_size_init(const struct range_t *r) _DP_ATTRIBUTE_CONST; -double get_range_size_v4(const struct range_t *r) _DP_ATTRIBUTE_PURE; -double get_range_size_v6(const struct range_t *r) _DP_ATTRIBUTE_PURE; +extern double (*get_range_size) (const struct range_t *r); +extern double get_range_size_init(const struct range_t *r) _DP_ATTRIBUTE_CONST; +extern double get_range_size_v4(const struct range_t *r) _DP_ATTRIBUTE_PURE; +extern double get_range_size_v6(const struct range_t *r) _DP_ATTRIBUTE_PURE; -int (*xstrstr) (const char *__restrict str); -int xstrstr_init(const char *__restrict str) _DP_ATTRIBUTE_CONST; -int xstrstr_v4(const char *__restrict str) +extern int (*xstrstr) (const char *__restrict str); +extern int xstrstr_init(const char *__restrict str) _DP_ATTRIBUTE_CONST; +extern int xstrstr_v4(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; -int xstrstr_v6(const char *__restrict str) +extern int xstrstr_v6(const char *__restrict str) _DP_ATTRIBUTE_HOT _DP_ATTRIBUTE_PURE; -double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); -void print_version(void) __attribute__ ((noreturn)); -void usage(int status) __attribute__ ((noreturn)); +extern double strtod_or_err(const char *__restrict str, const char *__restrict errmesg); +extern void print_version(void) __attribute__ ((noreturn)); +extern void usage(int status) __attribute__ ((noreturn)); /* qsort required functions... */ /* ...for ranges and... */ -int (*ipcomp) (const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); -int ipcomp_init(const union ipaddr_t *restrict a, - const union ipaddr_t *restrict b) _DP_ATTRIBUTE_CONST; -int ipcomp_v4(const union ipaddr_t *restrict a, - const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; -int ipcomp_v6(const union ipaddr_t *restrict a, - const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +extern int (*ipcomp) (const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +extern int ipcomp_init(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_CONST; +extern int ipcomp_v4(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +extern int ipcomp_v6(const union ipaddr_t *restrict a, + const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; -int comp_cur(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; -int comp_double(double f1, double f2) _DP_ATTRIBUTE_CONST; -int comp_ip(struct range_t *r1, struct range_t *r2); -int comp_max(struct range_t *r1, struct range_t *r2); -int comp_percent(struct range_t *r1, struct range_t *r2); -int comp_tc(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; -int comp_tcperc(struct range_t *r1, struct range_t *r2); -int comp_touched(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; -int rangecomp(const void *__restrict r1, const void *__restrict r2) +extern int comp_cur(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; +extern int comp_double(double f1, double f2) _DP_ATTRIBUTE_CONST; +extern int comp_ip(struct range_t *r1, struct range_t *r2); +extern int comp_max(struct range_t *r1, struct range_t *r2); +extern int comp_percent(struct range_t *r1, struct range_t *r2); +extern int comp_tc(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; +extern int comp_tcperc(struct range_t *r1, struct range_t *r2); +extern int comp_touched(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; +extern int rangecomp(const void *__restrict r1, const void *__restrict r2) __attribute__ ((nonnull(1, 2))); /* sort function pointer and functions */ typedef int (*comparer_t) (struct range_t *r1, struct range_t *r2); -comparer_t field_selector(char c); -double ret_percent(struct range_t r); -double ret_tc(struct range_t r) _DP_ATTRIBUTE_CONST; -double ret_tcperc(struct range_t r); -void mergesort_ranges(struct range_t *__restrict orig, int size, struct range_t *__restrict temp) +extern comparer_t field_selector(char c); +extern double ret_percent(struct range_t r); +extern double ret_tc(struct range_t r) _DP_ATTRIBUTE_CONST; +extern double ret_tcperc(struct range_t r); +extern void mergesort_ranges(struct range_t *__restrict orig, int size, + struct range_t *__restrict temp) __attribute__ ((nonnull(1, 3))); /* output function pointer and functions */ -int (*output_analysis) (void); -int output_txt(void); -int output_html(void); -int output_xml(void); -int output_json(void); -int output_csv(void); -int output_alarming(void); +extern int (*output_analysis) (void); +extern int output_txt(void); +extern int output_html(void); +extern int output_xml(void); +extern int output_json(void); +extern int output_csv(void); +extern int output_alarming(void); /* Memory release, file closing etc */ -void clean_up(void); +extern void clean_up(void); /* Hash functions */ -void (*add_lease) (union ipaddr_t *ip, enum ltype type); -void add_lease_init(union ipaddr_t *ip, enum ltype type) _DP_ATTRIBUTE_CONST; -void add_lease_v4(union ipaddr_t *ip, enum ltype type); -void add_lease_v6(union ipaddr_t *ip, enum ltype type); +extern void (*add_lease) (union ipaddr_t *ip, enum ltype type); +extern void add_lease_init(union ipaddr_t *ip, enum ltype type) _DP_ATTRIBUTE_CONST; +extern void add_lease_v4(union ipaddr_t *ip, enum ltype type); +extern void add_lease_v6(union ipaddr_t *ip, enum ltype type); -struct leases_t *(*find_lease) (union ipaddr_t *ip); -struct leases_t *find_lease_init(union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; -struct leases_t *find_lease_v4(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; -struct leases_t *find_lease_v6(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; +extern struct leases_t *(*find_lease) (union ipaddr_t *ip); +extern struct leases_t *find_lease_init(union ipaddr_t *ip) _DP_ATTRIBUTE_CONST; +extern struct leases_t *find_lease_v4(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; +extern struct leases_t *find_lease_v6(union ipaddr_t *ip) _DP_ATTRIBUTE_PURE; -void delete_lease(struct leases_t *lease); -void delete_all_leases(void); +extern void delete_lease(struct leases_t *lease); +extern void delete_all_leases(void); #endif /* DHCPD_POOLS_H */ From e09f655a7be0daffade2f33129577e034c3c84d9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 9 Aug 2014 19:26:29 +0100 Subject: [PATCH 107/313] add appropriate sorting function for struct leases_t The HASH_SORT in analyze needs this. Signed-off-by: Sami Kerola --- src/.indent.pro | 1 + src/analyze.c | 2 +- src/dhcpd-pools.c | 1 + src/dhcpd-pools.h | 7 +++++++ src/other.c | 3 +++ src/sort.c | 25 +++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/.indent.pro b/src/.indent.pro index fb2aa48..16702c4 100644 --- a/src/.indent.pro +++ b/src/.indent.pro @@ -1,6 +1,7 @@ -linux -TFILE -Tipaddr_t +-Tleases_t -Toff_t -Trange_t -Tsize_t diff --git a/src/analyze.c b/src/analyze.c index 2ec8626..9c05a43 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -51,7 +51,7 @@ int prepare_data(void) { /* Sort leases */ - HASH_SORT(leases, ipcomp); + HASH_SORT(leases, leasecomp); /* Sort ranges */ qsort(ranges, (size_t)num_ranges, sizeof(struct range_t), &rangecomp); return 0; diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 279db9a..974eaf6 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -71,6 +71,7 @@ const char *(*ntop_ipaddr) (const union ipaddr_t *ip); double (*get_range_size) (const struct range_t *r); int (*xstrstr) (const char *__restrict str); int (*ipcomp) (const union ipaddr_t *restrict a, const union ipaddr_t *restrict b); +int (*leasecomp) (const struct leases_t *restrict a, const struct leases_t *restrict b); int (*output_analysis) (void); void (*add_lease) (union ipaddr_t *ip, enum ltype type); struct leases_t *(*find_lease) (union ipaddr_t *ip); diff --git a/src/dhcpd-pools.h b/src/dhcpd-pools.h index f6dfd95..4c61273 100644 --- a/src/dhcpd-pools.h +++ b/src/dhcpd-pools.h @@ -269,6 +269,13 @@ extern int ipcomp_v4(const union ipaddr_t *restrict a, extern int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b) _DP_ATTRIBUTE_PURE; +extern int (*leasecomp) (const struct leases_t *restrict a, const struct leases_t *restrict b); +extern int leasecomp_init(const struct leases_t *restrict a + __attribute__ ((unused)), + const struct leases_t *restrict b __attribute__ ((unused))); +extern int leasecomp_v4(const struct leases_t *restrict a, const struct leases_t *restrict b); +extern int leasecomp_v6(const struct leases_t *restrict a, const struct leases_t *restrict b); + extern int comp_cur(struct range_t *r1, struct range_t *r2) _DP_ATTRIBUTE_PURE; extern int comp_double(double f1, double f2) _DP_ATTRIBUTE_CONST; extern int comp_ip(struct range_t *r1, struct range_t *r2); diff --git a/src/other.c b/src/other.c index fabb6d8..a983a5c 100644 --- a/src/other.c +++ b/src/other.c @@ -69,6 +69,7 @@ void set_ipv_functions(int version) find_lease = find_lease_v4; get_range_size = get_range_size_v4; ipcomp = ipcomp_v4; + leasecomp = leasecomp_v4; ntop_ipaddr = ntop_ipaddr_v4; parse_ipaddr = parse_ipaddr_v4; xstrstr = xstrstr_v4; @@ -81,6 +82,7 @@ void set_ipv_functions(int version) find_lease = find_lease_v6; get_range_size = get_range_size_v6; ipcomp = ipcomp_v6; + leasecomp = leasecomp_v6; ntop_ipaddr = ntop_ipaddr_v6; parse_ipaddr = parse_ipaddr_v6; xstrstr = xstrstr_v6; @@ -93,6 +95,7 @@ void set_ipv_functions(int version) find_lease = find_lease_init; get_range_size = get_range_size_init; ipcomp = ipcomp_init; + leasecomp = leasecomp_init; ntop_ipaddr = ntop_ipaddr_init; parse_ipaddr = parse_ipaddr_init; xstrstr = xstrstr_init; diff --git a/src/sort.c b/src/sort.c index bafc290..666b11e 100644 --- a/src/sort.c +++ b/src/sort.c @@ -74,6 +74,31 @@ int ipcomp_v6(const union ipaddr_t *restrict a, const union ipaddr_t *restrict b return memcmp(&a->v6, &b->v6, sizeof(a->v6)); } +/*! \brief Compare IP address in leases_t structure, with IPv4/v6 determination. + * \param a Binary IP address. + * \param b Binary IP address. + * \return If a < b return -1, if a < b return 1, when they are equal return 0. + */ +int leasecomp_init(const struct leases_t *restrict a __attribute__ ((unused)), + const struct leases_t *restrict b __attribute__ ((unused))) +{ + return 0; +} + +int leasecomp_v4(const struct leases_t *restrict a, const struct leases_t *restrict b) +{ + if (a->ip.v4 < b->ip.v4) + return -1; + if (a->ip.v4 > b->ip.v4) + return 1; + return 0; +} + +int leasecomp_v6(const struct leases_t *restrict a, const struct leases_t *restrict b) +{ + return memcmp(&a->ip.v6, &b->ip.v6, sizeof(a->ip.v6)); +} + /*! \brief Compare IP address in leases. Suitable for sorting range table. * \param r1 A range structure. * \param r2 A range structure. From 74c6ef25662819fdc56a913896c5c893dac3ca79 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 9 Aug 2014 19:34:18 +0100 Subject: [PATCH 108/313] update kernel.org url in README Signed-off-by: Sami Kerola --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 0e8ffa4..2c1fd7b 100644 --- a/README +++ b/README @@ -190,7 +190,7 @@ CODING STYLE: * The preferred coding style is based on the linux kernel Documentation/CodingStyle. For more details see: - http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/CodingStyle + http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/CodingStyle * Source code is pretty printed by using two, and only the two, indent command switches -kr -i8 From 15502d3c972332823dd379a6f6649a95f785030b Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 24 Oct 2014 20:56:41 +0100 Subject: [PATCH 109/313] getdata: fix buffer-overflows reported by address sanitizer These happen when input configuration or leases files are empty. ==12876==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900000a480 at pc 0x000000487442 bp 0x7fffbc3e16b0 sp 0x7fffbc3e0e70 READ of size 1025 at 0x61900000a480 thread T0 #0 0x487441 in __interceptor_strlen (/home/src/dhcpd-pools/dhcpd-pools+0x487441) #1 0x4bbb10 in parse_leases /home/src/dhcpd-pools/src/getdata.c:112:35 #2 0x4bb337 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:268:2 #3 0x7f51909bf03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f) #4 0x4b9c0c in _start (/home/src/dhcpd-pools/dhcpd-pools+0x4b9c0c) 0x61900000a480 is located 0 bytes to the right of 1024-byte region [0x61900000a080,0x61900000a480) allocated by thread T0 here: #0 0x49c58b in __interceptor_malloc (/home/src/dhcpd-pools/dhcpd-pools+0x49c58b) #1 0x4cbbcd in xmalloc /home/src/dhcpd-pools/lib/xmalloc.c:41:13 #2 0x4bb801 in parse_leases /home/src/dhcpd-pools/src/getdata.c:96:9 #3 0x4bb337 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:268:2 #4 0x7f51909bf03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f) Signed-off-by: Sami Kerola --- src/getdata.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/getdata.c b/src/getdata.c index 56d5088..976f0c1 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -94,7 +94,9 @@ int parse_leases(void) } line = xmalloc(sizeof(char) * MAXLEN); + line[0] = '\0'; ipstring = xmalloc(sizeof(char) * MAXLEN); + ipstring[0] = '\0'; if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { ethernets = true; } From bd5877bf4f9883eb05de109999473df193a8feb6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 24 Oct 2014 20:58:27 +0100 Subject: [PATCH 110/313] update bootstrap from gnulib Signed-off-by: Sami Kerola --- bootstrap | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/bootstrap b/bootstrap index 8c68fea..60ff8cd 100755 --- a/bootstrap +++ b/bootstrap @@ -211,7 +211,17 @@ bootstrap_sync=false use_git=true check_exists() { - ($1 --version /dev/null 2>&1 + if test "$1" = "--verbose"; then + ($2 --version /dev/null 2>&1 + if test $? -ge 126; then + # If not found, run with diagnostics as one may be + # presented with env variables to set to find the right version + ($2 --version /dev/null 2>&1 + fi + test $? -lt 126 } @@ -409,7 +419,7 @@ sort_ver() { # sort -V is not generally available get_version() { app=$1 - $app --version >/dev/null 2>&1 || return 1 + $app --version >/dev/null 2>&1 || { $app --version; return 1; } $app --version 2>&1 | sed -n '# Move version to start of line. @@ -468,7 +478,7 @@ check_versions() { if [ "$req_ver" = "-" ]; then # Merely require app to exist; not all prereq apps are well-behaved # so we have to rely on $? rather than get_version. - if ! check_exists $app; then + if ! check_exists --verbose $app; then warn_ "Error: '$app' not found" ret=1 fi @@ -599,8 +609,8 @@ case ${GNULIB_SRCDIR--} in # Note that $use_git is necessarily true in this case. if git_modules_config submodule.gnulib.url >/dev/null; then echo "$0: getting gnulib files..." - git submodule init || exit $? - git submodule update || exit $? + git submodule init -- "$gnulib_path" || exit $? + git submodule update -- "$gnulib_path" || exit $? elif [ ! -d "$gnulib_path" ]; then echo "$0: getting gnulib files..." @@ -629,13 +639,14 @@ case ${GNULIB_SRCDIR--} in # This fallback allows at least git 1.5.5. if test -f "$gnulib_path"/gnulib-tool; then # Since file already exists, assume submodule init already complete. - git submodule update || exit $? + git submodule update -- "$gnulib_path" || exit $? else # Older git can't clone into an empty directory. rmdir "$gnulib_path" 2>/dev/null git clone --reference "$GNULIB_SRCDIR" \ "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \ - && git submodule init && git submodule update \ + && git submodule init -- "$gnulib_path" \ + && git submodule update -- "$gnulib_path" \ || exit $? fi fi From 0d2b30b62d176b32ac2a8475139fab4cf03bf67d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 2 Nov 2014 21:56:43 +0000 Subject: [PATCH 111/313] getdata: fix buffer overflow [AddressSanitizer] ==12031==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61900000a980 at pc 0x0000004bca22 bp 0x7fff580dd6d0 sp 0x7fff580dd6c8 WRITE of size 1 at 0x61900000a980 thread T0 #0 0x4bca21 in parse_config /home/src/dhcpd-pools/src/getdata.c:323:4 #1 0x4bb332 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:266:2 #2 0x7fe03ecc403f in __libc_start_main (/usr/lib/libc.so.6+0x2003f) #3 0x4b9c0c in _start (/home/src/dhcpd-pools/dhcpd-pools+0x4b9c0c) 0x61900000a980 is located 0 bytes to the right of 1024-byte region [0x61900000a580,0x61900000a980) allocated by thread T0 here: #0 0x49c58b in __interceptor_malloc (/home/src/dhcpd-pools/dhcpd-pools+0x49c58b) #1 0x4cbc0d in xmalloc /home/src/dhcpd-pools/lib/xmalloc.c:41:13 #2 0x4bbed8 in parse_config /home/src/dhcpd-pools/src/getdata.c:195:9 #3 0x4bb332 in main /home/src/dhcpd-pools/src/dhcpd-pools.c:266:2 #4 0x7fe03ecc403f in __libc_start_main (/usr/lib/libc.so.6+0x2003f) SUMMARY: AddressSanitizer: heap-buffer-overflow /home/src/dhcpd-pools/src/getdata.c:323 parse_config Signed-off-by: Sami Kerola --- src/getdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getdata.c b/src/getdata.c index 976f0c1..0f5e8ae 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -325,7 +325,7 @@ void parse_config(int is_include, const char *restrict config_file, /* Long word which is almost causing overflow. None * of words are this long which the program is * searching. */ - if (MAXLEN < i) { + if (MAXLEN == i) { newclause = false; i = 0; continue; From e401c2c7e6e61e01b66dc1783ad813ce96ff1ddc Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Nov 2014 22:25:25 +0000 Subject: [PATCH 112/313] other: reduce variable scope Signed-off-by: Sami Kerola --- src/other.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/other.c b/src/other.c index a983a5c..b5ff78b 100644 --- a/src/other.c +++ b/src/other.c @@ -404,8 +404,6 @@ void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ /*! \brief Free memory, flush buffers etc. */ void clean_up(void) { - unsigned int i; - /* Just in case there something in buffers */ if (fflush(NULL)) { warn("clean_up: fflush"); @@ -416,6 +414,7 @@ void clean_up(void) free(ranges); delete_all_leases(); if (shared_networks) { + unsigned int i; num_shared_networks++; for (i = 0; i < num_shared_networks; i++) { free((shared_networks + i)->name); From 190df198a4e2c10f80f705bb3488c09bb9a453b3 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 9 Nov 2014 22:31:30 +0000 Subject: [PATCH 113/313] output: prefer thread safe function localtime_r() While the dhcpd-pools might not be threading there is no reason why software should use worse function when always correct alternative is equally easy to use. Signed-off-by: Sami Kerola --- src/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/output.c b/src/output.c index e713056..dc79bab 100644 --- a/src/output.c +++ b/src/output.c @@ -458,16 +458,16 @@ int output_json(void) static void html_header(FILE *restrict f) { char outstr[200]; - struct tm *tmp; + struct tm *tmp, result; struct stat statbuf; stat(config.dhcpdlease_file, &statbuf); - tmp = localtime(&statbuf.st_mtime); + tmp = localtime_r(&statbuf.st_mtime, &result); if (tmp == NULL) { err(EXIT_FAILURE, "html_header: localtime"); } - if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), tmp) == 0) { + if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) { errx(EXIT_FAILURE, "html_header: strftime returned 0"); } From 5519763ba9c567f6eb04764b0696da628565a585 Mon Sep 17 00:00:00 2001 From: Wolfgang Steudel Date: Thu, 13 Nov 2014 09:45:59 +0000 Subject: [PATCH 114/313] alarming: include last shared network in alarming [off by one] We have defined some shared networks with a couple of address ranges and wanted to monitor the availability of free IP addresses in the shared networks. We were wondering why in some cases there was no warning, although one shared network's usage was above the threshold. We found the reason. In output_alarming() the code was not skipping "All networks", but missing the last shared network in the list. Moving "shared_p++" to the beginning of the loop seems to solve the bug. Reviewed-by: Sami Kerola Signed-off-by: Wolfgang Steudel --- THANKS | 1 + src/output.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 8c18c15..949078f 100644 --- a/THANKS +++ b/THANKS @@ -31,3 +31,4 @@ Ryan Steinmetz Dan Pritts Fredrik Lysén Conor McCarthy +Wolfgang Steudel diff --git a/src/output.c b/src/output.c index dc79bab..9268b32 100644 --- a/src/output.c +++ b/src/output.c @@ -994,6 +994,7 @@ int output_alarming(void) } if (config.output_limit[1] & BIT2) { for (i = 0; i < num_shared_networks; i++) { + shared_p++; if (config.minsize < shared_p->available) { perc = (float)(100 * shared_p->used) / shared_p->available; if (config.critical < perc) @@ -1005,7 +1006,6 @@ int output_alarming(void) } else { si++; } - shared_p++; } } From 0705b0c17f0cf39808d8a48c5484a325a1d34294 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 14 Nov 2014 20:06:59 +0000 Subject: [PATCH 115/313] tests: add regression test to avoid shared-net off by one alarming issue This tests ensures the problem fixed by Wolfgang Steudel cannot reoccur. See the reference commit for details. Reference: 5519763ba9c567f6eb04764b0696da628565a585 Signed-off-by: Sami Kerola --- tests/Makemodule.am | 1 + tests/confs/shnet-alarm | 31 +++++++++ tests/expected/shnet-alarm | 3 + tests/leases/shnet-alarm | 136 +++++++++++++++++++++++++++++++++++++ tests/shnet-alarm | 16 +++++ 5 files changed, 187 insertions(+) create mode 100644 tests/confs/shnet-alarm create mode 100644 tests/expected/shnet-alarm create mode 100644 tests/leases/shnet-alarm create mode 100755 tests/shnet-alarm diff --git a/tests/Makemodule.am b/tests/Makemodule.am index f58a38f..fdb48be 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -8,6 +8,7 @@ TESTS = \ tests/alarm-warning \ tests/alarm-warning-ranges \ tests/alarm-warning-snets \ + tests/shnet-alarm \ tests/bootp \ tests/complete \ tests/empty \ diff --git a/tests/confs/shnet-alarm b/tests/confs/shnet-alarm new file mode 100644 index 0000000..0ef9eb0 --- /dev/null +++ b/tests/confs/shnet-alarm @@ -0,0 +1,31 @@ +shared-network example1 { + subnet 10.0.0.0 netmask 255.255.255.0 { + pool { + range 10.0.0.1 10.0.0.20; + } + } + subnet 10.1.0.0 netmask 255.255.255.0 { + pool { + range 10.1.0.1 10.1.0.20; + } + } +} + +shared-network example2 { + subnet 10.2.0.0 netmask 255.255.255.0 { + pool { + range 10.2.0.1 10.2.0.20; + } + } + subnet 10.3.0.0 netmask 255.255.255.0 { + pool { + range 10.3.0.1 10.3.0.20; + } + } +} + +subnet 10.4.0.0 netmask 255.255.255.0 { + pool { + range 10.4.0.1 10.4.0.20; + } +} diff --git a/tests/expected/shnet-alarm b/tests/expected/shnet-alarm new file mode 100644 index 0000000..250b77f --- /dev/null +++ b/tests/expected/shnet-alarm @@ -0,0 +1,3 @@ +CRITICAL: dhcpd-pools: Ranges - crit: 2 warn: 0 ok: 3; | range_crit=2 range_warn=0 range_ok=3 +Shared nets - crit: 1 warn: 0 ok: 1; | snet_crit=1 snet_warn=0 snet_ok=1 +2 diff --git a/tests/leases/shnet-alarm b/tests/leases/shnet-alarm new file mode 100644 index 0000000..d78db2c --- /dev/null +++ b/tests/leases/shnet-alarm @@ -0,0 +1,136 @@ +lease 10.0.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} + +lease 10.1.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} + +lease 10.2.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.2.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.2.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.2.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.2.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.2.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} + +lease 10.3.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.3.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.3.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.3.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.3.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.3.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.3.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.3.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.3.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} +lease 10.3.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:09; +} + +lease 10.4.0.0 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.4.0.1 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.4.0.2 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.4.0.3 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.4.0.4 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.4.0.5 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.4.0.6 { + binding state active; + hardware ethernet 00:00:00:00:00:00; +} +lease 10.4.0.7 { + binding state active; + hardware ethernet 00:00:00:00:00:01; +} +lease 10.4.0.8 { + binding state active; + hardware ethernet 00:00:00:00:00:02; +} +lease 10.4.0.9 { + binding state active; + hardware ethernet 00:00:00:00:00:03; +} +lease 10.4.0.10 { + binding state active; + hardware ethernet 00:00:00:00:00:04; +} +lease 10.4.0.11 { + binding state active; + hardware ethernet 00:00:00:00:00:05; +} +lease 10.4.0.12 { + binding state active; + hardware ethernet 00:00:00:00:00:06; +} +lease 10.4.0.13 { + binding state active; + hardware ethernet 00:00:00:00:00:07; +} +lease 10.4.0.14 { + binding state active; + hardware ethernet 00:00:00:00:00:08; +} diff --git a/tests/shnet-alarm b/tests/shnet-alarm new file mode 100755 index 0000000..24bb088 --- /dev/null +++ b/tests/shnet-alarm @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Alarm critical ranges only. + +IAM=$(basename $0) + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools --critical=30 -c $top_srcdir/tests/confs/shnet-alarm \ + -l $top_srcdir/tests/leases/shnet-alarm -o tests/outputs/$IAM +echo $? >> tests/outputs/$IAM + +diff -u $top_srcdir/tests/expected/$IAM tests/outputs/$IAM +exit $? From 8e076fcc4fb4ff3746a354d29047665e29880f1c Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 14 Nov 2014 21:48:22 +0000 Subject: [PATCH 116/313] output: avoid division by zero This correction makes the shared networks alarming to work when all available leases are used. Signed-off-by: Sami Kerola --- bootstrap.conf | 1 + src/output.c | 96 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 38 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index bb1840d..b815859 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -27,6 +27,7 @@ gnulib_modules=" fopen getopt-gnu inet_pton + isnan langinfo netinet_in progname diff --git a/src/output.c b/src/output.c index 9268b32..679a089 100644 --- a/src/output.c +++ b/src/output.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -147,12 +148,12 @@ int output_txt(void) "%-20s %5g %5g %10.3f %7g %6g %9.3f", shared_p->name, shared_p->available, shared_p->used, - (float)(100 * shared_p->used) / - shared_p->available, shared_p->touched, - shared_p->touched + shared_p->used, - (float)(100 * - (shared_p->touched + - shared_p->used)) / shared_p->available); + shared_p->available == + 0 ? -NAN : (float)(100 * shared_p->used) / shared_p->available, + shared_p->touched, shared_p->touched + shared_p->used, + shared_p->available == + 0 ? -NAN : ((float)(100 * (shared_p->touched + shared_p->used)) / + shared_p->available)); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", shared_p->backups, @@ -180,17 +181,18 @@ int output_txt(void) shared_networks->name, shared_networks->available, shared_networks->used, - (float)(100 * shared_networks->used) / - shared_networks->available, - shared_networks->touched, + shared_networks->available == + 0 ? -NAN : (float)(100 * shared_networks->used) / + shared_networks->available, shared_networks->touched, shared_networks->touched + shared_networks->used, - (float)(100 * - (shared_networks->touched + - shared_networks->used)) / shared_networks->available); + shared_networks->available == + 0 ? -NAN : (float)(100 * + (shared_networks->touched + + shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", - shared_networks->backups, + shared_networks->available == 0 ? -NAN : shared_networks->backups, (float)(100 * shared_networks->backups) / shared_networks->available); } @@ -736,18 +738,23 @@ int output_html(void) output_double(outfile, "td", shared_p->available); output_double(outfile, "td", shared_p->used); output_float(outfile, "td", - (float)(100 * shared_p->used) / shared_p->available); + shared_p->available == + 0 ? -NAN : (float)(100 * shared_p->used) / + shared_p->available); output_double(outfile, "td", shared_p->touched); output_double(outfile, "td", shared_p->touched + shared_p->used); output_float(outfile, "td", - (float)(100 * - (shared_p->touched + - shared_p->used)) / shared_p->available); + shared_p->available == 0 ? -NAN : (float)(100 * + (shared_p->touched + + shared_p->used)) / + shared_p->available); if (config.backups_found == true) { output_double(outfile, "td", shared_p->backups); output_float(outfile, "td", - (float)(100 * - shared_p->backups) / shared_p->available); + shared_p->available == 0 ? -NAN : (float)(100 * + shared_p-> + backups) / + shared_p->available); } endrow(outfile); @@ -776,18 +783,24 @@ int output_html(void) output_double(outfile, "td", shared_networks->available); output_double(outfile, "td", shared_networks->used); output_float(outfile, "td", - (float)(100 * shared_networks->used) / shared_networks->available); + shared_networks->available == + 0 ? -NAN : (float)(100 * shared_networks->used) / + shared_networks->available); output_double(outfile, "td", shared_networks->touched); output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_float(outfile, "td", - (float)(100 * - (shared_networks->touched + - shared_networks->used)) / shared_networks->available); + shared_networks->available == 0 ? -NAN : (float)(100 * + (shared_networks-> + touched + + shared_networks-> + used)) / + shared_networks->available); if (config.backups_found == true) { output_double(outfile, "td", shared_networks->backups); output_float(outfile, "td", - (float)(100 * - shared_networks->backups) / + shared_networks->available == 0 ? -NAN : (float)(100 * + shared_networks-> + backups) / shared_networks->available); } endrow(outfile); @@ -888,16 +901,19 @@ int output_csv(void) "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", shared_p->name, shared_p->available, shared_p->used, - (float)(100 * shared_p->used) / + shared_p->available == 0 ? -NAN : (float)(100 * shared_p->used) / shared_p->available, shared_p->touched, shared_p->touched + shared_p->used, - (float)(100 * - (shared_p->touched + - shared_p->used)) / shared_p->available); + shared_p->available == 0 ? -NAN : (float)(100 * + (shared_p->touched + + shared_p->used)) / + shared_p->available); if (config.backups_found == true) { fprintf(outfile, ",\"%g\",\"%.3f\"", shared_p->backups, - (float)(100 * shared_p->backups) / shared_p->available); + shared_p->available == + 0 ? -NAN : (float)(100 * shared_p->backups) / + shared_p->available); } fprintf(outfile, "\n"); @@ -919,17 +935,19 @@ int output_csv(void) "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", shared_networks->name, shared_networks->available, shared_networks->used, - (float)(100 * shared_networks->used) / - shared_networks->available, - shared_networks->touched, + shared_networks->available == + 0 ? -NAN : (float)(100 * shared_networks->used) / + shared_networks->available, shared_networks->touched, shared_networks->touched + shared_networks->used, - (float)(100 * - (shared_networks->touched + - shared_networks->used)) / shared_networks->available); + shared_networks->available == + 0 ? -NAN : (float)(100 * + (shared_networks->touched + + shared_networks->used)) / shared_networks->available); if (config.backups_found == true) { fprintf(outfile, "%7g %8.3f", shared_networks->backups, - (float)(100 * shared_networks->backups) / + shared_networks->available == + 0 ? -NAN : (float)(100 * shared_networks->backups) / shared_networks->available); } fprintf(outfile, "\n"); @@ -996,7 +1014,9 @@ int output_alarming(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; if (config.minsize < shared_p->available) { - perc = (float)(100 * shared_p->used) / shared_p->available; + perc = + shared_p->available == + 0 ? 100 : (float)(100 * shared_p->used) / shared_p->available; if (config.critical < perc) sc++; else if (config.warning < perc) From 33894fba74b8fc78d445b46f87fb83f5f96dc308 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 14 Nov 2014 21:55:17 +0000 Subject: [PATCH 117/313] other: disallow unsigned counter ever to have minus value src/other.c:398:4: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned int' Signed-off-by: Sami Kerola --- src/other.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/other.c b/src/other.c index b5ff78b..f81e506 100644 --- a/src/other.c +++ b/src/other.c @@ -393,9 +393,8 @@ void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ { unsigned int i = num_ranges - 1, j; - for (j = 0; j < num_ranges; j++) { + for (j = 0; j < num_ranges; j++, i--) { *(tmp_ranges + j) = *(flip_me + i); - i--; } memcpy(flip_me, tmp_ranges, num_ranges * sizeof(struct range_t)); From cfbd69c20b0a7de5028f0f4435876a3d44441355 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 15 Nov 2014 09:27:41 +0000 Subject: [PATCH 118/313] maint: remove unnecessary braces, spaces, update gnulib .gitignore Improve code readability, and small maintenance. Signed-off-by: Sami Kerola --- lib/.gitignore | 11 ++++++ src/.indent.pro | 2 + src/analyze.c | 17 ++------- src/dhcpd-pools.c | 33 ++++------------ src/getdata.c | 96 +++++++++++++++-------------------------------- src/hash.c | 6 +++ src/other.c | 47 ++++++++++++----------- src/sort.c | 15 ++------ 8 files changed, 86 insertions(+), 141 deletions(-) diff --git a/lib/.gitignore b/lib/.gitignore index 8208f92..928a516 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -40,6 +40,9 @@ /fd-hook.h /fdopen.c /fflush.c +/float+.h +/float.c +/float.in.h /fopen.c /fpending.c /fpending.h @@ -60,6 +63,11 @@ /gettimeofday.c /inet_pton.c /intprops.h +/isnan.c +/isnand.c +/isnanf.c +/isnanl.c +/itold.c /langinfo.h /langinfo.in.h /libdhcpd_pools.la @@ -67,6 +75,9 @@ /localcharset.h /lseek.c /malloc.c +/math.c +/math.h +/math.in.h /mbrtowc.c /mbsinit.c /memchr.c diff --git a/src/.indent.pro b/src/.indent.pro index 16702c4..3d15003 100644 --- a/src/.indent.pro +++ b/src/.indent.pro @@ -9,3 +9,5 @@ -Tuintmax_t -l100 -ppi1 +-bad +-sob diff --git a/src/analyze.c b/src/analyze.c index 9c05a43..4c39b62 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -65,19 +65,16 @@ int do_counting(void) const struct leases_t *restrict l = leases; unsigned long i, k, block_size; - range_p = ranges; - /* Walk through ranges */ + range_p = ranges; for (i = 0; i < num_ranges; i++) { for (; l != NULL && ipcomp(&range_p->first_ip, &l->ip) < 0; l = l->hh.prev) /* rewind */ ; if (l == NULL) l = leases; for (; l != NULL && ipcomp(&l->ip, &range_p->last_ip) <= 0; l = l->hh.next) { - if (ipcomp(&l->ip, &range_p->first_ip) < 0) { - /* should not be necessary */ - continue; - } + if (ipcomp(&l->ip, &range_p->first_ip) < 0) + continue; /* cannot happen? */ /* IP in range */ switch (l->type) { case FREE: @@ -90,7 +87,6 @@ int do_counting(void) range_p->backups++; break; } - if (range_p->shared_net) { switch (l->type) { case FREE: @@ -105,16 +101,12 @@ int do_counting(void) } } } - /* Size of range, shared net & all networks */ block_size = get_range_size(range_p); - if (range_p->shared_net) { + if (range_p->shared_net) range_p->shared_net->available += block_size; - } - range_p++; } - /* FIXME: During count of other shared networks default network * and all networks got mixed together semantically. The below * fixes the problem, but is not elegant. */ @@ -129,6 +121,5 @@ int do_counting(void) shared_networks->backups += range_p->backups; range_p++; } - return 0; } diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 974eaf6..bfb312b 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -99,7 +99,6 @@ int main(int argc, char **argv) }; int ret_val; - /* Options for getopt_long */ static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, {"leases", required_argument, NULL, 'l'}, @@ -118,20 +117,17 @@ int main(int argc, char **argv) atexit(close_stdout); set_program_name(argv[0]); - /* FIXME: These allocations should be fully dynamic, e.g., grow * if needed. */ config.dhcpdconf_file = xmalloc(sizeof(char) * MAXLEN); config.dhcpdlease_file = xmalloc(sizeof(char) * MAXLEN); config.output_file = xmalloc(sizeof(char) * MAXLEN); - /* Make sure string has zero length if there is no * command line option */ config.output_file[0] = '\0'; /* Alarming defaults. */ config.warning = ALARM_WARN; config.critical = ALARM_CRIT; - /* File location defaults */ strncpy(config.dhcpdconf_file, DHCPDCONF_FILE, MAXLEN - 1); strncpy(config.dhcpdlease_file, DHCPDLEASE_FILE, MAXLEN - 1); @@ -140,22 +136,18 @@ int main(int argc, char **argv) tmp++; config.output_limit[1] = (*tmp - '0'); config.fullhtml = false; - /* Make sure some output format is selected by default */ strncpy(config.output_format, OUTPUT_FORMAT, (size_t)1); - /* Default sort order is by IPs small to big */ config.reverse_order = false; config.backups_found = false; - /* Parse command line options */ while (1) { int c; - c = getopt_long(argc, argv, "c:l:f:o:s:rL:vh", long_options, &option_index); + c = getopt_long(argc, argv, "c:l:f:o:s:rL:vh", long_options, &option_index); if (c == EOF) break; - switch (c) { case 'c': /* config file */ @@ -176,12 +168,10 @@ int main(int argc, char **argv) warnx("main: only first 5 sort orders will be used"); strncpy(config.sort, optarg, (size_t)5); sorts = 5; - } else { + } else strncpy(config.sort, optarg, (size_t)sorts); - } - for (i = 0; i < sorts; i++) { + for (i = 0; i < sorts; i++) field_selector(config.sort[i]); - } break; case 'r': /* What ever sort in reverse order */ @@ -194,9 +184,9 @@ int main(int argc, char **argv) case 'L': /* Specification what will be printed */ for (i = 0; i < 2; i++) { - if (optarg[i] >= '0' && optarg[i] < '8') { + if (optarg[i] >= '0' && optarg[i] < '8') config.output_limit[i] = optarg[i] - '0'; - } else { + else { clean_up(); errx(EXIT_FAILURE, "main: output mask `%s' is illegal", optarg); @@ -224,7 +214,6 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); } } - /* Output function selection */ switch (config.output_format[0]) { case 't': @@ -259,25 +248,20 @@ int main(int argc, char **argv) clean_up(); errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); } - /* Do the job */ prepare_memory(); set_ipv_functions(VERSION_UNKNOWN); parse_config(true, config.dhcpdconf_file, shared_networks); - parse_leases(); prepare_data(); do_counting(); tmp_ranges = xmalloc(sizeof(struct range_t) * num_ranges); - if (sorts != 0) { + if (sorts != 0) mergesort_ranges(ranges, num_ranges, tmp_ranges); - } - if (config.reverse_order == true) { + if (config.reverse_order == true) flip_ranges(ranges, tmp_ranges); - } free(tmp_ranges); ret_val = output_analysis(); - clean_up(); return (ret_val); } @@ -291,14 +275,11 @@ int prepare_memory(void) RANGES = 64; num_ranges = num_shared_networks = 0; shared_networks = xmalloc(sizeof(struct shared_network_t) * SHARED_NETWORKS); - ranges = xmalloc(sizeof(struct range_t) * RANGES); - /* First shared network entry is all networks */ shared_networks->name = xstrdup("All networks"); shared_networks->used = 0; shared_networks->touched = 0; shared_networks->backups = 0; - return 0; } diff --git a/src/getdata.c b/src/getdata.c index 0f5e8ae..bf2de86 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -69,42 +69,33 @@ int parse_leases(void) struct leases_t *lease; dhcpd_leases = fopen(config.dhcpdlease_file, "r"); - if (dhcpd_leases == NULL) { + if (dhcpd_leases == NULL) err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); - } #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE - if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) { + if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); - } # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL - if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { + if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); - } # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ - /* I found out that there's one lease address per 300 bytes in * dhcpd.leases file. Malloc is little bit pessimistic and uses 250. * If someone has higher density in lease file I'm interested to * hear about that. */ - if (stat(config.dhcpdlease_file, &lease_file_stats)) { + if (stat(config.dhcpdlease_file, &lease_file_stats)) err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); - } - line = xmalloc(sizeof(char) * MAXLEN); line[0] = '\0'; ipstring = xmalloc(sizeof(char) * MAXLEN); ipstring[0] = '\0'; - if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { + if (config.output_format[0] == 'X' || config.output_format[0] == 'J') ethernets = true; - } - while (!feof(dhcpd_leases)) { - if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) { + if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); - } switch (xstrstr(line)) { /* It's a lease, save IP */ case PREFIX_LEASE: @@ -122,23 +113,20 @@ int parse_leases(void) case PREFIX_BINDING_STATE_ABANDONED: case PREFIX_BINDING_STATE_EXPIRED: case PREFIX_BINDING_STATE_RELEASED: - if ((lease = find_lease(&addr)) != NULL) { + if ((lease = find_lease(&addr)) != NULL) delete_lease(lease); - } add_lease(&addr, FREE); break; case PREFIX_BINDING_STATE_ACTIVE: /* remove old entry, if exists */ - if ((lease = find_lease(&addr)) != NULL) { + if ((lease = find_lease(&addr)) != NULL) delete_lease(lease); - } add_lease(&addr, ACTIVE); break; case PREFIX_BINDING_STATE_BACKUP: /* remove old entry, if exists */ - if ((lease = find_lease(&addr)) != NULL) { + if ((lease = find_lease(&addr)) != NULL) delete_lease(lease); - } add_lease(&addr, BACKUP); config.backups_found = true; break; @@ -147,9 +135,8 @@ int parse_leases(void) break; memcpy(macstring, line + 20, 17); macstring[17] = '\0'; - if ((lease = find_lease(&addr)) != NULL) { + if ((lease = find_lease(&addr)) != NULL) lease->ethernet = xstrdup(macstring); - } break; default: /* do nothing */ ; @@ -193,41 +180,34 @@ void parse_config(int is_include, const char *restrict config_file, struct range_t *range_p; word = xmalloc(sizeof(char) * MAXLEN); - - if (is_include) { + if (is_include) /* Default place holder for ranges "All networks". */ shared_p->name = shared_networks->name; - } - /* Open configuration file */ dhcpd_config = fopen(config_file, "r"); - if (dhcpd_config == NULL) { + if (dhcpd_config == NULL) err(EXIT_FAILURE, "parse_config: %s", config_file); - } #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE - if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) { + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); - } # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL - if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) { + if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); - } # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ - /* Very hairy stuff begins. */ while (unlikely(!feof(dhcpd_config))) { char c; + c = fgetc(dhcpd_config); /* Certain characters are magical */ switch (c) { /* Handle comments if they are not quoted */ case '#': - if (quote == 0) { + if (quote == 0) comment = true; - } continue; case '"': if (comment == false) { @@ -239,15 +219,13 @@ void parse_config(int is_include, const char *restrict config_file, case '\n': /* New line resets comment section, but * not if quoted */ - if (quote == 0) { + if (quote == 0) comment = false; - } break; case ';': /* Quoted colon does not mean new clause */ - if (0 < quote) { + if (0 < quote) break; - } if (comment == false && argument != ITS_A_RANGE_FIRST_IP && argument != ITS_A_RANGE_SECOND_IP && argument != ITS_AN_INCLUCE) { @@ -271,25 +249,21 @@ void parse_config(int is_include, const char *restrict config_file, } continue; case '{': - if (0 < quote) { + if (0 < quote) break; - } - if (comment == 0) { + if (comment == 0) braces++; - } /* i == 0 detects word that ends to brace like: * * shared-network DSL{ ... */ if (i == 0) { newclause = true; continue; - } else { + } else break; - } case '}': - if (0 < quote) { + if (0 < quote) break; - } if (comment == false) { braces--; /* End of shared-network */ @@ -307,16 +281,13 @@ void parse_config(int is_include, const char *restrict config_file, default: break; } - /* Either inside comment or Nth word of clause. */ - if (comment == true || (newclause == false && argument == ITS_NOTHING_INTERESTING)) { + if (comment == true || (newclause == false && argument == ITS_NOTHING_INTERESTING)) continue; - } /* Strip white spaces before new clause word. */ if ((newclause == true || argument != ITS_NOTHING_INTERESTING) - && isspace(c) && i == 0 && one_ip_range == false) { + && isspace(c) && i == 0 && one_ip_range == false) continue; - } /* Save to word which clause this is. */ if ((newclause == true || argument != ITS_NOTHING_INTERESTING) && (!isspace(c) || 0 < quote)) { @@ -335,14 +306,12 @@ void parse_config(int is_include, const char *restrict config_file, else if (newclause == true) { /* Insert string end & set state */ word[i] = '\0'; - if (word[i - 1] != '{') { + if (word[i - 1] != '{') newclause = false; - } i = 0; argument = is_interesting_config_clause(word); - if (argument == ITS_A_RANGE_FIRST_IP) { + if (argument == ITS_A_RANGE_FIRST_IP) one_ip_range = true; - } } /* words after range, shared-network or include */ else if (argument != ITS_NOTHING_INTERESTING) { @@ -377,11 +346,9 @@ void parse_config(int is_include, const char *restrict config_file, case ITS_A_RANGE_FIRST_IP: /* printf ("range 1nd ip: %s\n", word); */ range_p = ranges + num_ranges; - if (!(parse_ipaddr(word, &addr))) { - /* word was not ip, try - * again */ + if (!(parse_ipaddr(word, &addr))) + /* word was not ip, try again */ break; - } copy_ipaddr(&range_p->first_ip, &addr); one_ip_range = false; argument = ITS_A_RANGE_SECOND_IP; @@ -395,13 +362,10 @@ void parse_config(int is_include, const char *restrict config_file, shared_p->used = 0; shared_p->touched = 0; shared_p->backups = 0; - if (SHARED_NETWORKS < num_shared_networks + 2) { - /* FIXME: make this - * away by reallocating - * more space. */ + if (SHARED_NETWORKS < num_shared_networks + 2) + /* FIXME: make this to go away by reallocating more space. */ errx(EXIT_FAILURE, "parse_config: increase default.h SHARED_NETWORKS and recompile"); - } argument = ITS_NOTHING_INTERESTING; braces_shared = braces; break; diff --git a/src/hash.c b/src/hash.c index 4b42610..a75e9f4 100644 --- a/src/hash.c +++ b/src/hash.c @@ -55,6 +55,7 @@ void add_lease_init(union ipaddr_t *addr void add_lease_v4(union ipaddr_t *addr, enum ltype type) { struct leases_t *l; + l = xmalloc(sizeof(struct leases_t)); copy_ipaddr(&l->ip, addr); l->type = type; @@ -65,6 +66,7 @@ void add_lease_v4(union ipaddr_t *addr, enum ltype type) void add_lease_v6(union ipaddr_t *addr, enum ltype type) { struct leases_t *l; + l = xmalloc(sizeof(struct leases_t)); copy_ipaddr(&l->ip, addr); l->type = type; @@ -84,6 +86,7 @@ struct leases_t *find_lease_init(union ipaddr_t *addr __attribute__ ((unused))) struct leases_t *find_lease_v4(union ipaddr_t *addr) { struct leases_t *l; + HASH_FIND_INT(leases, &addr->v4, l); return l; } @@ -91,6 +94,7 @@ struct leases_t *find_lease_v4(union ipaddr_t *addr) struct leases_t *find_lease_v6(union ipaddr_t *addr) { struct leases_t *l; + HASH_FIND_V6(leases, &addr->v4, l); return l; } @@ -109,6 +113,7 @@ void delete_lease(struct leases_t *lease) void delete_all_leases(void) { struct leases_t *l, *tmp; + HASH_ITER(hh, leases, l, tmp) { free(l->ethernet); HASH_DEL(leases, l); @@ -120,6 +125,7 @@ void delete_all_leases(void) { while (leases) { struct leases_t *l; + l = leases; free(l->ethernet); HASH_DEL(leases, l); /* leases advances to next on delete */ diff --git a/src/other.c b/src/other.c index f81e506..e9f49c8 100644 --- a/src/other.c +++ b/src/other.c @@ -117,13 +117,13 @@ int parse_ipaddr_init(const char *restrict src, union ipaddr_t *restrict dst) { struct in_addr addr; struct in6_addr addr6; - if (inet_aton(src, &addr) == 1) { + + if (inet_aton(src, &addr) == 1) set_ipv_functions(VERSION_4); - } else if (inet_pton(AF_INET6, src, &addr6) == 1) { + else if (inet_pton(AF_INET6, src, &addr6) == 1) set_ipv_functions(VERSION_6); - } else { + else return 0; - } return parse_ipaddr(src, dst); } @@ -131,6 +131,7 @@ int parse_ipaddr_v4(const char *restrict src, union ipaddr_t *restrict dst) { int rv; struct in_addr addr; + rv = inet_aton(src, &addr); dst->v4 = ntohl(addr.s_addr); return rv == 1; @@ -140,6 +141,7 @@ int parse_ipaddr_v6(const char *restrict src, union ipaddr_t *restrict dst) { int rv; struct in6_addr addr; + rv = inet_pton(AF_INET6, src, &addr); memcpy(&dst->v6, addr.s6_addr, sizeof(addr.s6_addr)); return rv == 1; @@ -175,6 +177,7 @@ void copy_ipaddr_v6(union ipaddr_t *restrict dst, const union ipaddr_t *restrict const char *ntop_ipaddr_init(const union ipaddr_t *ip __attribute__ ((unused))) { static char buffer = '\0'; + return &buffer; } @@ -182,6 +185,7 @@ const char *ntop_ipaddr_v4(const union ipaddr_t *ip) { static char buffer[sizeof("255.255.255.255")]; struct in_addr addr; + addr.s_addr = htonl(ip->v4); return inet_ntop(AF_INET, &addr, buffer, sizeof(buffer)); } @@ -190,6 +194,7 @@ const char *ntop_ipaddr_v6(const union ipaddr_t *ip) { static char buffer[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; struct in6_addr addr; + memcpy(addr.s6_addr, ip->v6, sizeof(addr.s6_addr)); return inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer)); } @@ -214,6 +219,7 @@ double get_range_size_v6(const struct range_t *r) { double size = 0; int i; + /* When calculating the size of an IPv6 range overflow may occur. * In that case only the last LONG_BIT bits are preserved, thus * we just skip the first (16 - LONG_BIT) bits... */ @@ -260,11 +266,11 @@ int xstrstr_v4(const char *restrict str) { size_t len; - if (str[2] == 'b' || str[2] == 'h') { + + if (str[2] == 'b' || str[2] == 'h') len = strlen(str); - } else { + else len = 0; - } if (15 < len) { switch (str[16]) { case 'f': @@ -295,9 +301,8 @@ int break; } } - if (!memcmp("lease ", str, 6)) { + if (!memcmp("lease ", str, 6)) return PREFIX_LEASE; - } return NUM_OF_PREFIX; } @@ -314,11 +319,11 @@ int xstrstr_v6(const char *restrict str) { size_t len; - if (str[4] == 'b' || str[2] == 'h') { + + if (str[4] == 'b' || str[2] == 'h') len = strlen(str); - } else { + else len = 0; - } if (17 < len) { switch (str[18]) { case 'f': @@ -349,9 +354,8 @@ int break; } } - if (!memcmp(" iaaddr ", str, 9)) { + if (!memcmp(" iaaddr ", str, 9)) return PREFIX_LEASE; - } return NUM_OF_PREFIX; } @@ -370,15 +374,12 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg) goto err; errno = 0; num = strtod(str, &end); - if (errno || str == end || (end && *end)) goto err; - return num; err: if (errno) err(EXIT_FAILURE, "%s: '%s'", errmesg, str); - errx(EXIT_FAILURE, "%s: '%s'", errmesg, str); } @@ -393,10 +394,8 @@ void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ { unsigned int i = num_ranges - 1, j; - for (j = 0; j < num_ranges; j++, i--) { + for (j = 0; j < num_ranges; j++, i--) *(tmp_ranges + j) = *(flip_me + i); - } - memcpy(flip_me, tmp_ranges, num_ranges * sizeof(struct range_t)); } @@ -404,9 +403,8 @@ void flip_ranges(struct range_t *restrict flip_me, struct range_t *restrict tmp_ void clean_up(void) { /* Just in case there something in buffers */ - if (fflush(NULL)) { + if (fflush(NULL)) warn("clean_up: fflush"); - } free(config.dhcpdconf_file); free(config.dhcpdlease_file); free(config.output_file); @@ -414,10 +412,10 @@ void clean_up(void) delete_all_leases(); if (shared_networks) { unsigned int i; + num_shared_networks++; - for (i = 0; i < num_shared_networks; i++) { + for (i = 0; i < num_shared_networks; i++) free((shared_networks + i)->name); - } free(shared_networks); } } @@ -437,6 +435,7 @@ void __attribute__ ((__noreturn__)) print_version(void) void __attribute__ ((__noreturn__)) usage(int status) { FILE *out; + out = status != 0 ? stderr : stdout; fprintf(out, "\ diff --git a/src/sort.c b/src/sort.c index 666b11e..b01db91 100644 --- a/src/sort.c +++ b/src/sort.c @@ -265,20 +265,16 @@ static int merge(struct range_t *restrict left, struct range_t *restrict right) return (1); continue; } - /* Select which function is pointed by comparer */ comparer = field_selector(config.sort[i]); cmp = comparer(left, right); /* If fields are equal use next sort method */ - if (cmp == 0) { + if (cmp == 0) continue; - } - if (cmp < 0) { + if (cmp < 0) return (1); - } return (0); } - /* If all comparers where equal */ return (0); } @@ -300,23 +296,19 @@ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *r for (left = 0; left < size; left++) { hold = *(orig + left); for (right = left - 1; 0 <= right; right--) { - if (merge((orig + right), &hold)) { + if (merge((orig + right), &hold)) break; - } *(orig + right + 1) = *(orig + right); } *(orig + right + 1) = hold; } return; } - mergesort_ranges(orig, size / 2, temp); mergesort_ranges(orig + size / 2, size - size / 2, temp); - left = 0; right = size / 2; i = 0; - while (left < size / 2 && right < size) { if (merge((orig + left), (orig + right))) { *(temp + i) = *(orig + left); @@ -337,6 +329,5 @@ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *r right++; i++; } - memcpy(orig, temp, size * sizeof(struct range_t)); } From c7379e3e2518d19130dec8ad18674e70582f24f9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 15 Nov 2014 10:02:41 +0000 Subject: [PATCH 119/313] release: 2.26 Signed-off-by: Sami Kerola --- NEWS | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/NEWS b/NEWS index 905dc0e..8c0a1a2 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,29 @@ Please send dhcpd-pools bug reports to kerolasa@iki.fi. gpg: Signature is crated using RSA key ID FDE9B739. +Version 2.26 +$ git shortlog v2.25..v2.26 +Sami Kerola (15): + news: add the note about .sig pgp key id + reindent all files + declare global variables only once + add appropriate sorting function for struct leases_t + update kernel.org url in README + getdata: fix buffer-overflows reported by address sanitizer + update bootstrap from gnulib + getdata: fix buffer overflow [AddressSanitizer] + other: reduce variable scope + output: prefer thread safe function localtime_r() + tests: add regression test to avoid shared-net off by one alarming + issue + output: avoid division by zero + other: disallow unsigned counter ever to have minus value + maint: remove unnecessary braces, spaces, update gnulib .gitignore + release: 2.26 + +Wolfgang Steudel (1): + alarming: include last shared network in alarming [off by one] + Version 2.25 $ git shortlog v2.24..v2.25 Sami Kerola (14): From 34dd1dee6ef8a6cf984df1b001ac9c6ddea77277 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 1 Apr 2015 23:10:43 +0100 Subject: [PATCH 120/313] docs: remove very basic git usage info This is not a git beginner manual project. Signed-off-by: Sami Kerola --- README | 147 --------------------------------------------------------- 1 file changed, 147 deletions(-) diff --git a/README b/README index 2c1fd7b..d38bd29 100644 --- a/README +++ b/README @@ -47,150 +47,3 @@ This is dhcpd-pools which is made for ISC dhcpd pool range analysis. If you are interested to help this way put all files into tar.gz, and send them to kerolasa@iki.fi. It would be nice that email subject line would have 'dhcpd-pools test data'. - - -== Instructions for developers - -AUTOTOOLS: - - * "./bootstrap" generates all files needed to compile and - install the code (run it after checkout from git) - - * "make distclean" removes all unnecessary files, but the - code can still be recompiled with "./configure; make" - -PATCHES: - - * First get familiar with git. In case you are completely - lost watch Greg Kroah-Hartman explaining the very - basics. - http://archive.fosdem.org/2010/schedule/events/linuxkernelpatch - - * Get up to date version of the code base. - - $ git clone git://dhcpd-pools.git.sourceforge.net/gitroot/dhcpd-pools/dhcpd-pools - - * Don't include generated (autotools) stuff to your - patches (hint: use git-clean [-X]) - - * Add a Signed-off-by line, use "git commit -s" - - * Patches are delivered via email only. The following - commands will do the correct thing. - - $ git format-patch -C origin/master..yourbranch -o ~/patches - - When you send only one patch use the following. - - $ git send-email --to kerolasa@iki.fi 0001* - - The command above expects you have configured email - sending properly. See git.wiki for help. - https://git.wiki.kernel.org/index.php/GitTips#Mail - - * One patch per email, with the changelog in the body of - the email. - - * When you send series of pathes include introductory - message. - - $ git send-email --compose --to kerolasa@iki.fi ~/00* - - Good introductory message will have at least - - -- snip - Your Name (3): - firstfile.c: short description - secondfile.c: another description - - firstfile.c | 2 +- - secondfile.c | 2 +- - secondfile.c | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -- snip - - Above introductory can be generated with git. - - $ git shortlog master..yourbranch - $ git diff --stat master..yourbranch - - * Subject: [PATCH] subsystem: description. Following - ~/.gitconfig will help you a little. - - -- snip - [user] - name = Your Name - email = your.name@example.com - - [format] - subjectprefix = PATCH - numbered = auto - signoff = yes - - [sendemail] - chainreplyto = false - cc = your.name@example.com - -- snip - - * If someone else wrote the patch, they should be - credited (and blamed) for it. To communicate this, add - a line: - - From: John Doe - - The sign-off is a simple line at the end of the - explanation for the patch, which certifies that you - wrote it or otherwise have the right to pass it on as a - open-source patch. The rules are pretty simple: if you - can certify the below: - - By making a contribution to this project, I certify - that: - - (a) The contribution was created in whole or in - part by me and I have the right to submit it - under the open source license indicated in the - file; or - - (b) The contribution is based upon previous work - that, to the best of my knowledge, is covered - under an appropriate open source license and I - have the right under that license to submit - that work with modifications, whether created - in whole or in part by me, under the same open - source license (unless I am permitted to submit - under a different license), as indicated in the - file; or - - (c) The contribution was provided directly to me by - some other person who certified (a), (b) or (c) - and I have not modified it. - - (d) I understand and agree that this project and - the contribution are public and that a record - of the contribution (including all personal - information I submit with it, including my - sign-off) is maintained indefinitely and may be - redistributed consistent with this project or - the open source license(s) involved. - - then you just add a line saying - - Signed-off-by: Random J Developer - - using your real name (sorry, no pseudonyms or anonymous - contributions.) - - * If the the business with git is too difficult just send - source code files as is as email attachment to - maintainer. - -CODING STYLE: - - * The preferred coding style is based on the linux kernel - Documentation/CodingStyle. For more details see: - - http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/Documentation/CodingStyle - - * Source code is pretty printed by using two, and only - the two, indent command switches -kr -i8 From 735c5db817b274b2802e9d1f14667e816935890f Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 1 Apr 2015 23:15:38 +0100 Subject: [PATCH 121/313] docs: remove todo items that will never happen Signed-off-by: Sami Kerola --- TODO | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/TODO b/TODO index fe04930..fa08675 100644 --- a/TODO +++ b/TODO @@ -14,26 +14,3 @@ o When time stamps are part of lease situation evaluation (see bug 1) add a --now switch which will one can use to change when expiry happens. o Add lease time histogram support. - -### Next major version - -1 Well structured code, with extendible sane architecture. -2 Server, which has analysis in cache for N seconds and will - answer via socket. -3 Configuration file for server. -4 State file, where different ranges, shared networks etc have - unique identifiers (needed for graphs). -5 Support for snmp and munin protocols. -6 SNMP traps when limits get exceeded. -7 Some clever check_dhcpd_pools binary for Nagios & other - monitoring software. - -8 Super server support, which will collect analysis from other - dhcpd-pool servers. -9 Nice http view interface on super server, much can be copied - from http://piwik.org/ -10 And some other things perhaps... - -When items 1-7 are done v3 can be released. To support rewrite -there should be a design document with nice blue print, which is -a web page. From 73b357484d54fcdb7c97492ad8b4d78dcfaf4f7e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 May 2015 18:00:10 +0100 Subject: [PATCH 122/313] output: remove empty element from xml Signed-off-by: Sami Kerola --- src/output.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/output.c b/src/output.c index 679a089..1865266 100644 --- a/src/output.c +++ b/src/output.c @@ -264,12 +264,8 @@ int output_xml(void) } else { fprintf(outfile, "\t\n"); } - - fprintf(outfile, "\t\n"); - fprintf(outfile, "\t\n"); fprintf(outfile, "\t%s ", ntop_ipaddr(&range_p->first_ip)); fprintf(outfile, "- %s\n", ntop_ipaddr(&range_p->last_ip)); - fprintf(outfile, "\t\n"); fprintf(outfile, "\t%g\n", range_size); fprintf(outfile, "\t%g\n", range_p->count); fprintf(outfile, "\t%g\n", range_size - range_p->count); From 0d6c61d437541ee4b3b5a9fa23a8ad0f81d3544a Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 May 2015 18:48:52 +0100 Subject: [PATCH 123/313] add touched addresses counts to xml and json reports For some reason missing information has been overlooked for years. Perhaps there is aren't that many users who are interested of the touched addresses. Proposed-by: Aaron Paetznick Signed-off-by: Sami Kerola --- THANKS | 1 + src/output.c | 6 ++++++ tests/expected/same-twice-json | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/THANKS b/THANKS index 949078f..260293d 100644 --- a/THANKS +++ b/THANKS @@ -32,3 +32,4 @@ Dan Pritts Fredrik Lysén Conor McCarthy Wolfgang Steudel +Aaron Paetznick diff --git a/src/output.c b/src/output.c index 1865266..156be3d 100644 --- a/src/output.c +++ b/src/output.c @@ -268,6 +268,7 @@ int output_xml(void) fprintf(outfile, "- %s\n", ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\t%g\n", range_size); fprintf(outfile, "\t%g\n", range_p->count); + fprintf(outfile, "\t%g\n", range_p->touched); fprintf(outfile, "\t%g\n", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); @@ -282,6 +283,7 @@ int output_xml(void) fprintf(outfile, "\t%s\n", shared_p->name); fprintf(outfile, "\t%g\n", shared_p->available); fprintf(outfile, "\t%g\n", shared_p->used); + fprintf(outfile, "\t%g\n", shared_p->touched); fprintf(outfile, "\t%g\n", shared_p->available - shared_p->used); fprintf(outfile, "\n"); @@ -293,6 +295,7 @@ int output_xml(void) fprintf(outfile, "\t%s\n", shared_networks->name); fprintf(outfile, "\t%g\n", shared_networks->available); fprintf(outfile, "\t%g\n", shared_networks->used); + fprintf(outfile, "\t%g\n", shared_networks->touched); fprintf(outfile, "\t%g\n", shared_networks->available - shared_networks->used); fprintf(outfile, "\n"); @@ -385,6 +388,7 @@ int output_json(void) fprintf(outfile, " - %s\", ", ntop_ipaddr(&range_p->last_ip)); fprintf(outfile, "\"defined\":%g, ", range_size); fprintf(outfile, "\"used\":%g, ", range_p->count); + fprintf(outfile, "\"touched\":%g, ", range_p->touched); fprintf(outfile, "\"free\":%g ", range_size - range_p->count); range_p++; range_size = get_range_size(range_p); @@ -409,6 +413,7 @@ int output_json(void) fprintf(outfile, "\"location\":\"%s\", ", shared_p->name); fprintf(outfile, "\"defined\":%g, ", shared_p->available); fprintf(outfile, "\"used\":%g, ", shared_p->used); + fprintf(outfile, "\"touched\":%g, ", shared_p->touched); fprintf(outfile, "\"free\":%g ", shared_p->available - shared_p->used); if (i + 1 < num_shared_networks) fprintf(outfile, "},\n"); @@ -427,6 +432,7 @@ int output_json(void) fprintf(outfile, " \"location\":\"%s\",\n", shared_networks->name); fprintf(outfile, " \"defined\":%g,\n", shared_networks->available); fprintf(outfile, " \"used\":%g,\n", shared_networks->used); + fprintf(outfile, " \"touched\":%g,\n", shared_networks->touched); fprintf(outfile, " \"free\":%g\n", shared_networks->available - shared_networks->used); fprintf(outfile, " }"); /* end of summary */ diff --git a/tests/expected/same-twice-json b/tests/expected/same-twice-json index aa0c419..7d29ad9 100644 --- a/tests/expected/same-twice-json +++ b/tests/expected/same-twice-json @@ -3,7 +3,7 @@ { "ip":"10.0.0.5", "macaddress":"00:00:00:00:00:00" } ], "subnets": [ - { "location":"All networks", "range":"10.0.0.1 - 10.0.0.10", "defined":10, "used":1, "free":9 } + { "location":"All networks", "range":"10.0.0.1 - 10.0.0.10", "defined":10, "used":1, "touched":0, "free":9 } ], "shared-networks": [ ], @@ -11,6 +11,7 @@ "location":"All networks", "defined":10, "used":1, + "touched":0, "free":9 } } From c4e5ef61982b2ffc84940e38b76690b76e8f405e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 May 2015 18:51:39 +0100 Subject: [PATCH 124/313] add xml format check Signed-off-by: Sami Kerola --- tests/Makemodule.am | 1 + tests/expected/same-twice-xml | 21 +++++++++++++++++++++ tests/full-xml | 13 +++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/expected/same-twice-xml create mode 100755 tests/full-xml diff --git a/tests/Makemodule.am b/tests/Makemodule.am index fdb48be..07e55ae 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -13,6 +13,7 @@ TESTS = \ tests/complete \ tests/empty \ tests/full-json \ + tests/full-xml \ tests/leading0 \ tests/one-ip \ tests/one-line \ diff --git a/tests/expected/same-twice-xml b/tests/expected/same-twice-xml new file mode 100644 index 0000000..93612d6 --- /dev/null +++ b/tests/expected/same-twice-xml @@ -0,0 +1,21 @@ + + + 10.0.0.5 + 00:00:00:00:00:00 + + + All networks + 10.0.0.1 - 10.0.0.10 + 10 + 1 + 0 + 9 + + + All networks + 10 + 1 + 0 + 9 + + diff --git a/tests/full-xml b/tests/full-xml new file mode 100755 index 0000000..33fce2c --- /dev/null +++ b/tests/full-xml @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Minimal regression test suite. + +if [ ! -d tests/outputs ]; then + mkdir tests/outputs +fi + +dhcpd-pools -f X -c $top_srcdir/tests/confs/same-twice \ + -l $top_srcdir/tests/leases/same-twice \ + -o tests/outputs/same-twice-xml +diff -u $top_srcdir/tests/expected/same-twice-xml tests/outputs/same-twice-xml +exit $? From 9d1241c00644e4ff52aad4b2d5ff9fbdef24b33e Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 2 May 2015 19:40:06 +0100 Subject: [PATCH 125/313] improve html output Remove unnecessary html indentation, so that there is less page content to transfer. Right align the network names, and IP's so that they are easier to read. And ensure quoting is done correctly. Signed-off-by: Sami Kerola --- src/output.c | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/output.c b/src/output.c index 156be3d..28d6775 100644 --- a/src/output.c +++ b/src/output.c @@ -475,59 +475,59 @@ static void html_header(FILE *restrict f) errx(EXIT_FAILURE, "html_header: strftime returned 0"); } - fprintf(f, "\n"); + fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); - fprintf(f, " ISC dhcpd stats\n"); - fprintf(f, " \n"); + fprintf(f, "ISC dhcpd stats\n"); + fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "\n"); fprintf(f, "The lease file mtime: %s", outstr); @@ -541,12 +541,12 @@ static void html_footer(FILE *restrict f) { fprintf(f, "


\n"); fprintf(f, "
\n"); - fprintf(f, "

\nData generated by "); + fprintf(f, "

\nData generated by "); fprintf(f, "", PACKAGE_URL); fprintf(f, "%s.\n

\n", PACKAGE_STRING); - fprintf(f, "

\n"); + fprintf(f, "

\n"); fprintf(f, "\n
\n

\n"); fprintf(f, "\n"); @@ -568,7 +568,7 @@ static void newrow(FILE *restrict f) */ static void endrow(FILE *restrict f) { - fprintf(f, "\n\n"); + fprintf(f, "\n"); } /*! \brief Line with text in html output format. @@ -581,7 +581,7 @@ static void endrow(FILE *restrict f) static void output_line(FILE *restrict f, char const *restrict type, char const *restrict class, char const *restrict text) { - fprintf(f, " <%s class=%s>%s\n", type, class, text, type); + fprintf(f, "<%s class=\"%s\">%s\n", type, class, text, type); } /*! \brief Line with digit in html output format. @@ -592,7 +592,7 @@ static void output_line(FILE *restrict f, char const *restrict type, */ static void output_double(FILE *restrict f, char const *restrict type, double d) { - fprintf(f, " <%s class=ralign>%g\n", type, d, type); + fprintf(f, "<%s class=\"ralign\">%g\n", type, d, type); } /*! \brief Line with float in html output format. @@ -603,7 +603,7 @@ static void output_double(FILE *restrict f, char const *restrict type, double d) */ static void output_float(FILE *f, char const *restrict type, float fl) { - fprintf(f, " <%s class=ralign>%.3f\n", type, fl, type); + fprintf(f, "<%s class=\"ralign\">%.3f\n", type, fl, type); } /*! \brief Begin table in html output format. @@ -634,7 +634,7 @@ static void table_end(FILE *restrict f) static void newsection(FILE *restrict f, char const *restrict title) { newrow(f); - output_line(f, "td", "calign", " "); + output_line(f, "td", "lalign", " "); endrow(f); newrow(f); output_line(f, "th", "section", title); @@ -671,9 +671,9 @@ int output_html(void) if (config.output_limit[0] & BIT1) { newsection(outfile, "Ranges:"); newrow(outfile); - output_line(outfile, "th", "calign", "shared net name"); - output_line(outfile, "th", "calign", "first ip"); - output_line(outfile, "th", "calign", "last ip"); + output_line(outfile, "th", "lalign", "shared net name"); + output_line(outfile, "th", "lalign", "first ip"); + output_line(outfile, "th", "lalign", "last ip"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -690,12 +690,12 @@ int output_html(void) for (i = 0; i < num_ranges; i++) { newrow(outfile); if (range_p->shared_net) { - output_line(outfile, "td", "calign", range_p->shared_net->name); + output_line(outfile, "td", "lalign", range_p->shared_net->name); } else { - output_line(outfile, "td", "calign", "not_defined"); + output_line(outfile, "td", "lalign", "not_defined"); } - output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->first_ip)); - output_line(outfile, "td", "calign", ntop_ipaddr(&range_p->last_ip)); + output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->first_ip)); + output_line(outfile, "td", "lalign", ntop_ipaddr(&range_p->last_ip)); output_double(outfile, "td", range_size); output_double(outfile, "td", range_p->count); output_float(outfile, "td", (float)(100 * range_p->count) / range_size); @@ -719,7 +719,7 @@ int output_html(void) if (config.output_limit[0] & BIT2) { newsection(outfile, "Shared networks:"); newrow(outfile); - output_line(outfile, "th", "calign", "name"); + output_line(outfile, "th", "lalign", "name"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -736,7 +736,7 @@ int output_html(void) for (i = 0; i < num_shared_networks; i++) { shared_p++; newrow(outfile); - output_line(outfile, "td", "calign", shared_p->name); + output_line(outfile, "td", "lalign", shared_p->name); output_double(outfile, "td", shared_p->available); output_double(outfile, "td", shared_p->used); output_float(outfile, "td", @@ -765,7 +765,7 @@ int output_html(void) if (config.output_limit[0] & BIT3) { newsection(outfile, "Sum of all ranges:"); newrow(outfile); - output_line(outfile, "th", "calign", "name"); + output_line(outfile, "th", "lalign", "name"); output_line(outfile, "th", "ralign", "max"); output_line(outfile, "th", "ralign", "cur"); output_line(outfile, "th", "ralign", "percent"); @@ -781,7 +781,7 @@ int output_html(void) } if (config.output_limit[1] & BIT3) { newrow(outfile); - output_line(outfile, "td", "calign", shared_networks->name); + output_line(outfile, "td", "lalign", shared_networks->name); output_double(outfile, "td", shared_networks->available); output_double(outfile, "td", shared_networks->used); output_float(outfile, "td", From cf26e17fe761bbc4e21e501c8cf800c2990ba9a1 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 29 May 2015 09:18:08 +0100 Subject: [PATCH 126/313] add hint about configure options to README Proposed-by: Tim Cantin Signed-off-by: Sami Kerola --- README | 4 ++++ THANKS | 1 + 2 files changed, 5 insertions(+) diff --git a/README b/README index d38bd29..270c6b7 100644 --- a/README +++ b/README @@ -7,6 +7,10 @@ This is dhcpd-pools which is made for ISC dhcpd pool range analysis. make make install + # Notice that there are configuration options for dhcpd.conf, + # dhcpd.leases, and uthash include paths, among other things. + + ./configure --help == General information diff --git a/THANKS b/THANKS index 260293d..286cbce 100644 --- a/THANKS +++ b/THANKS @@ -33,3 +33,4 @@ Fredrik Lys Conor McCarthy Wolfgang Steudel Aaron Paetznick +Tim Cantin From d8aef85d012c483177fbe4acfe1d5fb0dca7a774 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 4 Sep 2015 11:11:56 +0100 Subject: [PATCH 127/313] man: fix character class change Debian package lint found going back to roman mode was broken. Reported-by: Martijn van Brummelen Signed-off-by: Sami Kerola --- THANKS | 1 + man/dhcpd-pools.1.in | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 286cbce..07b1f68 100644 --- a/THANKS +++ b/THANKS @@ -34,3 +34,4 @@ Conor McCarthy Wolfgang Steudel Aaron Paetznick Tim Cantin +Martijn van Brummelen diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index 28b2fc5..a054a5f 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -1,4 +1,4 @@ -.TH DHCPD-POOLS "1" "2012-11-25" "@PACKAGE_STRING@" "User Commands" +.TH DHCPD-POOLS "1" "2015-09-04" "@PACKAGE_STRING@" "User Commands" .SH NAME dhcpd-pools \- ISC dhcpd pools usage analysis .SH SYNOPSIS @@ -161,7 +161,7 @@ is If critical percentage is not specified it defaults to .BR @ALARM_CRIT@ . .TP -\fB\-\-minsize\fR=\fIsize\f +\fB\-\-minsize\fR=\fIsize\fR Ignore ranges and shared networks that are smaller or equal to the defined size. This option is meaningful only in context of alarming, and will intented to supress for example single host ranges. By default this From 167c4b698916b7d095beb3fda9da73d2dec8a9b2 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 5 Sep 2015 13:33:02 +0100 Subject: [PATCH 128/313] gitignore: update gnulib file list Signed-off-by: Sami Kerola --- lib/.gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/.gitignore b/lib/.gitignore index 928a516..2e2c50e 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -7,6 +7,7 @@ /Makefile.am /Makefile.in /_Exit.c +/alloca.in.h /arg-nonnull.h /arpa/ /arpa_inet.in.h @@ -75,6 +76,9 @@ /localcharset.h /lseek.c /malloc.c +/malloca.c +/malloca.h +/malloca.valgrind /math.c /math.h /math.in.h @@ -83,6 +87,8 @@ /memchr.c /memchr.valgrind /memcpy.c +/mktime-internal.h +/mktime.c /msvc-inval.c /msvc-inval.h /msvc-nothrow.c @@ -99,12 +105,14 @@ /ref-add.sin /ref-del.sed /ref-del.sin +/setenv.c /stat.c /stdalign.h /stdalign.in.h /stdarg.in.h /stdbool.in.h /stddef.in.h +/stdint.in.h /stdio-impl.h /stdio.c /stdio.h @@ -131,12 +139,16 @@ /sys_time.in.h /sys_types.in.h /sys_uio.in.h +/time-internal.h /time.h /time.in.h /time_r.c +/time_rz.c +/timegm.c /unistd.c /unistd.h /unistd.in.h +/unsetenv.c /unused-parameter.h /verify.h /warn-on-use.h From fae20302cf8dc8fe6ff354fec00a93b9b1f6a2c4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 5 Sep 2015 13:17:46 +0100 Subject: [PATCH 129/313] release: 2.27 Signed-off-by: Sami Kerola --- NEWS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 8c0a1a2..77360eb 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,19 @@ Please send dhcpd-pools bug reports to kerolasa@iki.fi. gpg: Signature is crated using RSA key ID FDE9B739. +Version 2.27 +Sami Kerola (9): + docs: remove very basic git usage info + docs: remove todo items that will never happen + output: remove empty element from xml + add touched addresses counts to xml and json reports + add xml format check + improve html output + add hint about configure options to README + man: fix character class change + gitignore: update gnulib file list + release: 2.27 + Version 2.26 $ git shortlog v2.25..v2.26 Sami Kerola (15): From 535dfc4fc2ac64183466a6e1f584852de19e45c6 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 26 Oct 2015 22:12:37 +0000 Subject: [PATCH 130/313] portability: Solaris 10 does not have err.h Use error(3) function, that has gnulib portability fixes, instead of err(3) and warn(3) family. Reported-by: Anton Tkachev Signed-off-by: Sami Kerola --- THANKS | 1 + bootstrap.conf | 1 + build-aux/.gitignore | 1 + lib/.gitignore | 1 + src/dhcpd-pools.c | 20 +++++++------ src/getdata.c | 29 ++++++++++--------- src/hash.c | 5 +++- src/other.c | 19 ++++++------ src/output.c | 69 +++++++++++++++++++++++--------------------- src/sort.c | 10 +++---- 10 files changed, 84 insertions(+), 72 deletions(-) diff --git a/THANKS b/THANKS index 07b1f68..331b868 100644 --- a/THANKS +++ b/THANKS @@ -35,3 +35,4 @@ Wolfgang Steudel Aaron Paetznick Tim Cantin Martijn van Brummelen +Anton Tkachev diff --git a/bootstrap.conf b/bootstrap.conf index b815859..b51e08a 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -20,6 +20,7 @@ gnulib_modules=" close-stream closeout + error fclose fcntl-h fdopen diff --git a/build-aux/.gitignore b/build-aux/.gitignore index a7f0fb2..a85ce13 100644 --- a/build-aux/.gitignore +++ b/build-aux/.gitignore @@ -1,3 +1,4 @@ +/ar-lib /compile /config.guess /config.sub diff --git a/lib/.gitignore b/lib/.gitignore index 2e2c50e..b0e5275 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -7,6 +7,7 @@ /Makefile.am /Makefile.in /_Exit.c +/alloca.h /alloca.in.h /arg-nonnull.h /arpa/ diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index bfb312b..267d185 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -38,10 +38,9 @@ */ #include + #include #include -#include -#include #include #include #include @@ -49,11 +48,13 @@ #include "close-stream.h" #include "closeout.h" -#include "defaults.h" -#include "dhcpd-pools.h" +#include "error.h" #include "progname.h" #include "xalloc.h" +#include "dhcpd-pools.h" +#include "defaults.h" + /* Global variables */ int prefix_length[2][NUM_OF_PREFIX]; struct configuration_t config; @@ -165,7 +166,7 @@ int main(int argc, char **argv) /* Output sorting option */ sorts = strlen(optarg); if (5 < sorts) { - warnx("main: only first 5 sort orders will be used"); + error(0, 0, "main: only first 5 sort orders will be used"); strncpy(config.sort, optarg, (size_t)5); sorts = 5; } else @@ -188,8 +189,8 @@ int main(int argc, char **argv) config.output_limit[i] = optarg[i] - '0'; else { clean_up(); - errx(EXIT_FAILURE, - "main: output mask `%s' is illegal", optarg); + error(EXIT_FAILURE, 0, + "main: output mask `%s' is illegal", optarg); } } break; @@ -211,7 +212,8 @@ int main(int argc, char **argv) /* Print help */ usage(EXIT_SUCCESS); default: - errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); + error(EXIT_FAILURE, 0, "Try `%s --help' for more information.", + program_name); } } /* Output function selection */ @@ -246,7 +248,7 @@ int main(int argc, char **argv) break; default: clean_up(); - errx(EXIT_FAILURE, "main: unknown output format `%c'", config.output_format[0]); + error(EXIT_FAILURE, 0, "main: unknown output format `%c'", config.output_format[0]); } /* Do the job */ prepare_memory(); diff --git a/src/getdata.c b/src/getdata.c index bf2de86..591d743 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -53,10 +52,12 @@ #include #include -#include "defaults.h" -#include "dhcpd-pools.h" +#include "error.h" #include "xalloc.h" +#include "dhcpd-pools.h" +#include "defaults.h" + /*! \brief Lease file parser. The parser can only read ISC DHCPD * dhcpd.leases file format. */ int parse_leases(void) @@ -70,15 +71,15 @@ int parse_leases(void) dhcpd_leases = fopen(config.dhcpdlease_file, "r"); if (dhcpd_leases == NULL) - err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); + error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file); #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_NOREUSE) != 0) - err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); + error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file); # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL if (posix_fadvise(fileno(dhcpd_leases), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) - err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file); + error(EXIT_FAILURE, errno, "parse_leases: fadvise %s", config.dhcpdlease_file); # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ /* I found out that there's one lease address per 300 bytes in @@ -86,7 +87,7 @@ int parse_leases(void) * If someone has higher density in lease file I'm interested to * hear about that. */ if (stat(config.dhcpdlease_file, &lease_file_stats)) - err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); + error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file); line = xmalloc(sizeof(char) * MAXLEN); line[0] = '\0'; ipstring = xmalloc(sizeof(char) * MAXLEN); @@ -95,7 +96,7 @@ int parse_leases(void) ethernets = true; while (!feof(dhcpd_leases)) { if (!fgets(line, MAXLEN, dhcpd_leases) && ferror(dhcpd_leases)) - err(EXIT_FAILURE, "parse_leases: %s", config.dhcpdlease_file); + error(EXIT_FAILURE, errno, "parse_leases: %s", config.dhcpdlease_file); switch (xstrstr(line)) { /* It's a lease, save IP */ case PREFIX_LEASE: @@ -186,15 +187,15 @@ void parse_config(int is_include, const char *restrict config_file, /* Open configuration file */ dhcpd_config = fopen(config_file, "r"); if (dhcpd_config == NULL) - err(EXIT_FAILURE, "parse_config: %s", config_file); + error(EXIT_FAILURE, errno, "parse_config: %s", config_file); #ifdef HAVE_POSIX_FADVISE # ifdef POSIX_FADV_NOREUSE if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_NOREUSE) != 0) - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); + error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file); # endif /* POSIX_FADV_NOREUSE */ # ifdef POSIX_FADV_SEQUENTIAL if (posix_fadvise(fileno(dhcpd_config), 0, 0, POSIX_FADV_SEQUENTIAL) != 0) - err(EXIT_FAILURE, "parse_config: fadvise %s", config_file); + error(EXIT_FAILURE, errno, "parse_config: fadvise %s", config_file); # endif /* POSIX_FADV_SEQUENTIAL */ #endif /* HAVE_POSIX_FADVISE */ /* Very hairy stuff begins. */ @@ -364,8 +365,8 @@ void parse_config(int is_include, const char *restrict config_file, shared_p->backups = 0; if (SHARED_NETWORKS < num_shared_networks + 2) /* FIXME: make this to go away by reallocating more space. */ - errx(EXIT_FAILURE, - "parse_config: increase default.h SHARED_NETWORKS and recompile"); + error(EXIT_FAILURE, 0, + "parse_config: increase default.h SHARED_NETWORKS and recompile"); argument = ITS_NOTHING_INTERESTING; braces_shared = braces; break; @@ -380,7 +381,7 @@ void parse_config(int is_include, const char *restrict config_file, argument = ITS_NOTHING_INTERESTING; break; default: - warnx("impossible occurred, report a bug"); + error(0, 0, "impossible occurred, report a bug"); assert(0); } } diff --git a/src/hash.c b/src/hash.c index a75e9f4..08b95b4 100644 --- a/src/hash.c +++ b/src/hash.c @@ -38,9 +38,12 @@ * analysis happen as quick as possible.. */ -#include "dhcpd-pools.h" +#include + #include "xalloc.h" +#include "dhcpd-pools.h" + #define HASH_FIND_V6(head, findv6, out) HASH_FIND(hh, head, findv6, 16, out) #define HASH_ADD_V6(head, v6field, add) HASH_ADD(hh, head, v6field, 16, add) diff --git a/src/other.c b/src/other.c index e9f49c8..67c2f4d 100644 --- a/src/other.c +++ b/src/other.c @@ -39,13 +39,9 @@ #include -#include "dhcpd-pools.h" -#include "defaults.h" -#include "progname.h" - #include -#include #include +#include #include #include #include @@ -53,7 +49,12 @@ #include #include #include -#include + +#include "error.h" +#include "progname.h" + +#include "dhcpd-pools.h" +#include "defaults.h" /*! \brief Set function pointers depending on IP version. * \param ip IP version. @@ -378,9 +379,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg) goto err; return num; err: - if (errno) - err(EXIT_FAILURE, "%s: '%s'", errmesg, str); - errx(EXIT_FAILURE, "%s: '%s'", errmesg, str); + error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str); } /*! \brief Reverse range. @@ -404,7 +403,7 @@ void clean_up(void) { /* Just in case there something in buffers */ if (fflush(NULL)) - warn("clean_up: fflush"); + error(0, 0, "clean_up: fflush"); free(config.dhcpdconf_file); free(config.dhcpdlease_file); free(config.output_file); diff --git a/src/output.c b/src/output.c index 28d6775..06a5469 100644 --- a/src/output.c +++ b/src/output.c @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -53,10 +52,12 @@ #include #include "close-stream.h" -#include "dhcpd-pools.h" +#include "error.h" #include "progname.h" #include "strftime.h" +#include "dhcpd-pools.h" + /*! \brief Text output format, which is the default. * FIXME: This function should return void. */ int output_txt(void) @@ -72,7 +73,7 @@ int output_txt(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_txt: %s", config.output_file); + error(EXIT_FAILURE, errno, "output_txt: %s", config.output_file); } } else { outfile = stdout; @@ -201,12 +202,12 @@ int output_txt(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_txt: fflush"); + error(0, 0, "output_txt: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_txt: fclose"); + error(0, 0, "output_txt: fclose"); } } @@ -228,7 +229,7 @@ int output_xml(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_xml: %s", config.output_file); + error(EXIT_FAILURE, errno, "output_xml: %s", config.output_file); } } else { outfile = stdout; @@ -242,6 +243,7 @@ int output_xml(void) if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { struct leases_t *l; + for (l = leases; l != NULL; l = l->hh.next) { if (l->type == ACTIVE) { fputs("\n\t", outfile); @@ -305,12 +307,12 @@ int output_xml(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_xml: fflush"); + error(0, 0, "output_xml: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_xml: fclose"); + error(0, 0, "output_xml: fclose"); } } @@ -333,7 +335,7 @@ int output_json(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_json: %s", config.output_file); + error(EXIT_FAILURE, errno, "output_json: %s", config.output_file); } } else { outfile = stdout; @@ -348,6 +350,7 @@ int output_json(void) if (config.output_format[0] == 'X' || config.output_format[0] == 'J') { struct leases_t *l; + fprintf(outfile, " \"active_leases\": ["); for (l = leases; l != NULL; l = l->hh.next) { if (l->type == ACTIVE) { @@ -443,12 +446,12 @@ int output_json(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_json: fflush"); + error(0, 0, "output_json: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_json: fclose"); + error(0, 0, "output_json: fclose"); } } @@ -465,14 +468,15 @@ static void html_header(FILE *restrict f) struct tm *tmp, result; struct stat statbuf; + stat(config.dhcpdlease_file, &statbuf); tmp = localtime_r(&statbuf.st_mtime, &result); if (tmp == NULL) { - err(EXIT_FAILURE, "html_header: localtime"); + error(EXIT_FAILURE, errno, "html_header: localtime"); } if (strftime(outstr, sizeof(outstr), nl_langinfo(D_T_FMT), &result) == 0) { - errx(EXIT_FAILURE, "html_header: strftime returned 0"); + error(EXIT_FAILURE, 0, "html_header: strftime returned 0"); } fprintf(f, "backups); output_float(outfile, "td", shared_p->available == 0 ? -NAN : (float)(100 * - shared_p-> - backups) / - shared_p->available); + shared_p->backups) + / shared_p->available); } endrow(outfile); @@ -792,18 +796,16 @@ int output_html(void) output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_float(outfile, "td", shared_networks->available == 0 ? -NAN : (float)(100 * - (shared_networks-> - touched + - shared_networks-> - used)) / - shared_networks->available); + (shared_networks->touched + + + shared_networks->used)) + / shared_networks->available); if (config.backups_found == true) { output_double(outfile, "td", shared_networks->backups); output_float(outfile, "td", shared_networks->available == 0 ? -NAN : (float)(100 * - shared_networks-> - backups) / - shared_networks->available); + shared_networks->backups) + / shared_networks->available); } endrow(outfile); } @@ -814,12 +816,12 @@ int output_html(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_html: fflush"); + error(0, 0, "output_html: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_html: fclose"); + error(0, 0, "output_html: fclose"); } } return 0; @@ -836,10 +838,11 @@ int output_csv(void) struct shared_network_t *shared_p; FILE *outfile; int ret; + if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_csv: %s", config.output_file); + error(EXIT_FAILURE, errno, "output_csv: %s", config.output_file); } } else { outfile = stdout; @@ -957,12 +960,12 @@ int output_csv(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_cvs: fflush"); + error(0, 0, "output_cvs: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_cvs: fclose"); + error(0, 0, "output_cvs: fclose"); } } return 0; @@ -989,7 +992,7 @@ int output_alarming(void) if (config.output_file[0]) { outfile = fopen(config.output_file, "w+"); if (outfile == NULL) { - err(EXIT_FAILURE, "output_alarming: %s", config.output_file); + error(EXIT_FAILURE, errno, "output_alarming: %s", config.output_file); } } else { outfile = stdout; @@ -1077,12 +1080,12 @@ int output_alarming(void) if (outfile == stdout) { ret = fflush(stdout); if (ret) { - warn("output_alarming: fflush"); + error(0, 0, "output_alarming: fflush"); } } else { ret = close_stream(outfile); if (ret) { - warn("output_alarming: fclose"); + error(0, 0, "output_alarming: fclose"); } } return ret_val; diff --git a/src/sort.c b/src/sort.c index b01db91..d0af3cb 100644 --- a/src/sort.c +++ b/src/sort.c @@ -40,15 +40,15 @@ #include -#include -#include #include #include #include -#include "dhcpd-pools.h" +#include "error.h" #include "progname.h" +#include "dhcpd-pools.h" + /*! \brief Compare IP address, with IPv4/v6 determination. * \param a Binary IP address. * \param b Binary IP address. @@ -237,8 +237,7 @@ comparer_t field_selector(char c) return comp_tcperc; default: clean_up(); - warnx("field_selector: unknown sort order `%c'", c); - errx(EXIT_FAILURE, "Try `%s --help' for more information.", program_name); + error(EXIT_FAILURE, 0, "field_selector: unknown sort order `%c'", c); } return NULL; } @@ -289,6 +288,7 @@ void mergesort_ranges(struct range_t *restrict orig, int size, struct range_t *r { int left, right, i; struct range_t hold; + /* Merge sort split size */ static const int MIN_MERGE_SIZE = 8; From c30c122027811fc158c5d5711d0fb9116f75a089 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Mon, 26 Oct 2015 22:43:31 +0000 Subject: [PATCH 131/313] fix couple compiler warnings src/getdata.c:248:22: warning: 'range_p' may be used uninitialized in this function [-Wmaybe-uninitialized] src/other.c:383:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Sami Kerola --- src/getdata.c | 5 ++++- src/other.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/getdata.c b/src/getdata.c index 591d743..ce56a2b 100644 --- a/src/getdata.c +++ b/src/getdata.c @@ -178,7 +178,7 @@ void parse_config(int is_include, const char *restrict config_file, char *word; int braces_shared = 1000; union ipaddr_t addr; - struct range_t *range_p; + struct range_t *range_p = NULL; word = xmalloc(sizeof(char) * MAXLEN); if (is_include) @@ -245,6 +245,9 @@ void parse_config(int is_include, const char *restrict config_file, c = ' '; break; } else if (argument == ITS_A_RANGE_SECOND_IP && i == 0) { + if (!range_p) { + error(EXIT_FAILURE, 0, "parse_config: range_p uninitialized: please report a bug"); + } range_p->last_ip = range_p->first_ip; goto newrange; } diff --git a/src/other.c b/src/other.c index 67c2f4d..040c55a 100644 --- a/src/other.c +++ b/src/other.c @@ -380,6 +380,7 @@ double strtod_or_err(const char *restrict str, const char *restrict errmesg) return num; err: error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str); + return 0; } /*! \brief Reverse range. From 2528c4c9d693d16d2b57582e008e3e59e1f537af Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 25 Nov 2015 21:53:29 +0000 Subject: [PATCH 132/313] make binary exec path dynamic in scripts referring to it Everything should just work out of the box without poking. This change makes that goal to be yet agian one step closer. In same go make all autotools related variable substitutions better. Requested-by: Martijn van Brummelen Signed-off-by: Sami Kerola --- Makefile.am | 28 ++++++++++++++++++- configure.ac | 4 +-- contrib/.gitignore | 2 ++ contrib/Makemodule.am | 4 ++- .../{dhcpd-pools.cgi => dhcpd-pools.cgi.in} | 4 +-- contrib/nagios.conf | 1 - contrib/nagios.conf.in | 1 + doc/.gitignore | 1 + doc/Makemodule.am | 6 +++- doc/doxy.conf.in | 2 +- man/Makemodule.am | 3 +- man/dhcpd-pools.1.in | 2 +- 12 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 contrib/.gitignore rename contrib/{dhcpd-pools.cgi => dhcpd-pools.cgi.in} (91%) delete mode 100644 contrib/nagios.conf create mode 100644 contrib/nagios.conf.in create mode 100644 doc/.gitignore diff --git a/Makefile.am b/Makefile.am index b2beaca..0daa8bf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,9 +16,35 @@ $(top_srcdir)/.version: dist-hook: echo $(VERSION) > $(distdir)/.tarball-version -CLEANFILES = +PATHFILES = +CLEANFILES = $(PATHFILES) +EXTRA_DIST += $(PATHFILES:=.in) CLEAN_LOCALS = +edit_cmd = sed \ + -e 's|@ALARM_CRIT[@]|$(ALARM_CRIT)|g' \ + -e 's|@ALARM_WARN[@]|$(ALARM_WARN)|g' \ + -e 's|@DHCPDCONF_FILE[@]|$(DHCPDCONF_FILE)|g' \ + -e 's|@DHCPDLEASE_FILE[@]|$(DHCPDLEASE_FILE)|g' \ + -e 's|@OUTPUT_FORMAT[@]|$(OUTPUT_FORMAT)|g' \ + -e 's|@OUTPUT_LIMIT[@]|$(OUTPUT_LIMIT)|g' \ + -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \ + -e 's|@PACKAGE_MAINTAINER[@]|$(PACKAGE_MAINTAINER)|g' \ + -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ + -e 's|@PACKAGE_URL[@]|$(PACKAGE_URL)|g' \ + -e 's|@SHELL[@]|$(SHELL)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@top_srcdir[@]|$(top_srcdir)|g' + +$(PATHFILES): Makefile + @ rm -f $@ $@.tmp + $(AM_V_at) test -d $(dir $@) || mkdir -p $(dir $@) + $(AM_V_GEN) srcdir=''; \ + test -f ./$@.in || srcdir=$(srcdir)/; \ + $(edit_cmd) $${srcdir}$@.in >$@.tmp + @ mv $@.tmp $@ + include contrib/Makemodule.am include doc/Makemodule.am include man/Makemodule.am diff --git a/configure.ac b/configure.ac index cfa9271..ec993c7 100644 --- a/configure.ac +++ b/configure.ac @@ -134,8 +134,7 @@ AM_CONDITIONAL([ENABLE_DOXYGEN], [test "x$enable_doxygen" = "xyes"]) AS_IF([test x$enable_doxygen = xyes], [ AC_CHECK_PROGS([DOXYGEN], [doxygen]) AS_IF([test "x$DOXYGEN" = "x"], - AC_MSG_ERROR([doxygen not in path]), - AC_CONFIG_FILES([doc/doxy.conf]) + AC_MSG_ERROR([doxygen not in path]) ) AC_CHECK_PROGS([DOXYGEN_DOT], [dot]) @@ -149,7 +148,6 @@ AM_CONDITIONAL([HAVE_DOXYGEN_DOT], [test "x$DOXYGEN_DOT" != "x"]) AC_CONFIG_FILES([ Makefile lib/Makefile - man/dhcpd-pools.1 ]) AC_OUTPUT diff --git a/contrib/.gitignore b/contrib/.gitignore new file mode 100644 index 0000000..591c7bd --- /dev/null +++ b/contrib/.gitignore @@ -0,0 +1,2 @@ +/dhcpd-pools.cgi +/nagios.conf diff --git a/contrib/Makemodule.am b/contrib/Makemodule.am index f6aee1f..a6bbc1e 100644 --- a/contrib/Makemodule.am +++ b/contrib/Makemodule.am @@ -1,3 +1,5 @@ contribdir = $(datadir)/dhcpd-pools/ +PATHFILES += contrib/dhcpd-pools.cgi contrib/nagios.conf dist_contrib_SCRIPTS = contrib/dhcpd-pools.cgi contrib/snmptest.pl -EXTRA_DIST += contrib/nagios.conf contrib/munin_plugins +dist_contrib_DATA = contrib/nagios.conf +EXTRA_DIST += contrib/munin_plugins diff --git a/contrib/dhcpd-pools.cgi b/contrib/dhcpd-pools.cgi.in similarity index 91% rename from contrib/dhcpd-pools.cgi rename to contrib/dhcpd-pools.cgi.in index 15a73fb..117a7cf 100755 --- a/contrib/dhcpd-pools.cgi +++ b/contrib/dhcpd-pools.cgi.in @@ -1,4 +1,4 @@ -#!/bin/sh +#!@SHELL@ # # Simple CGI for dhcpd-pools. @@ -26,7 +26,7 @@ echo "

This was situation at " date echo "

" -/usr/local/bin/dhcpd-pools --format html +@bindir@/dhcpd-pools --format html echo "" echo "" diff --git a/contrib/nagios.conf b/contrib/nagios.conf deleted file mode 100644 index 0159fca..0000000 --- a/contrib/nagios.conf +++ /dev/null @@ -1 +0,0 @@ -command[check_dhcpd_pools]=/usr/bin/dhcpd-pools --warning $ARG1$ --critical $ARG2$ diff --git a/contrib/nagios.conf.in b/contrib/nagios.conf.in new file mode 100644 index 0000000..1881c1a --- /dev/null +++ b/contrib/nagios.conf.in @@ -0,0 +1 @@ +command[check_dhcpd_pools]=@bindir@/dhcpd-pools --warning $ARG1$ --critical $ARG2$ diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..2063aaa --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +/doxy.conf diff --git a/doc/Makemodule.am b/doc/Makemodule.am index 5a5686d..8069c66 100644 --- a/doc/Makemodule.am +++ b/doc/Makemodule.am @@ -1,5 +1,9 @@ +PATHFILES += \ + doc/doxy.conf +nodist_noinst_DATA = \ + doc/doxy.conf + EXTRA_DIST += \ - doc/doxy.conf.in \ doc/introduction.dox if ENABLE_DOXYGEN diff --git a/doc/doxy.conf.in b/doc/doxy.conf.in index 86e2d3b..0427f34 100644 --- a/doc/doxy.conf.in +++ b/doc/doxy.conf.in @@ -32,7 +32,7 @@ PROJECT_NAME = @PACKAGE_NAME@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @PACKAGE_VERSION@ +PROJECT_NUMBER = @VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/man/Makemodule.am b/man/Makemodule.am index 102705a..75f7eb1 100644 --- a/man/Makemodule.am +++ b/man/Makemodule.am @@ -1,3 +1,2 @@ man_MANS = man/dhcpd-pools.1 -EXTRA_DIST += man/dhcpd-pools.1.in -CLEANFILES += man/dhcpd-pools.1 +PATHFILES += man/dhcpd-pools.1 diff --git a/man/dhcpd-pools.1.in b/man/dhcpd-pools.1.in index a054a5f..fcd2fdb 100644 --- a/man/dhcpd-pools.1.in +++ b/man/dhcpd-pools.1.in @@ -1,4 +1,4 @@ -.TH DHCPD-POOLS "1" "2015-09-04" "@PACKAGE_STRING@" "User Commands" +.TH DHCPD-POOLS "1" "2015-09-04" "@VERSION@" "User Commands" .SH NAME dhcpd-pools \- ISC dhcpd pools usage analysis .SH SYNOPSIS From 99b6af70ef607486cdd1a484a1e144714eeb35e7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 25 Nov 2015 22:02:41 +0000 Subject: [PATCH 133/313] update doxygen.conf file Signed-off-by: Sami Kerola --- doc/doxy.conf.in | 2448 ++++++++++++++++++++++++++++------------------ 1 file changed, 1514 insertions(+), 934 deletions(-) diff --git a/doc/doxy.conf.in b/doc/doxy.conf.in index 0427f34..d64080e 100644 --- a/doc/doxy.conf.in +++ b/doc/doxy.conf.in @@ -1,110 +1,129 @@ -# Doxyfile 1.8.2 +# Doxyfile 1.8.10 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored. +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. PROJECT_NAME = @PACKAGE_NAME@ -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. PROJECT_NUMBER = @VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "ISC dhcpd lease usage analyser" -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. PROJECT_LOGO = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. OUTPUT_DIRECTORY = @top_srcdir@/doc -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. CREATE_SUBDIRS = NO +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. +# The default value is: YES. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# doxygen will generate a detailed section even if there is only a brief # description. +# The default value is: NO. ALWAYS_DETAILED_SEC = NO @@ -112,242 +131,276 @@ ALWAYS_DETAILED_SEC = NO # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. +# The default value is: NO. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = src -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. QT_AUTOBRIEF = YES -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. TCL_SUBST = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. EXTENSION_MAPPING = -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. MARKDOWN_SUPPORT = YES -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. +# The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. +# The default value is: NO. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter and setter methods for a property. Setting this option to YES (the default) will make doxygen replace the get and set methods by a property in the documentation. This will only work if the methods are indeed getting or setting a simple type. If this is not the case, or you want to show the methods anyway, you should set this option to NO. +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first +# tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. +# The default value is: NO. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. INLINE_GROUPED_CLASSES = NO -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. INLINE_SIMPLE_STRUCTS = NO -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. TYPEDEF_HIDES_STRUCT = NO -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 @@ -355,357 +408,421 @@ LOOKUP_CACHE_SIZE = 0 # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. EXTRACT_PRIVATE = NO -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. +# The default value is: NO. EXTRACT_PACKAGE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. EXTRACT_STATIC = YES -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. INTERNAL_DOCS = YES -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. +# The default value is: system dependent. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. SHOW_INCLUDE_FILES = YES -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. +# The default value is: YES. SHOW_USED_FILES = YES -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. LAYOUT_FILE = -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- -# configuration options related to warning and progress messages +# Configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. WARN_IF_DOC_ERROR = YES -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). WARN_LOGFILE = #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. INPUT = @top_srcdir@ # This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, +# *.vhdl, *.ucf, *.qsf, *.as and *.js. -FILE_PATTERNS = *.c *.h *.dox +FILE_PATTERNS = *.c \ + *.h \ + *.dox -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. +# # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = build-aux contrib +EXCLUDE = build-aux \ + contrib # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. +# The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = @@ -714,765 +831,1115 @@ EXCLUDE_PATTERNS = # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. -FILTER_SOURCE_PATTERNS = *.c *.h +FILTER_SOURCE_PATTERNS = *.c \ + *.h + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- -# configuration options related to source browsing +# Configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index +# Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be # written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 250 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /