]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IPv6: Print some header fields, even if the header is incomplete
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 27 Aug 2023 09:20:58 +0000 (11:20 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 27 Aug 2023 11:28:12 +0000 (13:28 +0200)
Add a test file with a 39-byte header.

Moreover:
Fix an indentation.

print-ip6.c
tests/TESTLIST
tests/ipv6_39_byte_header.out [new file with mode: 0644]
tests/ipv6_39_byte_header.pcap [new file with mode: 0644]

index 827151eb3d068dd6dcfb4bde41a31ea76bee7b55..460795c744af0138cf9c2f73d7c59372d4eb89be 100644 (file)
@@ -249,7 +249,6 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
        ND_ICHECK_ZU(length, <, sizeof (struct ip6_hdr));
        ND_ICHECKMSG_U("version", IP6_VERSION(ip6), !=, 6);
 
-       ND_TCHECK_SIZE(ip6);
        payload_len = GET_BE_U_2(ip6->ip6_plen);
        /*
         * RFC 1883 says:
@@ -301,6 +300,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                         nh,
                         payload_len);
        }
+       ND_TCHECK_SIZE(ip6);
 
        /*
         * Cut off the snapshot length to the end of the IP payload.
@@ -328,7 +328,7 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
                    nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
                    nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
                        ND_PRINT("%s > %s: ", GET_IP6ADDR_STRING(ip6->ip6_src),
-                                    GET_IP6ADDR_STRING(ip6->ip6_dst));
+                                GET_IP6ADDR_STRING(ip6->ip6_dst));
                }
 
                switch (nh) {
index 8cfd344273d01466427662ef1e1d15312c26f0b3..73b9aef8f83e565b7a0c80f7d519a9922bca58cf 100644 (file)
@@ -362,6 +362,7 @@ ipv6-srh-tlv-pad1-padn-5-v ipv6-srh-tlv-pad1-padn-5.pcap ipv6-srh-tlv-pad1-padn-
 ipv6_invalid_length ipv6_invalid_length.pcap ipv6_invalid_length.out
 ipv6_invalid_length_2 ipv6_invalid_length_2.pcap ipv6_invalid_length_2.out -v
 ipv6_jumbogram_invalid_length ipv6_jumbogram_invalid_length.pcap ipv6_jumbogram_invalid_length.out -v
+ipv6_39_byte_header ipv6_39_byte_header.pcap ipv6_39_byte_header.out -v
 
 # Loopback/CTP test case
 loopback       loopback.pcap           loopback.out
diff --git a/tests/ipv6_39_byte_header.out b/tests/ipv6_39_byte_header.out
new file mode 100644 (file)
index 0000000..17e936a
--- /dev/null
@@ -0,0 +1 @@
+    1  07:30:59.044880 IP6 (flowlabel 0x74111, hlim 64, next-header UDP (17) payload length: 64)  [|ip6]
diff --git a/tests/ipv6_39_byte_header.pcap b/tests/ipv6_39_byte_header.pcap
new file mode 100644 (file)
index 0000000..b0a51b8
Binary files /dev/null and b/tests/ipv6_39_byte_header.pcap differ