diff --git a/CREDITS b/CREDITS index 035884d..c086450 100644 --- a/CREDITS +++ b/CREDITS @@ -1,148 +1,148 @@ This file lists people who have contributed to libpcap: The current maintainers: - Bill Fenner - Fulvio Risso - Guy Harris - Hannes Gredler - Michael Richardson + Bill Fenner + Fulvio Risso + Guy Harris + Hannes Gredler + Michael Richardson Additional people who have contributed patches: - Alan Bawden - Albert Chin - Alexander 'Leo' Bergolth - Alexey Kuznetsov - Alon Bar-Lev - Andrew Brown - - Antti Kantee - Arien Vijn - Arkadiusz Miskiewicz - Armando L. Caro Jr. - Assar Westerlund - Brian Ginsbach - Charles M. Hannum - Chris G. Demetriou - Chris Lightfoot - Chris Maynard - Chris Pepper - Christian Bell - Christian Peron - Daniele Orlandi - Darren Reed - David Kaelbling - David Young - Dean Gaudet - Don Ebright - Dug Song - Dustin Spicuzza - Eric Anderson - Erik de Castro Lopo - Felix Obenhuber - Florent Drouin - Franz Schaefer - Fulko Hew - Fumiyuki Shimizu - Gianluca Varenni - Gilbert Hoyek - Gisle Vanem - Graeme Hewson - Greg Stark - Greg Troxel - Gregor Maier - Guillaume Pelat - Hagen Paul Pfeifer - Hyung Sik Yoon - Igor Khristophorov - Jan-Philip Velders - Jason R. Thorpe - Javier Achirica - Jean Tourrilhes - Jean-Louis Charton - Jefferson Ogata - Jesper Peterson - Joerg Mayer - John Bankier - Jon Lindgren - Jon Smirl - Juergen Schoenwaelder - Jung-uk Kim - Kazushi Sugyo - Klaus Klein - Koryn Grant - Kris Katterjohn - Krzysztof Halasa - Lorenzo Cavallaro - Loris Degioanni - Love Hörnquist-Åstrand - Luis Martin Garcia - Maciej W. Rozycki - Marcus Felipe Pereira - Mark C. Brown - Mark Pizzolato - Markus Mayer - Martin Husemann - Márton Németh - Matthew Luckie - Max Laier - Mike Frysinger - Mike Kershaw - Mike Wiacek - Monroe Williams - - N. Leiten - Nicolas Dade - Octavian Cerna - Olaf Kirch - Ollie Wild - Onno van der Linden - Paolo Abeni - Patrick Marie - Patrick McHardy - Paul Mundt - Pavel Kankovsky - Pawel Pokrywka - Peter Fales - Peter Jeremy - Peter Volkov - Phil Wood - Rafal Maszkowski - - Richard Stearn - Rick Jones - Robert Edmonds - Roberto Mariani - Romain Francoise - Sagun Shakya - Scott Barron - Scott Gifford - Scott Mcmillan - Sebastian Krahmer - Sebastien Roy - Sepherosa Ziehau - Shaun Clowes - Solomon Peachy - Stefan Hudson - Stephen Donnelly - Takashi Yamamoto - Tanaka Shin-ya - Tobias Poschwatta - Tony Li - Torsten Landschoff - Uns Lider - Uwe Girlich - Wesley Shields - Xianjie Zhang - Xin Li - Yen Yen Lim - Yvan Vanhullebus - Yoann Vandoorselaere + Alan Bawden + Albert Chin + Alexander 'Leo' Bergolth + Alexey Kuznetsov + Alon Bar-Lev + Andrew Brown + + Antti Kantee + Arien Vijn + Arkadiusz Miskiewicz + Armando L. Caro Jr. + Assar Westerlund + Brian Ginsbach + Charles M. Hannum + Chris G. Demetriou + Chris Lightfoot + Chris Maynard + Chris Pepper + Christian Bell + Christian Peron + Daniele Orlandi + Darren Reed + David Kaelbling + David Young + Dean Gaudet + Don Ebright + Dug Song + Dustin Spicuzza + Eric Anderson + Erik de Castro Lopo + Felix Obenhuber + Florent Drouin + Franz Schaefer + Fulko Hew + Fumiyuki Shimizu + Gianluca Varenni + Gilbert Hoyek + Gisle Vanem + Graeme Hewson + Greg Stark + Greg Troxel + Gregor Maier + Guillaume Pelat + Hagen Paul Pfeifer + Hyung Sik Yoon + Igor Khristophorov + Jan-Philip Velders + Jason R. Thorpe + Javier Achirica + Jean Tourrilhes + Jean-Louis Charton + Jefferson Ogata + Jesper Peterson + Joerg Mayer + John Bankier + Jon Lindgren + Jon Smirl + Juergen Schoenwaelder + Jung-uk Kim + Kazushi Sugyo + Klaus Klein + Koryn Grant + Kris Katterjohn + Krzysztof Halasa + Lorenzo Cavallaro + Loris Degioanni + Love Hörnquist-Åstrand + Luis MartinGarcia + Maciej W. Rozycki + Marcus Felipe Pereira + Mark C. Brown + Mark Pizzolato + Markus Mayer + Martin Husemann + Márton Németh + Matthew Luckie + Max Laier + Mike Frysinger + Mike Kershaw + Mike Wiacek + Monroe Williams + + N. Leiten + Nicolas Dade + Octavian Cerna + Olaf Kirch + Ollie Wild + Onno van der Linden + Paolo Abeni + Patrick Marie + Patrick McHardy + Paul Mundt + Pavel Kankovsky + Pawel Pokrywka + Peter Fales + Peter Jeremy + Peter Volkov + Phil Wood + Rafal Maszkowski + + Richard Stearn + Rick Jones + Robert Edmonds + Roberto Mariani + Romain Francoise + Sagun Shakya + Scott Barron + Scott Gifford + Scott Mcmillan + Sebastian Krahmer + Sebastien Roy + Sepherosa Ziehau + Shaun Clowes + Solomon Peachy + Stefan Hudson + Stephen Donnelly + Takashi Yamamoto + Tanaka Shin-ya + Tobias Poschwatta + Tony Li + Torsten Landschoff + Uns Lider + Uwe Girlich + Wesley Shields + Xianjie Zhang + Xin Li + Yen Yen Lim + Yvan Vanhullebus + Yoann Vandoorselaere The original LBL crew: - Steve McCanne - Craig Leres - Van Jacobson + Steve McCanne + Craig Leres + Van Jacobson Past maintainers: - Jun-ichiro itojun Hagino + Jun-ichiro itojun Hagino diff --git a/Makefile.in b/Makefile.in index 5fcfb78..05edb96 100644 --- a/Makefile.in +++ b/Makefile.in @@ -492,11 +492,7 @@ bpf_filter.o: bpf_filter.c # pcap-config: $(srcdir)/pcap-config.in @rm -f $@ $@.tmp - sed -e 's|@includedir[@]|$(includedir)|g' \ - -e 's|@libdir[@]|$(libdir)|g' \ - -e 's|@LIBS[@]|$(LIBS)|g' \ - -e 's|@V_RPATH_OPT[@]|$(V_RPATH_OPT)|g' \ - $(srcdir)/pcap-config.in >$@.tmp + ./config.status --file=$@.tmp:$< mv $@.tmp $@ chmod a+x $@ diff --git a/Win32/Src/getaddrinfo.c b/Win32/Src/getaddrinfo.c index 8e8ad85..ebfe8c2 100644 --- a/Win32/Src/getaddrinfo.c +++ b/Win32/Src/getaddrinfo.c @@ -45,6 +45,12 @@ * in ai_flags? */ +/* + * Mingw64 has its own implementation of getaddrinfo, mingw32 no + */ +#ifndef __MINGW64__ + + #ifdef HAVE_CONFIG_H #include #endif @@ -85,7 +91,7 @@ static const char rcsid[] _U_ = #ifdef NEED_ADDRINFO_H #include "addrinfo.h" #ifdef WIN32 -#include "IP6_misc.h" +#include "ip6_misc.h" #endif #endif @@ -1118,3 +1124,6 @@ find_afd(af) } return NULL; } + + +#endif /*__MING64__*/ diff --git a/config.h.in b/config.h.in index 688f596..6ea10ad 100644 --- a/config.h.in +++ b/config.h.in @@ -52,9 +52,15 @@ /* if libnl exists */ #undef HAVE_LIBNL +/* if libnl exists and is version 2.x */ +#undef HAVE_LIBNL_2_x + /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_COMPILER_H + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_NET_TSTAMP_H diff --git a/configure b/configure index bd78b34..675d2c7 100755 --- a/configure +++ b/configure @@ -7347,7 +7347,93 @@ fi if test x$with_libnl != xno ; then - { echo "$as_me:$LINENO: checking for nl_handle_alloc in -lnl" >&5 + # + # Try libnl 2.x first. + # + { echo "$as_me:$LINENO: checking for nl_socket_alloc in -lnl" >&5 +echo $ECHO_N "checking for nl_socket_alloc in -lnl... $ECHO_C" >&6; } +if test "${ac_cv_lib_nl_nl_socket_alloc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char nl_socket_alloc (); +int +main () +{ +return nl_socket_alloc (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_nl_nl_socket_alloc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_nl_nl_socket_alloc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_nl_nl_socket_alloc" >&5 +echo "${ECHO_T}$ac_cv_lib_nl_nl_socket_alloc" >&6; } +if test $ac_cv_lib_nl_nl_socket_alloc = yes; then + + # + # Yes, we have libnl 2.x. + # + LIBS="-lnl-genl -lnl $LIBS" + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBNL 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBNL_2_x 1 +_ACEOF + + +else + + # + # No, we don't; do we have libnl 1.x? + # + { echo "$as_me:$LINENO: checking for nl_handle_alloc in -lnl" >&5 echo $ECHO_N "checking for nl_handle_alloc in -lnl... $ECHO_C" >&6; } if test "${ac_cv_lib_nl_nl_handle_alloc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7409,18 +7495,30 @@ fi { echo "$as_me:$LINENO: result: $ac_cv_lib_nl_nl_handle_alloc" >&5 echo "${ECHO_T}$ac_cv_lib_nl_nl_handle_alloc" >&6; } if test $ac_cv_lib_nl_nl_handle_alloc = yes; then - LIBS="-lnl $LIBS" + + # + # Yes. + # + LIBS="-lnl $LIBS" cat >>confdefs.h <<\_ACEOF #define HAVE_LIBNL 1 _ACEOF + else - if test x$with_libnl = xyes ; then - { { echo "$as_me:$LINENO: error: libnl support requested but libnl not found" >&5 + + # + # No, we don't have libnl at all. + # + if test x$with_libnl = xyes ; then + { { echo "$as_me:$LINENO: error: libnl support requested but libnl not found" >&5 echo "$as_me: error: libnl support requested but libnl not found" >&2;} { (exit 1); exit 1; }; } - fi + fi + +fi + fi @@ -10329,6 +10427,213 @@ _ACEOF { echo "$as_me:$LINENO: Device for USB sniffing is /dev/$ac_usb_dev_name" >&5 echo "$as_me: Device for USB sniffing is /dev/$ac_usb_dev_name" >&6;} + # + # Do we have a version of available? + # If so, we might need it for . + # + +for ac_header in linux/compiler.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + if test "$ac_cv_header_linux_compiler_h" = yes; then + # + # Yes - include it when testing for . + # + +for ac_header in linux/usbdevice_fs.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + else for ac_header in linux/usbdevice_fs.h do @@ -10469,6 +10774,7 @@ fi done + fi if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then # # OK, does it define bRequestType? Older versions of the kernel @@ -10492,6 +10798,9 @@ $ac_includes_default #ifdef HAVE_SYS_BITYPES_H #include #endif +#ifdef HAVE_LINUX_COMPILER_H +#include +#endif # include int main () diff --git a/configure.in b/configure.in index 16e0299..cd8ed95 100644 --- a/configure.in +++ b/configure.in @@ -445,13 +445,39 @@ linux) with_libnl=$withval,,) if test x$with_libnl != xno ; then - AC_CHECK_LIB(nl, nl_handle_alloc, - LIBS="-lnl $LIBS" - AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]), - if test x$with_libnl = xyes ; then - AC_MSG_ERROR([libnl support requested but libnl not found]) - fi - ) + # + # Try libnl 2.x first. + # + AC_CHECK_LIB(nl, nl_socket_alloc, + [ + # + # Yes, we have libnl 2.x. + # + LIBS="-lnl-genl -lnl $LIBS" + AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) + AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x]) + ], + [ + # + # No, we don't; do we have libnl 1.x? + # + AC_CHECK_LIB(nl, nl_handle_alloc, + [ + # + # Yes. + # + LIBS="-lnl $LIBS" + AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]) + ], + [ + # + # No, we don't have libnl at all. + # + if test x$with_libnl = xyes ; then + AC_MSG_ERROR([libnl support requested but libnl not found]) + fi + ]) + ]) fi AC_LBL_TPACKET_STATS @@ -1365,7 +1391,19 @@ linux*) fi AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing]) AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name) - AC_CHECK_HEADERS(linux/usbdevice_fs.h) + # + # Do we have a version of available? + # If so, we might need it for . + # + AC_CHECK_HEADERS(linux/compiler.h) + if test "$ac_cv_header_linux_compiler_h" = yes; then + # + # Yes - include it when testing for . + # + AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include ]) + else + AC_CHECK_HEADERS(linux/usbdevice_fs.h) + fi if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then # # OK, does it define bRequestType? Older versions of the kernel @@ -1380,6 +1418,9 @@ AC_INCLUDES_DEFAULT #ifdef HAVE_SYS_BITYPES_H #include #endif +#ifdef HAVE_LINUX_COMPILER_H +#include +#endif # include ], [u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)], ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes, diff --git a/gencode.c b/gencode.c index 5b113cf..a105138 100644 --- a/gencode.c +++ b/gencode.c @@ -47,7 +47,7 @@ static const char rcsid[] _U_ = * XXX - why was this included even on UNIX? */ #ifdef __MINGW32__ -#include "IP6_misc.h" +#include "ip6_misc.h" #endif #ifndef WIN32 diff --git a/inet.c b/inet.c index 642ffb0..3c09316 100644 --- a/inet.c +++ b/inet.c @@ -881,8 +881,10 @@ pcap_lookupdev(errbuf) */ while(NAdapts--) { - strcpy((char*)tUstr, tAstr); - (char*)tUstr += strlen(tAstr) + 1;; + char* tmp = (char*)tUstr; + strcpy(tmp, tAstr); + tmp += strlen(tAstr) + 1; + tUstr = (WCHAR*)tmp; tAstr += strlen(tAstr) + 1; } diff --git a/pcap-common.c b/pcap-common.c index 5f6a929..3989dfc 100644 --- a/pcap-common.c +++ b/pcap-common.c @@ -735,6 +735,24 @@ static const char rcsid[] _U_ = */ #define LINKTYPE_IEEE802_15_4_NOFCS 230 +/* + * Raw D-Bus: + * + * http://www.freedesktop.org/wiki/Software/dbus + * + * messages: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages + * + * starting with the endianness flag, followed by the message type, etc., + * but without the authentication handshake before the message sequence: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * + * Requested by Martin Vidner . + */ +#define LINKTYPE_DBUS 231 + static struct linktype_map { int dlt; @@ -1084,6 +1102,9 @@ static struct linktype_map { /* IEEE 802.15.4 exactly as it appears in the spec, without FCS */ { DLT_IEEE802_15_4_NOFCS, LINKTYPE_IEEE802_15_4_NOFCS }, + /* D-Bus messages */ + { DLT_DBUS, LINKTYPE_DBUS }, + { -1, -1 } }; diff --git a/pcap-config.in b/pcap-config.in index 37526d7..206be3b 100644 --- a/pcap-config.in +++ b/pcap-config.in @@ -4,6 +4,13 @@ # Script to give the appropriate compiler flags and linker flags # to use when building code that uses libpcap. # +prefix="@prefix@" +exec_prefix="@exec_prefix@" +includedir="@includedir@" +libdir="@libdir@" +V_RPATH_OPT="@V_RPATH_OPT@" +LIBS="@LIBS@" + static=0 show_cflags=0 show_libs=0 @@ -29,14 +36,14 @@ do esac shift done -if [ "@V_RPATH_OPT@" != "" ] +if [ "$V_RPATH_OPT" != "" ] then # # If libdir isn't /usr/lib, add it to the run-time linker path. # - if [ "@libdir@" != "/usr/lib" ] + if [ "$libdir" != "/usr/lib" ] then - RPATH=@V_RPATH_OPT@@libdir@ + RPATH=$V_RPATH_OPT$libdir fi fi if [ "$static" = 1 ] @@ -47,19 +54,19 @@ then # if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] then - echo "-I@includedir@ -L@libdir@ -lpcap @LIBS@" + echo "-I$includedir -L$libdir -lpcap $LIBS" elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] then - echo "-I@includedir@ -L@libdir@ @LIBS@" + echo "-I$includedir -L$libdir $LIBS" elif [ "$show_cflags" = 1 ] then - echo "-I@includedir@" + echo "-I$includedir" elif [ "$show_libs" = 1 ] then - echo "-L@libdir@ -lpcap @LIBS@" + echo "-L$libdir -lpcap $LIBS" elif [ "$show_additional_libs" = 1 ] then - echo "@LIBS@" + echo "$LIBS" fi else # @@ -68,15 +75,15 @@ else # if [ "$show_cflags" = 1 -a "$show_libs" = 1 ] then - echo "-I@includedir@ -L@libdir@ $RPATH -lpcap" + echo "-I$includedir -L$libdir $RPATH -lpcap" elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ] then - echo "-I@includedir@" + echo "-I$includedir" elif [ "$show_cflags" = 1 ] then - echo "-I@includedir@" + echo "-I$includedir" elif [ "$show_libs" = 1 ] then - echo "-L@libdir@ $RPATH -lpcap" + echo "-L$libdir $RPATH -lpcap" fi fi diff --git a/pcap-linux.c b/pcap-linux.c index 9cdc0bf..8b4409e 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -537,8 +537,41 @@ get_mac80211_phydev(pcap_t *handle, const char *device, char *phydev_path, return 1; } +#ifdef HAVE_LIBNL_2_x +#define get_nl_errmsg nl_geterror +#else +/* libnl 2.x compatibility code */ + +#define nl_sock nl_handle + +static inline struct nl_handle * +nl_socket_alloc(void) +{ + return nl_handle_alloc(); +} + +static inline void +nl_socket_free(struct nl_handle *h) +{ + nl_handle_destroy(h); +} + +#define get_nl_errmsg strerror + +static inline int +__genl_ctrl_alloc_cache(struct nl_handle *h, struct nl_cache **cache) +{ + struct nl_cache *tmp = genl_ctrl_alloc_cache(h); + if (!tmp) + return -ENOMEM; + *cache = tmp; + return 0; +} +#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache +#endif /* !HAVE_LIBNL_2_x */ + struct nl80211_state { - struct nl_handle *nl_handle; + struct nl_sock *nl_sock; struct nl_cache *nl_cache; struct genl_family *nl80211; }; @@ -546,23 +579,26 @@ struct nl80211_state { static int nl80211_init(pcap_t *handle, struct nl80211_state *state, const char *device) { - state->nl_handle = nl_handle_alloc(); - if (!state->nl_handle) { + int err; + + state->nl_sock = nl_socket_alloc(); + if (!state->nl_sock) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: failed to allocate netlink handle", device); return PCAP_ERROR; } - if (genl_connect(state->nl_handle)) { + if (genl_connect(state->nl_sock)) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: failed to connect to generic netlink", device); goto out_handle_destroy; } - state->nl_cache = genl_ctrl_alloc_cache(state->nl_handle); - if (!state->nl_cache) { + err = genl_ctrl_alloc_cache(state->nl_sock, &state->nl_cache); + if (err < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "%s: failed to allocate generic netlink cache", device); + "%s: failed to allocate generic netlink cache: %s", + device, get_nl_errmsg(-err)); goto out_handle_destroy; } @@ -578,7 +614,7 @@ nl80211_init(pcap_t *handle, struct nl80211_state *state, const char *device) out_cache_free: nl_cache_free(state->nl_cache); out_handle_destroy: - nl_handle_destroy(state->nl_handle); + nl_socket_free(state->nl_sock); return PCAP_ERROR; } @@ -587,7 +623,7 @@ nl80211_cleanup(struct nl80211_state *state) { genl_family_put(state->nl80211); nl_cache_free(state->nl_cache); - nl_handle_destroy(state->nl_handle); + nl_socket_free(state->nl_sock); } static int @@ -615,12 +651,19 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, mondevice); NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, NL80211_IFTYPE_MONITOR); - err = nl_send_auto_complete(state->nl_handle, msg); + err = nl_send_auto_complete(state->nl_sock, msg); if (err < 0) { +#ifdef HAVE_LIBNL_2_x + if (err == -NLE_FAILURE) { +#else if (err == -ENFILE) { +#endif /* * Device not available; our caller should just - * keep trying. + * keep trying. (libnl 2.x maps ENFILE to + * NLE_FAILURE; it can also map other errors + * to that, but there's not much we can do + * about that.) */ nlmsg_free(msg); return 0; @@ -631,17 +674,24 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, */ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: nl_send_auto_complete failed adding %s interface: %s", - device, mondevice, strerror(-err)); + device, mondevice, get_nl_errmsg(-err)); nlmsg_free(msg); return PCAP_ERROR; } } - err = nl_wait_for_ack(state->nl_handle); + err = nl_wait_for_ack(state->nl_sock); if (err < 0) { +#ifdef HAVE_LIBNL_2_x + if (err == -NLE_FAILURE) { +#else if (err == -ENFILE) { +#endif /* * Device not available; our caller should just - * keep trying. + * keep trying. (libnl 2.x maps ENFILE to + * NLE_FAILURE; it can also map other errors + * to that, but there's not much we can do + * about that.) */ nlmsg_free(msg); return 0; @@ -652,7 +702,7 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, */ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: nl_wait_for_ack failed adding %s interface: %s", - device, mondevice, strerror(-err)); + device, mondevice, get_nl_errmsg(-err)); nlmsg_free(msg); return PCAP_ERROR; } @@ -695,47 +745,21 @@ del_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, 0, NL80211_CMD_DEL_INTERFACE, 0); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex); - err = nl_send_auto_complete(state->nl_handle, msg); + err = nl_send_auto_complete(state->nl_sock, msg); if (err < 0) { - if (err == -ENFILE) { - /* - * Device not available; our caller should just - * keep trying. - */ - nlmsg_free(msg); - return 0; - } else { - /* - * Real failure, not just "that device is not - * available. - */ - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "%s: nl_send_auto_complete failed deleting %s interface: %s", - device, mondevice, strerror(-err)); - nlmsg_free(msg); - return PCAP_ERROR; - } + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_send_auto_complete failed deleting %s interface: %s", + device, mondevice, get_nl_errmsg(-err)); + nlmsg_free(msg); + return PCAP_ERROR; } - err = nl_wait_for_ack(state->nl_handle); + err = nl_wait_for_ack(state->nl_sock); if (err < 0) { - if (err == -ENFILE) { - /* - * Device not available; our caller should just - * keep trying. - */ - nlmsg_free(msg); - return 0; - } else { - /* - * Real failure, not just "that device is not - * available. - */ - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "%s: nl_wait_for_ack failed adding %s interface: %s", - device, mondevice, strerror(-err)); - nlmsg_free(msg); - return PCAP_ERROR; - } + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "%s: nl_wait_for_ack failed adding %s interface: %s", + device, mondevice, get_nl_errmsg(-err)); + nlmsg_free(msg); + return PCAP_ERROR; } /* diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index daaa900..f1b430c 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -61,8 +61,15 @@ static const char rcsid[] _U_ = #include #include #ifdef HAVE_LINUX_USBDEVICE_FS_H +/* + * We might need to define __user for + * . + */ +#ifdef HAVE_LINUX_COMPILER_H +#include +#endif /* HAVE_LINUX_COMPILER_H */ #include -#endif +#endif /* HAVE_LINUX_USBDEVICE_FS_H */ #define USB_IFACE "usbmon" #define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon" diff --git a/pcap-win32.c b/pcap-win32.c index 0e2201e..fc6eed1 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -39,7 +39,12 @@ static const char rcsid[] _U_ = #include #include #ifdef __MINGW32__ +#ifdef __MINGW64__ +#include +#else /*__MINGW64__*/ +#include #include +#endif /*__MINGW64__*/ #else /*__MINGW32__*/ #include #endif /*__MINGW32__*/ diff --git a/pcap.c b/pcap.c index 3db3320..411ce0a 100644 --- a/pcap.c +++ b/pcap.c @@ -57,7 +57,7 @@ static const char rcsid[] _U_ = #include #include #include -#if !defined(_MSC_VER) && !defined(__BORLANDC__) +#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__MINGW32__) #include #endif #include diff --git a/pcap/bpf.h b/pcap/bpf.h index 938a62a..18464b9 100644 --- a/pcap/bpf.h +++ b/pcap/bpf.h @@ -969,10 +969,28 @@ struct bpf_version { */ #define DLT_IEEE802_15_4_NOFCS 230 +/* + * Raw D-Bus: + * + * http://www.freedesktop.org/wiki/Software/dbus + * + * messages: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages + * + * starting with the endianness flag, followed by the message type, etc., + * but without the authentication handshake before the message sequence: + * + * http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * + * Requested by Martin Vidner . + */ +#define DLT_DBUS 231 + /* * DECT */ -#define DLT_DECT_LINUX 231 +#define DLT_DECT_LINUX 232 /* * DLT and savefile link type values are split into a class and diff --git a/scanner.l b/scanner.l index a061a7e..c8e2d20 100644 --- a/scanner.l +++ b/scanner.l @@ -54,7 +54,7 @@ static const char rcsid[] _U_ = #include #ifdef __MINGW32__ -#include "IP6_misc.h" +#include "ip6_misc.h" #endif #else /* WIN32 */ #include /* for "struct sockaddr" in "struct addrinfo" */ diff --git a/sf-pcap-ng.c b/sf-pcap-ng.c index 9049991..1554320 100644 --- a/sf-pcap-ng.c +++ b/sf-pcap-ng.c @@ -1053,7 +1053,7 @@ found: /* * Is the interface ID an interface we know? */ - if (interface_id > p->sf.ifcount) { + if (interface_id >= p->sf.ifcount) { /* * Yes. Fail. */