]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IPv6: Print the protocol name before any test
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 31 Jul 2023 10:11:26 +0000 (12:11 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 31 Jul 2023 10:33:41 +0000 (12:33 +0200)
Use nd_print_protocol_caps().
IP6_VERSION() uses GET_U_1(), so there's no need for ND_TCHECK_*()
beforehand.

print-ip6.c

index 2f1183c00699b577dc4d5723cc558899b74c085e..285fc97981a84ab32e967d59e61e53190992663c 100644 (file)
@@ -241,20 +241,22 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
        ndo->ndo_protocol = "ip6";
        ip6 = (const struct ip6_hdr *)bp;
 
        ndo->ndo_protocol = "ip6";
        ip6 = (const struct ip6_hdr *)bp;
 
+       if (!ndo->ndo_eflag) {
+               nd_print_protocol_caps(ndo);
+               ND_PRINT(" ");
+       }
+
+       if (IP6_VERSION(ip6) != 6) {
+               ND_PRINT("version error: %u != 6", IP6_VERSION(ip6));
+               return;
+       }
+
        ND_TCHECK_SIZE(ip6);
        if (length < sizeof (struct ip6_hdr)) {
                ND_PRINT("truncated-ip6 %u", length);
                return;
        }
 
        ND_TCHECK_SIZE(ip6);
        if (length < sizeof (struct ip6_hdr)) {
                ND_PRINT("truncated-ip6 %u", length);
                return;
        }
 
-       if (!ndo->ndo_eflag)
-           ND_PRINT("IP6 ");
-
-       if (IP6_VERSION(ip6) != 6) {
-         ND_PRINT("version error: %u != 6", IP6_VERSION(ip6));
-         return;
-       }
-
        payload_len = GET_BE_U_2(ip6->ip6_plen);
        /*
         * RFC 1883 says:
        payload_len = GET_BE_U_2(ip6->ip6_plen);
        /*
         * RFC 1883 says: