[PATCH 11/28] batctl: tcpdump: correct output of VLAN IDs
Sven Eckelmann <[email protected]> Sun, 21 Jun 2026 16:24:01 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
The 16 bit TCI header for VLAN tagging (IEEE 802.1Q) stores 12 bit for the
12 bit VID, 1 bit DEI and 3 bit PCP. It is therefore unexpected to print
the 16 bit as vlan identifier without masking out the upper 4 bit.
At the same time, also split the DEI ( Drop Eligible Indicator) and the PCP
(Priority Code Point) in separate output fields.
Fixes: 7738b534fb07 ("batctl: tcpdump - add vlan support")
Signed-off-by: Sven Eckelmann <[email protected]>
---
tcpdump.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tcpdump.c b/tcpdump.c
index ddcee03..e417cd1 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -823,7 +823,8 @@ static void dump_vlan(unsigned char *packet_buff, ssize_t buff_len, int read_opt
time_printed = print_time();
vlanhdr->vid = ntohs(vlanhdr->vid);
- printf("vlan %u, p %u, ", vlanhdr->vid, vlanhdr->vid >> 12);
+ printf("vlan %u, d %u, p %u, ", vlanhdr->vid & 0x0fff, (vlanhdr->vid >> 12) & 0x1,
+ vlanhdr->vid >> 13);
/* overwrite vlan tags */
memmove(packet_buff + 4, packet_buff, 2 * ETH_ALEN);
--
2.47.3