]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-slow.c
CMake: Fix the comment about versions. [skip ci]
[tcpdump] / print-slow.c
index 1eb4c96ab907910ae77ceffcd64dffec55dba619..72062d930f2279b47b3f1b25348a8e1466270782 100644 (file)
 
 /* \summary: IEEE "slow protocols" (802.3ad/802.3ah) printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -251,7 +250,6 @@ slow_print(netdissect_options *ndo,
     ndo->ndo_protocol = "slow";
     if (len < 1)
         goto tooshort;
-    ND_TCHECK_1(pptr);
     subtype = GET_U_1(pptr);
 
     /*
@@ -261,7 +259,6 @@ slow_print(netdissect_options *ndo,
     case SLOW_PROTO_LACP:
         if (len < 2)
             goto tooshort;
-        ND_TCHECK_1(pptr + 1);
         if (GET_U_1(pptr + 1) != LACP_VERSION) {
             ND_PRINT("LACP version %u packet not supported",
                      GET_U_1(pptr + 1));
@@ -273,7 +270,6 @@ slow_print(netdissect_options *ndo,
     case SLOW_PROTO_MARKER:
         if (len < 2)
             goto tooshort;
-        ND_TCHECK_1(pptr + 1);
         if (GET_U_1(pptr + 1) != MARKER_VERSION) {
             ND_PRINT("MARKER version %u packet not supported",
                      GET_U_1(pptr + 1));
@@ -339,10 +335,6 @@ tooshort:
         ND_PRINT(" (packet is too short)");
     else
         ND_PRINT("\n\t\t packet is too short");
-    return;
-
-trunc:
-    nd_print_trunc(ndo);
 }
 
 static void
@@ -366,7 +358,6 @@ slow_marker_lacp_print(netdissect_options *ndo,
         if (tlen < sizeof(struct tlv_header_t))
             goto tooshort;
         /* did we capture enough for fully decoding the tlv header ? */
-        ND_TCHECK_LEN(tptr, sizeof(struct tlv_header_t));
         tlv_header = (const struct tlv_header_t *)tptr;
         tlv_type = GET_U_1(tlv_header->type);
         tlv_len = GET_U_1(tlv_header->length);
@@ -389,7 +380,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
         /* length includes the type and length fields */
         if (tlv_len < sizeof(struct tlv_header_t)) {
             ND_PRINT("\n\t    ERROR: illegal length - should be >= %zu",
-                   sizeof(struct tlv_header_t));
+                     sizeof(struct tlv_header_t));
             return;
         }
 
@@ -410,7 +401,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
             if (tlv_tlen !=
                 sizeof(struct lacp_tlv_actor_partner_info_t)) {
                 ND_PRINT("\n\t    ERROR: illegal length - should be %zu",
-                       sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_actor_partner_info_t));
+                         sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_actor_partner_info_t));
                 goto badlength;
             }
 
@@ -418,7 +409,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
 
             ND_PRINT("\n\t  System %s, System Priority %u, Key %u"
                    ", Port %u, Port Priority %u\n\t  State Flags [%s]",
-                   etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
+                   GET_ETHERADDR_STRING(tlv_ptr.lacp_tlv_actor_partner_info->sys),
                    GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
                    GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->key),
                    GET_BE_U_2(tlv_ptr.lacp_tlv_actor_partner_info->port),
@@ -433,7 +424,7 @@ slow_marker_lacp_print(netdissect_options *ndo,
             if (tlv_tlen !=
                 sizeof(struct lacp_tlv_collector_info_t)) {
                 ND_PRINT("\n\t    ERROR: illegal length - should be %zu",
-                       sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_collector_info_t));
+                         sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_collector_info_t));
                 goto badlength;
             }
 
@@ -448,14 +439,14 @@ slow_marker_lacp_print(netdissect_options *ndo,
             if (tlv_tlen !=
                 sizeof(struct marker_tlv_marker_info_t)) {
                 ND_PRINT("\n\t    ERROR: illegal length - should be %zu",
-                       sizeof(struct tlv_header_t) + sizeof(struct marker_tlv_marker_info_t));
+                         sizeof(struct tlv_header_t) + sizeof(struct marker_tlv_marker_info_t));
                 goto badlength;
             }
 
             tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr;
 
             ND_PRINT("\n\t  Request System %s, Request Port %u, Request Transaction ID 0x%08x",
-                   etheraddr_string(ndo, tlv_ptr.marker_tlv_marker_info->req_sys),
+                   GET_ETHERADDR_STRING(tlv_ptr.marker_tlv_marker_info->req_sys),
                    GET_BE_U_2(tlv_ptr.marker_tlv_marker_info->req_port),
                    GET_BE_U_4(tlv_ptr.marker_tlv_marker_info->req_trans_id));
 
