This also fixes backup state counts that were added to shared networks
twice, making the numbers to be much greater than they really where.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier variables magically appeared to scope of functions that took void as
argument. One could figure out perhaps they were globals, but programs that
do that are unnessarily hard to follow.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Not all markups were quite right. The output_* functions must return an
int. The rest were as a matter of fact correct.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When ./configure --enable-doxygen is used one can browse internal api
documentation from docs/html directory.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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 <lzm@cernet.edu.cn>
CC: Xing Li <xing@cernet.edu.cn>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Cheer Xiao <xiaqqaix@gmail.com>
There were too clever tricks done with first and last. Earlier the aim
was to minimize '<=' and '>=' by fiddling with the numbers at the time
when they were saved. While the program logic seemed to work there were
some off by one mistakes, resulting to a count error. Even worse there
is not even that many of such comparisons, so that one cannot really even
justify added complexity. I really hope this patch is last this kind fix
ever needed.
Reported-by: Cheer Xiao <xiaqqaix@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
At the other day I where wondering why so much time was spent on analysis
function, when I realized regression. At the time uthash was introduced
to the project range sorting got to be dropped, which caused same leases
to be walked in analysis time after time.
Now when the regression is removed, and the test cases run about 28% over
all quicker. The rule of thumb is that the greater the data set the
bigger is the benefit having this fix. My largest test data is now
roughly 35% faster.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Fix to a very severe bug. In cases when IP addresses in lease file had
a range of using highest bit, e.g. signed int minus, the sort caused
high ranges to be counted first and low ranges skipped. The usual case
when this happen was when ranges contained 10.0.0.0/8 addresses
together with addresses greater than 128.0.0.0/32.
Reported-by: Ryan Malek <rmalek@osage.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The problem is, that you simply count all lease occurrences in
dhcpd.leases, but only the last ones for each ip address are
valid. The lease file is more like a logfile of what has been
done, than a real database. To fix the counting issue, I'm using
a single hash (from uthash.h [1]) for the counting. This way
only the last lease entry for each IP gets into my counting
structure.
When you remove the duplicates in prepare_data(), you don't have
the information anymore, if the active lease entry or the free
lease entry came last. Simply deleting each ip from the touches
array, that is already in the leases array, gives you a big
chance to count wrong. Another way of fixing this would be to
not only store the ips in your arrays, but a structure containing
the ip and a global lease entry counter. Then you could delete
all entries except for the latest.
[1] http://uthash.sourceforge.net/
Reported-by: Huangy
Signed-off-by: Enno Gröper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit 1e82461875 was
incomplete, and at the end was a cause of off by one miscount.
The reason was bsearch where long int needed to be unsigned.
Weird that the original had work while there where so many type
mismatches.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Remove unnecessary type casting, move .gitignore file contents to
right location, reindent to use Linux coding style, fix few type
mismatches, clean up to help & version output and hint compiler
call to these functions will end program.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
My stupid mistake to leave statement hanging around while I where
wondering where the uninitialized memory came from.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
After uint32_t fix from 1e82461875
it was good idea to check which headers where needed where. And
generally clean up the includes while doing the check.
There where long and unsigned long used for IPs in use which
caused occasional off by one errors. The word occasional should
be read: pretty much every one with large enough configuration
has been affected.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Usage of includes are set up the way found to be in use, with a help of
magnificent utility.
http://code.google.com/p/include-what-you-use/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The eprintf removed and replaced with err & warn. Option parsing
no longer tries to find missing optargs, which are getopts should
notice. Few complier warnings got to be removed as well. Finally
the commments will no longer exceed standard terminal width.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>