diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-03-06 18:44:51 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2005-03-06 18:44:51 +0000 |
commit | 6e1548880c87b524b8ae1988a871ed6b944120ca (patch) | |
tree | 570325c02da4642c61fa369223de8b42d6f9bc95 /usr.sbin/tcpdump/privsep_pcap.c | |
parent | 62ec1c4762096038ae10b3296a05f6dc8ffeed67 (diff) |
add support for multiple DLTs using the -L and -y options.
ok canacar@
Diffstat (limited to 'usr.sbin/tcpdump/privsep_pcap.c')
-rw-r--r-- | usr.sbin/tcpdump/privsep_pcap.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/tcpdump/privsep_pcap.c b/usr.sbin/tcpdump/privsep_pcap.c index 4771511929c..d826d548e99 100644 --- a/usr.sbin/tcpdump/privsep_pcap.c +++ b/usr.sbin/tcpdump/privsep_pcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep_pcap.c,v 1.6 2004/04/29 04:19:37 deraadt Exp $ */ +/* $OpenBSD: privsep_pcap.c,v 1.7 2005/03/06 18:44:50 reyk Exp $ */ /* * Copyright (c) 2004 Can Erkin Acar @@ -171,7 +171,7 @@ priv_pcap_setfilter(pcap_t *hpcap, int oflag, u_int32_t netmask) /* privileged part of priv_pcap_live */ int -pcap_live(const char *device, int snaplen, int promisc) +pcap_live(const char *device, int snaplen, int promisc, u_int dlt) { char bpf[sizeof "/dev/bpf0000000000"]; int fd = -1, n = 0; @@ -200,6 +200,9 @@ pcap_live(const char *device, int snaplen, int promisc) /* this is allowed to fail */ ioctl(fd, BIOCPROMISC, NULL); + if (dlt != (u_int) -1 && ioctl(fd, BIOCSDLT, &dlt)) + goto error; + /* lock the descriptor */ if (ioctl(fd, BIOCLOCK, NULL) < 0) goto error; @@ -217,7 +220,8 @@ pcap_live(const char *device, int snaplen, int promisc) * unprivileged part. */ pcap_t * -priv_pcap_live(const char *dev, int slen, int prom, int to_ms, char *ebuf) +priv_pcap_live(const char *dev, int slen, int prom, int to_ms, + char *ebuf, u_int dlt) { int fd, err; struct bpf_version bv; @@ -242,6 +246,7 @@ priv_pcap_live(const char *dev, int slen, int prom, int to_ms, char *ebuf) write_command(priv_fd, PRIV_OPEN_BPF); must_write(priv_fd, &slen, sizeof(int)); must_write(priv_fd, &prom, sizeof(int)); + must_write(priv_fd, &dlt, sizeof(u_int)); write_string(priv_fd, dev); fd = receive_fd(priv_fd); |