- vtp_vlan = (struct vtp_vlan_*)tptr;
- printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
- tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status),
- tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type),
- EXTRACT_16BITS(&vtp_vlan->vlanid),
- EXTRACT_16BITS(&vtp_vlan->mtu),
- EXTRACT_32BITS(&vtp_vlan->index),
- (tptr + VTP_VLAN_INFO_OFFSET));
- tptr += len;
-
- /* FIXME: TLV dissector missing */
-
- /* The following URL:
- http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
- talks about type (2 bytes) and length (2 bytes), that is not true...
- */
+ vtp_vlan = (const struct vtp_vlan_*)tptr;
+ if (len < VTP_VLAN_INFO_FIXED_PART_LEN)
+ goto trunc;
+ ND_TCHECK_SIZE(vtp_vlan);
+ ND_PRINT("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ",
+ tok2str(vtp_vlan_status,"Unknown",GET_U_1(vtp_vlan->status)),
+ tok2str(vtp_vlan_type_values,"Unknown",GET_U_1(vtp_vlan->type)),
+ GET_BE_U_2(vtp_vlan->vlanid),
+ GET_BE_U_2(vtp_vlan->mtu),
+ GET_BE_U_4(vtp_vlan->index));
+ len -= VTP_VLAN_INFO_FIXED_PART_LEN;
+ tptr += VTP_VLAN_INFO_FIXED_PART_LEN;
+ name_len = GET_U_1(vtp_vlan->name_len);
+ if (len < 4*((name_len + 3)/4))
+ goto trunc;
+ ND_TCHECK_LEN(tptr, name_len);
+ nd_printzp(ndo, tptr, name_len, NULL);
+
+ /*
+ * Vlan names are aligned to 32-bit boundaries.
+ */
+ len -= 4*((name_len + 3)/4);
+ tptr += 4*((name_len + 3)/4);
+
+ /* TLV information follows */
+
+ while (len > 0) {
+
+ /*
+ * Cisco specs say 2 bytes for type + 2 bytes for length;
+ * see https://docstore.mik.ua/univercd/cc/td/doc/product/lan/trsrb/frames.htm
+ * However, actual packets on the wire appear to use 1
+ * byte for the type and 1 byte for the length, so that's
+ * what we do.
+ */
+ if (len < 2)
+ goto trunc;
+ ND_TCHECK_2(tptr);
+ type = GET_U_1(tptr);
+ tlv_len = GET_U_1(tptr + 1);
+
+ ND_PRINT("\n\t\t%s (0x%04x) TLV",
+ tok2str(vtp_vlan_tlv_values, "Unknown", type),
+ type);
+
+ if (len < tlv_len * 2 + 2) {
+ ND_PRINT(" (TLV goes past the end of the packet)");
+ return;
+ }
+ ND_TCHECK_LEN(tptr, tlv_len * 2 + 2);
+
+ /*
+ * We assume the value is a 2-byte integer; the length is
+ * in units of 16-bit words.
+ */
+ if (tlv_len != 1) {
+ ND_PRINT(" (invalid TLV length %u != 1)", tlv_len);
+ return;
+ } else {
+ tlv_value = GET_BE_U_2(tptr + 2);
+
+ switch (type) {
+ case VTP_VLAN_STE_HOP_COUNT:
+ ND_PRINT(", %u", tlv_value);
+ break;
+
+ case VTP_VLAN_PRUNING:
+ ND_PRINT(", %s (%u)",
+ tlv_value == 1 ? "Enabled" : "Disabled",
+ tlv_value);
+ break;
+
+ case VTP_VLAN_STP_TYPE:
+ ND_PRINT(", %s (%u)",
+ tok2str(vtp_stp_type_values, "Unknown", tlv_value),
+ tlv_value);
+ break;
+
+ case VTP_VLAN_BRIDGE_TYPE:
+ ND_PRINT(", %s (%u)",
+ tlv_value == 1 ? "SRB" : "SRT",
+ tlv_value);
+ break;
+
+ case VTP_VLAN_BACKUP_CRF_MODE:
+ ND_PRINT(", %s (%u)",
+ tlv_value == 1 ? "Backup" : "Not backup",
+ tlv_value);
+ break;
+
+ /*
+ * FIXME those are the defined TLVs that lack a decoder
+ * you are welcome to contribute code ;-)
+ */
+
+ case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER:
+ case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER:
+ case VTP_VLAN_PARENT_VLAN:
+ case VTP_VLAN_TRANS_BRIDGED_VLAN:
+ case VTP_VLAN_ARP_HOP_COUNT:
+ default:
+ print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2);
+ break;
+ }
+ }
+ len -= 2 + tlv_len*2;
+ tptr += 2 + tlv_len*2;
+ }