/* \summary: REdis Serialization Protocol (RESP) printer */
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
#include "netdissect.h"
#include <limits.h>
#include <string.h>
#include "extract.h"
-static const char tstr[] = " [|RESP]";
/*
* For information regarding RESP, see: http://redis.io/topics/protocol
/* \
* 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? \
*/
#define RESP_PRINT_SEGMENT(_ndo, _bp, _len) \
ND_PRINT(" \""); \
- if (fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
+ if (nd_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
goto trunc; \
fn_print_char(_ndo, '"');
{
int ret_len = 0, length_cur = length;
+ ndo->ndo_protocol = "resp";
if(!bp || length <= 0)
return;
return;
trunc:
- ND_PRINT("%s", tstr);
+ nd_print_trunc(ndo);
}
static int
LCHECK2(length, 1);
ND_TCHECK_1(bp);
- op = EXTRACT_U_1(bp);
+ op = GET_U_1(bp);
/* bp now points to the op, so these routines must skip it */
switch(op) {
/*
* 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);
ND_TCHECK_1(bp);
too_large = 0;
neg = 0;
- if (EXTRACT_U_1(bp) == '-') {
+ if (GET_U_1(bp) == '-') {
neg = 1;
bp++;
len--;
if (len == 0)
goto trunc;
ND_TCHECK_1(bp);
- c = EXTRACT_U_1(bp);
+ c = GET_U_1(bp);
if (!(c >= '0' && c <= '9')) {
if (!saw_digit) {
bp++;
* OK, we found a non-digit character. It should be a \r, followed
* by a \n.
*/
- if (EXTRACT_U_1(bp) != '\r') {
+ if (GET_U_1(bp) != '\r') {
bp++;
goto invalid;
}
if (len == 0)
goto trunc;
ND_TCHECK_1(bp);
- if (EXTRACT_U_1(bp) != '\n') {
+ if (GET_U_1(bp) != '\n') {
bp++;
goto invalid;
}