Commit 5a69f89b authored by Adam Wujek's avatar Adam Wujek 💬

[BUG: 1544, 1810] tools: fix displaying of sent packets with VLANs

This commit fixes dumping PTP packets in ptpdump and PPSi (via -d 002)
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 97a65848
......@@ -60,7 +60,18 @@ static int dump_eth(char *prefix, struct ethhdr *eth)
unsigned char *d = eth->h_dest;
unsigned char *s = eth->h_source;
int proto = ntohs(eth->h_proto);
int ret = sizeof(*eth);
int ret;
/* Between eth header and payload may be a VLAN tag;
* NOTE: We cannot distinguish between both cases looking at
* the content of a vlan variable, because vlan number may come from
* frame itself or from the socket (CMSG) */
if (proto == 0x8100) {
ret = sizeof(struct pp_vlanhdr); /* ETH header + VLAN tag */
/* Get the proto knowing that there is a VLAN tag */
proto = ntohs(((struct pp_vlanhdr *)eth)->h_proto);
} else
ret = sizeof(struct ethhdr);
printf("%sETH: %04x (%02x:%02x:%02x:%02x:%02x:%02x -> "
"%02x:%02x:%02x:%02x:%02x:%02x)\n", prefix, proto,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment