From 4f278d5429de98e3b9af7178650e6e3fbf68d4c7 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 15 Jun 2007 17:55:50 +0000 Subject: [PATCH] Check for "/dev/bpf"; if we find it, use BPF as the capture mechanism, and assume it's a cloning device. --- config.h.in | 3 +++ configure | 12 +++++++++++- configure.in | 10 ++++++++-- pcap-bpf.c | 11 ++--------- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/config.h.in b/config.h.in index ca0b706..b480129 100644 --- a/config.h.in +++ b/config.h.in @@ -10,6 +10,9 @@ /* Enable optimizer debugging */ #undef BDEBUG +/* define if you have a cloning BPF device */ +#undef HAVE_CLONING_BPF + /* define if you have the DAG API */ #undef HAVE_DAG_API diff --git a/configure b/configure index 0867f32..dbbea4f 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.135 . +# From configure.in Revision: 1.136 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -5207,6 +5207,16 @@ echo "$as_me:$LINENO: checking packet capture type" >&5 echo $ECHO_N "checking packet capture type... $ECHO_C" >&6 if test ! -z "$with_pcap" ; then V_PCAP="$withval" +elif test -r /dev/bpf ; then + # + # Cloning BPF device. + # + V_PCAP=bpf + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CLONING_BPF 1 +_ACEOF + elif test -r /dev/bpf0 ; then V_PCAP=bpf elif test -r /usr/include/net/pfilt.h ; then diff --git a/configure.in b/configure.in index 038d521..39af0fb 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.135 2007-06-11 10:04:24 guy Exp $ (LBL) +dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.136 2007-06-15 17:55:50 guy Exp $ (LBL) dnl dnl Copyright (c) 1994, 1995, 1996, 1997 dnl The Regents of the University of California. All rights reserved. @@ -6,7 +6,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl -AC_REVISION($Revision: 1.135 $) +AC_REVISION($Revision: 1.136 $) AC_PREREQ(2.50) AC_INIT(pcap.c) @@ -184,6 +184,12 @@ AC_ARG_WITH(pcap, [ --with-pcap=TYPE use packet capture TYPE]) AC_MSG_CHECKING(packet capture type) if test ! -z "$with_pcap" ; then V_PCAP="$withval" +elif test -r /dev/bpf ; then + # + # Cloning BPF device. + # + V_PCAP=bpf + AC_DEFINE(HAVE_CLONING_BPF,1,[define if you have a cloning BPF device]) elif test -r /dev/bpf0 ; then V_PCAP=bpf elif test -r /usr/include/net/pfilt.h ; then diff --git a/pcap-bpf.c b/pcap-bpf.c index 6e2047a..ecbc3ed 100644 --- a/pcap-bpf.c +++ b/pcap-bpf.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.98 2007-06-11 10:04:25 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.99 2007-06-15 17:55:50 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -35,13 +35,6 @@ static const char rcsid[] _U_ = #include #include -#ifdef HAVE_PATHS_H -#include -#if defined(__NetBSD__) && defined(_PATH_BPF) -#define HAVE_CLONING_BPF -#endif /* __NetBSD__ && _PATH_BPF */ -#endif /* HAVE_PATHS_H */ - #include #ifdef _AIX @@ -531,7 +524,7 @@ bpf_open(pcap_t *p, char *errbuf) { int fd; #ifdef HAVE_CLONING_BPF - static const char device[] = _PATH_BPF; + static const char device[] = "/dev/bpf"; #else int n = 0; char device[sizeof "/dev/bpf0000000000"];