@@ -481,10 +472,6 @@ slow_marker_lacp_print(netdissect_options *ndo,
 
 tooshort:
     ND_PRINT("\n\t\t packet is too short");
-    return;
-
-trunc:
-    nd_print_trunc(ndo);
 }
 
 static void
@@ -513,7 +500,7 @@ slow_oam_print(netdissect_options *ndo,
     } ptr;
 
     union {
-       const struct slow_oam_info_t *slow_oam_info;
+        const struct slow_oam_info_t *slow_oam_info;
         const struct slow_oam_link_event_t *slow_oam_link_event;
         const struct slow_oam_variablerequest_t *slow_oam_variablerequest;
         const struct slow_oam_variableresponse_t *slow_oam_variableresponse;
@@ -558,8 +545,8 @@ slow_oam_print(netdissect_options *ndo,
 
             /* length includes the type and length fields */
             if (length < sizeof(struct slow_oam_tlv_header_t)) {
-                ND_PRINT("\n\t    ERROR: illegal length - should be >= %u",
-                       (u_int)sizeof(struct slow_oam_tlv_header_t));
+                ND_PRINT("\n\t    ERROR: illegal length - should be >= %zu",
+                         sizeof(struct slow_oam_tlv_header_t));
                 return;
             }
 
@@ -628,7 +615,6 @@ slow_oam_print(netdissect_options *ndo,
         /* Sequence number */
         if (tlen < 2)
             goto tooshort;
-        ND_TCHECK_2(tptr);
         ND_PRINT("\n\t  Sequence Number %u", GET_BE_U_2(tptr));
         tlen -= 2;
         tptr += 2;
@@ -638,7 +624,6 @@ slow_oam_print(netdissect_options *ndo,
             ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
             if (tlen < sizeof(*ptr.slow_oam_tlv_header))
                 goto tooshort;
-            ND_TCHECK_SIZE(ptr.slow_oam_tlv_header);
             type = GET_U_1(ptr.slow_oam_tlv_header->type);
             length = GET_U_1(ptr.slow_oam_tlv_header->length);
             ND_PRINT("\n\t  %s Link Event Type (%u), length %u",
@@ -657,8 +642,8 @@ slow_oam_print(netdissect_options *ndo,
 
             /* length includes the type and length fields */
             if (length < sizeof(struct slow_oam_tlv_header_t)) {
-                ND_PRINT("\n\t    ERROR: illegal length - should be >= %u",
-                       (u_int)sizeof(struct slow_oam_tlv_header_t));
+                ND_PRINT("\n\t    ERROR: illegal length - should be >= %zu",
+                         sizeof(struct slow_oam_tlv_header_t));
                 return;
             }
 
@@ -677,7 +662,7 @@ slow_oam_print(netdissect_options *ndo,
                 if (GET_U_1(tlv.slow_oam_link_event->event_length) !=
                     sizeof(struct slow_oam_link_event_t)) {
                     ND_PRINT("\n\t    ERROR: illegal length - should be %zu",
-                           sizeof(struct slow_oam_link_event_t));
+                             sizeof(struct slow_oam_link_event_t));
                     hexdump = TRUE;
                     goto badlength_event_notif;
                 }
@@ -720,7 +705,6 @@ slow_oam_print(netdissect_options *ndo,
         tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr;
         if (tlen < sizeof(*tlv.slow_oam_loopbackctrl))
             goto tooshort;
-        ND_TCHECK_SIZE(tlv.slow_oam_loopbackctrl);
         command = GET_U_1(tlv.slow_oam_loopbackctrl->command);
         ND_PRINT("\n\t  Command %s (%u)",
                tok2str(slow_oam_loopbackctrl_cmd_values,
@@ -748,8 +732,4 @@ slow_oam_print(netdissect_options *ndo,
 
 tooshort:
     ND_PRINT("\n\t\t packet is too short");
-    return;
-
-trunc:
-    nd_print_trunc(ndo);
 }