summaryrefslogtreecommitdiff
path: root/addrtoname.c
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2015-01-29 19:48:25 +0000
committerDenis Ovsienko <denis@ovsienko.info>2015-01-29 20:38:54 +0000
commit1d66439981bbb9edf25b2a61ab571991ff353923 (patch)
tree3b9eaa070376fd163a8f50bf09b35b554647f50b /addrtoname.c
parent913899bcbfbf37808b659b88518c6a29df89339a (diff)
downloadtcpdump-1d66439981bbb9edf25b2a61ab571991ff353923.tar.gz
refine 802.1Q VLAN TCI decoding
Factor the common code out to a new function and rename the CFI bit to DEI to match the terminology in Clause 9.6 of IEEE 802.1Q-2011.
Diffstat (limited to 'addrtoname.c')
-rw-r--r--addrtoname.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/addrtoname.c b/addrtoname.c
index f6e070e7..d0437fe4 100644
--- a/addrtoname.c
+++ b/addrtoname.c
@@ -1215,3 +1215,15 @@ newh6namemem(void)
return (p);
}
#endif /* INET6 */
+
+/* Represent TCI part of the 802.1Q 4-octet tag as text. */
+const char *
+ieee8021q_tci_string(const uint16_t tci)
+{
+ static char buf[128];
+ snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
+ tci & 0xfff,
+ tci >> 13,
+ (tci & 0x1000) ? ", DEI" : "");
+ return buf;
+}