]> The Tcpdump Group git mirrors - tcpdump/commitdiff
GRE: Print the protocol name before any ND_LCHECK_U()/GET_()
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 26 Dec 2021 10:46:22 +0000 (11:46 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 26 Dec 2021 10:55:34 +0000 (11:55 +0100)
This change will print the protocol name even if the length is invalid
or if the packet is truncated at the beginning.
Use nd_print_protocol_caps().

Moreover:
Remove an useless variable.

print-gre.c

index fccff7c5982dd397687a1a42b2b72abf1970913c..a28edf5cd4b4fcd794df1598c9ddb29d7cc4b150 100644 (file)
@@ -79,19 +79,20 @@ static int gre_sre_asn_print(netdissect_options *, uint8_t, uint8_t, const u_cha
 void
 gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
-       u_int len = length, vers;
+       u_int vers;
 
        ndo->ndo_protocol = "gre";
-       ND_LCHECK_U(len, 2);
+       nd_print_protocol_caps(ndo);
+       ND_LCHECK_U(length, 2);
        vers = GET_BE_U_2(bp) & GRE_VERS_MASK;
-       ND_PRINT("GREv%u",vers);
+       ND_PRINT("v%u",vers);
 
        switch(vers) {
        case 0:
-               gre_print_0(ndo, bp, len);
+               gre_print_0(ndo, bp, length);
                break;
        case 1:
-               gre_print_1(ndo, bp, len);
+               gre_print_1(ndo, bp, length);
                break;
        default:
                ND_PRINT(" ERROR: unknown-version");