diff options
| author | 2018-04-03 01:57:31 +0000 | |
|---|---|---|
| committer | 2018-04-03 01:57:31 +0000 | |
| commit | 0560242b8de60019ce6f977455b22a59d35d32c9 (patch) | |
| tree | 544cc5290667c41487ee7c02a3b7cfa79bdba9f8 /usr.sbin/tcpdump/print-ether.c | |
| parent | sync (diff) | |
| download | wireguard-openbsd-0560242b8de60019ce6f977455b22a59d35d32c9.tar.xz wireguard-openbsd-0560242b8de60019ce6f977455b22a59d35d32c9.zip | |
tweak vlan printing to properly decode the priority field.
the vlan specs have the priority of 0 and 1 swapped on the wire,
which is how the kernel handles them. eg, if you use pf to set prio
1, it will end up being 0 on the wire. this makes 0 on the wire
come out as 1 in tcpdump so it is consistent with the rest of the
tooling.
ok henning@
Diffstat (limited to 'usr.sbin/tcpdump/print-ether.c')
| -rw-r--r-- | usr.sbin/tcpdump/print-ether.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c index d701f1e795c..72093a5b34a 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.31 2016/07/11 00:27:50 rzalamena Exp $ */ +/* $OpenBSD: print-ether.c,v 1.32 2018/04/03 01:57:31 dlg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -182,6 +182,7 @@ int ether_encap_print(u_short ethertype, const u_char *p, u_int length, u_int caplen) { + uint16_t vlan, pri, vid; recurse: extracted_ethertype = ethertype; @@ -221,10 +222,17 @@ recurse: case ETHERTYPE_QINQ: if (ethertype == ETHERTYPE_QINQ) printf("QinQ s"); - printf("vid %d pri %d%s", - ntohs(*(unsigned short*)p)&0xFFF, - ntohs(*(unsigned short*)p)>>13, - (ntohs(*(unsigned short*)p)&0x1000) ? " cfi " : " "); + + /* XXX caplen check */ + + vlan = ntohs(*(unsigned short*)p); + vid = vlan & 0xfff; + pri = vlan >> 13; + if (pri <= 1) + pri = !pri; + + printf("vid %d pri %d%s", vid, pri, + vlan & 0x1000 ? " cfi " : " "); ethertype = ntohs(*(unsigned short*)(p+2)); p += 4; length -= 4; |
