Make sure net/bpf.h not only exists but defines BIOCSETIF.
This way, if some system has Linux packet sockets *and* BPF, we still
choose BPF. Some systems might offer Linux packet sockets for
compatibility.
This also handles non-Linux systems that have net/bpf.h but don't have
BPF as a capture mechanism.
# Check for a bunch of headers for various packet capture mechanisms.
#
check_include_files("sys/types.h;net/bpf.h" HAVE_NET_BPF_H)
+ if(HAVE_NET_BPF_H)
+ #
+ # Does it define BIOCSETIF?
+ # I.e., is it a header for an LBL/BSD-style capture
+ # mechanism, or is it just a header for a BPF filter
+ # engine? Some versions of Arch Linux, for example,
+ # have a net/bpf.h that doesn't define BIOCSETIF;
+ # as it's a Linux, it should use packet sockets,
+ # instead.
+ #
+ check_symbol_exists(BIOCSETIF net/bpf.h BPF_H_DEFINES_BIOCSETIF)
+ endif(HAVE_NET_BPF_H)
check_include_file(net/pfilt.h HAVE_NET_PFILT_H)
check_include_file(net/enet.h HAVE_NET_ENET_H)
check_include_file(net/nit.h HAVE_NET_NIT_H)
check_include_file(net/raw.h HAVE_NET_RAW_H)
check_include_file(sys/dlpi.h HAVE_SYS_DLPI_H)
- if(HAVE_LINUX_SOCKET_H)
- #
- # No prizes for guessing this one.
- # Check this before BPF, because it appears that
- # at least one Arch Linux system might have a net/bpf.h.
- #
- set(PCAP_TYPE linux)
- elseif(HAVE_NET_BPF_H)
+ if(BPF_H_DEFINES_BIOCSETIF)
#
# BPF.
# Check this before DLPI, so that we pick BPF on
# Solaris 11 and later.
#
set(PCAP_TYPE bpf)
+ elseif(HAVE_LINUX_SOCKET_H)
+ #
+ # No prizes for guessing this one.
+ #
+ set(PCAP_TYPE linux)
elseif(HAVE_NET_PFILT_H)
#
# DEC OSF/1, Digital UNIX, Tru64 UNIX
# Check for a bunch of headers for various packet
# capture mechanisms.
#
- for ac_header in net/bpf.h net/pfilt.h net/enet.h
+ for ac_header in net/bpf.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "net/bpf.h" "ac_cv_header_net_bpf_h" "$ac_includes_default"
+if test "x$ac_cv_header_net_bpf_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_BPF_H 1
+_ACEOF
+
+fi
+
+done
+
+ if test "$ac_cv_header_net_bpf_h" = yes; then
+ #
+ # Does it define BIOCSETIF?
+ # I.e., is it a header for an LBL/BSD-style capture
+ # mechanism, or is it just a header for a BPF filter
+ # engine? Some versions of Arch Linux, for example,
+ # have a net/bpf.h that doesn't define BIOCSETIF;
+ # as it's a Linux, it should use packet sockets,
+ # instead.
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if net/bpf.h defines BIOCSETIF" >&5
+$as_echo_n "checking if net/bpf.h defines BIOCSETIF... " >&6; }
+ if ${ac_cv_lbl_bpf_h_defines_biocsetif+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <sys/ioctl.h>
+#ifdef HAVE_SYS_IOCCOM_H
+#include <sys/ioccom.h>
+#endif
+#include <net/bpf.h>
+#include <net/if.h>
+
+int
+main ()
+{
+u_int i = BIOCSETIF;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_lbl_bpf_h_defines_biocsetif=yes
+else
+ ac_cv_lbl_bpf_h_defines_biocsetif=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_bpf_h_defines_biocsetif" >&5
+$as_echo "$ac_cv_lbl_bpf_h_defines_biocsetif" >&6; }
+ fi
+ for ac_header in net/pfilt.h net/enet.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
done
- if test "$ac_cv_header_linux_socket_h" = yes; then
- #
- # No prizes for guessing this one.
- # Check this before BPF, because it appears that
- # at least one Arch Linux system might have a net/bpf.h.
- #
- V_PCAP=linux
-
- #
- # XXX - this won't work with older kernels that have
- # SOCK_PACKET sockets but not PF_PACKET sockets.
- #
- VALGRINDTEST=valgrindtest
- elif test "$ac_cv_header_net_bpf_h" = yes; then
+ if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
#
# BPF.
# Check this before DLPI, so that we pick BPF on
VALGRINDTEST=valgrindtest
;;
esac
+ elif test "$ac_cv_header_linux_socket_h" = yes; then
+ #
+ # No prizes for guessing this one.
+ #
+ V_PCAP=linux
+
+ #
+ # XXX - this won't work with older kernels that have
+ # SOCK_PACKET sockets but not PF_PACKET sockets.
+ #
+ VALGRINDTEST=valgrindtest
elif test "$ac_cv_header_net_pfilt_h" = yes; then
#
# DEC OSF/1, Digital UNIX, Tru64 UNIX
# Check for a bunch of headers for various packet
# capture mechanisms.
#
- AC_CHECK_HEADERS(net/bpf.h net/pfilt.h net/enet.h)
+ AC_CHECK_HEADERS(net/bpf.h)
+ if test "$ac_cv_header_net_bpf_h" = yes; then
+ #
+ # Does it define BIOCSETIF?
+ # I.e., is it a header for an LBL/BSD-style capture
+ # mechanism, or is it just a header for a BPF filter
+ # engine? Some versions of Arch Linux, for example,
+ # have a net/bpf.h that doesn't define BIOCSETIF;
+ # as it's a Linux, it should use packet sockets,
+ # instead.
+ #
+ AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
+ AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
+ AC_TRY_COMPILE(
+[
+#include <sys/ioctl.h>
+#ifdef HAVE_SYS_IOCCOM_H
+#include <sys/ioccom.h>
+#endif
+#include <net/bpf.h>
+#include <net/if.h>
+],
+ [u_int i = BIOCSETIF;],
+ ac_cv_lbl_bpf_h_defines_biocsetif=yes,
+ ac_cv_lbl_bpf_h_defines_biocsetif=no))
+ AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
+ fi
+ AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
- if test "$ac_cv_header_linux_socket_h" = yes; then
- #
- # No prizes for guessing this one.
- # Check this before BPF, because it appears that
- # at least one Arch Linux system might have a net/bpf.h.
- #
- V_PCAP=linux
-
- #
- # XXX - this won't work with older kernels that have
- # SOCK_PACKET sockets but not PF_PACKET sockets.
- #
- VALGRINDTEST=valgrindtest
- elif test "$ac_cv_header_net_bpf_h" = yes; then
+ if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
#
# BPF.
# Check this before DLPI, so that we pick BPF on
VALGRINDTEST=valgrindtest
;;
esac
+ elif test "$ac_cv_header_linux_socket_h" = yes; then
+ #
+ # No prizes for guessing this one.
+ #
+ V_PCAP=linux
+
+ #
+ # XXX - this won't work with older kernels that have
+ # SOCK_PACKET sockets but not PF_PACKET sockets.
+ #
+ VALGRINDTEST=valgrindtest
elif test "$ac_cv_header_net_pfilt_h" = yes; then
#
# DEC OSF/1, Digital UNIX, Tru64 UNIX