X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/921a67c2989e0e4bbdb15f0b35f2f57e11a591ff..f085c93f59fb2332e09f3da20eef5fb2bbd04431:/print-udld.c diff --git a/print-udld.c b/print-udld.c index 0dc10d3c..94c32566 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 @@ -105,14 +106,14 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) ND_TCHECK2(*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), @@ -165,13 +166,13 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length) 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: