]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ICMPv6: Fix the Node Information flags
authorNicholas Reilly <[email protected]>
Wed, 31 Aug 2022 21:01:08 +0000 (17:01 -0400)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 13 Sep 2022 06:33:42 +0000 (08:33 +0200)
Don't use htons() when defining the constants because the flags
field is already eventually swapped by fetching with GET_BE_U_2().
Remove unused flags NI_SUPTYPE_FLAG_COMPRESS and NI_FQDN_FLAG_VALIDTTL.
Add a test file with various NI_NODEADDR_FLAG* flags.

(cherry picked from commit 425359f7b8e74a0f466ce05a2c24bddaee5c15a1)

print-icmp6.c
tests/TESTLIST
tests/icmpv6-ni-flags.out [new file with mode: 0644]
tests/icmpv6-ni-flags.pcap [new file with mode: 0644]

index 11c8677b0c0dd077ce7b2812991acf54ea5c01ff..47690f5a1ee2d586446eb1155de05c1a597e05f2 100644 (file)
@@ -394,18 +394,13 @@ struct icmp6_nodeinfo {
 #define NI_QTYPE_NODEADDR      3 /* Node Addresses */
 #define NI_QTYPE_IPV4ADDR      4 /* IPv4 Addresses */
 
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS       ((uint16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL          ((uint16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE      ((uint16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL           ((uint16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT                ((uint16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL     ((uint16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL     ((uint16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL                ((uint16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST       ((uint16_t)htons(0x40)) /* just experimental. not in spec */
+#define NI_NODEADDR_FLAG_TRUNCATE      0x0001
+#define NI_NODEADDR_FLAG_ALL           0x0002
+#define NI_NODEADDR_FLAG_COMPAT                0x0004
+#define NI_NODEADDR_FLAG_LINKLOCAL     0x0008
+#define NI_NODEADDR_FLAG_SITELOCAL     0x0010
+#define NI_NODEADDR_FLAG_GLOBAL                0x0020
+#define NI_NODEADDR_FLAG_ANYCAST       0x0040 /* just experimental. not in spec */
 
 struct ni_reply_fqdn {
        nd_uint32_t ni_fqdn_ttl;        /* TTL */
index 8090583b3cf7e99c63a04f877dc54f478a6bb07e..2b009ef20419ae3195594741f8355dcb51f007f1 100644 (file)
@@ -177,6 +177,7 @@ icmpv6-length-zero icmpv6-length-zero.pcapng icmpv6-length-zero.out
 icmpv6-rfc7112 icmpv6-rfc7112.pcap     icmpv6-rfc7112.out
 icmpv6-RFC2894-RR icmpv6-RFC2894-RR.pcap icmpv6-RFC2894-RR.out
 icmpv6-RFC2894-RR-v icmpv6-RFC2894-RR.pcap icmpv6-RFC2894-RR-v.out -v
+icmpv6-ni-flags        icmpv6-ni-flags.pcap    icmpv6-ni-flags.out
 
 # SPB tests
 spb                spb.pcap                spb.out
diff --git a/tests/icmpv6-ni-flags.out b/tests/icmpv6-ni-flags.out
new file mode 100644 (file)
index 0000000..f1c18ba
--- /dev/null
@@ -0,0 +1,5 @@
+    1  13:56:00.443595 IP6 fe80::5054:ff:fe43:2ca8 > fe80::5054:ff:fe2c:3629: ICMP6, who-are-you request node information query (node addresses [A], subject=fe80::5054:ff:fe2c:3629), length 32
+    2  13:56:46.614177 IP6 fe80::5054:ff:fe43:2ca8 > fe80::5054:ff:fe2c:3629: ICMP6, who-are-you request node information query (node addresses [C], subject=fe80::5054:ff:fe2c:3629), length 32
+    3  13:57:14.854456 IP6 fe80::5054:ff:fe43:2ca8 > fe80::5054:ff:fe2c:3629: ICMP6, who-are-you request node information query (node addresses [L], subject=fe80::5054:ff:fe2c:3629), length 32
+    4  13:57:22.010951 IP6 fe80::5054:ff:fe43:2ca8 > fe80::5054:ff:fe2c:3629: ICMP6, who-are-you request node information query (node addresses [S], subject=fe80::5054:ff:fe2c:3629), length 32
+    5  13:57:41.727114 IP6 fe80::5054:ff:fe43:2ca8 > fe80::5054:ff:fe2c:3629: ICMP6, who-are-you request node information query (node addresses [G], subject=fe80::5054:ff:fe2c:3629), length 32
diff --git a/tests/icmpv6-ni-flags.pcap b/tests/icmpv6-ni-flags.pcap
new file mode 100644 (file)
index 0000000..19615d5
Binary files /dev/null and b/tests/icmpv6-ni-flags.pcap differ