X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ee68aa36460d7efeca48747f33b7f2adc0900bfb..a63600a1fc28dbc7ae7ce9f996829c49a25fb33c:/print-bfd.c diff --git a/print-bfd.c b/print-bfd.c index 941586d7..2db14354 100644 --- a/print-bfd.c +++ b/print-bfd.c @@ -26,6 +26,7 @@ #include "netdissect-stdinc.h" +#define ND_LONGJMP_FROM_TCHECK #include "netdissect.h" #include "extract.h" @@ -142,6 +143,14 @@ static const struct tok bfd_diag_values[] = { { 0, NULL } }; +static const struct tok bfd_port_values[] = { + { BFD_CONTROL_PORT, "Control" }, + { BFD_MULTIHOP_PORT, "Multihop" }, + { BFD_LAG_PORT, "LAG" }, + { SBFD_PORT, "S-BFD" }, + { 0, NULL } +}; + #define BFD_FLAG_AUTH 0x04 static const struct tok bfd_v0_flag_values[] = { @@ -174,7 +183,7 @@ static const struct tok bfd_v1_state_values[] = { { 0, NULL } }; -static int +static void auth_print(netdissect_options *ndo, const u_char *pptr) { const struct bfd_auth_header_t *bfd_auth_header; @@ -214,9 +223,7 @@ auth_print(netdissect_options *ndo, const u_char *pptr) pptr++; ND_PRINT(", Password: "); /* the length is equal to the password length plus three */ - if (nd_printn(ndo, pptr, auth_len - 3, - ndo->ndo_snapend)) - goto trunc; + nd_printjn(ndo, pptr, auth_len - 3); break; case AUTH_MD5: case AUTH_MET_MD5: @@ -241,7 +248,6 @@ auth_print(netdissect_options *ndo, const u_char *pptr) break; } pptr += 2; - ND_TCHECK_4(pptr); ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr)); pptr += 4; ND_TCHECK_LEN(pptr, AUTH_MD5_HASH_LEN); @@ -272,7 +278,6 @@ auth_print(netdissect_options *ndo, const u_char *pptr) break; } pptr += 2; - ND_TCHECK_4(pptr); ND_PRINT(", Sequence Number: 0x%08x", GET_BE_U_4(pptr)); pptr += 4; ND_TCHECK_LEN(pptr, AUTH_SHA1_HASH_LEN); @@ -281,10 +286,6 @@ auth_print(netdissect_options *ndo, const u_char *pptr) ND_PRINT("%02x", GET_U_1(pptr + i)); break; } - return 0; - -trunc: - return 1; } void @@ -292,7 +293,10 @@ bfd_print(netdissect_options *ndo, const u_char *pptr, u_int len, u_int port) { ndo->ndo_protocol = "bfd"; - if (port == BFD_CONTROL_PORT) { + if (port == BFD_CONTROL_PORT || + port == BFD_MULTIHOP_PORT || + port == BFD_LAG_PORT || + port == SBFD_PORT) { /* * Control packet. */ @@ -311,8 +315,7 @@ bfd_print(netdissect_options *ndo, const u_char *pptr, /* BFDv0 */ case 0: - if (ndo->ndo_vflag < 1) - { + if (ndo->ndo_vflag < 1) { ND_PRINT("BFDv0, Control, Flags: [%s], length: %u", bittok2str(bfd_v0_flag_values, "none", flags), len); @@ -343,24 +346,24 @@ bfd_print(netdissect_options *ndo, const u_char *pptr, GET_BE_U_4(bfd_header->required_min_echo_interval)/1000); if (flags & BFD_FLAG_AUTH) { - if (auth_print(ndo, pptr)) - goto trunc; + auth_print(ndo, pptr); } break; /* BFDv1 */ case 1: - if (ndo->ndo_vflag < 1) - { - ND_PRINT("BFDv1, Control, State %s, Flags: [%s], length: %u", + if (ndo->ndo_vflag < 1) { + ND_PRINT("BFDv1, %s, State %s, Flags: [%s], length: %u", + tok2str(bfd_port_values, "unknown (%u)", port), tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6), bittok2str(bfd_v1_flag_values, "none", flags & 0x3f), len); return; } - ND_PRINT("BFDv1, length: %u\n\tControl, State %s, Flags: [%s], Diagnostic: %s (0x%02x)", + ND_PRINT("BFDv1, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)", len, + tok2str(bfd_port_values, "unknown (%u)", port), tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6), bittok2str(bfd_v1_flag_values, "none", flags & 0x3f), tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)), @@ -384,8 +387,7 @@ bfd_print(netdissect_options *ndo, const u_char *pptr, GET_BE_U_4(bfd_header->required_min_echo_interval)/1000); if (flags & BFD_FLAG_AUTH) { - if (auth_print(ndo, pptr)) - goto trunc; + auth_print(ndo, pptr); } break; @@ -421,8 +423,4 @@ bfd_print(netdissect_options *ndo, const u_char *pptr, return; } } - return; - -trunc: - nd_print_trunc(ndo); }