Repository : ssh://git@diktynna/batctl
On branch : master
commit e42f73d0d2a04edfbed1b9d0ad9fd57af9e90faf Author: Linus L��ssing linus.luessing@c0d3.blue Date: Sun Sep 13 23:30:19 2020 +0200
batctl: tcpdump: Fix endianness in ICMPv6 Echo Request/Reply parsing
The ICMPv6 Echo Request/Reply sequence number and id as well as the IPv6 header length are two byte long fields and therefore might need a conversion on a little endian system. Otherwise the output will be broken on such a machine.
Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser") Signed-off-by: Linus L��ssing linus.luessing@c0d3.blue Signed-off-by: Sven Eckelmann sven@narfation.org
e42f73d0d2a04edfbed1b9d0ad9fd57af9e90faf tcpdump.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tcpdump.c b/tcpdump.c index db93681..b9edc20 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -589,13 +589,15 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len, break; case ICMP6_ECHO_REQUEST: printf(" echo request, id: %d, seq: %d, length: %hu\n", - icmphdr->icmp6_id, icmphdr->icmp6_seq, - iphdr->ip6_plen); + ntohs(icmphdr->icmp6_id), + ntohs(icmphdr->icmp6_seq), + ntohs(iphdr->ip6_plen)); break; case ICMP6_ECHO_REPLY: printf(" echo reply, id: %d, seq: %d, length: %hu\n", - icmphdr->icmp6_id, icmphdr->icmp6_seq, - iphdr->ip6_plen); + ntohs(icmphdr->icmp6_id), + ntohs(icmphdr->icmp6_seq), + ntohs(iphdr->ip6_plen)); break; case ICMP6_TIME_EXCEEDED: printf(" time exceeded in-transit, length %zu\n",