Merge pull request #624 from ecsv/batadv-for-18.06
[feed/routing.git] / batctl / patches / 0004-batctl-tcpdump-Fix-endianness-in-ICMPv6-Echo-Request.patch
1 From: Linus Lüssing <linus.luessing@c0d3.blue>
2 Date: Sun, 13 Sep 2020 23:30:19 +0200
3 Subject: batctl: tcpdump: Fix endianness in ICMPv6 Echo Request/Reply parsing
4
5 The ICMPv6 Echo Request/Reply sequence number and id as well as the
6 IPv6 header length are two byte long fields and therefore might need a
7 conversion on a little endian system. Otherwise the output will be
8 broken on such a machine.
9
10 Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser")
11 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
12 Signed-off-by: Sven Eckelmann <sven@narfation.org>
13
14 Origin: upstream, https://git.open-mesh.org/batctl.git/commit/e42f73d0d2a04edfbed1b9d0ad9fd57af9e90faf
15
16 diff --git a/tcpdump.c b/tcpdump.c
17 index c41500e21eda0abc1f024a3265c23fc3a4802d17..22847aecf887566ac62ff2084079683d0acf83aa 100644
18 --- a/tcpdump.c
19 +++ b/tcpdump.c
20 @@ -551,13 +551,15 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len,
21 break;
22 case ICMP6_ECHO_REQUEST:
23 printf(" echo request, id: %d, seq: %d, length: %hu\n",
24 - icmphdr->icmp6_id, icmphdr->icmp6_seq,
25 - iphdr->ip6_plen);
26 + ntohs(icmphdr->icmp6_id),
27 + ntohs(icmphdr->icmp6_seq),
28 + ntohs(iphdr->ip6_plen));
29 break;
30 case ICMP6_ECHO_REPLY:
31 printf(" echo reply, id: %d, seq: %d, length: %hu\n",
32 - icmphdr->icmp6_id, icmphdr->icmp6_seq,
33 - iphdr->ip6_plen);
34 + ntohs(icmphdr->icmp6_id),
35 + ntohs(icmphdr->icmp6_seq),
36 + ntohs(iphdr->ip6_plen));
37 break;
38 case ICMP6_TIME_EXCEEDED:
39 printf(" time exceeded in-transit, length %zu\n",