X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/436ced3bd83f6b3a5b4a206538c56189837add59..e01c9bf76740802025c9328901b55ee4a0c49ed6:/print-ospf.c diff --git a/print-ospf.c b/print-ospf.c index e8aa26ce..4c09912a 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -21,6 +21,8 @@ * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ +/* \summary: Open Shortest Path First (OSPF) printer */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -566,16 +568,16 @@ trunc: /* draft-ietf-ospf-mt-09 */ static const struct tok ospf_topology_values[] = { - { 0, "default " }, - { 1, "multicast " }, - { 2, "management " }, + { 0, "default" }, + { 1, "multicast" }, + { 2, "management" }, { 0, NULL } }; /* * Print all the per-topology metrics. */ -static void +static int ospf_print_tos_metrics(netdissect_options *ndo, const union un_tos *tos) { @@ -588,9 +590,10 @@ ospf_print_tos_metrics(netdissect_options *ndo, /* * All but the first metric contain a valid topology id. */ - while (toscount) { - ND_PRINT((ndo, "\n\t\ttopology %s(%u), metric %u", - tok2str(ospf_topology_values, "", + while (toscount > 0) { + ND_TCHECK(*tos); + ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u", + tok2str(ospf_topology_values, "Unknown", metric_count ? tos->metrics.tos_type : 0), metric_count ? tos->metrics.tos_type : 0, EXTRACT_16BITS(&tos->metrics.tos_metric))); @@ -598,6 +601,9 @@ ospf_print_tos_metrics(netdissect_options *ndo, tos++; toscount--; } + return 0; +trunc: + return 1; } /* @@ -671,7 +677,8 @@ ospf_print_lsa(netdissect_options *ndo, return (ls_end); } - ospf_print_tos_metrics(ndo, &rlp->un_tos); + if (ospf_print_tos_metrics(ndo, &rlp->un_tos)) + goto trunc; rlp = (const struct rlalink *)((const u_char *)(rlp + 1) + ((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos))); @@ -699,11 +706,11 @@ ospf_print_lsa(netdissect_options *ndo, while ((const u_char *)lp < ls_end) { register uint32_t ul; - ND_TCHECK(*lp); + ND_TCHECK_32BITS(lp); ul = EXTRACT_32BITS(lp); topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; - ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d", - tok2str(ospf_topology_values, "", topology), + ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d", + tok2str(ospf_topology_values, "Unknown", topology), topology, ul & SLA_MASK_METRIC)); ++lp; @@ -716,11 +723,11 @@ ospf_print_lsa(netdissect_options *ndo, while ((const u_char *)lp < ls_end) { register uint32_t ul; - ND_TCHECK(*lp); + ND_TCHECK_32BITS(lp); ul = EXTRACT_32BITS(lp); topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS; - ND_PRINT((ndo, "\n\t\ttopology %s(%u) metric %d", - tok2str(ospf_topology_values, "", topology), + ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d", + tok2str(ospf_topology_values, "Unknown", topology), topology, ul & SLA_MASK_METRIC)); ++lp; @@ -741,8 +748,8 @@ ospf_print_lsa(netdissect_options *ndo, ND_TCHECK(almp->asla_tosmetric); ul = EXTRACT_32BITS(&almp->asla_tosmetric); topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS); - ND_PRINT((ndo, "\n\t\ttopology %s(%u), type %d, metric", - tok2str(ospf_topology_values, "", topology), + ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric", + tok2str(ospf_topology_values, "Unknown", topology), topology, (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1)); if ((ul & ASLA_MASK_METRIC) == 0xffffff) @@ -989,6 +996,7 @@ ospf_decode_v2(netdissect_options *ndo, break; case OSPF_TYPE_HELLO: + ND_TCHECK(op->ospf_hello.hello_options); ND_PRINT((ndo, "\n\tOptions [%s]", bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));