+ return;
+
+trunc:
+ nd_print_trunc(ndo);
+}
+
+static void
+isis_print_mcid(netdissect_options *ndo,
+ const struct isis_spb_mcid *mcid)
+{
+ int i;
+
+ ND_TCHECK_SIZE(mcid);
+ ND_PRINT("ID: %u, Name: ", GET_U_1(mcid->format_id));
+
+ nd_printjnp(ndo, mcid->name, sizeof(mcid->name));
+
+ ND_PRINT("\n\t Lvl: %u", GET_BE_U_2(mcid->revision_lvl));
+
+ ND_PRINT(", Digest: ");
+
+ for(i=0;i<16;i++)
+ ND_PRINT("%.2x ", mcid->digest[i]);
+ return;
+
+trunc:
+ nd_print_trunc(ndo);
+}
+
+static int
+isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, u_int len)
+{
+ u_int stlv_type, stlv_len;
+ const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
+ int i;
+
+ while (len > 2)
+ {
+ stlv_type = GET_U_1(tptr);
+ stlv_len = GET_U_1(tptr + 1);
+
+ /* first lets see if we know the subTLVs name*/
+ ND_PRINT("\n\t %s subTLV #%u, length: %u",
+ tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
+ stlv_type,
+ stlv_len);
+
+ tptr += 2;
+ /*len -= TLV_TYPE_LEN_OFFSET;*/
+ len -= 2;
+
+ /* Make sure the subTLV fits within the space left */
+ if (len < stlv_len)
+ goto subtlv_too_long;
+ /* Make sure the entire subTLV is in the captured data */
+ ND_TCHECK_LEN(tptr, stlv_len);
+
+ switch (stlv_type)
+ {
+ case ISIS_SUBTLV_SPB_MCID:
+ {
+ if (stlv_len < ISIS_SUBTLV_SPB_MCID_MIN_LEN)
+ goto subtlv_too_short;
+
+ subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
+
+ ND_PRINT("\n\t MCID: ");
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
+
+ /*tptr += SPB_MCID_MIN_LEN;
+ len -= SPB_MCID_MIN_LEN; */
+
+ ND_PRINT("\n\t AUX-MCID: ");
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
+
+ /*tptr += SPB_MCID_MIN_LEN;
+ len -= SPB_MCID_MIN_LEN; */
+ tptr += ISIS_SUBTLV_SPB_MCID_MIN_LEN;
+ len -= ISIS_SUBTLV_SPB_MCID_MIN_LEN;
+ stlv_len -= ISIS_SUBTLV_SPB_MCID_MIN_LEN;
+
+ break;
+ }
+
+ case ISIS_SUBTLV_SPB_DIGEST:
+ {
+ if (stlv_len < ISIS_SUBTLV_SPB_DIGEST_MIN_LEN)
+ goto subtlv_too_short;
+
+ ND_PRINT("\n\t RES: %u V: %u A: %u D: %u",
+ (GET_U_1(tptr) >> 5),
+ ((GET_U_1(tptr) >> 4) & 0x01),
+ ((GET_U_1(tptr) >> 2) & 0x03),
+ (GET_U_1(tptr) & 0x03));
+
+ tptr++;
+
+ ND_PRINT("\n\t Digest: ");
+
+ for(i=1;i<=8; i++)
+ {
+ ND_PRINT("%08x ", GET_BE_U_4(tptr));
+ if (i%4 == 0 && i != 8)
+ ND_PRINT("\n\t ");
+ tptr += 4;
+ }
+
+ len -= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
+ stlv_len -= ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
+
+ break;
+ }
+
+ case ISIS_SUBTLV_SPB_BVID:
+ {
+ while (stlv_len != 0)
+ {
+ if (stlv_len < 4)
+ goto subtlv_too_short;
+ ND_PRINT("\n\t ECT: %08x",
+ GET_BE_U_4(tptr));
+
+ tptr += 4;
+ len -= 4;
+ stlv_len -= 4;
+
+ if (stlv_len < 2)
+ goto subtlv_too_short;
+ ND_PRINT(" BVID: %u, U:%01x M:%01x ",
+ (GET_BE_U_2(tptr) >> 4) ,
+ (GET_BE_U_2(tptr) >> 3) & 0x01,
+ (GET_BE_U_2(tptr) >> 2) & 0x01);
+
+ tptr += 2;
+ len -= 2;
+ stlv_len -= 2;
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+ tptr += stlv_len;
+ len -= stlv_len;
+ }
+ return (0);
+
+trunc:
+ nd_print_trunc(ndo);
+ return (1);
+
+subtlv_too_long:
+ ND_PRINT(" (> containing TLV length)");
+ return (1);
+
+subtlv_too_short:
+ ND_PRINT(" (too short)");
+ return (1);
+}
+
+static int
+isis_print_mt_capability_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, u_int len)
+{
+ u_int stlv_type, stlv_len, treecount;
+
+ while (len > 2)
+ {
+ stlv_type = GET_U_1(tptr);
+ stlv_len = GET_U_1(tptr + 1);
+ tptr += 2;
+ len -= 2;
+
+ /* first lets see if we know the subTLVs name*/
+ ND_PRINT("\n\t %s subTLV #%u, length: %u",
+ tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
+ stlv_type,
+ stlv_len);
+
+ /* Make sure the subTLV fits within the space left */
+ if (len < stlv_len)
+ goto subtlv_too_long;
+ /* Make sure the entire subTLV is in the captured data */
+ ND_TCHECK_LEN(tptr, stlv_len);
+
+ switch (stlv_type)
+ {
+ case ISIS_SUBTLV_SPB_INSTANCE:
+ if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN)
+ goto subtlv_too_short;
+
+ ND_PRINT("\n\t CIST Root-ID: %08x", GET_BE_U_4(tptr));
+ tptr += 4;
+ ND_PRINT(" %08x", GET_BE_U_4(tptr));
+ tptr += 4;
+ ND_PRINT(", Path Cost: %08x", GET_BE_U_4(tptr));
+ tptr += 4;
+ ND_PRINT(", Prio: %u", GET_BE_U_2(tptr));
+ tptr += 2;
+ ND_PRINT("\n\t RES: %u",
+ GET_BE_U_2(tptr) >> 5);
+ ND_PRINT(", V: %u",
+ (GET_BE_U_2(tptr) >> 4) & 0x0001);
+ ND_PRINT(", SPSource-ID: %u",
+ (GET_BE_U_4(tptr) & 0x000fffff));
+ tptr += 4;
+ ND_PRINT(", No of Trees: %x", GET_U_1(tptr));
+
+ treecount = GET_U_1(tptr);
+ tptr++;
+
+ len -= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
+ stlv_len -= ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
+
+ while (treecount)
+ {
+ if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN)
+ goto trunc;
+
+ ND_PRINT("\n\t U:%u, M:%u, A:%u, RES:%u",
+ GET_U_1(tptr) >> 7,
+ (GET_U_1(tptr) >> 6) & 0x01,
+ (GET_U_1(tptr) >> 5) & 0x01,
+ (GET_U_1(tptr) & 0x1f));
+
+ tptr++;
+
+ ND_PRINT(", ECT: %08x", GET_BE_U_4(tptr));
+
+ tptr += 4;
+
+ ND_PRINT(", BVID: %u, SPVID: %u",
+ (GET_BE_U_3(tptr) >> 12) & 0x000fff,
+ GET_BE_U_3(tptr) & 0x000fff);
+
+ tptr += 3;
+ len -= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
+ stlv_len -= ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
+ treecount--;
+ }
+
+ break;
+
+ case ISIS_SUBTLV_SPBM_SI:
+ if (stlv_len < 8)
+ goto trunc;
+
+ ND_PRINT("\n\t BMAC: %08x", GET_BE_U_4(tptr));
+ tptr += 4;
+ ND_PRINT("%04x", GET_BE_U_2(tptr));
+ tptr += 2;
+
+ ND_PRINT(", RES: %u, VID: %u", GET_BE_U_2(tptr) >> 12,
+ (GET_BE_U_2(tptr)) & 0x0fff);
+
+ tptr += 2;
+ len -= 8;
+ stlv_len -= 8;
+
+ while (stlv_len >= 4) {
+ ND_PRINT("\n\t T: %u, R: %u, RES: %u, ISID: %u",
+ (GET_BE_U_4(tptr) >> 31),
+ (GET_BE_U_4(tptr) >> 30) & 0x01,
+ (GET_BE_U_4(tptr) >> 24) & 0x03f,
+ (GET_BE_U_4(tptr)) & 0x0ffffff);
+
+ tptr += 4;
+ len -= 4;
+ stlv_len -= 4;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+ tptr += stlv_len;
+ len -= stlv_len;
+ }
+ return (0);
+