]> 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)
committerfxlb <[email protected]>
Tue, 13 Sep 2022 06:32:18 +0000 (06:32 +0000)
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.

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 9ad75de83a0183aac10c229b9cd9675ade4dd83d..050b0fecd82b3cb5a4dad21ace7f2588fad9bbe6 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 e48342a4abcaccdc8593b4ff475211f00920da53..1b0d9593ed0951420601f8b01b4884e2625a1d1e 100644 (file)
@@ -213,6 +213,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