libpcap compatibility problem (Re: new bro "CURRENT" release - 0.8a57)
José María González
chema at cs.berkeley.edu
Tue Dec 16 15:23:45 PST 2003
Yups, incomplete patch.
This is the complete one.
-Chema
José María González wrote:
>
> Hi,
>
> This patch should recognize how many parameters
> pcap_compile_nopcap needs.
>
> Can somebody with a NetBSD box try it?
>
> -Chema
-------------- next part --------------
diff -Naur ./bro-pub-0.8a58.orig/PktSrc.cc bro-pub-0.8a58/PktSrc.cc
--- ./bro-pub-0.8a58.orig/PktSrc.cc Tue Dec 16 08:55:36 2003
+++ bro-pub-0.8a58/PktSrc.cc Tue Dec 16 15:24:43 2003
@@ -188,8 +188,14 @@
SecondaryEvent* se = secondary_path->EventTable()[i];
program = new struct bpf_program;
+#ifndef LIBPCAP_PCAP_COMPILE_NOPCAP_HAS_ERROR_PARAMETER
int i = pcap_compile_nopcap(snaplen, datalink, program,
(char*) (se->Filter()), 1, netmask);
+#else
+ char error[1024];
+ int i = pcap_compile_nopcap(snaplen, datalink, program,
+ (char*) (se->Filter()), 1, netmask, &error);
+#endif
if ( i < 0 )
{
snprintf(errbuf, sizeof(errbuf),
diff -Naur ./bro-pub-0.8a58.orig/config.h.in bro-pub-0.8a58/config.h.in
--- ./bro-pub-0.8a58.orig/config.h.in Thu Dec 11 17:21:20 2003
+++ bro-pub-0.8a58/config.h.in Tue Dec 16 15:13:24 2003
@@ -112,6 +112,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Some libpcap versions use an extra parameter (error) in pcap_compile_nopcap
+ */
+#undef LIBPCAP_PCAP_COMPILE_NOPCAP_HAS_ERROR_PARAMETER
+
/* Include krb5.h */
#undef NEED_KRB5_H
diff -Naur ./bro-pub-0.8a58.orig/configure bro-pub-0.8a58/configure
--- ./bro-pub-0.8a58.orig/configure Thu Dec 11 17:24:35 2003
+++ bro-pub-0.8a58/configure Tue Dec 16 15:26:29 2003
@@ -6119,7 +6119,6 @@
fi
if test "$ac_cv_lib_pcap_pcap_freecode" = no ; then
- unset ac_cv_lib_pcap_pcap_freecode
cat >>confdefs.h <<\_ACEOF
#define DONT_HAVE_LIBPCAP_PCAP_FREECODE
@@ -6154,6 +6153,133 @@
V_INCLS="$V_INCLS -I$pcap_includes"
fi
+ if test "$ac_cv_lib_pcap_pcap_freecode" = yes ; then
+ CFLAGS="$CFLAGS -I$pcap_includes"
+ echo "$as_me:$LINENO: checking if pcap_compile_nopcap needs error parameter" >&5
+echo $ECHO_N "checking if pcap_compile_nopcap needs error parameter... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <pcap.h>
+
+int
+main ()
+{
+
+ int snaplen;
+ int linktype;
+ struct bpf_program fp;
+ int optimize;
+ bpf_u_int32 netmask;
+ char str[10];
+ snaplen = 50;
+ linktype = DLT_EN10MB;
+ optimize = 1;
+ netmask = 0L;
+ str[0] = 'i'; str[1] = 'p'; str[2] = '\0';
+ (void)pcap_compile_nopcap(snaplen, linktype, &fp, str, optimize, netmask);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ result="ok"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+result="wrong"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ if test "$result" = "ok" ; then
+ echo "$as_me:$LINENO: result: not needed" >&5
+echo "${ECHO_T}not needed" >&6
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <pcap.h>
+
+int
+main ()
+{
+
+ int snaplen;
+ int linktype;
+ struct bpf_program fp;
+ int optimize;
+ bpf_u_int32 netmask;
+ char str[10];
+ char error[1024];
+ snaplen = 50;
+ linktype = DLT_EN10MB;
+ optimize = 1;
+ netmask = 0L;
+ str[0] = 'i'; str[1] = 'p'; str[2] = '\0';
+ (void)pcap_compile_nopcap(snaplen, linktype, &fp, str, optimize, netmask, &error);
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ result="ok"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+result="wrong"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ if test "$result" = "ok" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define LIBPCAP_PCAP_COMPILE_NOPCAP_HAS_ERROR_PARAMETER
+_ACEOF
+
+ echo "$as_me:$LINENO: result: needed" >&5
+echo "${ECHO_T}needed" >&6
+ else
+ { { echo "$as_me:$LINENO: error: don't know (weird pcap_compile_nopcap)" >&5
+echo "$as_me: error: don't know (weird pcap_compile_nopcap)" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+ fi
+
case "$target_os" in
diff -Naur ./bro-pub-0.8a58.orig/lbl-aclocal.m4 bro-pub-0.8a58/lbl-aclocal.m4
--- ./bro-pub-0.8a58.orig/lbl-aclocal.m4 Tue Dec 16 08:55:37 2003
+++ bro-pub-0.8a58/lbl-aclocal.m4 Tue Dec 16 15:26:18 2003
@@ -246,7 +246,6 @@
dnl check libpcap is modern enough for Bro (>= 0.6.1)
AC_CHECK_LIB(pcap, pcap_freecode)
if test "$ac_cv_lib_pcap_pcap_freecode" = no ; then
- unset ac_cv_lib_pcap_pcap_freecode
AC_DEFINE([DONT_HAVE_LIBPCAP_PCAP_FREECODE],[],[Old libpcap versions (< 0.6.1) need defining pcap_freecode and pcap_compile_nopcap])
fi
@@ -274,6 +273,58 @@
V_INCLS="$V_INCLS -I$pcap_includes"
fi
+ dnl check if pcap_compile_nopcap needs error parameter (NetBSDism)
+ if test "$ac_cv_lib_pcap_pcap_freecode" = yes ; then
+ CFLAGS="$CFLAGS -I$pcap_includes"
+ AC_MSG_CHECKING(if pcap_compile_nopcap needs error parameter)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <pcap.h>
+ ]], [[
+ int snaplen;
+ int linktype;
+ struct bpf_program fp;
+ int optimize;
+ bpf_u_int32 netmask;
+ char str[10];
+ snaplen = 50;
+ linktype = DLT_EN10MB;
+ optimize = 1;
+ netmask = 0L;
+ str[0] = 'i'; str[1] = 'p'; str[2] = '\0';
+ (void)pcap_compile_nopcap(snaplen, linktype, &fp, str, optimize, netmask);
+ ]])],result="ok",result="wrong")
+ if test "$result" = "ok" ; then
+ AC_MSG_RESULT(not needed)
+ else
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <pcap.h>
+ ]], [[
+ int snaplen;
+ int linktype;
+ struct bpf_program fp;
+ int optimize;
+ bpf_u_int32 netmask;
+ char str[10];
+ char error[1024];
+ snaplen = 50;
+ linktype = DLT_EN10MB;
+ optimize = 1;
+ netmask = 0L;
+ str[0] = 'i'; str[1] = 'p'; str[2] = '\0';
+ (void)pcap_compile_nopcap(snaplen, linktype, &fp, str, optimize, netmask, &error);
+ ]])],result="ok",result="wrong")
+ if test "$result" = "ok" ; then
+ AC_DEFINE([LIBPCAP_PCAP_COMPILE_NOPCAP_HAS_ERROR_PARAMETER],[],
+ [Some libpcap versions use an extra parameter (error) in pcap_compile_nopcap])
+ AC_MSG_RESULT(needed)
+ else
+ AC_MSG_ERROR(don't know (weird pcap_compile_nopcap))
+ fi
+ fi
+ fi
+
case "$target_os" in
More information about the Bro
mailing list