X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/e6e6fb6e374479c0a02e04038cbd82a40daaaaec..refs/heads/coverity_scan:/print-ospf.c diff --git a/print-ospf.c b/print-ospf.c index 18eeab96..38f44745 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -23,9 +23,7 @@ /* \summary: Open Shortest Path First (OSPF) printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -36,7 +34,6 @@ #include "ospf.h" - static const struct tok ospf_option_values[] = { { OSPF_OPTION_MT, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */ { OSPF_OPTION_E, "External" }, @@ -131,7 +128,6 @@ static const struct tok ep_range_tlv_prefix_sid_subtlv_flag_values[] = { { 0, NULL} }; - static const struct tok lsa_opaque_ep_route_type_values[] = { { 0, "Unspecified" }, { 1, "Intra-Area" }, @@ -239,7 +235,6 @@ ospf_grace_lsa_print(netdissect_options *ndo, { u_int tlv_type, tlv_length; - while (ls_length != 0) { ND_TCHECK_4(tptr); if (ls_length < 4) { @@ -320,6 +315,7 @@ ospf_grace_lsa_print(netdissect_options *ndo, return 0; trunc: + nd_print_trunc(ndo); return -1; } @@ -329,7 +325,6 @@ ospf_te_tlv_link_print(netdissect_options *ndo, { u_int subtlv_type, subtlv_length; u_int priority_level, te_class, count_srlg; - float bw; while (tlv_length != 0) { if (tlv_length < 4) { @@ -393,8 +388,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo, ND_PRINT(" != 4"); goto invalid; } - bw = GET_BE_F_4(tptr); - ND_PRINT(", %.3f Mbps", bw * 8 / 1000000); + ND_PRINT(", %.3f Mbps", GET_BE_F_4(tptr) * 8 / 1000000); break; case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW: if (subtlv_length != 32) { @@ -402,10 +396,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo, goto invalid; } for (te_class = 0; te_class < 8; te_class++) { - bw = GET_BE_F_4(tptr + te_class * 4); ND_PRINT("\n\t\tTE-Class %u: %.3f Mbps", te_class, - bw * 8 / 1000000); + GET_BE_F_4(tptr + te_class * 4) * 8 / 1000000); } break; case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS: @@ -427,10 +420,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo, } /* decode BCs until the subTLV ends */ for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) { - bw = GET_BE_F_4(tptr + 4 + te_class * 4); ND_PRINT("\n\t\t Bandwidth constraint CT%u: %.3f Mbps", te_class, - bw * 8 / 1000000); + GET_BE_F_4(tptr + 4 + te_class * 4) * 8 / 1000000); } break; case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC: @@ -460,10 +452,9 @@ ospf_te_tlv_link_print(netdissect_options *ndo, ND_PRINT("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:", tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1)))); for (priority_level = 0; priority_level < 8; priority_level++) { - bw = GET_BE_F_4(tptr + 4 + (priority_level * 4)); ND_PRINT("\n\t\t priority level %u: %.3f Mbps", priority_level, - bw * 8 / 1000000); + GET_BE_F_4(tptr + 4 + (priority_level * 4)) * 8 / 1000000); } break; case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE: @@ -483,7 +474,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo, count_srlg = subtlv_length / 4; if (count_srlg != 0) ND_PRINT("\n\t\t Shared risk group: "); - while (count_srlg > 0) { + while (count_srlg != 0) { ND_PRINT("%u", GET_BE_U_4(tptr)); tptr+=4; count_srlg--; @@ -513,6 +504,7 @@ ospf_te_tlv_link_print(netdissect_options *ndo, } return 0; trunc: + nd_print_trunc(ndo); return -1; invalid: nd_print_invalid(ndo); @@ -588,6 +580,7 @@ ospf_te_lsa_print(netdissect_options *ndo, } return 0; trunc: + nd_print_trunc(ndo); return -1; invalid: nd_print_invalid(ndo); @@ -1257,6 +1250,7 @@ ospf_print_lsa(netdissect_options *ndo, return (ls_end); trunc: + nd_print_trunc(ndo); return (NULL); }