diff options
author | fenner <fenner@FreeBSD.org> | 2000-01-30 00:32:56 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 2000-01-30 00:32:56 +0000 |
commit | aae9bd2bccda7ddbeb438e8238ced9c4cd1e9d1d (patch) | |
tree | d7ccf2b8332af627d9692b32089580fd3967581f /contrib/libpcap/pcap-bpf.c | |
parent | ca0d84cb8bfc8789fd48ada56322a575c4a1aa68 (diff) | |
download | FreeBSD-src-aae9bd2bccda7ddbeb438e8238ced9c4cd1e9d1d.zip FreeBSD-src-aae9bd2bccda7ddbeb438e8238ced9c4cd1e9d1d.tar.gz |
Virgin import of tcpdump.org libpcap v0.5
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)); |