libpcap compatibility problem (Re: new bro "CURRENT" release - 0.8a57)

José María González chema at cs.berkeley.edu
Tue Dec 16 15:15:52 PST 2003


Hi, 

This patch should recognize how many parameters 
pcap_compile_nopcap needs. 

Can somebody with a NetBSD box try it? 

-Chema




Vern Paxson wrote:
> 
> > is Bro supported on NetBSD?
> 
> Not directly, since we don't have any NetBSD machines in house, but
> it's certainly the intent that it runs under NetBSD (and in general
> on systems with libpcap), if it's not too painful.
> 
> > If so, a recent thread on ethereal-dev
> > discussed pcap_compile_nopcap() in that context and might be relevant
> > for Bro. Have a look at
> >
> > http://www.ethereal.com/lists/ethereal-dev/200312/msg00401.html
> 
> Looks like some more autoconf'ing will be needed :-(.  If someone cares
> to contribute it, that would be great.
> 
>                 Vern
-------------- next part --------------
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:17:57 2003
@@ -6154,6 +6154,131 @@
 	    V_INCLS="$V_INCLS -I$pcap_includes"
     fi
 
+				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
+
 
     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:17:50 2003
@@ -274,6 +274,56 @@
 	    V_INCLS="$V_INCLS -I$pcap_includes"
     fi
 
+		dnl check if pcap_compile_nopcap needs error parameter (NetBSDism)
+		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
+
 
     case "$target_os" in
 


More information about the Bro mailing list