Version 2.3

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2008-04-20 00:00:00 +02:00
parent 658fe50312
commit 609b7faeee
20 changed files with 268 additions and 608 deletions

View file

@ -1,4 +1,4 @@
Authors of dhcpd-pools.
See also the files THANKS and ChangeLog.
Sami Kerola designed and implemented dhcpd-pools.
Sami Kerola made design and implemented dhcpd-pools.

View file

@ -1,10 +1,19 @@
2006-xx-yy Sami Kerola <kerolasa@iki.fi>
2008-04-20 Sami Kerola <kerolasa@iki.fi>
* Release 2.3
* From bug report by Frank Bulk.
- Ranges was matching strings that where not ranges.
- Unchomped new lines made ascii raport to look bad.
* Thank's Frank.
2006-03-27 Sami Kerola <kerolasa@iki.fi>
* Release 2.2
* No ranges defined -> crash bug fixed.
* Better error messages for command line options.
* File flushes more clean and error messages added.
* Possibility to limit what is printed out.
* Output limit update to man page.
* Include statement is now followed thou relative paths
are problem.
2006-03-13 Sami Kerola <sami.kerola@iki.fi>

7
NEWS
View file

@ -5,12 +5,19 @@ See the end for copying conditions.
Please send dhcpd-pools bug reports to kerolasa@iki.fi.
Version 2.3
* Bugfixes:
* Ranges was matching strings that where not ranges.
* Unchomped new lines made ascii raport to look bad.
Version 2.2
* Bugfixes:
*. No ranges in dhcpd.conf -> crash.
* Better error messages.
* Possibility to limit output.
* Dhcpd.conf include statement will be followed.
Version 2.1

11
README
View file

@ -14,4 +14,13 @@ printed is the right thing to do when there is thousands of
addresses. If your address space is small some other dhcp
analyzer might be more suitable for you.
Command home page is located at http://www.iki.fi/kerolasa/dhcp/
Source code is pretty printed with this indent command
configuration.
-nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2 -ndj
-nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob
If you write patch please use indent and keep style constant.
Command home page is located at
http://dhcpd-pools.sourceforge.net/

3
THANKS
View file

@ -8,5 +8,4 @@ and exempt of errors.
Otto J. Mäkelä
Mika Paananen
Brian W. Kernighan
Rob Pike
Frank Bulk

2
TODO
View file

@ -2,8 +2,6 @@ Todo:
* dhcpd.conf file parser should understand semantics of
configuration directives.
* Current dhcpd.conf parser will not follow include
directive.
* Better use of autoconfig. Author admits to be beginer in
using auto tools. Help needed.
* Bad english to good english translation for all files that

View file

