]> The Tcpdump Group git mirrors - tcpdump/commitdiff
STP: Use more ND_TCHECK_n() macros
authorFrancois-Xavier Le Bail <[email protected]>
Sun, 7 Jan 2018 20:51:55 +0000 (21:51 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 7 Jan 2018 20:51:55 +0000 (21:51 +0100)
print-stp.c

index 78cf1f4a1c31227b4d13954d30ffef9caaa16d6a..01c39edef2acfe529ed5eb5c29c78064bd21a78f 100644 (file)
@@ -106,12 +106,12 @@ stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
 {
     uint8_t bpdu_flags;
 
-    ND_TCHECK(stp_bpdu->flags);
+    ND_TCHECK_1(stp_bpdu->flags);
     bpdu_flags = EXTRACT_U_1(stp_bpdu->flags);
     ND_PRINT(", Flags [%s]",
            bittok2str(stp_bpdu_flag_values, "none", bpdu_flags));
 
-    ND_TCHECK(stp_bpdu->port_id);
+    ND_TCHECK_2(stp_bpdu->port_id);
     ND_PRINT(", bridge-id %s.%04x, length %u",
            stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
            EXTRACT_BE_U_2(stp_bpdu->port_id), length);
@@ -121,7 +121,7 @@ stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
         return 1;
     }
 
-    ND_TCHECK(stp_bpdu->forward_delay);
+    ND_TCHECK_2(stp_bpdu->forward_delay);
     ND_PRINT("\n\tmessage-age %.2fs, max-age %.2fs"
            ", hello-time %.2fs, forwarding-delay %.2fs",
            (float) EXTRACT_BE_U_2(stp_bpdu->message_age) / STP_TIME_BASE,
@@ -252,7 +252,7 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
     u_int          offset;
 
     ptr = (const u_char *)stp_bpdu;
-    ND_TCHECK(stp_bpdu->flags);
+    ND_TCHECK_1(stp_bpdu->flags);
     bpdu_flags = EXTRACT_U_1(stp_bpdu->flags);
     ND_PRINT(", CIST Flags [%s], length %u",
            bittok2str(stp_bpdu_flag_values, "none", bpdu_flags), length);
@@ -268,7 +268,7 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
            tok2str(rstp_obj_port_role_values, "Unknown",
                    RSTP_EXTRACT_PORT_ROLE(bpdu_flags)));
 
-    ND_TCHECK(stp_bpdu->root_path_cost);
+    ND_TCHECK_4(stp_bpdu->root_path_cost);
     ND_PRINT("CIST root-id %s, CIST ext-pathcost %u",
            stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
            EXTRACT_BE_U_4(stp_bpdu->root_path_cost));
@@ -277,10 +277,10 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
     ND_PRINT("\n\tCIST regional-root-id %s, ",
            stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
 
-    ND_TCHECK(stp_bpdu->port_id);
+    ND_TCHECK_2(stp_bpdu->port_id);
     ND_PRINT("CIST port-id %04x,", EXTRACT_BE_U_2(stp_bpdu->port_id));
 
-    ND_TCHECK(stp_bpdu->forward_delay);
+    ND_TCHECK_2(stp_bpdu->forward_delay);
     ND_PRINT("\n\tmessage-age %.2fs, max-age %.2fs"
            ", hello-time %.2fs, forwarding-delay %.2fs",
            (float) EXTRACT_BE_U_2(stp_bpdu->message_age) / STP_TIME_BASE,
@@ -418,13 +418,13 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
     if (length < 4)
         goto trunc;
 
-    ND_TCHECK(stp_bpdu->protocol_id);
+    ND_TCHECK_2(stp_bpdu->protocol_id);
     if (EXTRACT_BE_U_2(stp_bpdu->protocol_id)) {
         ND_PRINT("unknown STP version, length %u", length);
         return;
     }
 
-    ND_TCHECK(stp_bpdu->protocol_version);
+    ND_TCHECK_1(stp_bpdu->protocol_version);
     protocol_version = EXTRACT_U_1(stp_bpdu->protocol_version);
     ND_PRINT("STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
                          protocol_version));
@@ -439,7 +439,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
         return;
     }
 
-    ND_TCHECK(stp_bpdu->bpdu_type);
+    ND_TCHECK_1(stp_bpdu->bpdu_type);
     bpdu_type = EXTRACT_U_1(stp_bpdu->bpdu_type);
     ND_PRINT(", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
                            bpdu_type));
@@ -466,7 +466,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
                 goto trunc;
             }
 
-            ND_TCHECK(stp_bpdu->v1_length);
+            ND_TCHECK_1(stp_bpdu->v1_length);
             if (EXTRACT_U_1(stp_bpdu->v1_length) != 0) {
                 /* FIX ME: Emit a message here ? */
                 goto trunc;