summaryrefslogtreecommitdiff
path: root/print-stp.c
diff options
context:
space:
mode:
authorAjith Adapa <adapa.ajith@gmail.com>2012-10-05 11:11:22 +0530
committerAjith Adapa <adapa.ajith@gmail.com>2012-10-05 11:11:22 +0530
commitdf33a28a6c42ceeacf718de718143d731a2ff153 (patch)
tree1ef25421b2399d01583009319622963162d764c9 /print-stp.c
parent0b3ef304c3f822295b7b7d19b4847dde729b9478 (diff)
downloadtcpdump-df33a28a6c42ceeacf718de718143d731a2ff153.tar.gz
Modified-mstp-display-as-per-standard
Diffstat (limited to 'print-stp.c')
-rw-r--r--print-stp.c98
1 files changed, 65 insertions, 33 deletions
diff --git a/print-stp.c b/print-stp.c
index db0f210e..e2aa471b 100644
--- a/print-stp.c
+++ b/print-stp.c
@@ -165,7 +165,24 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* 8 - bytes CIST Bridge Identifier
* 1 - byte CIST Remaining Hops
* 16 - bytes MSTI information [Max 64 MSTI, each 16 bytes]
- *
+ *
+ *
+ * SPB BPDU
+ * Ref. IEEE 802.1aq. Section 14
+ *
+ * 2 - bytes Version 4 length
+ * 1 - byte Aux Config Identifier
+ * 32 - bytes Aux Config Name
+ * 2 - bytes Aux Revision level
+ * 16 - bytes Aux Config Digest [MD5]
+ * 1 - byte (1 - 2) Agreement Number
+ * (3 - 4) Discarded Agreement Number
+ * (5) Agreement Valid Flag
+ * (6) Restricted Role Flag
+ * (7 - 8) Unused sent zero
+ * 1 - byte Unused
+ * 20 - bytes Agreement Digest
+ *
*
* MSTI Payload
*
@@ -175,6 +192,7 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* 1 - byte MSTI Bridge Priority
* 1 - byte MSTI Port Priority
* 1 - byte MSTI Remaining Hops
+ *
*/
#define MST_BPDU_MSTI_LENGTH 16
@@ -200,23 +218,27 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
#define SPB_BPDU_CONFIG_REV_OFFSET SPB_BPDU_CONFIG_NAME_OFFSET + 32
#define SPB_BPDU_CONFIG_DIGEST_OFFSET SPB_BPDU_CONFIG_REV_OFFSET + 2
#define SPB_BPDU_AGREEMENT_OFFSET SPB_BPDU_CONFIG_DIGEST_OFFSET + 16
-#define SPB_BPDU_AGREEMENT_CON_OFFSET SPB_BPDU_AGREEMENT_OFFSET + 1
+#define SPB_BPDU_AGREEMENT_UNUSED_OFFSET SPB_BPDU_AGREEMENT_OFFSET + 1
+#define SPB_BPDU_AGREEMENT_FORMAT_OFFSET SPB_BPDU_AGREEMENT_UNUSED_OFFSET + 1
+#define SPB_BPDU_AGREEMENT_CON_OFFSET SPB_BPDU_AGREEMENT_FORMAT_OFFSET + 1
#define SPB_BPDU_AGREEMENT_EDGE_OFFSET SPB_BPDU_AGREEMENT_CON_OFFSET + 1
-#define SPB_BPDU_AGREEMENT_DIGEST_OFFSET SPB_BPDU_AGREEMENT_EDGE_OFFSET + 10
+#define SPB_BPDU_AGREEMENT_RES1_OFFSET SPB_BPDU_AGREEMENT_EDGE_OFFSET + 2
+#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 void
stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
{
- const u_char *ptr;
+ const u_char *ptr;
u_int16_t v3len;
u_int16_t len;
u_int16_t msti;
u_int16_t offset;
ptr = (const u_char *)stp_bpdu;
- printf(", CIST Flags [%s]",
- bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+ printf(", CIST Flags [%s], length %u",
+ bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length);
/*
* in non-verbose mode just print the flags. We dont read that much
@@ -226,10 +248,18 @@ stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
return;
}
- printf(", CIST bridge-id %s.%04x, length %u",
- stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET),
- EXTRACT_16BITS(&stp_bpdu->port_id), length);
+ printf("\n\tport-role %s, ",
+ tok2str(rstp_obj_port_role_values, "Unknown",
+ RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+ printf("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));
+
+ printf("\n\tCIST regional-root-id %s, ",
+ stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+
+ printf("CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id));
printf("\n\tmessage-age %.2fs, max-age %.2fs"
", hello-time %.2fs, forwarding-delay %.2fs",
@@ -238,27 +268,23 @@ stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
- printf("\n\tCIST root-id %s, ext-pathcost %u int-pathcost %u",
- stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
- EXTRACT_32BITS(&stp_bpdu->root_path_cost),
- EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));
+ printf ("\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET));
+ printf("MCID Name %s, 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 + 8),
+ EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
- printf("\n\t\tport-role %s",
- tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
-
- printf("\n\tCIST regional-root-id %s",
- stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+ printf ("CIST int-root-pathcost %u, ",
+ EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));
- printf("\n\tMSTP Configuration Name %s, revision %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 + 8),
- EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
+ printf("\n\tCIST bridge-id %s, ",
+ stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
- printf("\n\tCIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+ printf("CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
/* Dump all MSTI's */
v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
@@ -289,9 +315,9 @@ stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
}
}
- if ((length-offset) == SPB_BPDU_MIN_LEN)
+ if ((length-offset) >= SPB_BPDU_MIN_LEN)
{
- printf("\n\tv4len: %d AUXMCID Name %s, Rev: %u, \n\t\tdigest %08x%08x%08x%08x",
+ printf("\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,
EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
@@ -300,10 +326,16 @@ stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12));
- printf("\n\tFormat ID: %d, Cap: %d, Convention ID: %d, Cap: %d, EdgeCount:%d\n"
- "\tDigest: %08x%08x%08x%08x%08x\n",
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]&0x00ff,
+ printf("\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, "
+ "Agreement digest %08x%08x%08x%08x%08x\n",
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),