X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/582b5862e1402a6f6039f9a951ab8444a31df779..c39d40a767a1ae36171e5bcbf6f157ff3e80fb6c:/print-zep.c diff --git a/print-zep.c b/print-zep.c index d4986106..e10ecb35 100644 --- a/print-zep.c +++ b/print-zep.c @@ -27,6 +27,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" @@ -43,7 +44,6 @@ *********************************************************************** * * ZEP v1 Header will have the following format: - * * |Preamble|Version|Channel ID|Device ID|CRC/LQI Mode|LQI Val|Reserved|Length| * |2 bytes |1 byte | 1 byte | 2 bytes | 1 byte |1 byte |7 bytes |1 byte| * @@ -57,7 +57,6 @@ *------------------------------------------------------------ */ -#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */ #define JAN_1970 2208988800U /* Print timestamp */ @@ -105,29 +104,33 @@ zep_print(netdissect_options *ndo, uint8_t version, inner_len; uint32_t seq_no; - ndo->ndo_protocol ="zep"; + ndo->ndo_protocol = "zep"; nd_print_protocol_caps(ndo); - ND_TCHECK_LEN(bp, 8); - - if (GET_U_1(bp) != 'E' || GET_U_1(bp + 1) != 'X') - goto trunc; + /* Preamble Code (must be "EX") */ + if (GET_U_1(bp) != 'E' || GET_U_1(bp + 1) != 'X') { + ND_PRINT(" [Preamble Code: "); + fn_print_char(ndo, GET_U_1(bp)); + fn_print_char(ndo, GET_U_1(bp + 1)); + ND_PRINT("]"); + nd_print_invalid(ndo); + return; + } version = GET_U_1(bp + 2); - ND_PRINT("v%d ", version); + ND_PRINT("v%u ", version); if (version == 1) { /* ZEP v1 packet. */ - ND_TCHECK_LEN(bp, 16); - ND_PRINT("Channel ID %d, Device ID 0x%04x, ", + ND_PRINT("Channel ID %u, Device ID 0x%04x, ", GET_U_1(bp + 3), GET_BE_U_2(bp + 4)); if (GET_U_1(bp + 6)) ND_PRINT("CRC, "); else - ND_PRINT("LQI %d, ", GET_U_1(bp + 7)); + ND_PRINT("LQI %u, ", GET_U_1(bp + 7)); inner_len = GET_U_1(bp + 15); - ND_PRINT("inner len = %d", inner_len); + ND_PRINT("inner len = %u", inner_len); bp += 16; len -= 16; @@ -136,26 +139,24 @@ zep_print(netdissect_options *ndo, if (GET_U_1(bp + 3) == 2) { /* ZEP v2 ack. */ seq_no = GET_BE_U_4(bp + 4); - ND_PRINT("ACK, seq# = %d", seq_no); + ND_PRINT("ACK, seq# = %u", seq_no); inner_len = 0; bp += 8; len -= 8; } else { /* ZEP v2 data, or some other. */ - ND_TCHECK_LEN(bp, 32); - - ND_PRINT("Type %d, Channel ID %d, Device ID 0x%04x, ", + ND_PRINT("Type %u, Channel ID %u, Device ID 0x%04x, ", GET_U_1(bp + 3), GET_U_1(bp + 4), GET_BE_U_2(bp + 5)); if (GET_U_1(bp + 7)) ND_PRINT("CRC, "); else - ND_PRINT("LQI %d, ", GET_U_1(bp + 8)); + ND_PRINT("LQI %u, ", GET_U_1(bp + 8)); zep_print_ts(ndo, bp + 9); seq_no = GET_BE_U_4(bp + 17); inner_len = GET_U_1(bp + 31); - ND_PRINT(", seq# = %d, inner len = %d", + ND_PRINT(", seq# = %u, inner len = %u", seq_no, inner_len); bp += 32; len -= 32; @@ -166,6 +167,7 @@ zep_print(netdissect_options *ndo, /* Call 802.15.4 dissector. */ ND_PRINT("\n\t"); if (ieee802_15_4_print(ndo, bp, inner_len)) { + ND_TCHECK_LEN(bp, len); bp += len; len = 0; } @@ -173,8 +175,4 @@ zep_print(netdissect_options *ndo, if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(bp, len); - - return; - trunc: - nd_print_trunc(ndo); }