]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zeromq.c
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[tcpdump] / print-zeromq.c
index cfab5878b64a80e7d86f7a93236ee6142caaa8a2..820104758a2b27148c2bc6cfbdf259d26487dfc8 100644 (file)
  */
 
 /* \summary: ZeroMQ Message Transport Protocol (ZMTP) printer */
+/* specification: https://rfc.zeromq.org/spec/13/ */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
  */
 #define VBYTES 128
 
+static const struct tok flags_bm[] = {
+       { 0x01, "MORE"  },
+       { 0x02, "R1" },
+       { 0x04, "R2" },
+       { 0x08, "R3" },
+       { 0x10, "R4" },
+       { 0x20, "R5" },
+       { 0x40, "R6" },
+       { 0x80, "R7" },
+       { 0, NULL }
+};
+
 /*
  * Below is an excerpt from the "13/ZMTP" specification:
  *
@@ -79,9 +90,8 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
        uint8_t flags;
 
        ND_PRINT("\n\t");
-       ND_TCHECK_1(cp); /* length/0xFF */
 
-       if (GET_U_1(cp) != 0xFF) {
+       if (GET_U_1(cp) != 0xFF) {      /* length/0xFF */
                header_len = 1; /* length */
                body_len_declared = GET_U_1(cp);
                ND_PRINT(" frame flags+body  (8-bit) length %" PRIu64, body_len_declared);
@@ -105,16 +115,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
        if (ndo->ndo_vflag) {
                uint64_t body_len_printed = ND_MIN(body_len_captured, body_len_declared);
 
-               ND_PRINT(" (%s|%s|%s|%s|%s|%s|%s|%s)",
-                       flags & 0x80 ? "MBZ" : "-",
-                       flags & 0x40 ? "MBZ" : "-",
-                       flags & 0x20 ? "MBZ" : "-",
-                       flags & 0x10 ? "MBZ" : "-",
-                       flags & 0x08 ? "MBZ" : "-",
-                       flags & 0x04 ? "MBZ" : "-",
-                       flags & 0x02 ? "MBZ" : "-",
-                       flags & 0x01 ? "MORE" : "-");
-
+               ND_PRINT(" (%s)", bittok2str(flags_bm, "none", flags));
                if (ndo->ndo_vflag == 1)
                        body_len_printed = ND_MIN(VBYTES + 1, body_len_printed);
                if (body_len_printed > 1) {
@@ -134,8 +135,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
        return cp + body_len_declared;
 
 trunc:
-       nd_print_trunc(ndo);
-       return ep;
+       nd_trunc_longjmp(ndo);
 }
 
 void
@@ -171,7 +171,6 @@ zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u
        u_int frame_offset;
        u_int remaining_len;
 
-       ND_TCHECK_2(cp);
        frame_offset = GET_BE_U_2(cp);
        ND_PRINT("\n\t frame offset 0x%04x", frame_offset);
        cp += 2;
@@ -203,8 +202,7 @@ zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u
        return cp + frame_offset;
 
 trunc:
-       nd_print_trunc(ndo);
-       return cp + len;
+       nd_trunc_longjmp(ndo);
 }
 
 void