X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9a6a6502413e657277e74ac1d0842ddca34cab50..a36b3aeb877e4357918cfd99ddad5ce913a3a0b6:/print-zephyr.c diff --git a/print-zephyr.c b/print-zephyr.c index b0f8cd31..aa552aaa 100644 --- a/print-zephyr.c +++ b/print-zephyr.c @@ -35,6 +35,7 @@ #include "netdissect-ctype.h" #include "netdissect.h" +#include "extract.h" struct z_packet { const char *version; @@ -85,7 +86,7 @@ static const struct tok z_types[] = { static char z_buf[256]; static const char * -parse_field(netdissect_options *ndo, const char **pptr, int *len, int *truncated) +parse_field(netdissect_options *ndo, const char **pptr, int *len) { const char *s; @@ -97,12 +98,7 @@ parse_field(netdissect_options *ndo, const char **pptr, int *len, int *truncated /* Ran out of packet data without finding it */ return NULL; } - if (!ND_TTEST_SIZE(*pptr)) { - /* Ran out of captured data without finding it */ - *truncated = 1; - return NULL; - } - if (**pptr == '\0') { + if (GET_U_1(*pptr) == '\0') { /* Found it */ break; } @@ -144,7 +140,7 @@ str_to_lower(const char *string) } void -zephyr_print(netdissect_options *ndo, const u_char *cp, int length) +zephyr_print(netdissect_options *ndo, const u_char *cp, u_int length) { struct z_packet z = { NULL, /* version */ @@ -169,14 +165,12 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length) int parselen = length; const char *s; int lose = 0; - int truncated = 0; ndo->ndo_protocol = "zephyr"; /* squelch compiler warnings */ #define PARSE_STRING \ - s = parse_field(ndo, &parse, &parselen, &truncated); \ - if (truncated) goto trunc; \ + s = parse_field(ndo, &parse, &parselen); \ if (!s) lose = 1; #define PARSE_FIELD_INT(field) \ @@ -188,7 +182,9 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length) if (!lose) field = s; PARSE_FIELD_STR(z.version); - if (lose) return; + if (lose) + goto invalid; + if (strncmp(z.version, "ZEPH", 4)) return; @@ -210,7 +206,7 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length) PARSE_FIELD_STR(z.multi_uid); if (lose) - goto trunc; + goto invalid; ND_PRINT(" zephyr"); if (strncmp(z.version+4, "0.2", 3)) { @@ -344,7 +340,6 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length) ND_PRINT(" op %s", z.opcode); return; -trunc: - nd_print_trunc(ndo); - return; +invalid: + nd_print_invalid(ndo); }