diff options
Diffstat (limited to 'contrib/libpcap/pcap-bpf.c')
-rw-r--r-- | contrib/libpcap/pcap-bpf.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/contrib/libpcap/pcap-bpf.c b/contrib/libpcap/pcap-bpf.c index 6f8f199..9c9a554 100644 --- a/contrib/libpcap/pcap-bpf.c +++ b/contrib/libpcap/pcap-bpf.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: pcap-bpf.c,v 1.31 98/07/12 13:14:55 leres Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.32 1999/10/19 15:18:30 itojun Exp $ (LBL)"; #endif #include <sys/param.h> /* optionally get BSD define */ @@ -47,6 +47,8 @@ static const char rcsid[] = #include "os-proto.h" #endif +#include "gencode.h" + int pcap_stats(pcap_t *p, struct pcap_stat *ps) { @@ -202,6 +204,13 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf) sprintf(ebuf, "BIOCGDLT: %s", pcap_strerror(errno)); goto bad; } +#ifdef __OpenBSD__ + switch (v) { + case DLT_LOOP: + v = DLT_NULL; + break; + } +#endif #if _BSDI_VERSION - 0 >= 199510 /* The SLIP and PPP link layer header changed in BSD/OS 2.1 */ switch (v) { @@ -213,6 +222,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf) case DLT_PPP: v = DLT_PPP_BSDOS; break; + + case 11: /*DLT_FR*/ + v = DLT_RAW; /*XXX*/ + break; + + case 12: /*DLT_C_HDLC*/ + v = DLT_CHDLC; + break; } #endif p->linktype = v; @@ -253,7 +270,14 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf) int pcap_setfilter(pcap_t *p, struct bpf_program *fp) { - if (p->sf.rfile != NULL) + /* + * It looks that BPF code generated by gen_protochain() is not + * compatible with some of kernel BPF code (for example BSD/OS 3.1). + * Take a safer side for now. + */ + if (no_optimize) + p->fcode = *fp; + else if (p->sf.rfile != NULL) p->fcode = *fp; else if (ioctl(p->fd, BIOCSETF, (caddr_t)fp) < 0) { sprintf(p->errbuf, "BIOCSETF: %s", pcap_strerror(errno)); |