This will allow nth_field function to begin from first field, and stop
immediately when it ends, which makes function much more simple and quite
a bit quicker.
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>
This will mean better portability, and a good reason to get rid of
various portability autotools directives which where part of this
project.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
output.c:819:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
for (i = 0; i < num_ranges; i++) {
~ ^ ~~~~~~~~~~
output.c:832:17: warning: comparison of integers of different signs:
'int' and ' unsigned int' [-Wsign-compare]
for (i = 0; i < num_shared_networks; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~
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 Grper <groepeen@cms.hu-berlin.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
[src/getdata.c:307]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:324]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:340]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:362]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:366]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:371]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:372]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
[src/getdata.c:385]: (warning) Comparison of a boolean with integer that is neither 1 nor 0
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When { is wrote together with a word, such as
pool{
range 10.0.0.100 100.0.0.200;
range ..
the parser ignored first range, resulting it to disappear from analysis.
Reported-by: Robert Viou <robert.viou@ndsu.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Version 2.16 needs the patche to compile correctly and without
warnings (tested on NetBSD, Mac OS X and Debian/Ubuntu).
Signed-off-by: Adam Ciarcinski <adam@netbsd.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
other.c:77:7: warning: ISO C90 does not support the 'z' gnu_printf length modifier [-Wformat]
other.c:169:2: warning: string length '1046' is greater than the length '509' ISO C90 compilers are required to support [-Woverlength-strings]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The strstr is changed to xstrstr, which short cuts to points in
string where first differences are expected to found. This made
the tool tiny bit quicker.
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>
The full html will now print the mtime of dhcpd.leases file in
header. Additionally at the footer of the page the dhcpd-pools
will have package name and version number.
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>
Ahmed reported he saw the following error with version 2.15 which
is an indication of unusual high number of clients that has been
seen. I am not sure where that happen, but I suspect an airport
or some other 'lots of mobiles getting leases' might be able to
case same situation.
dhcpd-pools: getdata.c:136: parse_leases: Assertion `!(touchesmallocsize < num_touches)' failed.
The problem was quite easy to fix simply getting rid of assert
and putting realloc in place.
Reported-by: Ahmed AL Dakhil <a.aldakhil@go.com.sa>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The lack of initialization may have cause unexpected outputs to
some users some times. That sort of behavior is also known by
name a bug.
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 help screen has now same notation as most of the GNU/Linux
utilities, e.g. if a option requires argument it is marked as
option=ARG. That enabled me to use help2man to make small nroff
fixes to manual page to unify it's outlook as well.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>