X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/968776fbf5cd65c7ea2168912bd9f4379727eb11..2d02497b02b040bd885825dba9230f86a8ffce0e:/print-stp.c diff --git a/print-stp.c b/print-stp.c index 953715b6..ee0627ca 100644 --- a/print-stp.c +++ b/print-stp.c @@ -235,7 +235,6 @@ trunc: #define SPB_BPDU_AGREEMENT_RES2_OFFSET SPB_BPDU_AGREEMENT_RES1_OFFSET + 4 #define SPB_BPDU_AGREEMENT_DIGEST_OFFSET SPB_BPDU_AGREEMENT_RES2_OFFSET + 4 - static int stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, u_int length) @@ -257,12 +256,13 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, return 1; } + ND_TCHECK(stp_bpdu->flags); ND_PRINT((ndo, "\n\tport-role %s, ", tok2str(rstp_obj_port_role_values, "Unknown", RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)))); ND_TCHECK(stp_bpdu->root_path_cost); - ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u ", + ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u", stp_print_bridge_id((const u_char *)&stp_bpdu->root_id), EXTRACT_32BITS(&stp_bpdu->root_path_cost))); @@ -271,7 +271,7 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id))); ND_TCHECK(stp_bpdu->port_id); - ND_PRINT((ndo, "CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id))); + ND_PRINT((ndo, "CIST port-id %04x,", EXTRACT_16BITS(&stp_bpdu->port_id))); ND_TCHECK(stp_bpdu->forward_delay); ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs" @@ -284,17 +284,19 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET); ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET))); ND_TCHECK_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12); - ND_PRINT((ndo, "MCID Name %s, rev %u, " + ND_PRINT((ndo, "MCID Name ")); + if (fn_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend)) + goto trunc; + ND_PRINT((ndo, ", rev %u," "\n\t\tdigest %08x%08x%08x%08x, ", - ptr + MST_BPDU_CONFIG_NAME_OFFSET, EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32), - EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET), - EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4), + EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET), + EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8), EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12))); ND_TCHECK_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET); - ND_PRINT((ndo, "CIST int-root-pathcost %u, ", + ND_PRINT((ndo, "CIST int-root-pathcost %u,", EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET))); ND_TCHECK_BRIDGE_ID(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET); @@ -355,12 +357,14 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, } ptr = (const u_char *)stp_bpdu; - if (!ND_TTEST_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+16)) - return 0; - - ND_PRINT((ndo, "\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x", - EXTRACT_16BITS (ptr + offset), - ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, + ND_TCHECK_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET + 16); + + ND_PRINT((ndo, "\n\tv4len %d, ", EXTRACT_16BITS (ptr + offset))); + ND_PRINT((ndo, "AUXMCID Name ")); + if (fn_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32, + ndo->ndo_snapend)) + goto trunc; + ND_PRINT((ndo, ", Rev %u,\n\t\tdigest %08x%08x%08x%08x", EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET), EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4), @@ -368,8 +372,8 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12))); ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-" - "flag %d, \n\tRestricted role-flag: %d, Format id %d cap %d, " - "Convention id %d cap %d, \n\tEdge count %d, " + "flag %d,\n\tRestricted role-flag: %d, Format id %d cap %d, " + "Convention id %d cap %d,\n\tEdge count %d, " "Agreement digest %08x%08x%08x%08x%08x\n", ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6, ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3, @@ -386,6 +390,9 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu, EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+12), EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+16))); return 1; + +trunc: + return 0; } /* @@ -469,6 +476,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length) if (stp_bpdu->protocol_version == STP_PROTO_SPB) { /* Validate v4 length */ + ND_TCHECK_16BITS(p + MST_BPDU_VER3_LEN_OFFSET + mstp_len); spb_len = EXTRACT_16BITS (p + MST_BPDU_VER3_LEN_OFFSET + mstp_len); spb_len += 2; if (length < (sizeof(struct stp_bpdu_) + mstp_len + spb_len) || @@ -490,7 +498,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length) } return; - trunc: +trunc: ND_PRINT((ndo, "[|stp %d]", length)); }