X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/6ec714988caac3bf9fedc766ae51a2248896ec80..c0af6af3011d4c55bdadf3dd76cd5fc1115c50d0:/print-resp.c diff --git a/print-resp.c b/print-resp.c index 1d24b58e..6529c745 100644 --- a/print-resp.c +++ b/print-resp.c @@ -30,10 +30,10 @@ /* \summary: REdis Serialization Protocol (RESP) printer */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif -#include +#include "netdissect-stdinc.h" #include "netdissect.h" #include #include @@ -42,7 +42,6 @@ #include "extract.h" -static const char tstr[] = " [|RESP]"; /* * For information regarding RESP, see: http://redis.io/topics/protocol @@ -54,11 +53,11 @@ static const char tstr[] = " [|RESP]"; #define RESP_BULK_STRING '$' #define RESP_ARRAY '*' -#define resp_print_empty(ndo) ND_PRINT((ndo, " empty")) -#define resp_print_null(ndo) ND_PRINT((ndo, " null")) -#define resp_print_length_too_large(ndo) ND_PRINT((ndo, " length too large")) -#define resp_print_length_negative(ndo) ND_PRINT((ndo, " length negative and not -1")) -#define resp_print_invalid(ndo) ND_PRINT((ndo, " invalid")) +#define resp_print_empty(ndo) ND_PRINT(" empty") +#define resp_print_null(ndo) ND_PRINT(" null") +#define resp_print_length_too_large(ndo) ND_PRINT(" length too large") +#define resp_print_length_negative(ndo) ND_PRINT(" length negative and not -1") +#define resp_print_invalid(ndo) ND_PRINT(" invalid") void resp_print(netdissect_options *, const u_char *, u_int); static int resp_parse(netdissect_options *, const u_char *, int); @@ -116,7 +115,7 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch #define FIND_CR_OR_LF(_ptr, _len) \ for (;;) { \ LCHECK(_len); \ - ND_TCHECK(*_ptr); \ + ND_TCHECK_1(_ptr); \ if (*_ptr == '\r' || *_ptr == '\n') \ break; \ _ptr++; \ @@ -136,7 +135,7 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch /* \ * Have we hit the end of data? \ */ \ - if (_len == 0 || !ND_TTEST(*_ptr)) { \ + if (_len == 0 || !ND_TTEST_1(_ptr)) {\ /* \ * Yes. Have we seen a \r \ * or \n? \ @@ -204,8 +203,8 @@ static int resp_get_length(netdissect_options *, const u_char *, int, const u_ch * Assumes the data has already been verified as present. */ #define RESP_PRINT_SEGMENT(_ndo, _bp, _len) \ - ND_PRINT((_ndo, " \"")); \ - if (fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \ + ND_PRINT(" \""); \ + if (nd_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \ goto trunc; \ fn_print_char(_ndo, '"'); @@ -214,10 +213,11 @@ resp_print(netdissect_options *ndo, const u_char *bp, u_int length) { int ret_len = 0, length_cur = length; + ndo->ndo_protocol = "resp"; if(!bp || length <= 0) return; - ND_PRINT((ndo, ": RESP")); + ND_PRINT(": RESP"); while (length_cur > 0) { /* * This block supports redis pipelining. @@ -237,7 +237,7 @@ resp_print(netdissect_options *ndo, const u_char *bp, u_int length) return; trunc: - ND_PRINT((ndo, "%s", tstr)); + nd_print_trunc(ndo); } static int @@ -434,7 +434,7 @@ resp_print_inline(netdissect_options *ndo, const u_char *bp, int length) { /* * Found it; bp_ptr points to the \r or \n, so bp_ptr - bp is the - * Length of the line text that preceeds it. Print it. + * Length of the line text that precedes it. Print it. */ len = (bp_ptr - bp); RESP_PRINT_SEGMENT(ndo, bp, len);