summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-11-18 08:53:38 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-11-18 08:53:38 +0000
commitc76f167b584d60d4d9ad2c8ce4a4f2f1c1c9cd88 (patch)
treec4918a116ab0f8aef00a2bac2fb80455586df157
parente5468996fa2da1a0018bd8423886ff886a30c249 (diff)
handle the 802.1Q i-tag format for provider backbone bridges.
-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: