#include <string.h>
#include <stdlib.h>
+#include "netdissect-ctype.h"
+
#include "netdissect.h"
+#include "extract.h"
struct z_packet {
const char *version;
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;
/* 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;
}
zb_string = z_buf;
while (*zb_string) {
- *zb_string = ND_TOLOWER((unsigned char)(*zb_string));
+ *zb_string = ND_ASCII_TOLOWER(*zb_string);
zb_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 */
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) \
if (!lose) field = s;
PARSE_FIELD_STR(z.version);
- if (lose) return;
+ if (lose)
+ goto invalid;
+
if (strncmp(z.version, "ZEPH", 4))
return;
PARSE_FIELD_STR(z.multi_uid);
if (lose)
- goto trunc;
+ goto invalid;
ND_PRINT(" zephyr");
if (strncmp(z.version+4, "0.2", 3)) {
ND_PRINT(" op %s", z.opcode);
return;
-trunc:
- nd_print_trunc(ndo);
- return;
+invalid:
+ nd_print_invalid(ndo);
}