aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-snoop.c
diff options
context:
space:
mode:
authorguy <guy>2003-11-12 23:15:00 +0000
committerguy <guy>2003-11-12 23:15:00 +0000
commitd8ccb0422bffa2d6550707b362b79c5714546a5b (patch)
treec2c35ef2f5752ed208c3431ea3fb44cdc8b7ce68 /pcap-snoop.c
parent4a0eb920224369ec31295b1d37cc2db2e7fc4ce1 (diff)
From Brian Ginsbach <ginsbach@cray.com>:
correctly handle loopback devices on IRIX and UNICOS/mp (tweak the packet header so that it's a 4-byte AF_ value rather than the 2-byte AF_ value supplied on snoop sockets); add support for IP-over-FC and pseudo-link devices on UNICOS/mp.
Diffstat (limited to 'pcap-snoop.c')
-rw-r--r--pcap-snoop.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/pcap-snoop.c b/pcap-snoop.c
index a1b530e..bd04233 100644
--- a/pcap-snoop.c
+++ b/pcap-snoop.c
@@ -20,7 +20,7 @@
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.45 2003-11-04 07:05:37 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.46 2003-11-12 23:15:00 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -100,6 +100,17 @@ again:
caplen = (datalen < p->snapshot) ? datalen : p->snapshot;
cp = (u_char *)(sh + 1) + p->offset; /* XXX */
+ /*
+ * XXX unfortunately snoop loopback isn't exactly like
+ * BSD's. The address family is encoded in the first 2
+ * bytes rather than the first 4 bytes! Luckily the last
+ * two snoop loopback bytes are zeroed.
+ */
+ if (p->linktype == DLT_NULL && *((short *)(cp + 2)) == 0) {
+ u_int *uip = (u_int *)cp;
+ *uip >>= 16;
+ }
+
if (p->fcode.bf_insns == NULL ||
bpf_filter(p->fcode.bf_insns, cp, datalen, caplen)) {
struct pcap_pkthdr h;
@@ -235,9 +246,15 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
} else if (strncmp("ppp", device, 3) == 0) {
p->linktype = DLT_RAW;
ll_hdrlen = 0; /* DLT_RAW meaning "no PPP header, just the IP packet"? */
+ } else if (strncmp("qfa", device, 3) == 0) {
+ p->linktype = DLT_IP_OVER_FC;
+ ll_hdrlen = 24;
+ } else if (strncmp("pl", device, 2) == 0) {
+ p->linktype = DLT_RAW;
+ ll_hdrlen = 0; /* Cray UNICOS/mp pseudo link */
} else if (strncmp("lo", device, 2) == 0) {
p->linktype = DLT_NULL;
- ll_hdrlen = 4; /* is this just like BSD's loopback device? */
+ ll_hdrlen = 4;
} else {
snprintf(ebuf, PCAP_ERRBUF_SIZE,
"snoop: unknown physical layer type");