X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3b8ff4bf0d8f389e00c19d6c094bce2bbf00deca..refs/pull/1034/head:/print-isoclns.c diff --git a/print-isoclns.c b/print-isoclns.c index e842a008..9ce2dfd1 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -1022,8 +1022,6 @@ clnp_print(netdissect_options *ndo, } if (source_address_length > 0) { source_address=(tptr+1); - ND_TCHECK_LEN(source_address, - source_address_length); ND_PRINT("\n\t NSAP address (length %u): %s", source_address_length, GET_ISONSAP_STRING(source_address, source_address_length)); @@ -1300,7 +1298,7 @@ esis_print(netdissect_options *ndo, pptr += netal; li -= netal; - if (snpal == 6) + if (snpal == MAC_ADDR_LEN) ND_PRINT("\n\t SNPA (length: %u): %s", snpal, GET_ETHERADDR_STRING(snpa)); @@ -1467,8 +1465,7 @@ isis_print_mcid(netdissect_options *ndo, ND_TCHECK_SIZE(mcid); ND_PRINT("ID: %u, Name: ", GET_U_1(mcid->format_id)); - if (nd_printzp(ndo, mcid->name, 32, ndo->ndo_snapend)) - goto trunc; + nd_printjnp(ndo, mcid->name, sizeof(mcid->name)); ND_PRINT("\n\t Lvl: %u", GET_BE_U_2(mcid->revision_lvl)); @@ -1805,7 +1802,7 @@ isis_print_metric_block(netdissect_options *ndo, static int isis_print_tlv_ip_reach(netdissect_options *ndo, - const uint8_t *cp, const char *ident, u_int length) + const uint8_t *cp, const char *indent, u_int length) { int prefix_len; const struct isis_tlv_ip_reach *tlv_ip_reach; @@ -1826,12 +1823,12 @@ isis_print_tlv_ip_reach(netdissect_options *ndo, if (prefix_len == -1) ND_PRINT("%sIPv4 prefix: %s mask %s", - ident, + indent, GET_IPADDR_STRING(tlv_ip_reach->prefix), GET_IPADDR_STRING(tlv_ip_reach->mask)); else ND_PRINT("%sIPv4 prefix: %15s/%u", - ident, + indent, GET_IPADDR_STRING(tlv_ip_reach->prefix), prefix_len); @@ -1842,19 +1839,19 @@ isis_print_tlv_ip_reach(netdissect_options *ndo, if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay)) ND_PRINT("%s Delay Metric: %u, %s", - ident, + indent, ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense)) ND_PRINT("%s Expense Metric: %u, %s", - ident, + indent, ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"); if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error)) ND_PRINT("%s Error Metric: %u, %s", - ident, + indent, ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error), ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"); @@ -1874,11 +1871,11 @@ trunc: static int isis_print_ip_reach_subtlv(netdissect_options *ndo, const uint8_t *tptr, u_int subt, u_int subl, - const char *ident) + const char *indent) { /* first lets see if we know the subTLVs name*/ ND_PRINT("%s%s subTLV #%u, length: %u", - ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt), + indent, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt), subt, subl); ND_TCHECK_LEN(tptr, subl); @@ -1951,10 +1948,10 @@ trunc: static int isis_print_ext_is_reach(netdissect_options *ndo, - const uint8_t *tptr, const char *ident, u_int tlv_type, + const uint8_t *tptr, const char *indent, u_int tlv_type, u_int tlv_remaining) { - char ident_buffer[20]; + char indent_buffer[20]; u_int subtlv_type,subtlv_len,subtlv_sum_len; int proc_bytes = 0; /* how many bytes did we process ? */ u_int te_class,priority_level,gmpls_switch_cap; @@ -1967,7 +1964,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (tlv_remaining < NODE_ID_LEN) return(0); - ND_PRINT("%sIS Neighbor: %s", ident, isis_print_id(ndo, tptr, NODE_ID_LEN)); + ND_PRINT("%sIS Neighbor: %s", indent, isis_print_id(ndo, tptr, NODE_ID_LEN)); tptr+=NODE_ID_LEN; tlv_remaining-=NODE_ID_LEN; proc_bytes+=NODE_ID_LEN; @@ -1993,17 +1990,17 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (subtlv_sum_len) { ND_PRINT(" (%u)", subtlv_sum_len); /* prepend the indent string */ - snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); - ident = ident_buffer; + snprintf(indent_buffer, sizeof(indent_buffer), "%s ", indent); + indent = indent_buffer; while (subtlv_sum_len != 0) { ND_TCHECK_2(tptr); if (tlv_remaining < 2) { - ND_PRINT("%sRemaining data in TLV shorter than a subTLV header",ident); + ND_PRINT("%sRemaining data in TLV shorter than a subTLV header", indent); proc_bytes += tlv_remaining; break; } if (subtlv_sum_len < 2) { - ND_PRINT("%sRemaining data in subTLVs shorter than a subTLV header",ident); + ND_PRINT("%sRemaining data in subTLVs shorter than a subTLV header", indent); proc_bytes += subtlv_sum_len; break; } @@ -2014,7 +2011,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, subtlv_sum_len -= 2; proc_bytes += 2; ND_PRINT("%s%s subTLV #%u, length: %u", - ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subtlv_type), + indent, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subtlv_type), subtlv_type, subtlv_len); if (subtlv_sum_len < subtlv_len) { @@ -2058,7 +2055,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, for (te_class = 0; te_class < 8; te_class++) { bw.i = GET_BE_U_4(tptr); ND_PRINT("%s TE-Class %u: %.3f Mbps", - ident, + indent, te_class, bw.f * 8 / 1000000); tptr += 4; @@ -2073,7 +2070,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (subtlv_len == 0) break; ND_PRINT("%sBandwidth Constraints Model ID: %s (%u)", - ident, + indent, tok2str(diffserv_te_bc_values, "unknown", GET_U_1(tptr)), GET_U_1(tptr)); tptr++; @@ -2086,7 +2083,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, break; bw.i = GET_BE_U_4(tptr); ND_PRINT("%s Bandwidth constraint CT%u: %.3f Mbps", - ident, + indent, te_class, bw.f * 8 / 1000000); tptr += 4; @@ -2134,7 +2131,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (subtlv_len >= 36) { gmpls_switch_cap = GET_U_1(tptr); ND_PRINT("%s Interface Switching Capability:%s", - ident, + indent, tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)); ND_PRINT(", LSP Encoding: %s", tok2str(gmpls_encoding_values, "Unknown", GET_U_1((tptr + 1)))); @@ -2142,11 +2139,11 @@ isis_print_ext_is_reach(netdissect_options *ndo, subtlv_len -= 4; subtlv_sum_len -= 4; proc_bytes += 4; - ND_PRINT("%s Max LSP Bandwidth:", ident); + ND_PRINT("%s Max LSP Bandwidth:", indent); for (priority_level = 0; priority_level < 8; priority_level++) { bw.i = GET_BE_U_4(tptr); ND_PRINT("%s priority level %u: %.3f Mbps", - ident, + indent, priority_level, bw.f * 8 / 1000000); tptr += 4; @@ -2162,16 +2159,16 @@ isis_print_ext_is_reach(netdissect_options *ndo, if (subtlv_len < 6) break; bw.i = GET_BE_U_4(tptr); - ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000); - ND_PRINT("%s Interface MTU: %u", ident, + ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", indent, bw.f * 8 / 1000000); + ND_PRINT("%s Interface MTU: %u", indent, GET_BE_U_2(tptr + 4)); break; case GMPLS_TSC: if (subtlv_len < 8) break; bw.i = GET_BE_U_4(tptr); - ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000); - ND_PRINT("%s Indication %s", ident, + ND_PRINT("%s Min LSP Bandwidth: %.3f Mbps", indent, bw.f * 8 / 1000000); + ND_PRINT("%s Indication %s", indent, tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", GET_U_1((tptr + 4)))); break; default: @@ -2186,7 +2183,7 @@ isis_print_ext_is_reach(netdissect_options *ndo, break; case ISIS_SUBTLV_EXT_IS_REACH_LAN_ADJ_SEGMENT_ID: if (subtlv_len >= 8) { - ND_PRINT("%s Flags: [%s]", ident, + ND_PRINT("%s Flags: [%s]", indent, bittok2str(isis_lan_adj_sid_flag_values, "none", GET_U_1(tptr))); @@ -2196,14 +2193,14 @@ isis_print_ext_is_reach(netdissect_options *ndo, subtlv_len--; subtlv_sum_len--; proc_bytes++; - ND_PRINT("%s Weight: %u", ident, GET_U_1(tptr)); + ND_PRINT("%s Weight: %u", indent, GET_U_1(tptr)); tptr++; subtlv_len--; subtlv_sum_len--; proc_bytes++; if(subtlv_len>=SYSTEM_ID_LEN) { ND_TCHECK_LEN(tptr, SYSTEM_ID_LEN); - ND_PRINT("%s Neighbor System-ID: %s", ident, + ND_PRINT("%s Neighbor System-ID: %s", indent, isis_print_id(ndo, tptr, SYSTEM_ID_LEN)); } /* RFC 8667 section 2.2.2 */ @@ -2211,10 +2208,10 @@ isis_print_ext_is_reach(netdissect_options *ndo, /* if V-flag is set to 0 and L-flag is set to 0 ==> 4 octet index */ if (vflag && lflag) { ND_PRINT("%s Label: %u", - ident, GET_BE_U_3(tptr+SYSTEM_ID_LEN)); + indent, GET_BE_U_3(tptr+SYSTEM_ID_LEN)); } else if ((!vflag) && (!lflag)) { ND_PRINT("%s Index: %u", - ident, GET_BE_U_4(tptr+SYSTEM_ID_LEN)); + indent, GET_BE_U_4(tptr+SYSTEM_ID_LEN)); } else nd_print_invalid(ndo); } @@ -2244,13 +2241,13 @@ trunc: static uint8_t isis_print_mtid(netdissect_options *ndo, - const uint8_t *tptr, const char *ident, u_int tlv_remaining) + const uint8_t *tptr, const char *indent, u_int tlv_remaining) { if (tlv_remaining < 2) goto trunc; ND_PRINT("%s%s", - ident, + indent, tok2str(isis_mt_values, "Reserved for IETF Consensus", ISIS_MASK_MTID(GET_BE_U_2(tptr)))); @@ -2273,9 +2270,9 @@ trunc: static u_int isis_print_extd_ip_reach(netdissect_options *ndo, - const uint8_t *tptr, const char *ident, uint16_t afi) + const uint8_t *tptr, const char *indent, uint16_t afi) { - char ident_buffer[20]; + char indent_buffer[20]; uint8_t prefix[sizeof(nd_ipv6)]; /* shared copy buffer for IPv4 and IPv6 prefixes */ u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen; @@ -2289,7 +2286,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo, bit_length = status_byte&0x3f; if (bit_length > 32) { ND_PRINT("%sIPv4 prefix: bad bit length %u", - ident, + indent, bit_length); return (0); } @@ -2299,7 +2296,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo, bit_length=GET_U_1(tptr + 1); if (bit_length > 128) { ND_PRINT("%sIPv6 prefix: bad bit length %u", - ident, + indent, bit_length); return (0); } @@ -2310,20 +2307,19 @@ isis_print_extd_ip_reach(netdissect_options *ndo, byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */ - ND_TCHECK_LEN(tptr, byte_length); memset(prefix, 0, sizeof(prefix)); /* clear the copy buffer */ - memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ + GET_CPY_BYTES(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */ tptr+=byte_length; processed+=byte_length; if (afi == AF_INET) ND_PRINT("%sIPv4 prefix: %15s/%u", - ident, + indent, ipaddr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IPADDR_STRING() */ bit_length); else if (afi == AF_INET6) ND_PRINT("%sIPv6 prefix: %s/%u", - ident, + indent, ip6addr_string(ndo, prefix), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */ bit_length); @@ -2355,16 +2351,14 @@ isis_print_extd_ip_reach(netdissect_options *ndo, subtlvlen=GET_U_1(tptr + 1); tptr+=2; /* prepend the indent string */ - snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident); - if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer)) + snprintf(indent_buffer, sizeof(indent_buffer), "%s ", indent); + if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, indent_buffer)) return(0); tptr+=subtlvlen; sublen-=(subtlvlen+2); } } return (processed); -trunc: - return 0; } static void @@ -2891,7 +2885,6 @@ isis_print(netdissect_options *ndo, tlen--; if (tlen < alen) goto tlv_trunc; - ND_TCHECK_LEN(tptr, alen); ND_PRINT("\n\t Area address (length: %u): %s", alen, GET_ISONSAP_STRING(tptr, alen)); @@ -3123,8 +3116,7 @@ isis_print(netdissect_options *ndo, switch (auth_type) { case ISIS_SUBTLV_AUTH_SIMPLE: - if (nd_printzp(ndo, tptr, tlen, ndo->ndo_snapend)) - goto trunc; + nd_printjnp(ndo, tptr, tlen); break; case ISIS_SUBTLV_AUTH_MD5: for(i=0;indo_snapend)) - goto trunc; + nd_printjnp(ndo, tptr, tlen); break; case ISIS_TLV_SHARED_RISK_GROUP: @@ -3459,7 +3450,6 @@ isis_print(netdissect_options *ndo, } if (tlen < prefix_len/2) break; - ND_TCHECK_LEN(tptr, prefix_len / 2); ND_PRINT("\n\t\tAddress: %s/%u", GET_ISONSAP_STRING(tptr, prefix_len / 2), prefix_len * 4); tptr+=prefix_len/2;