freebsd_build.patch for Traffic Gist v0.1.0. Portability fixes, successfully builds on FreeBSD now. diff -rU20 a/configure.in b/configure.in --- a/configure.in 2010-09-30 23:19:30.000000000 +0400 +++ b/configure.in 2010-10-12 05:04:54.000000000 +0400 @@ -14,32 +14,38 @@ AC_CONFIG_HEADERS(src/autoconf.h) AH_TOP([ #ifndef TRAFFICGIST_AUTOCONF_H #define TRAFFICGIST_AUTOCONF_H ]) AH_BOTTOM([ #endif // TRAFFICGIST_AUTOCONF_H ]) AM_INIT_AUTOMAKE([nostdinc]) AC_PROG_LIBTOOL m4_include(import/xstd/cfgaux/xstd_init.ac) m4_include(import/xstd/cfgaux/xstd_common.ac) m4_include(import/xstd/cfgaux/xstd_cxx_flags.ac) m4_include(import/xstd/cfgaux/xstd_cpp_checks.ac) +AC_CHECK_HEADERS([\ + features.h \ + pcap.h \ + pcap/pcap.h +]) + AC_CHECK_LIB(pcap, pcap_open_live, [], AC_MSG_ERROR([TrafficGist requires libpcap.])) AC_MSG_NOTICE([configuring imported libraries to be installed in ${install_prefix}]) APR_SUBDIR_CONFIG(import/xstd, [--prefix=${install_prefix} --with-libltdl=no], [\'--prefix=*]) APR_SUBDIR_CONFIG(import/DnsPaxxer, [--prefix=${install_prefix}], [\'--prefix=*]) AC_CONFIG_FILES([ Makefile import/Makefile src/Makefile ]) AC_OUTPUT diff -rU20 a/import/DnsPaxxer/cfgaux/ax_prefix_config_h.m4 b/import/DnsPaxxer/cfgaux/ax_prefix_config_h.m4 --- a/import/DnsPaxxer/cfgaux/ax_prefix_config_h.m4 2010-05-25 02:10:00.000000000 +0400 +++ b/import/DnsPaxxer/cfgaux/ax_prefix_config_h.m4 2010-10-12 02:01:59.000000000 +0400 @@ -1,104 +1,146 @@ -dnl @synopsis AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] -dnl -dnl This is a new variant from ac_prefix_config_ this one will use a -dnl lowercase-prefix if the config-define was starting with a -dnl lowercase-char, e.g. "#define const", "#define restrict", or -dnl "#define off_t", (and this one can live in another directory, e.g. -dnl testpkg/config.h therefore I decided to move the output-header to -dnl be the first arg) -dnl -dnl takes the usual config.h generated header file; looks for each of -dnl the generated "#define SOMEDEF" lines, and prefixes the defined name -dnl (ie. makes it "#define PREFIX_SOMEDEF". The result is written to -dnl the output config.header file. The PREFIX is converted to uppercase -dnl for the conversions. -dnl -dnl Defaults: -dnl -dnl OUTPUT-HEADER = $PACKAGE-config.h -dnl PREFIX = $PACKAGE -dnl ORIG-HEADER, from AM_CONFIG_HEADER(config.h) -dnl -dnl Your configure.ac script should contain both macros in this order, -dnl and unlike the earlier variations of this prefix-macro it is okay to -dnl place the AX_PREFIX_CONFIG_H call before the AC_OUTPUT invokation. -dnl -dnl Example: -dnl -dnl AC_INIT(config.h.in) # config.h.in as created by "autoheader" -dnl AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE -dnl AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in -dnl AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. -dnl AC_MEMORY_H # makes "#undef NEED_MEMORY_H" -dnl AC_C_CONST_H # makes "#undef const" -dnl AC_OUTPUT(Makefile) # creates the "config.h" now -dnl # and also mylib/_config.h -dnl -dnl if the argument to AX_PREFIX_CONFIG_H would have been omitted then the -dnl default outputfile would have been called simply "testpkg-config.h", but -dnl even under the name "mylib/_config.h" it contains prefix-defines like -dnl -dnl #ifndef TESTPKG_VERSION -dnl #define TESTPKG_VERSION "0.1.1" -dnl #endif -dnl #ifndef TESTPKG_NEED_MEMORY_H -dnl #define TESTPKG_NEED_MEMORY_H 1 -dnl #endif -dnl #ifndef _testpkg_const -dnl #define _testpkg_const _const -dnl #endif -dnl -dnl and this "mylib/_config.h" can be installed along with other -dnl header-files, which is most convenient when creating a shared -dnl library (that has some headers) where some functionality is -dnl dependent on the OS-features detected at compile-time. No -dnl need to invent some "mylib-confdefs.h.in" manually. :-) -dnl -dnl Note that some AC_DEFINEs that end up in the config.h file are -dnl actually self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the -dnl AC_TYPE_OFF_T say that they "will define inline|const|off_t if the -dnl system does not do it by itself". You might want to clean up about -dnl these - consider an extra mylib/conf.h that reads something like: -dnl -dnl #include -dnl #ifndef _testpkg_const -dnl #define _testpkg_const const -dnl #endif -dnl -dnl and then start using _testpkg_const in the header files. That is -dnl also a good thing to differentiate whether some library-user has -dnl starting to take up with a different compiler, so perhaps it could -dnl read something like this: -dnl -dnl #ifdef _MSC_VER -dnl #include -dnl #else -dnl #include -dnl #endif -dnl #ifndef _testpkg_const -dnl #define _testpkg_const const -dnl #endif -dnl -dnl @author Guiodo Draheim -dnl -AC_DEFUN([AX_PREFIX_CONFIG_H],[AC_REQUIRE([AC_CONFIG_HEADERS]) +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] +# +# DESCRIPTION +# +# This is a new variant from ac_prefix_config_ this one will use a +# lowercase-prefix if the config-define was starting with a +# lowercase-char, e.g. "#define const", "#define restrict", or "#define +# off_t", (and this one can live in another directory, e.g. +# testpkg/config.h therefore I decided to move the output-header to be the +# first arg) +# +# takes the usual config.h generated header file; looks for each of the +# generated "#define SOMEDEF" lines, and prefixes the defined name (ie. +# makes it "#define PREFIX_SOMEDEF". The result is written to the output +# config.header file. The PREFIX is converted to uppercase for the +# conversions. +# +# Defaults: +# +# OUTPUT-HEADER = $PACKAGE-config.h +# PREFIX = $PACKAGE +# ORIG-HEADER, from AM_CONFIG_HEADER(config.h) +# +# Your configure.ac script should contain both macros in this order, and +# unlike the earlier variations of this prefix-macro it is okay to place +# the AX_PREFIX_CONFIG_H call before the AC_OUTPUT invokation. +# +# Example: +# +# AC_INIT(config.h.in) # config.h.in as created by "autoheader" +# AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE +# AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in +# AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. +# AC_MEMORY_H # makes "#undef NEED_MEMORY_H" +# AC_C_CONST_H # makes "#undef const" +# AC_OUTPUT(Makefile) # creates the "config.h" now +# # and also mylib/_config.h +# +# if the argument to AX_PREFIX_CONFIG_H would have been omitted then the +# default outputfile would have been called simply "testpkg-config.h", but +# even under the name "mylib/_config.h" it contains prefix-defines like +# +# #ifndef TESTPKG_VERSION +# #define TESTPKG_VERSION "0.1.1" +# #endif +# #ifndef TESTPKG_NEED_MEMORY_H +# #define TESTPKG_NEED_MEMORY_H 1 +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const _const +# #endif +# +# and this "mylib/_config.h" can be installed along with other +# header-files, which is most convenient when creating a shared library +# (that has some headers) where some functionality is dependent on the +# OS-features detected at compile-time. No need to invent some +# "mylib-confdefs.h.in" manually. :-) +# +# Note that some AC_DEFINEs that end up in the config.h file are actually +# self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T +# say that they "will define inline|const|off_t if the system does not do +# it by itself". You might want to clean up about these - consider an +# extra mylib/conf.h that reads something like: +# +# #include +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# and then start using _testpkg_const in the header files. That is also a +# good thing to differentiate whether some library-user has starting to +# take up with a different compiler, so perhaps it could read something +# like this: +# +# #ifdef _MSC_VER +# #include +# #else +# #include +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2008 Marten Svantesson +# Copyright (c) 2008 Gerald Point +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 10 + +AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl +AC_PREREQ([2.62]) +AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl m4_pushdef([_script],[conftest.prefix])dnl m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` _PKG=`echo ifelse($2, , $PACKAGE, $2)` _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` if test ".$_INP" = "."; then for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue case "$ac_file" in *.h) _INP=$ac_file ;; *) @@ -107,48 +149,48 @@ done fi if test ".$_INP" = "."; then case "$_OUT" in */*) _INP=`basename "$_OUT"` ;; *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` ;; *) _INP=config.h ;; esac fi if test -z "$_PKG" ; then AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) else if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then _INP="$srcdir/$_INP" fi fi AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) if test -f $_INP ; then - printf "s/@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\\1/\n" > _script - printf "s/@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\\1/\n" >> _script - printf "s/@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\\1\\\\\n" >> _script - printf "@%:@def[]ine $_UPP""_\\\1 \\\2\\\\\n" >> _script - printf "@%:@endif/\n" >>_script - printf "s/@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\\1\\\\\n" >> _script - printf "@%:@define $_LOW""_\\\1 \\\2\\\\\n" >> _script - printf "@%:@endif/\n" >> _script + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script + AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script + AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script # now executing _script on _DEF input to create _OUT output file echo "@%:@ifndef $_DEF" >$tmp/pconfig.h echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h sed -f _script $_INP >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h echo "@%:@endif" >>$tmp/pconfig.h if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then AC_MSG_NOTICE([$_OUT is unchanged]) else ac_dir=`AS_DIRNAME(["$_OUT"])` AS_MKDIR_P(["$ac_dir"]) rm -f "$_OUT" mv $tmp/pconfig.h "$_OUT" fi cp _script _configs.sed else diff -rU20 a/import/xstd/cfgaux/ax_prefix_config_h.m4 b/import/xstd/cfgaux/ax_prefix_config_h.m4 --- a/import/xstd/cfgaux/ax_prefix_config_h.m4 2010-05-25 02:05:46.000000000 +0400 +++ b/import/xstd/cfgaux/ax_prefix_config_h.m4 2010-10-12 01:56:29.000000000 +0400 @@ -1,104 +1,146 @@ -dnl @synopsis AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] -dnl -dnl This is a new variant from ac_prefix_config_ this one will use a -dnl lowercase-prefix if the config-define was starting with a -dnl lowercase-char, e.g. "#define const", "#define restrict", or -dnl "#define off_t", (and this one can live in another directory, e.g. -dnl testpkg/config.h therefore I decided to move the output-header to -dnl be the first arg) -dnl -dnl takes the usual config.h generated header file; looks for each of -dnl the generated "#define SOMEDEF" lines, and prefixes the defined name -dnl (ie. makes it "#define PREFIX_SOMEDEF". The result is written to -dnl the output config.header file. The PREFIX is converted to uppercase -dnl for the conversions. -dnl -dnl Defaults: -dnl -dnl OUTPUT-HEADER = $PACKAGE-config.h -dnl PREFIX = $PACKAGE -dnl ORIG-HEADER, from AM_CONFIG_HEADER(config.h) -dnl -dnl Your configure.ac script should contain both macros in this order, -dnl and unlike the earlier variations of this prefix-macro it is okay to -dnl place the AX_PREFIX_CONFIG_H call before the AC_OUTPUT invokation. -dnl -dnl Example: -dnl -dnl AC_INIT(config.h.in) # config.h.in as created by "autoheader" -dnl AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE -dnl AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in -dnl AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. -dnl AC_MEMORY_H # makes "#undef NEED_MEMORY_H" -dnl AC_C_CONST_H # makes "#undef const" -dnl AC_OUTPUT(Makefile) # creates the "config.h" now -dnl # and also mylib/_config.h -dnl -dnl if the argument to AX_PREFIX_CONFIG_H would have been omitted then the -dnl default outputfile would have been called simply "testpkg-config.h", but -dnl even under the name "mylib/_config.h" it contains prefix-defines like -dnl -dnl #ifndef TESTPKG_VERSION -dnl #define TESTPKG_VERSION "0.1.1" -dnl #endif -dnl #ifndef TESTPKG_NEED_MEMORY_H -dnl #define TESTPKG_NEED_MEMORY_H 1 -dnl #endif -dnl #ifndef _testpkg_const -dnl #define _testpkg_const _const -dnl #endif -dnl -dnl and this "mylib/_config.h" can be installed along with other -dnl header-files, which is most convenient when creating a shared -dnl library (that has some headers) where some functionality is -dnl dependent on the OS-features detected at compile-time. No -dnl need to invent some "mylib-confdefs.h.in" manually. :-) -dnl -dnl Note that some AC_DEFINEs that end up in the config.h file are -dnl actually self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the -dnl AC_TYPE_OFF_T say that they "will define inline|const|off_t if the -dnl system does not do it by itself". You might want to clean up about -dnl these - consider an extra mylib/conf.h that reads something like: -dnl -dnl #include -dnl #ifndef _testpkg_const -dnl #define _testpkg_const const -dnl #endif -dnl -dnl and then start using _testpkg_const in the header files. That is -dnl also a good thing to differentiate whether some library-user has -dnl starting to take up with a different compiler, so perhaps it could -dnl read something like this: -dnl -dnl #ifdef _MSC_VER -dnl #include -dnl #else -dnl #include -dnl #endif -dnl #ifndef _testpkg_const -dnl #define _testpkg_const const -dnl #endif -dnl -dnl @author Guiodo Draheim -dnl -AC_DEFUN([AX_PREFIX_CONFIG_H],[AC_REQUIRE([AC_CONFIG_HEADERS]) +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] +# +# DESCRIPTION +# +# This is a new variant from ac_prefix_config_ this one will use a +# lowercase-prefix if the config-define was starting with a +# lowercase-char, e.g. "#define const", "#define restrict", or "#define +# off_t", (and this one can live in another directory, e.g. +# testpkg/config.h therefore I decided to move the output-header to be the +# first arg) +# +# takes the usual config.h generated header file; looks for each of the +# generated "#define SOMEDEF" lines, and prefixes the defined name (ie. +# makes it "#define PREFIX_SOMEDEF". The result is written to the output +# config.header file. The PREFIX is converted to uppercase for the +# conversions. +# +# Defaults: +# +# OUTPUT-HEADER = $PACKAGE-config.h +# PREFIX = $PACKAGE +# ORIG-HEADER, from AM_CONFIG_HEADER(config.h) +# +# Your configure.ac script should contain both macros in this order, and +# unlike the earlier variations of this prefix-macro it is okay to place +# the AX_PREFIX_CONFIG_H call before the AC_OUTPUT invokation. +# +# Example: +# +# AC_INIT(config.h.in) # config.h.in as created by "autoheader" +# AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE +# AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in +# AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. +# AC_MEMORY_H # makes "#undef NEED_MEMORY_H" +# AC_C_CONST_H # makes "#undef const" +# AC_OUTPUT(Makefile) # creates the "config.h" now +# # and also mylib/_config.h +# +# if the argument to AX_PREFIX_CONFIG_H would have been omitted then the +# default outputfile would have been called simply "testpkg-config.h", but +# even under the name "mylib/_config.h" it contains prefix-defines like +# +# #ifndef TESTPKG_VERSION +# #define TESTPKG_VERSION "0.1.1" +# #endif +# #ifndef TESTPKG_NEED_MEMORY_H +# #define TESTPKG_NEED_MEMORY_H 1 +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const _const +# #endif +# +# and this "mylib/_config.h" can be installed along with other +# header-files, which is most convenient when creating a shared library +# (that has some headers) where some functionality is dependent on the +# OS-features detected at compile-time. No need to invent some +# "mylib-confdefs.h.in" manually. :-) +# +# Note that some AC_DEFINEs that end up in the config.h file are actually +# self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T +# say that they "will define inline|const|off_t if the system does not do +# it by itself". You might want to clean up about these - consider an +# extra mylib/conf.h that reads something like: +# +# #include +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# and then start using _testpkg_const in the header files. That is also a +# good thing to differentiate whether some library-user has starting to +# take up with a different compiler, so perhaps it could read something +# like this: +# +# #ifdef _MSC_VER +# #include +# #else +# #include +# #endif +# #ifndef _testpkg_const +# #define _testpkg_const const +# #endif +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2008 Marten Svantesson +# Copyright (c) 2008 Gerald Point +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 10 + +AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl +AC_PREREQ([2.62]) +AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl m4_pushdef([_script],[conftest.prefix])dnl m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)` _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` _PKG=`echo ifelse($2, , $PACKAGE, $2)` _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'` if test ".$_INP" = "."; then for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue case "$ac_file" in *.h) _INP=$ac_file ;; *) @@ -107,48 +149,48 @@ done fi if test ".$_INP" = "."; then case "$_OUT" in */*) _INP=`basename "$_OUT"` ;; *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` ;; *) _INP=config.h ;; esac fi if test -z "$_PKG" ; then AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) else if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then _INP="$srcdir/$_INP" fi fi AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) if test -f $_INP ; then - printf "s/@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\\1/\n" > _script - printf "s/@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\\1/\n" >> _script - printf "s/@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\\1\\\\\n" >> _script - printf "@%:@def[]ine $_UPP""_\\\1 \\\2\\\\\n" >> _script - printf "@%:@endif/\n" >>_script - printf "s/@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\\1\\\\\n" >> _script - printf "@%:@define $_LOW""_\\\1 \\\2\\\\\n" >> _script - printf "@%:@endif/\n" >> _script + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script + AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script + AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script + AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script + AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script + AS_ECHO(["@%:@endif/"]) >> _script # now executing _script on _DEF input to create _OUT output file echo "@%:@ifndef $_DEF" >$tmp/pconfig.h echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h sed -f _script $_INP >>$tmp/pconfig.h echo ' ' >>$tmp/pconfig.h echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h echo "@%:@endif" >>$tmp/pconfig.h if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then AC_MSG_NOTICE([$_OUT is unchanged]) else ac_dir=`AS_DIRNAME(["$_OUT"])` AS_MKDIR_P(["$ac_dir"]) rm -f "$_OUT" mv $tmp/pconfig.h "$_OUT" fi cp _script _configs.sed else diff -rU20 a/import/xstd/configure.in b/import/xstd/configure.in --- a/import/xstd/configure.in 2010-03-03 20:01:20.000000000 +0300 +++ b/import/xstd/configure.in 2010-10-12 02:08:35.000000000 +0400 @@ -77,83 +77,84 @@ AC_CHECK_LIB(dl, dlopen, [ HAVE_DLOPEN_SOMEWHERE=yes LIB_DL="-ldl" ],[ LIB_DL="" ]) ] ) if test $HAVE_DLOPEN_SOMEWHERE = yes then AC_DEFINE(HAVE_DLOPEN, 1, [Define if you have the dlopen/sum/error/close.]) fi fi dnl checks for header files AC_CHECK_HEADERS(\ arpa/inet.h \ dlfcn.h \ + endian.h \ fcntl.h \ tr1/unordered_map \ tr1/unordered_set \ ext/hash_map \ ext/hash_set \ ios \ iosfwd \ iosfwd.h \ iomanip \ iomanip.h \ iostream \ iostream.h \ math.h \ ncurses.h \ netdb.h \ netinet/in.h \ - netinet/ip_dummynet.h \ - netinet/ip_fw.h \ netinet/tcp.h \ net/if.h \ process.h \ pwd.h \ signal.h \ string \ string.h \ strings.h \ sstream \ strstrea.h \ strstream.h \ + sys/endian.h \ sys/ioctl.h \ sys/param.h \ sys/resource.h \ sys/select.h \ sys/socket.h \ sys/sockio.h \ sys/sysinfo.h \ sys/time.h \ sys/types.h \ time.h \ unistd.h \ regex.h \ winbase.h \ - winsock2.h + winsock2.h, + [], [], [AC_INCLUDES_DEFAULT] ) dnl check whether compiler is ok with passing -rdynamic to linker dnl that flag is required with GCC for linking executables that call dlopen if test "x$GXX" = "xyes" then AC_MSG_CHECKING(whether -rdynamic $CXX flag works) AC_TRY_LINK( [ ],[ return 0; ],[ AC_MSG_RESULT(probably) LDFLAG_RDYNAMIC=-rdynamic ],[ AC_MSG_RESULT(no) LDFLAG_RDYNAMIC="" ] ) diff -rU20 a/import/xstd/include/xstd/BinStream.h b/import/xstd/include/xstd/BinStream.h --- a/import/xstd/include/xstd/BinStream.h 2010-07-31 18:52:10.000000000 +0400 +++ b/import/xstd/include/xstd/BinStream.h 2010-10-12 02:06:57.000000000 +0400 @@ -1,35 +1,40 @@ /* (C) 2005 The Measurement Factory Licensed under the Apache License, Version 2.0 */ #ifndef TMF_BASE_XSTD__BINSTREAM_H #define TMF_BASE_XSTD__BINSTREAM_H -#include #include #include #include #include #include #include #include /* for ntoh and hton */ +#if XSTD_HAVE_ENDIAN_H +#include +#elif XSTD_HAVE_SYS_ENDIAN_H +#include +#endif + // a collection of streams that store binary objects, without // conversion to their textual representation common to STL iostreams; // storage format is platform-independent (network byte order) struct sockaddr_storage; class IBinStream { public: typedef streamoff off_type; typedef void (Manip)(class IBinStream &); public: IBinStream(); void open(istream *aStream); bool good() const { return theStream && theStream->good(); } char getChar() { char c; get(&c, 1); return c; } bool getb() { return getChar() != 0; } diff -rU20 a/src/Sniffer.cc b/src/Sniffer.cc --- a/src/Sniffer.cc 2010-10-01 02:10:55.000000000 +0400 +++ b/src/Sniffer.cc 2010-10-12 05:04:54.000000000 +0400 @@ -1,32 +1,34 @@ /* * Traffic Gist http://www.measurement-factory.com/ * ---------------------------------------------------------------------- * Copyright 2010 The Measurement Factory. All rights reserved. */ +#include "TrafficGist.h" + +#include // include before other network-related headers #include +#include #include #include #include -#include -#include #include #include #include #include #include #include #include #include #include "Config.h" #include "Dhcp.h" #include "Dns.h" #include "Global.h" #include "Packet.h" #include "Tcp.h" #include "Sniffer.h" static const int PcapSnaplen = 65535; static const int PcapPromisc = 1; @@ -47,81 +49,81 @@ Count Sniffer::TheUdpErrors; static void HandlePcap(unsigned char * const, const pcap_pkthdr * const hdr, const unsigned char * const data) { Should(!sigprocmask(SIG_BLOCK, &sig_set, 0)); if (!Global::startTime().known()) Global::startTime(hdr->ts); LastPacketTime = hdr->ts; ++Sniffer::ThePacketCount; Packet pkt(hdr->ts, data, hdr->caplen); HandleDatalink(pkt); Should(!sigprocmask(SIG_UNBLOCK, &sig_set, 0)); } static void HandleUdp(Packet &pkt) { const udphdr * const hdr = reinterpret_cast(pkt.data()); if (pkt.length() < sizeof(*hdr) || - pkt.length() < ntohs(hdr->len)) { + pkt.length() < ntohs(hdr->uh_ulen)) { ++Sniffer::TheUdpErrors; return; } - pkt.setSrcPort(ntohs(hdr->source)); - pkt.setDstPort(ntohs(hdr->dest)); + pkt.setSrcPort(ntohs(hdr->uh_sport)); + pkt.setDstPort(ntohs(hdr->uh_dport)); pkt.advance(sizeof(*hdr)); if (pkt.srcAddr().port() == Dns::Port || pkt.dstAddr().port() == Dns::Port) Dns::HandleUdp(pkt); else if (pkt.srcAddr().port() == Dhcp::ClientPort || pkt.dstAddr().port() == Dhcp::ClientPort || pkt.srcAddr().port() == Dhcp::ServerPort || pkt.dstAddr().port() == Dhcp::ServerPort) Dhcp::Handle(pkt); } static void HandleIpv4(Packet &pkt) { - const iphdr * const hdr = reinterpret_cast(pkt.data()); + const ip * const hdr = reinterpret_cast(pkt.data()); if (pkt.length() < sizeof(*hdr) || - hdr->version != 4 || - pkt.length() < ntohs(hdr->tot_len)) { + hdr->ip_v != 4 || + pkt.length() < ntohs(hdr->ip_len)) { ++Sniffer::TheIpv4Errors; return; } // Discard fragments. - const uint16_t frag_off = ntohs(hdr->frag_off); + const uint16_t frag_off = ntohs(hdr->ip_off); if (frag_off & IP_OFFMASK || frag_off & IP_MF) return; - pkt.setSrcAddr(*reinterpret_cast(&hdr->saddr)); - pkt.setDstAddr(*reinterpret_cast(&hdr->daddr)); - pkt.advance(hdr->ihl * 4); + pkt.setSrcAddr(*reinterpret_cast(&hdr->ip_src)); + pkt.setDstAddr(*reinterpret_cast(&hdr->ip_dst)); + pkt.advance(hdr->ip_hl * 4); - switch (hdr->protocol) { + switch (hdr->ip_p) { case IPPROTO_TCP: Tcp::Handle(pkt); break; case IPPROTO_UDP: HandleUdp(pkt); break; } } static void HandleIpv6(Packet &pkt) { const ip6_hdr * const hdr = reinterpret_cast(pkt.data()); if (pkt.length() < sizeof(*hdr) || hdr->ip6_vfc >> 4 != 6) { ++Sniffer::TheIpv6Errors; return; } pkt.advance(sizeof(*hdr)); @@ -155,42 +157,42 @@ pkt.setSrcAddr(hdr->ip6_src); pkt.setDstAddr(hdr->ip6_dst); switch (type) { case IPPROTO_TCP: Tcp::Handle(pkt); break; case IPPROTO_UDP: HandleUdp(pkt); break; } } static void HandleIp(Packet &pkt) { if (pkt.length() < 1) { // IP version is in the first byte. ++Sniffer::TheIpErrors; return; } - const iphdr * const hdr = reinterpret_cast(pkt.data()); - switch (hdr->version) { + const ip * const hdr = reinterpret_cast(pkt.data()); + switch (hdr->ip_v) { case 4: HandleIpv4(pkt); break; case 6: HandleIpv6(pkt); break; default: ++Sniffer::TheIpErrors; } } static void HandleEther(Packet &pkt) { const ether_header * hdr = reinterpret_cast(pkt.data()); if (pkt.length() < sizeof(*hdr)) { ++Sniffer::TheEtherErrors; return; } diff -rU20 a/src/Sniffer.h b/src/Sniffer.h --- a/src/Sniffer.h 2010-09-30 20:30:31.000000000 +0400 +++ b/src/Sniffer.h 2010-10-12 05:04:54.000000000 +0400 @@ -1,32 +1,36 @@ /* * Traffic Gist http://www.measurement-factory.com/ * ---------------------------------------------------------------------- * Copyright 2010 The Measurement Factory. All rights reserved. */ #ifndef TRAFFICGIST_SNIFFER_H #define TRAFFICGIST_SNIFFER_H #include "TrafficGist.h" +#if HAVE_PCAP_H +#include +#elif HAVE_PCAP_PCAP_H #include +#endif // Captures packets and handles low level protocols class Sniffer { public: Sniffer(); ~Sniffer(); void run(); void stop(); void reportAndContinue(); static void Report(); static Count ThePacketCount; static Count TheLinuxSllErrors; static Count TheLoopErrors; static Count TheEtherErrors; static Count TheIpErrors; static Count TheIpv4Errors; static Count TheIpv6Errors; diff -rU20 a/src/Tcp.cc b/src/Tcp.cc --- a/src/Tcp.cc 2010-10-01 00:18:58.000000000 +0400 +++ b/src/Tcp.cc 2010-10-12 05:04:54.000000000 +0400 @@ -113,52 +113,52 @@ Connection::PacketMap Connection::ThePacketMap; Connection::AgingList Connection::TheAgingList; static Count TheErrors; typedef hash_map UserMap; // port : user creator static UserMap TheUserMap; const Nime MaxIdle = Nime::Sec(60); void Tcp::Handle(Packet &pkt) { const tcphdr *const hdr = reinterpret_cast(pkt.data()); if (pkt.length() < sizeof(*hdr)) { ++TheErrors; return; } - const unsigned int hdr_len = hdr->doff * 4; + const unsigned int hdr_len = hdr->th_off * 4; if (pkt.length() < hdr_len) { ++TheErrors; return; } - pkt.setSrcPort(ntohs(hdr->source)); - pkt.setDstPort(ntohs(hdr->dest)); + pkt.setSrcPort(ntohs(hdr->th_sport)); + pkt.setDstPort(ntohs(hdr->th_dport)); pkt.advance(hdr_len); Connection *conn = Connection::Find(pkt); - if (!conn && hdr->syn && !hdr->ack) { + if (!conn && (hdr->th_flags & TH_SYN) && !hdr->th_ack) { const UserMap::const_iterator i = TheUserMap.find(pkt.dstAddr().port()); if (i != TheUserMap.end()) { Tcp::User *const user = i->second(); conn = new Connection(pkt, user); } } if (conn) conn->handle(*hdr, pkt); Connection::RemoveIdle(pkt.timestamp() - MaxIdle); } void Tcp::RegisterUser(const int port, const User::Creator creator) { Should(TheUserMap.insert(std::make_pair(port, creator)).second); } void Tcp::Report() { cout << "tcp.errors: " << TheErrors << '\n'; @@ -189,68 +189,68 @@ theSeq(0), theFinSeq(0) { } Stream::~Stream() { while (!theSegments.empty()) { delete theSegments.front(); theSegments.pop_front(); } } void Stream::connection(Connection *const aConn) { Should(!theConn && aConn); theConn = aConn; } void Stream::handle(const tcphdr &hdr, Packet &pkt) { if (!Should(theConn && theConn->user())) return; - uint32_t seq = ntohl(hdr.seq); + uint32_t seq = ntohl(hdr.th_seq); if (!theSeq) { - if (hdr.syn) + if (hdr.th_flags & TH_SYN) theSeq = seq + 1; else return; } - if (hdr.psh) { + if (hdr.th_flags & TH_PUSH) { if (theSeq > seq) { // (partial) retransmission const uint32_t size = theSeq - seq; pkt.advance(size); seq += size; } if (theSeq == seq) handleData(pkt); else bufferData(seq, pkt); } - if (hdr.rst) { + if (hdr.th_flags & TH_RST) { theConn->handleReset(); return; } - if (hdr.fin && !theFinSeq) - theSeq = hdr.seq; + if ((hdr.th_flags & TH_FIN) && !theFinSeq) + theSeq = hdr.th_seq; } void Stream::bufferData(uint32_t seq, const Packet &pkt) { unsigned int offset = 0; unsigned int length = pkt.length(); Segments::iterator i = theSegments.begin(); for (; i != theSegments.end(); ++i) { if (seq < (*i)->seq()) { const unsigned int maxLength = (*i)->seq() - seq; if (length > maxLength) length = maxLength; continue; } const uint32_t nextSeq = (*i)->seq() + (*i)->length(); if (seq < nextSeq) { unsigned int retransmissionLength = nextSeq - seq; if (length > retransmissionLength) { offset += retransmissionLength; length -= retransmissionLength; } else diff -rU20 a/src/TrafficGist.h b/src/TrafficGist.h --- a/src/TrafficGist.h 2010-09-30 20:30:31.000000000 +0400 +++ b/src/TrafficGist.h 2010-10-12 05:04:54.000000000 +0400 @@ -1,19 +1,24 @@ /* * Traffic Gist http://www.measurement-factory.com/ * ---------------------------------------------------------------------- * Copyright 2010 The Measurement Factory. All rights reserved. */ #ifndef TRAFFICGIST_TRAFFICGIST_H #define TRAFFICGIST_TRAFFICGIST_H #if defined(HAVE_CONFIG_H) # include "autoconf.h" # include "xstd/config.h" #endif +#if HAVE_FEATURES_H +#include +#define __FAVOR_BSD // on Linux use BSD version of UDP and TCP headers +#endif + #include typedef uint64_t Count; #endif // TRAFFICGIST_TRAFFICGIST_H