@ -1,6 +1,6 @@
@%:@! /bin/sh
@%:@ Guess values for system-dependent variables and create Makefiles.
@%:@ Generated by GNU Autoconf 2.59 for dhcpd-pools 2.1.
@%:@ Generated by GNU Autoconf 2.59 for dhcpd-pools 2.3.
@%:@
@%:@ Report bugs to <kerolasa@iki.fi>.
@%:@
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='dhcpd-pools'
PACKAGE_TARNAME='dhcpd-pools'
PACKAGE_VERSION='2.1'
PACKAGE_STRING='dhcpd-pools 2.1'
PACKAGE_VERSION='2.3'
PACKAGE_STRING='dhcpd-pools 2.3'
PACKAGE_BUGREPORT='kerolasa@iki.fi'
# Factoring default headers for most tests.
@ -310,7 +310,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE dhcpd_conf dhcpd_leases output_format CPP EGREP ALLOCA PERL LIB@&t@OBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE dhcpd_conf dhcpd_leases output_format output_limit CPP EGREP ALLOCA PERL LIB@&t@OBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -779,7 +779,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures dhcpd-pools 2.1 to adapt to many kinds of systems.
\`configure' configures dhcpd-pools 2.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -841,7 +841,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of dhcpd-pools 2.1:";;
short | recursive ) echo "Configuration of dhcpd-pools 2.3:";;
esac
cat <<\_ACEOF
@ -857,6 +857,7 @@ Optional Packages:
--with-dhcpd-conf=PATH Path where dhcpd.conf is located
--with-dhcpd-leases=PATH Path where dhcpd.leases is located
--with-output-format=FORMAT Default output format
--with-output-limit=NRO Default output limit 00 - 77
Some influential environment variables:
CC C compiler command
@ -966,7 +967,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
dhcpd-pools configure 2.1
dhcpd-pools configure 2.3
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@ -980,7 +981,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by dhcpd-pools $as_me 2.1, which was
It was created by dhcpd-pools $as_me 2.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@ -1624,7 +1625,7 @@ fi
# Define the identity of the package.
PACKAGE='dhcpd-pools'
VERSION='2.1'
VERSION='2.3'
cat >>confdefs.h <<_ACEOF
@ -3030,6 +3031,18 @@ fi;
# Check whether --with-output-limit or --without-output-limit was given.
if test "${with_output_limit+set}" = set; then
withval="$with_output_limit"
output_limit=$withval
CPPFLAGS="$CPPFLAGS -DOUTPUT_LIMIT='\"$withval\"'"
else
output_limit=$output_limit_default
fi;
for ac_func in getopt_long inet_aton inet_addr
@ -4789,7 +4802,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by dhcpd-pools $as_me 2.1, which was
This file was extended by dhcpd-pools $as_me 2.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -4852,7 +4865,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
dhcpd-pools config.status 2.1
dhcpd-pools config.status 2.3
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@ -5093,6 +5106,7 @@ s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
s,@dhcpd_conf@,$dhcpd_conf,;t t
s,@dhcpd_leases@,$dhcpd_leases,;t t
s,@output_format@,$output_format,;t t
s,@output_limit@,$output_limit,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
s,@ALLOCA@,$ALLOCA,;t t

View file

@ -1,4 +1,4 @@
m4trace:configure.in:5: -1- AC_INIT([dhcpd-pools], [2.1], [kerolasa@iki.fi])
m4trace:configure.in:5: -1- AC_INIT([dhcpd-pools], [2.3], [kerolasa@iki.fi])
m4trace:configure.in:5: -1- m4_pattern_forbid([^_?A[CHUM]_])
m4trace:configure.in:5: -1- m4_pattern_forbid([_AC_])
m4trace:configure.in:5: -1- m4_pattern_forbid([^LIBOBJS$], [do not use LIBOBJS directly, use AC_LIBOBJ (see section `AC_LIBOBJ vs LIBOBJS'])
@ -119,102 +119,103 @@ m4trace:configure.in:10: -1- AC_SUBST([am__fastdepCC_FALSE])
m4trace:configure.in:25: -1- AC_SUBST([dhcpd_conf])
m4trace:configure.in:33: -1- AC_SUBST([dhcpd_leases])
m4trace:configure.in:41: -1- AC_SUBST([output_format])
m4trace:configure.in:43: -1- AC_CHECK_FUNCS([getopt_long inet_aton inet_addr], [break])
m4trace:configure.in:43: -1- AH_OUTPUT([HAVE_GETOPT_LONG], [/* Define to 1 if you have the `getopt_long\' function. */
m4trace:configure.in:49: -1- AC_SUBST([output_limit])
m4trace:configure.in:51: -1- AC_CHECK_FUNCS([getopt_long inet_aton inet_addr], [break])
m4trace:configure.in:51: -1- AH_OUTPUT([HAVE_GETOPT_LONG], [/* Define to 1 if you have the `getopt_long\' function. */
#undef HAVE_GETOPT_LONG])
m4trace:configure.in:43: -1- AH_OUTPUT([HAVE_INET_ATON], [/* Define to 1 if you have the `inet_aton\' function. */
m4trace:configure.in:51: -1- AH_OUTPUT([HAVE_INET_ATON], [/* Define to 1 if you have the `inet_aton\' function. */
#undef HAVE_INET_ATON])
m4trace:configure.in:43: -1- AH_OUTPUT([HAVE_INET_ADDR], [/* Define to 1 if you have the `inet_addr\' function. */
m4trace:configure.in:51: -1- AH_OUTPUT([HAVE_INET_ADDR], [/* Define to 1 if you have the `inet_addr\' function. */
#undef HAVE_INET_ADDR])
m4trace:configure.in:45: -1- AC_CHECK_LIB([resolv], [inet_ntoa])
m4trace:configure.in:45: -1- AH_OUTPUT([HAVE_LIBRESOLV], [/* Define to 1 if you have the `resolv\' library (-lresolv). */
m4trace:configure.in:53: -1- AC_CHECK_LIB([resolv], [inet_ntoa])
m4trace:configure.in:53: -1- AH_OUTPUT([HAVE_LIBRESOLV], [/* Define to 1 if you have the `resolv\' library (-lresolv). */
#undef HAVE_LIBRESOLV])
m4trace:configure.in:45: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBRESOLV])
m4trace:configure.in:48: -1- AC_CHECK_HEADERS([arpa/inet.h errno.h netinet/in.h stdio.h \
m4trace:configure.in:53: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBRESOLV])
m4trace:configure.in:56: -1- AC_CHECK_HEADERS([arpa/inet.h errno.h netinet/in.h stdio.h \
stdlib.h string.h sys/socket.h sys/stat.h sys/types.h unistd.h])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_ARPA_INET_H], [/* Define to 1 if you have the <arpa/inet.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_ARPA_INET_H], [/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_ERRNO_H], [/* Define to 1 if you have the <errno.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_ERRNO_H], [/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_NETINET_IN_H], [/* Define to 1 if you have the <netinet/in.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_NETINET_IN_H], [/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STDIO_H], [/* Define to 1 if you have the <stdio.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STDIO_H], [/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STRING_H], [/* Define to 1 if you have the <string.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STRING_H], [/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_SYS_SOCKET_H], [/* Define to 1 if you have the <sys/socket.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_SYS_SOCKET_H], [/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_SYS_STAT_H], [/* Define to 1 if you have the <sys/stat.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_SYS_STAT_H], [/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_SYS_TYPES_H], [/* Define to 1 if you have the <sys/types.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_SYS_TYPES_H], [/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H])
m4trace:configure.in:48: -1- AC_HEADER_STDC
m4trace:configure.in:48: -1- AC_PROG_CPP
m4trace:configure.in:48: -1- AC_SUBST([CPP])
m4trace:configure.in:48: -1- AC_SUBST([CPPFLAGS])
m4trace:configure.in:48: -1- AC_SUBST([CPP])
m4trace:configure.in:48: -1- AC_SUBST([EGREP])
m4trace:configure.in:48: -1- AC_DEFINE_TRACE_LITERAL([STDC_HEADERS])
m4trace:configure.in:48: -1- AH_OUTPUT([STDC_HEADERS], [/* Define to 1 if you have the ANSI C header files. */
m4trace:configure.in:56: -1- AC_HEADER_STDC
m4trace:configure.in:56: -1- AC_PROG_CPP
m4trace:configure.in:56: -1- AC_SUBST([CPP])
m4trace:configure.in:56: -1- AC_SUBST([CPPFLAGS])
m4trace:configure.in:56: -1- AC_SUBST([CPP])
m4trace:configure.in:56: -1- AC_SUBST([EGREP])
m4trace:configure.in:56: -1- AC_DEFINE_TRACE_LITERAL([STDC_HEADERS])
m4trace:configure.in:56: -1- AH_OUTPUT([STDC_HEADERS], [/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS])
m4trace:configure.in:48: -1- AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
m4trace:configure.in:56: -1- AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h], [], [], [$ac_includes_default])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_SYS_TYPES_H], [/* Define to 1 if you have the <sys/types.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_SYS_TYPES_H], [/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_SYS_STAT_H], [/* Define to 1 if you have the <sys/stat.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_SYS_STAT_H], [/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STDLIB_H], [/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STRING_H], [/* Define to 1 if you have the <string.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STRING_H], [/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_MEMORY_H], [/* Define to 1 if you have the <memory.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_MEMORY_H], [/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STRINGS_H], [/* Define to 1 if you have the <strings.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STRINGS_H], [/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define to 1 if you have the <inttypes.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_INTTYPES_H], [/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_STDINT_H], [/* Define to 1 if you have the <stdint.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_STDINT_H], [/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H])
m4trace:configure.in:48: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
m4trace:configure.in:56: -1- AH_OUTPUT([HAVE_UNISTD_H], [/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H])
m4trace:configure.in:51: -2- AC_DEFINE_TRACE_LITERAL([HAVE_GETOPT_H])
m4trace:configure.in:52: -1- AC_CHECK_HEADERS([getopt.h], [cat >>confdefs.h <<\_ACEOF
m4trace:configure.in:59: -2- AC_DEFINE_TRACE_LITERAL([HAVE_GETOPT_H])
m4trace:configure.in:60: -1- AC_CHECK_HEADERS([getopt.h], [cat >>confdefs.h <<\_ACEOF
@%:@define HAVE_GETOPT_H 1
_ACEOF
], [import_sources="getopt.c getopt1.c $import_sources"])
m4trace:configure.in:52: -1- AH_OUTPUT([HAVE_GETOPT_H], [/* Define to 1 if you have the <getopt.h> header file. */
m4trace:configure.in:60: -1- AH_OUTPUT([HAVE_GETOPT_H], [/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H])
m4trace:configure.in:55: -1- AC_FUNC_ALLOCA
m4trace:configure.in:55: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ALLOCA_H])
m4trace:configure.in:55: -1- AH_OUTPUT([HAVE_ALLOCA_H], [/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
m4trace:configure.in:63: -1- AC_FUNC_ALLOCA
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ALLOCA_H])
m4trace:configure.in:63: -1- AH_OUTPUT([HAVE_ALLOCA_H], [/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H])
m4trace:configure.in:55: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ALLOCA])
m4trace:configure.in:55: -1- AH_OUTPUT([HAVE_ALLOCA], [/* Define to 1 if you have `alloca\', as a function or macro. */
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([HAVE_ALLOCA])
m4trace:configure.in:63: -1- AH_OUTPUT([HAVE_ALLOCA], [/* Define to 1 if you have `alloca\', as a function or macro. */
#undef HAVE_ALLOCA])
m4trace:configure.in:55: -1- AC_LIBSOURCE([alloca.c])
m4trace:configure.in:55: -1- AC_SUBST([ALLOCA], [alloca.$ac_objext])
m4trace:configure.in:55: -1- AC_DEFINE_TRACE_LITERAL([C_ALLOCA])
m4trace:configure.in:55: -1- AH_OUTPUT([C_ALLOCA], [/* Define to 1 if using `alloca.c\'. */
m4trace:configure.in:63: -1- AC_LIBSOURCE([alloca.c])
m4trace:configure.in:63: -1- AC_SUBST([ALLOCA], [alloca.$ac_objext])
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([C_ALLOCA])
m4trace:configure.in:63: -1- AH_OUTPUT([C_ALLOCA], [/* Define to 1 if using `alloca.c\'. */
#undef C_ALLOCA])
m4trace:configure.in:55: -1- AC_DEFINE_TRACE_LITERAL([CRAY_STACKSEG_END])
m4trace:configure.in:55: -1- AH_OUTPUT([CRAY_STACKSEG_END], [/* Define to one of `_getb67\', `GETB67\', `getb67\' for Cray-2 and Cray-YMP
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([CRAY_STACKSEG_END])
m4trace:configure.in:63: -1- AH_OUTPUT([CRAY_STACKSEG_END], [/* Define to one of `_getb67\', `GETB67\', `getb67\' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c\' support on those systems.
*/
#undef CRAY_STACKSEG_END])
m4trace:configure.in:55: -1- AH_OUTPUT([STACK_DIRECTION], [/* If using the C implementation of alloca, define if you know the
m4trace:configure.in:63: -1- AH_OUTPUT([STACK_DIRECTION], [/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
@%:@undef STACK_DIRECTION])
m4trace:configure.in:55: -1- AC_DEFINE_TRACE_LITERAL([STACK_DIRECTION])
m4trace:configure.in:58: -1- AC_SUBST([PERL])
m4trace:configure.in:60: -1- AC_CONFIG_FILES([Makefile man/Makefile src/Makefile])
m4trace:configure.in:62: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:62: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
m4trace:configure.in:63: -1- AC_DEFINE_TRACE_LITERAL([STACK_DIRECTION])
m4trace:configure.in:66: -1- AC_SUBST([PERL])
m4trace:configure.in:68: -1- AC_CONFIG_FILES([Makefile man/Makefile src/Makefile])
m4trace:configure.in:70: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
m4trace:configure.in:70: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])

View file

@ -1,4 +1,4 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
@ -8,10 +8,6 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
@ -19,130 +15,53 @@
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the <argz.h> header file. */
#undef HAVE_ARGZ_H
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the `feof_unlocked' function. */
#undef HAVE_FEOF_UNLOCKED
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* Define to 1 if you have the `fgets_unlocked' function. */
#undef HAVE_FGETS_UNLOCKED
/* Define to 1 if you have the `inet_addr' function. */
#undef HAVE_INET_ADDR
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* Define to 1 if you have the `getc_unlocked' function. */
#undef HAVE_GETC_UNLOCKED
/* Define to 1 if you have the `getegid' function. */
#undef HAVE_GETEGID
/* Define to 1 if you have the `geteuid' function. */
#undef HAVE_GETEUID
/* Define to 1 if you have the `getgid' function. */
#undef HAVE_GETGID
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the `inet_aton' function. */
#undef HAVE_INET_ATON
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Define if your <locale.h> file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the `resolv' library (-lresolv). */
#undef HAVE_LIBRESOLV
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mempcpy' function. */
#undef HAVE_MEMPCPY
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define to 1 if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `stpcpy' function. */
#undef HAVE_STPCPY
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if `st_blksize' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
/* Define if your `struct stat' has `st_blksize'. Deprecated, use
`HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
#undef HAVE_ST_BLKSIZE
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@ -150,24 +69,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `tsearch' function. */
#undef HAVE_TSEARCH
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `__argz_count' function. */
#undef HAVE___ARGZ_COUNT
/* Define to 1 if you have the `__argz_next' function. */
#undef HAVE___ARGZ_NEXT
/* Define to 1 if you have the `__argz_stringify' function. */
#undef HAVE___ARGZ_STRINGIFY
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Name of package */
#undef PACKAGE
@ -189,9 +93,9 @@
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
@ -199,16 +103,3 @@
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t

36
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.59 for dhcpd-pools 2.1.
# Generated by GNU Autoconf 2.59 for dhcpd-pools 2.3.
#
# Report bugs to <kerolasa@iki.fi>.
#
@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='dhcpd-pools'
PACKAGE_TARNAME='dhcpd-pools'
PACKAGE_VERSION='2.1'
PACKAGE_STRING='dhcpd-pools 2.1'
PACKAGE_VERSION='2.3'
PACKAGE_STRING='dhcpd-pools 2.3'
PACKAGE_BUGREPORT='kerolasa@iki.fi'
# Factoring default headers for most tests.
@ -310,7 +310,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE dhcpd_conf dhcpd_leases output_format CPP EGREP ALLOCA PERL LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE dhcpd_conf dhcpd_leases output_format output_limit CPP EGREP ALLOCA PERL LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -779,7 +779,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures dhcpd-pools 2.1 to adapt to many kinds of systems.
\`configure' configures dhcpd-pools 2.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -841,7 +841,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of dhcpd-pools 2.1:";;
short | recursive ) echo "Configuration of dhcpd-pools 2.3:";;
esac
cat <<\_ACEOF
@ -857,6 +857,7 @@ Optional Packages:
--with-dhcpd-conf=PATH Path where dhcpd.conf is located
--with-dhcpd-leases=PATH Path where dhcpd.leases is located
--with-output-format=FORMAT Default output format
--with-output-limit=NRO Default output limit 00 - 77
Some influential environment variables:
CC C compiler command
@ -966,7 +967,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
dhcpd-pools configure 2.1
dhcpd-pools configure 2.3
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@ -980,7 +981,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by dhcpd-pools $as_me 2.1, which was
It was created by dhcpd-pools $as_me 2.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@ -1624,7 +1625,7 @@ fi
# Define the identity of the package.
PACKAGE='dhcpd-pools'
VERSION='2.1'
VERSION='2.3'
cat >>confdefs.h <<_ACEOF
@ -3030,6 +3031,18 @@ fi;
# Check whether --with-output-limit or --without-output-limit was given.
if test "${with_output_limit+set}" = set; then
withval="$with_output_limit"
output_limit=$withval
CPPFLAGS="$CPPFLAGS -DOUTPUT_LIMIT='\"$withval\"'"
else
output_limit=$output_limit_default
fi;
for ac_func in getopt_long inet_aton inet_addr
@ -4789,7 +4802,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by dhcpd-pools $as_me 2.1, which was
This file was extended by dhcpd-pools $as_me 2.3, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -4852,7 +4865,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
dhcpd-pools config.status 2.1
dhcpd-pools config.status 2.3
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@ -5093,6 +5106,7 @@ s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
s,@dhcpd_conf@,$dhcpd_conf,;t t
s,@dhcpd_leases@,$dhcpd_leases,;t t
s,@output_format@,$output_format,;t t
s,@output_limit@,$output_limit,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
s,@ALLOCA@,$ALLOCA,;t t

View file

@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([dhcpd-pools], [2.2], [kerolasa@iki.fi])
AC_INIT([dhcpd-pools], [2.3], [kerolasa@iki.fi])
AM_INIT_AUTOMAKE([1.9 foreign])

View file

@ -2,7 +2,7 @@
.\" http://www.iki.fi/kerolasa/
.\" kerolasa@iki.fi
.\"
.TH DHCPD-POOLS 1 "Mar 14 2006 - version 2.2"
.TH DHCPD-POOLS 1 "Apr 20 2008 - version 2.3"
.SH NAME
dhcpd-pools \- ISC dhcp pools usage analysis
.SH SYNOPSIS

View file

@ -104,8 +104,8 @@ do_counting (void)
if (range_p->last_ip < leases[i])
{
range_p++;
/* Break loop before trying to access memorory that is
* not allocated. */
/* Break loop before trying to access memorory that is
* not allocated. */
if (range_p - ranges > num_ranges)
{
break;

View file

@ -25,16 +25,16 @@
#endif
#ifndef DHCPDLEASE_FILE
# define DHCPDLEASE_FILE "/var/lib/dhcp/dhcpd.leases"
#endif
#endif
/* Default output style
* possible formats are the same as you can see from --help */
#ifndef OUTPUT_FORMAT
# define OUTPUT_FORMAT "text"
#endif
#endif
#ifndef OUTPUT_LIMIT
# define OUTPUT_LIMIT "77"
#endif
#endif
/* Maximum line length in dhcpd.conf and dhcpd.leases */
static const int MAXLEN = 1024;

View file

@ -162,7 +162,8 @@ main (int argc, char **argv)
}
else
{
eprintf ("main: output limit mask %s illegal", argv[optind]);
eprintf ("main: output limit mask %s illegal",
argv[optind]);
print_help ();
exit (EXIT_FAILURE);
}
@ -172,7 +173,8 @@ main (int argc, char **argv)
}
else
{
eprintf ("main: output limit mask %s illegal", argv[optind]);
eprintf ("main: output limit mask %s illegal",
argv[optind]);
print_help ();
exit (EXIT_FAILURE);
}
@ -219,7 +221,8 @@ main (int argc, char **argv)
}
/* Do actual job */
parse_config ();
prepare_storage ();
parse_config (config.dhcpdconf_file);
parse_leases ();
prepare_data ();
do_counting ();
@ -228,3 +231,18 @@ main (int argc, char **argv)
return 0;
}
/* Global allocations, counter resets etc */
int
prepare_storage ()
{
num_ranges = num_shared_networks = 0;
shared_networks =
safe_malloc (sizeof (struct shared_network_t) * SHARED_NETWORKS);
shared_net_names = safe_malloc (sizeof (char) * SHARED_NETWORKS_NAMES);
ranges = safe_malloc (sizeof (struct range_t) * RANGES);
/* First shared network entry is all networks */
strcpy (shared_net_names, "All networks");
}

View file

@ -55,7 +55,7 @@ struct range_t
/* External variables */
char *program_name;
static const float version_number = 2.2;
static const float version_number = 2.3;
struct configuration_t config;
static int output_limit_bit_1 = 1;
@ -73,8 +73,9 @@ unsigned long int *leases;
unsigned long int num_leases;
/* Function prototypes */
int prepare_storage (void);
int parse_leases (void);
int parse_config (void);
int parse_config (char *);
int do_counting (void);
int intcomp (const void *x, const void *y);
int rangecomp (const void *r1, const void *r2);

View file

@ -51,55 +51,52 @@ extern char *malloc ();
/* Parser for dhcpd.conf */
int
parse_config (void)
parse_config (char *config_file)
{
FILE *dhcpd_config;
char *line, *shared_name_p, *last_shared, *tmp, *null_here;
char *line, *shared_name_p, *last_shared, *tmp, *matchp;
unsigned int braces = 0, linelen, i;
struct in_addr inp;
struct range_t *range_p;
struct shared_network_t *shared_p;
num_ranges = num_shared_networks = 0;
line = safe_malloc (sizeof (char) * MAXLEN);
tmp = safe_malloc (sizeof (char) * MAXLEN);
shared_networks =
safe_malloc (sizeof (struct shared_network_t) * SHARED_NETWORKS);
shared_p = shared_networks;
ranges = safe_malloc (sizeof (struct range_t) * RANGES);
range_p = ranges;
shared_net_names = safe_malloc (sizeof (char) * SHARED_NETWORKS_NAMES);
last_shared = SHARED_NETWORKS_NAMES + shared_net_names;
/* First shared network entry is all networks */
strcpy (shared_net_names, "All networks");
shared_p->name = shared_net_names;
shared_name_p = shared_net_names;
/* Save and skip all networks name */
shared_p->name = shared_net_names;
shared_name_p += strlen (shared_name_p) + 1;
shared_p++;
dhcpd_config = fopen (config.dhcpdconf_file, "r");
dhcpd_config = fopen (config_file, "r");
if (dhcpd_config == NULL)
{
eprintf ("parse_config: %s:", config.dhcpdconf_file);
eprintf ("parse_config: %s:", config_file);
exit (EXIT_FAILURE);
}
while (!feof (dhcpd_config))
{
fgets (line, MAXLEN, dhcpd_config);
null_here = strchr (line, '#');
if (null_here)
matchp = strchr (line, '#');
if (matchp)
{
*null_here = '\0';
*matchp = '\0';
}
null_here = strchr (line, ';');
if (null_here)
matchp = strchr (line, ';');
if (matchp)
{
*null_here = '\0';
*matchp = '\0';
}
matchp = strchr (line, '\n');
if (matchp)
{
*matchp = '\0';
}
linelen = strlen (line);
if (linelen == 0)
@ -123,12 +120,24 @@ parse_config (void)
}
/* Smells like line that defines range. */
if (strstr (line, "range"))
matchp = strstr (line, "range");
if (matchp)
{
/* Match "range" that part of some other text. */
matchp--;
i = matchp[0];
if (!isspace(i)) {
continue;
}
matchp = matchp + 6;
i = matchp[0];
if (!isspace(i)) {
continue;
}
/* shared_p is incremented too early. This glue is
* ugly and should be fixed. */
if (braces > 1)
{
/* shared_p is incremented too early. This glue is
* ugly and should be fixed. */
range_p->shared_net = shared_p - 1;
}
else
@ -162,7 +171,8 @@ parse_config (void)
if (num_ranges > RANGES)
{
eprintf ("parse_config: Range space full! Increase RANGES and recompile.");
eprintf
("parse_config: Range space full! Increase RANGES and recompile.");
exit (EXIT_FAILURE);
}
}
@ -172,7 +182,8 @@ parse_config (void)
linelen = strlen (line);
if (shared_name_p + linelen > last_shared)
{
eprintf ("parse_config: Shared network name space full! Increase SHARED_NETWORKS_NAMES and recompile.\n");
eprintf
("parse_config: Shared network name space full! Increase SHARED_NETWORKS_NAMES and recompile.\n");
exit (EXIT_FAILURE);
}
@ -188,11 +199,34 @@ parse_config (void)
if (num_shared_networks > SHARED_NETWORKS)
{
eprintf ("parse_config: Shared network space full! Increase SHARED_NETWORKS and recompile.\n");
eprintf
("parse_config: Shared network space full! Increase SHARED_NETWORKS and recompile.\n");
exit (EXIT_FAILURE);
}
}
/* If include files are allowed to write with relative path
* this if needs to be fixed. */
else if (strstr (line, "include"))
{
nth_field (2, tmp, line);
/* Perhaps quote mark striping could more pretty, but
* it isn't - Yours Sincerely lazy author. */
matchp = strrchr (tmp, '"');
if (matchp)
{
*matchp = '\0';
}
if (tmp[0] == '"')
{
parse_config (++tmp);
}
else
{
parse_config (tmp);
}
}
}
return 0;
}

View file

@ -101,7 +101,12 @@ void
print_version (void)
{
fprintf (stdout, "%s version %.2f\n", program_name, version_number);
fprintf (stdout, "Written by Sami Kerola.\n");
fprintf (stdout, "Written by Sami Kerola.\n\n");
fprintf (stdout,
"%s may be copied only under the terms of GNU General Public\n",
program_name);
fprintf (stdout,
"License, which may be found in the dhcpd-pools source kit.\n");
}
void

View file

@ -90,6 +90,10 @@ output_txt (void)
range_p->first_ip - 1));
range_p++;
}
}
if (config.output_limit[1] & output_limit_bit_1
&& config.output_limit[0] & output_limit_bit_2)
{
fprintf (outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_2)
@ -108,6 +112,10 @@ output_txt (void)
shared_p->used,
(float) (100 * shared_p->used) / shared_p->available);
}
}
if (config.output_limit[1] & output_limit_bit_2
&& config.output_limit[0] & output_limit_bit_3)
{
fprintf (outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_3)

View file

@ -1,348 +0,0 @@
/*
** Copyright (C) 2006 Sami Kerola <kerolasa@iki.fi>
**
** 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
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include "dhcpd-pools.h"
/* There should be command line switches that can be used to
* limit output. Not always one wishes to see headers, ranges,
* shared networks or total. Perhaps this is fixed on next
* version. */
int
output_txt (void)
{
unsigned int i;
struct in_addr first, last;
struct range_t *range_p;
struct shared_network_t *shared_p;
FILE *outfile;
if (config.output_file[0])
{
outfile = fopen (config.output_file, "w+");
if (outfile == NULL)
{
eprintf ("output_txt: %s:", config.output_file);
exit (EXIT_FAILURE);
}
}
else
{
outfile = stdout;
}
range_p = ranges;
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\n");
}
if (config.output_limit[1] & output_limit_bit_1) {
for (i = 0; i < num_ranges; i++)
{
first.s_addr = ntohl (range_p->first_ip + 1);
last.s_addr = ntohl (range_p->last_ip - 1);
if (range_p->shared_net)
{
fprintf (outfile, "%-20s", range_p->shared_net->name);
}
else
{
fprintf (outfile, "not_defined ");
}
fprintf (outfile, "%-16s", inet_ntoa (first));
fprintf (outfile, " - %-16s %5lu %5lu %10.3f\n",
inet_ntoa (last),
range_p->last_ip - range_p->first_ip - 1,
range_p->count,
(float) (100 * range_p->count) / (range_p->last_ip -
range_p->first_ip - 1));
range_p++;
}
fprintf(outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_2) {
fprintf (outfile, "Shared networks:\n");
fprintf (outfile, "name max cur percent\n");
}
if (config.output_limit[1] & output_limit_bit_2) {
for (i = 0; i < num_shared_networks; i++)
{
shared_p++;
fprintf (outfile, "%-20s %5lu %5lu %10.3f\n",
shared_p->name,
shared_p->available,
shared_p->used,
(float) (100 * shared_p->used) / shared_p->available);
}
fprintf(outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_3) {
fprintf (outfile, "Sum of all ranges:\n");
fprintf (outfile, "name max cur percent\n");
}
if (config.output_limit[1] & output_limit_bit_3) {
fprintf (outfile, "%-20s %5lu %5lu %10.3f\n",
shared_networks->name,
shared_networks->available,
shared_networks->used,
(float) (100 * shared_networks->used) /
shared_networks->available);
}
if (outfile == stdout) {
fflush(stdout);
} else {
fclose (outfile);
}
if (errno)
{
if (config.output_file[0]) {
eprintf ("output_txt: %s:", config.output_file);
} else {
eprintf ("output_txt: stdout:");
}
exit (EXIT_FAILURE);
}
return 0;
}
int
output_html (void)
{
unsigned int i;
struct in_addr first, last;
struct range_t *range_p;
struct shared_network_t *shared_p;
FILE *outfile;
if (config.output_file[0])
{
outfile = fopen (config.output_file, "w+");
if (outfile == NULL)
{
eprintf ("output_html: %s:", config.output_file);
exit (EXIT_FAILURE);
}
}
else
{
outfile = stdout;
}
range_p = ranges;
shared_p = shared_networks;
fprintf (outfile,
"<table width=\"75%\" class=\"dhcpd-pools\" summary=\"ISC dhcpd pool usage raport\">\n");
if (config.output_limit[0] & output_limit_bit_1) {
fprintf (outfile, "<tr><th>Ranges:</th></tr>\n");
fprintf
(outfile,
"<tr><th>shared net name</th><th>first ip</th><th>last ip</th><th align=\"right\">max</th><th align=\"right\">cur</th><th align=\"right\">percent</th></tr>\n");
}
if (config.output_limit[1] & output_limit_bit_1) {
for (i = 0; i < num_ranges; i++)
{
first.s_addr = ntohl (range_p->first_ip + 1);
last.s_addr = ntohl (range_p->last_ip - 1);
if (range_p->shared_net)
{
fprintf (outfile, "<tr><td>%s</td>", range_p->shared_net->name);
}
else
{
fprintf (outfile, "<tr><td>not_defined</td>");
}
fprintf (outfile, "<td>%s</td>", inet_ntoa (first));
fprintf (outfile,
"<td>%s</td><td align=\"right\">%lu</td><td align=\"right\">%lu</td><td align=\"right\">%.3f</td></tr>\n",
inet_ntoa (last), range_p->last_ip - range_p->first_ip - 1,
range_p->count,
(float) (100 * range_p->count) / (range_p->last_ip -
range_p->first_ip - 1));
range_p++;
}
}
if (config.output_limit[0] & output_limit_bit_2) {
fprintf (outfile, "\n<tr><th>Shared networks:</th></tr>\n");
fprintf (outfile,
"<tr><th>name</td><th align=\"right\">max</th><th align=\"right\">cur</th><th align=\"right\">percent</th></tr>\n");
}
if (config.output_limit[1] & output_limit_bit_2) {
for (i = 0; i < num_shared_networks; i++)
{
shared_p++;
fprintf (outfile,
"<tr><td>%s</td><td align=\"right\">%lu</td><td align=\"right\">%lu</td><td align=\"right\">%.3f</td></tr>\n",
shared_p->name, shared_p->available, shared_p->used,
(float) (100 * shared_p->used) / shared_p->available);
}
}
if (config.output_limit[0] & output_limit_bit_3) {
fprintf (outfile, "\n<tr><th>Sum of all ranges:</th></tr>\n");
fprintf (outfile,
"<tr><th>name</th><th align=\"right\">max</th><th align=\"right\">cur</th><th align=\"right\">percent</th></tr>\n");
}
if (config.output_limit[1] & output_limit_bit_3) {
fprintf (outfile,
"<tr><td>%s</td><td align=\"right\">%lu</td><td align=\"right\">%lu</td><td align=\"right\">%.3f</td></tr>\n",
shared_networks->name, shared_networks->available,
shared_networks->used,
(float) (100 * shared_networks->used) /
shared_networks->available);
}
fprintf (outfile, "</table>\n");
if (outfile == stdout) {
fflush(stdout);
} else {
fclose (outfile);
}
if (errno)
{
if (config.output_file[0]) {
eprintf ("output_html: %s:", config.output_file);
} else {
eprintf ("output_html: stdout:");
}
exit (EXIT_FAILURE);
}
return 0;
}
int
output_csv (void)
{
unsigned int i;
struct in_addr first, last;
struct range_t *range_p;
struct shared_network_t *shared_p;
FILE *outfile;
if (config.output_file[0])
{
outfile = fopen (config.output_file, "w+");
if (outfile == NULL)
{
eprintf ("output_csv: %s:", config.output_file);
exit (EXIT_FAILURE);
}
}
else
{
outfile = stdout;
}
range_p = ranges;
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\"\n");
}
if (config.output_limit[1] & output_limit_bit_1) {
for (i = 0; i < num_ranges; i++)
{
first.s_addr = ntohl (range_p->first_ip + 1);
last.s_addr = ntohl (range_p->last_ip - 1);
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\",\"%lu\",\"%lu\",\"%.3f\"\n",
inet_ntoa (last),
range_p->last_ip - range_p->first_ip - 1,
range_p->count,
(float) (100 * range_p->count) / (range_p->last_ip -
range_p->first_ip - 1));
range_p++;
}
fprintf (outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_2) {
fprintf (outfile, "\"Shared networks:\"\n");
fprintf (outfile, "\"name\",\"max\",\"cur\",\"percent\"\n");
}
if (config.output_limit[1] & output_limit_bit_2) {
for (i = 0; i < num_shared_networks; i++)
{
shared_p++;
fprintf (outfile, "\"%s\",\"%lu\",\"%lu\",\"%.3f\"\n",
shared_p->name,
shared_p->available,
shared_p->used,
(float) (100 * shared_p->used) / shared_p->available);
}
fprintf (outfile, "\n");
}
if (config.output_limit[0] & output_limit_bit_3) {
fprintf (outfile, "\"Sum of all ranges:\"\n");
fprintf (outfile, "\"name\",\"max\",\"cur\",\"percent\"\n");
}
if (config.output_limit[1] & output_limit_bit_3) {
fprintf (outfile, "\"%s\",\"%lu\",\"%lu\",\"%.3f\"\n",
shared_networks->name,
shared_networks->available,
shared_networks->used,
(float) (100 * shared_networks->used) /
shared_networks->available);
}
if (outfile == stdout) {
fflush(stdout);
} else {
fclose (outfile);
}
if (errno)
{
if (config.output_file[0]) {
eprintf ("output_csv: %s:", config.output_file);
} else {
eprintf ("output_csv: stdout:");
}
exit (EXIT_FAILURE);
}
return 0;
}