summaryrefslogtreecommitdiffstats
path: root/usr.sbin/tcpdump/print-ether.c
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2018-11-18 08:53:37 +0000
committerdlg <dlg@openbsd.org>2018-11-18 08:53:37 +0000
commite388b113e4f0447e49b1e90934602101ec76071f (patch)
tree6a23a3a7dfb9ae5c6facfca185c562960e51573e /usr.sbin/tcpdump/print-ether.c
parentWhen parsing extended capabilities, bail out if a register read returns (diff)
downloadwireguard-openbsd-e388b113e4f0447e49b1e90934602101ec76071f.tar.xz
wireguard-openbsd-e388b113e4f0447e49b1e90934602101ec76071f.zip
handle the 802.1Q i-tag format for provider backbone bridges.
Diffstat (limited to 'usr.sbin/tcpdump/print-ether.c')
-rw-r--r--usr.sbin/tcpdump/print-ether.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c
index a3163a8057b..0625f34c204 100644
--- a/usr.sbin/tcpdump/print-ether.c
+++ b/usr.sbin/tcpdump/print-ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-ether.c,v 1.33 2018/10/22 16:12:45 kn Exp $ */
+/* $OpenBSD: print-ether.c,v 1.34 2018/11/18 08:53:37 dlg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -50,6 +50,7 @@ const u_char *packetp;
const u_char *snapend;
void ether_macctl(const u_char *, u_int);
+void ether_pbb_print(const u_char *, u_int, u_int);
void
ether_print(const u_char *bp, u_int length)
@@ -166,6 +167,43 @@ ether_tryprint(const u_char *p, u_int length, int first_header)
putchar('\n');
}
+void
+ether_pbb_print(const u_char *bp, u_int length, u_int caplen)
+{
+ uint32_t itag;
+ uint8_t pri, res;
+
+ if (caplen < sizeof(itag))
+ goto trunc;
+
+ itag = EXTRACT_32BITS(bp);
+
+ bp += sizeof(itag);
+ length -= sizeof(itag);
+ caplen -= sizeof(itag);
+
+ pri = itag >> 29;
+ if (pri <= 1)
+ pri = !pri;
+
+ res = (itag >> 24) & 0x7;
+
+ printf("802.1Q ivid %u pri %u ", itag & 0xffffff, pri);
+ if (itag & (1 << 28))
+ printf("dei ");
+ if (itag & (1 << 27))
+ printf("uca ");
+ if (res)
+ printf("res %u! ", res);
+
+ ether_tryprint(bp, length, 0);
+
+ return;
+
+trunc:
+ printf("[|pbb] ");
+}
+
/*
* Prints the packet encapsulated in an Ethernet data segment
* (or an equivalent encapsulation), given the Ethernet type code.
@@ -251,6 +289,13 @@ recurse:
}
return (1);
+#ifndef ETHERTYPE_PBB
+#define ETHERTYPE_PBB 0x88e7
+#endif
+ case ETHERTYPE_PBB:
+ ether_pbb_print(p, length, caplen);
+ return (1);
+
#ifdef PPP
case ETHERTYPE_PPPOEDISC:
case ETHERTYPE_PPPOE: