From cc1a80e41edebdf636deb1df98d3b2640407e3b3 Mon Sep 17 00:00:00 2001 From: Gianluca Varenni Date: Fri, 15 Oct 2010 01:42:59 -0700 Subject: [PATCH 01/12] Fixes to compile WinPcap under MINGW32 and MINGW64. --- Win32/Src/getaddrinfo.c | 11 ++++++++++- gencode.c | 2 +- inet.c | 6 ++++-- pcap-win32.c | 7 ++++++- pcap.c | 2 +- scanner.l | 2 +- 6 files changed, 23 insertions(+), 7 deletions(-) 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/gencode.c b/gencode.c index f66492e..b94ea72 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 178eb81..5bdae11 100644 --- a/inet.c +++ b/inet.c @@ -878,8 +878,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-win32.c b/pcap-win32.c index 0e2201e..0e11ed5 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -39,7 +39,12 @@ static const char rcsid[] _U_ = #include #include #ifdef __MINGW32__ -#include +#ifdef __MINGW64__ +#include +#else /*__MINGW64__*/ +#include +#include +#endif /*__MINGW64__*/ #else /*__MINGW32__*/ #include #endif /*__MINGW32__*/ diff --git a/pcap.c b/pcap.c index 4b64a38..91a62e4 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/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" */ From 38ef87dd396d9f2a13f640828815e3067a360c0d Mon Sep 17 00:00:00 2001 From: Gianluca Varenni Date: Fri, 15 Oct 2010 16:44:32 -0700 Subject: [PATCH 02/12] Another fix for the compilation of WinPcap under MINGW32/MINGW64. --- pcap-win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcap-win32.c b/pcap-win32.c index 0e11ed5..fc6eed1 100644 --- a/pcap-win32.c +++ b/pcap-win32.c @@ -43,7 +43,7 @@ static const char rcsid[] _U_ = #include #else /*__MINGW64__*/ #include -#include +#include #endif /*__MINGW64__*/ #else /*__MINGW32__*/ #include From ade794238b623a81e2585d1c2073a3bececa10ae Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 13 Nov 2010 17:42:47 -0800 Subject: [PATCH 03/12] Add support for libnl 2.x, adapted from a newer version of the iw command. --- config.h.in | 3 ++ configure | 108 ++++++++++++++++++++++++++++++++++++++++++++++++--- configure.in | 40 +++++++++++++++---- pcap-linux.c | 58 ++++++++++++++++++++------- 4 files changed, 184 insertions(+), 25 deletions(-) diff --git a/config.h.in b/config.h.in index f988e8f..3b9ce3c 100644 --- a/config.h.in +++ b/config.h.in @@ -52,6 +52,9 @@ /* 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 diff --git a/configure b/configure index e85d87e..c204a87 100755 --- a/configure +++ b/configure @@ -7341,7 +7341,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 @@ -7403,18 +7489,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 diff --git a/configure.in b/configure.in index d71d3fd..3c1cedf 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 diff --git a/pcap-linux.c b/pcap-linux.c index f8b3f10..deabbc4 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -527,8 +527,37 @@ get_mac80211_phydev(pcap_t *handle, const char *device, char *phydev_path, return 1; } +#ifndef HAVE_LIBNL_2_x +/* 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); +} + +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; }; @@ -536,23 +565,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, strerror(-err)); goto out_handle_destroy; } @@ -568,7 +600,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; } @@ -577,7 +609,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 @@ -605,7 +637,7 @@ 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) { if (err == -ENFILE) { /* @@ -626,7 +658,7 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, 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) { /* @@ -685,7 +717,7 @@ 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) { /* @@ -706,7 +738,7 @@ del_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, 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) { /* From 77ed5cdd1f218377524830b0cee868bdbdb7aae2 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 14 Nov 2010 13:48:19 -0800 Subject: [PATCH 04/12] Libnl 2.x returns its own error codes, not errnos; handle that. While we're at it, don't special-case ENFILE for "delete monitor device" operations; that's not like "add monitor device", where we want to drive on if a device with that name already exists. --- pcap-linux.c | 76 +++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/pcap-linux.c b/pcap-linux.c index deabbc4..5d291e9 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -527,7 +527,9 @@ get_mac80211_phydev(pcap_t *handle, const char *device, char *phydev_path, return 1; } -#ifndef HAVE_LIBNL_2_x +#ifdef HAVE_LIBNL_2_x +#define get_nl_errmsg nl_geterror +#else /* libnl 2.x compatibility code */ #define nl_sock nl_handle @@ -544,6 +546,8 @@ 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) { @@ -584,7 +588,7 @@ nl80211_init(pcap_t *handle, struct nl80211_state *state, const char *device) if (err < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "%s: failed to allocate generic netlink cache: %s", - device, strerror(-err)); + device, get_nl_errmsg(-err)); goto out_handle_destroy; } @@ -639,10 +643,17 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, 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; @@ -653,17 +664,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_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; @@ -674,7 +692,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; } @@ -719,45 +737,19 @@ del_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state, 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_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; } /* From cbf0ba1e349271898225e77628c16cb04457c1b9 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 15 Nov 2010 08:57:38 -0800 Subject: [PATCH 05/12] Add DLT_DBUS, for raw D-Bus messages. --- pcap-common.c | 21 +++++++++++++++++++++ pcap/bpf.h | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) 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/bpf.h b/pcap/bpf.h index 6048fff..9b662b9 100644 --- a/pcap/bpf.h +++ b/pcap/bpf.h @@ -969,6 +969,24 @@ 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 + /* * DLT and savefile link type values are split into a class and * a member of that class. A class value of 0 indicates a regular From 0920898be2ede72baafa2a02e77ea223ecbe4f9a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 25 Nov 2010 13:49:16 -0800 Subject: [PATCH 06/12] Include before including . Some versions of the Linux kernel require that. --- pcap-usb-linux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index daaa900..61695b6 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -61,6 +61,11 @@ static const char rcsid[] _U_ = #include #include #ifdef HAVE_LINUX_USBDEVICE_FS_H +/* + * We assume that any Linux that supports USB sniffing has ; + * we might need it for to define __user. + */ +#include #include #endif From b019cc06cb4fdc01f99a36581fe7b55e2533d663 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 25 Nov 2010 14:06:01 -0800 Subject: [PATCH 07/12] Check whether we have . Not all distributions have it in /usr/include; I guess the ones that don't have it have versions of other kernel headers that don't require it. --- config.h.in | 3 + configure | 208 +++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 14 +++- pcap-usb-linux.c | 8 +- 4 files changed, 229 insertions(+), 4 deletions(-) diff --git a/config.h.in b/config.h.in index 3b9ce3c..39d46b4 100644 --- a/config.h.in +++ b/config.h.in @@ -58,6 +58,9 @@ /* 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 c204a87..31aeac1 100755 --- a/configure +++ b/configure @@ -10421,6 +10421,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 @@ -10561,6 +10768,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 diff --git a/configure.in b/configure.in index 3c1cedf..fe36ee7 100644 --- a/configure.in +++ b/configure.in @@ -1391,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 diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index 61695b6..f1b430c 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -62,12 +62,14 @@ static const char rcsid[] _U_ = #include #ifdef HAVE_LINUX_USBDEVICE_FS_H /* - * We assume that any Linux that supports USB sniffing has ; - * we might need it for to define __user. + * 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" From a092bafeee07c97352d2c6d06780220286ab2db0 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 30 Nov 2010 15:52:45 -0800 Subject: [PATCH 08/12] In test programs, just as in pcap-usb-linux.c, if we have we (probably need to include it before including , otherwise the test may fail when it shouldn't. --- configure | 3 +++ configure.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/configure b/configure index 31aeac1..36e416e 100755 --- a/configure +++ b/configure @@ -10792,6 +10792,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 fe36ee7..01c65c7 100644 --- a/configure.in +++ b/configure.in @@ -1418,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, From 16f6b49c87c030be6c4ffc5890a93309f810c849 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 30 Nov 2010 16:06:14 -0800 Subject: [PATCH 09/12] Use config.status to generate pcap-config. Rather than use a custom sed script to replace things in pcap-config, use the already existing config.status script. This keeps people from having to update the Makefile.in every time they want to add a new var to the file. Also, clean up the pcap-config.in script a bit to set local vars at the top of the file and then refer to those rather than replacing all things through out. This makes it easier to tweak on the fly as there is only line to change rather than trying and figure out all the locations. Reviewed-By: Guy Harris --- Makefile.in | 6 +----- pcap-config.in | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index ae2e4a3..e9863dd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -490,11 +490,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/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 From 6feaf847e5dc527c6fbdef0a53931e0cc7e7534f Mon Sep 17 00:00:00 2001 From: Luis MartinGarcia Date: Tue, 30 Nov 2010 16:37:51 -0800 Subject: [PATCH 10/12] Use spaces for all entries. Fix Luis MartinGarcia's name. Reviewed-By: Guy Harris --- CREDITS | 276 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/CREDITS b/CREDITS index 035884d..2f49daf 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 From d58b82da9f8606b8222ae4a5996b9bc14f7272bd Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 30 Nov 2010 16:42:35 -0800 Subject: [PATCH 11/12] Fix alignment of Love's name. --- CREDITS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CREDITS b/CREDITS index 2f49daf..c086450 100644 --- a/CREDITS +++ b/CREDITS @@ -75,7 +75,7 @@ Additional people who have contributed patches: Krzysztof Halasa Lorenzo Cavallaro Loris Degioanni - Love Hörnquist-Åstrand + Love Hörnquist-Åstrand Luis MartinGarcia Maciej W. Rozycki Marcus Felipe Pereira From 028204e0f99f0bad5dfd01add364ebd4f4befabb Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 28 Dec 2010 13:15:26 -0800 Subject: [PATCH 12/12] Interface IDs are 0-origin. That means that if an interface ID is greater than *or equal to* the number of Interface Description Blocks we've seen, we haven't seen an IDB for that interface. --- sf-pcap-ng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. */