]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-bcm-li.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-bcm-li.c
index 0233c3cb8a4b15cb52a6abfb58eef8c0a1e5852d..5ecb9ff94cad5dc90d738c23795c6bc782a866ed 100644 (file)
 
 /* \summary: Broadcom LI Printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
@@ -61,16 +60,17 @@ static const struct tok bcm_li_pkt_subtype_values[] = {
 };
 
 void
-bcm_li_print(netdissect_options *ndo, const u_char *p, u_int length)
+bcm_li_print(netdissect_options *ndo,
+             const u_char *bp, u_int length)
 {
-    u_int shim, direction, pkt_type, pkt_subtype, li_id;
-       const u_char *bp = p;
+       u_int shim, direction, pkt_type, pkt_subtype, li_id;
 
        ndo->ndo_protocol = "bcm_li";
-       if (length < BCM_LI_SHIM_LEN)
-               goto trunc;
-       ND_TCHECK_LEN(p, BCM_LI_SHIM_LEN);
-       shim = GET_BE_U_4(p);
+       if (length < BCM_LI_SHIM_LEN) {
+           ND_PRINT(" (length %u < %u)", length, BCM_LI_SHIM_LEN);
+           goto invalid;
+       }
+       shim = GET_BE_U_4(bp);
 
        direction = (shim >> 29) & 0x7;
        pkt_type = (shim >> 25) & 0xf;
@@ -80,22 +80,22 @@ bcm_li_print(netdissect_options *ndo, const u_char *p, u_int length)
        length -= BCM_LI_SHIM_LEN;
        bp += BCM_LI_SHIM_LEN;
 
-       ND_PRINT("%sBCM-LI-SHIM: direction %s, pkt-type %s, pkt-subtype %s, li-id %u",
+       ND_PRINT("%sBCM-LI-SHIM: direction %s, pkt-type %s, pkt-subtype %s, li-id %u%s",
                 ndo->ndo_vflag ? "\n    " : "",
                 tok2str(bcm_li_direction_values, "unknown", direction),
                 tok2str(bcm_li_pkt_type_values, "unknown", pkt_type),
                 tok2str(bcm_li_pkt_subtype_values, "unknown", pkt_subtype),
-                li_id);
+                li_id,
+                ndo->ndo_vflag ? "\n    ": "");
 
-       if (ndo->ndo_vflag) {
-           ND_PRINT("\n    ");
-       } else {
+       if (!ndo->ndo_vflag) {
+           ND_TCHECK_LEN(bp, length);
            return;
        }
 
        switch (pkt_type) {
        case BCM_LI_PKT_TYPE_ETHERNET:
-           ether_print(ndo, bp, length, length, NULL, NULL);
+           ether_print(ndo, bp, length, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
            break;
        case BCM_LI_PKT_TYPE_IPV4:
            ip_print(ndo, bp, length);
@@ -118,11 +118,11 @@ bcm_li_print(netdissect_options *ndo, const u_char *p, u_int length)
            break;
 
        default:
-           break;
+           goto invalid;
        }
 
        return;
-trunc:
-       nd_print_trunc(ndo);
+invalid:
+       nd_print_invalid(ndo);
 }