X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9759a5bc71a30159479f85a2d8aceb1f348ef818..1a04b92e365f5ed01ca38619b41bcc4fc9cbd63c:/print-udld.c diff --git a/print-udld.c b/print-udld.c index 22a3487f..0bc71ea8 100644 --- a/print-udld.c +++ b/print-udld.c @@ -12,11 +12,13 @@ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE. * - * UNIDIRECTIONAL LINK DETECTION (UDLD) as per RFC5171 - * * Original code by Carles Kishimoto */ +/* \summary: Cisco UniDirectional Link Detection (UDLD) protocol printer */ + +/* specification: RFC 5171 */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -27,7 +29,6 @@ #include "extract.h" static const char tstr[] = " [|udld]"; -static const char istr[] = " (invalid)"; #define UDLD_HEADER_LEN 4 #define UDLD_DEVICE_ID_TLV 0x0001 @@ -103,16 +104,16 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) tptr = pptr; - ND_TCHECK2(*tptr, UDLD_HEADER_LEN); + ND_TCHECK_LEN(tptr, UDLD_HEADER_LEN); - code = UDLD_EXTRACT_OPCODE(*tptr); + code = UDLD_EXTRACT_OPCODE(EXTRACT_U_1(tptr)); ND_PRINT((ndo, "UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u", - UDLD_EXTRACT_VERSION(*tptr), + UDLD_EXTRACT_VERSION(EXTRACT_U_1(tptr)), tok2str(udld_code_values, "Reserved", code), code, - bittok2str(udld_flags_values, "none", *(tptr+1)), - *(tptr+1), + bittok2str(udld_flags_values, "none", EXTRACT_U_1((tptr + 1))), + EXTRACT_U_1((tptr + 1)), length)); /* @@ -122,15 +123,15 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) return; } - ND_PRINT((ndo, "\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2))); + ND_PRINT((ndo, "\n\tChecksum 0x%04x (unverified)", EXTRACT_BE_U_2(tptr + 2))); tptr += UDLD_HEADER_LEN; while (tptr < (pptr+length)) { - ND_TCHECK2(*tptr, 4); - type = EXTRACT_16BITS(tptr); - len = EXTRACT_16BITS(tptr+2); + ND_TCHECK_4(tptr); + type = EXTRACT_BE_U_2(tptr); + len = EXTRACT_BE_U_2(tptr + 2); ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u", tok2str(udld_tlv_values, "Unknown", type), @@ -146,7 +147,7 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) len -= 4; tptr += 4; - ND_TCHECK2(*tptr, len); + ND_TCHECK_LEN(tptr, len); switch (type) { case UDLD_DEVICE_ID_TLV: @@ -158,20 +159,20 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) case UDLD_ECHO_TLV: ND_PRINT((ndo, ", ")); - fn_printn(ndo, tptr, len, NULL); + (void)fn_printn(ndo, tptr, len, NULL); break; case UDLD_MESSAGE_INTERVAL_TLV: case UDLD_TIMEOUT_INTERVAL_TLV: if (len != 1) goto invalid; - ND_PRINT((ndo, ", %us", (*tptr))); + ND_PRINT((ndo, ", %us", (EXTRACT_U_1(tptr)))); break; case UDLD_SEQ_NUMBER_TLV: if (len != 4) goto invalid; - ND_PRINT((ndo, ", %u", EXTRACT_32BITS(tptr))); + ND_PRINT((ndo, ", %u", EXTRACT_BE_U_4(tptr))); break; default: