diff options
Diffstat (limited to 'contrib/libpcap/pcap-bpf.c')
-rw-r--r-- | contrib/libpcap/pcap-bpf.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/libpcap/pcap-bpf.c b/contrib/libpcap/pcap-bpf.c index e8492d3..91bfdcb 100644 --- a/contrib/libpcap/pcap-bpf.c +++ b/contrib/libpcap/pcap-bpf.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.86.2.8 2005/07/10 10:55:31 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.86.2.12 2007/06/15 17:57:27 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -525,8 +525,12 @@ static inline int bpf_open(pcap_t *p, char *errbuf) { int fd; +#ifdef HAVE_CLONING_BPF + static const char device[] = "/dev/bpf"; +#else int n = 0; char device[sizeof "/dev/bpf0000000000"]; +#endif #ifdef _AIX /* @@ -538,6 +542,12 @@ bpf_open(pcap_t *p, char *errbuf) return (-1); #endif +#ifdef HAVE_CLONING_BPF + if ((fd = open(device, O_RDWR)) == -1 && + (errno != EACCES || (fd = open(device, O_RDONLY)) == -1)) + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "(cannot open device) %s: %s", device, pcap_strerror(errno)); +#else /* * Go through all the minors and find one that isn't in use. */ @@ -568,6 +578,7 @@ bpf_open(pcap_t *p, char *errbuf) if (fd < 0) snprintf(errbuf, PCAP_ERRBUF_SIZE, "(no devices found) %s: %s", device, pcap_strerror(errno)); +#endif return (fd); } |