2 * Routines for the disassembly of Cisco's VLAN Trunking Protocol
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #include <epan/packet.h>
35 * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
37 * for some information on VTP.
39 * It's incomplete, and it appears to be inaccurate in a number of places,
40 * but it's all I could find....
43 static int proto_vtp = -1;
44 static int hf_vtp_version = -1;
45 static int hf_vtp_code = -1;
46 static int hf_vtp_followers = -1;
47 static int hf_vtp_md_len = -1;
48 static int hf_vtp_md = -1;
49 static int hf_vtp_conf_rev_num = -1;
50 static int hf_vtp_upd_id = -1;
51 static int hf_vtp_upd_ts = -1;
52 static int hf_vtp_md5_digest = -1;
53 static int hf_vtp_seq_num = -1;
54 static int hf_vtp_start_value = -1;
55 static int hf_vtp_vlan_info_len = -1;
56 static int hf_vtp_vlan_status_vlan_susp = -1;
57 static int hf_vtp_vlan_type = -1;
58 static int hf_vtp_vlan_name_len = -1;
59 static int hf_vtp_isl_vlan_id = -1;
60 static int hf_vtp_mtu_size = -1;
61 static int hf_vtp_802_10_index = -1;
62 static int hf_vtp_vlan_name = -1;
63 static int hf_vtp_vlan_tlvtype = -1;
64 static int hf_vtp_vlan_tlvlength = -1;
65 static gint hf_vtp_pruning_first_vid = -1;
66 static gint hf_vtp_pruning_last_vid = -1;
67 static gint hf_vtp_pruning_active_vid = -1;
69 static gint ett_vtp = -1;
70 static gint ett_vtp_vlan_info = -1;
71 static gint ett_vtp_vlan_status = -1;
72 static gint ett_vtp_tlv = -1;
73 static gint ett_vtp_pruning = -1;
76 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree);
78 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
79 proto_tree *tree, proto_item *ti, guint8 type);
81 #define SUMMARY_ADVERT 0x01
82 #define SUBSET_ADVERT 0x02
83 #define ADVERT_REQUEST 0x03
86 static const value_string type_vals[] = {
87 { SUMMARY_ADVERT, "Summary Advertisement" },
88 { SUBSET_ADVERT, "Subset Advertisement" },
89 { ADVERT_REQUEST, "Advertisement Request" },
90 { JOIN_MSG, "Join/Prune Message" },
95 set_vtp_info_col(tvbuff_t *tvb, packet_info *pinfo)
97 switch (tvb_get_guint8(tvb, 1)) {
100 col_add_fstr(pinfo->cinfo, COL_INFO,
101 "Summary Advertisement, Revision: %u", tvb_get_ntohl(tvb, 36));
103 if (tvb_get_guint8(tvb, 2) > 0) {
104 col_append_fstr(pinfo->cinfo, COL_INFO,
105 ", Followers: %u", tvb_get_guint8(tvb, 2));
111 col_add_fstr(pinfo->cinfo, COL_INFO,
112 "Subset Advertisement, Revision: %u, Seq: %u",
113 tvb_get_ntohl(tvb, 36), tvb_get_guint8(tvb, 2));
117 col_set_str(pinfo->cinfo, COL_INFO, "Advertisement Request");
121 col_set_str(pinfo->cinfo, COL_INFO, "Join");
125 col_set_str(pinfo->cinfo, COL_INFO, "Unrecognized VTP message");
131 dissect_vtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
134 proto_tree *vtp_tree = NULL, *vtp_pruning_tree = NULL;
138 const guint8 *upd_timestamp;
142 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VTP");
143 set_vtp_info_col(tvb, pinfo);
146 ti = proto_tree_add_item(tree, proto_vtp, tvb, offset, -1,
148 vtp_tree = proto_item_add_subtree(ti, ett_vtp);
150 proto_tree_add_item(vtp_tree, hf_vtp_version, tvb, offset, 1,
154 code = tvb_get_guint8(tvb, offset);
155 proto_tree_add_uint(vtp_tree, hf_vtp_code, tvb, offset, 1,
162 proto_tree_add_item(vtp_tree, hf_vtp_followers, tvb, offset,
166 md_len = tvb_get_guint8(tvb, offset);
167 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
171 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
175 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
179 proto_tree_add_item(vtp_tree, hf_vtp_upd_id, tvb,
183 upd_timestamp = tvb_get_ptr(tvb, offset, 12);
184 proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, tvb,
185 offset, 12, (gchar*)upd_timestamp,
186 "Update Timestamp: %.2s-%.2s-%.2s %.2s:%.2s:%.2s",
187 &upd_timestamp[0], &upd_timestamp[2], &upd_timestamp[4],
188 &upd_timestamp[6], &upd_timestamp[8], &upd_timestamp[10]);
191 proto_tree_add_item(vtp_tree, hf_vtp_md5_digest, tvb,
196 proto_tree_add_item(vtp_tree, hf_vtp_seq_num, tvb, offset,
200 md_len = tvb_get_guint8(tvb, offset);
201 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
205 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
209 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
213 while (tvb_reported_length_remaining(tvb, offset) > 0) {
215 dissect_vlan_info(tvb, offset, vtp_tree);
216 if (vlan_info_len < 0)
218 offset += vlan_info_len;
223 offset += 1; /* skip reserved field */
225 md_len = tvb_get_guint8(tvb, offset);
226 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
230 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
234 proto_tree_add_item(vtp_tree, hf_vtp_start_value, tvb,
239 offset += 1; /* skip reserved/unused field */
241 md_len = tvb_get_guint8(tvb, offset);
242 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
246 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
250 proto_tree_add_item(vtp_tree, hf_vtp_pruning_first_vid, tvb, offset,
252 pruning_vlan_id = tvb_get_ntohs(tvb, offset);
255 proto_tree_add_item(vtp_tree, hf_vtp_pruning_last_vid, tvb, offset,
259 ti = proto_tree_add_text (vtp_tree, tvb, offset, -1,
260 "Advertised active (i.e. not pruned) VLANs");
261 vtp_pruning_tree = proto_item_add_subtree(ti, ett_vtp_pruning);
263 while (tvb_reported_length_remaining(tvb, offset) > 0) {
264 guint8 vlan_usage_bitmap;
267 vlan_usage_bitmap = tvb_get_guint8(tvb, offset);
269 for (shift = 0; shift < 8; shift++) {
270 if (vlan_usage_bitmap & (1<<7)) {
271 proto_tree_add_uint(vtp_pruning_tree, hf_vtp_pruning_active_vid,
272 tvb, offset, 1, pruning_vlan_id);
275 pruning_vlan_id += 1;
276 vlan_usage_bitmap <<= 1;
287 #define VLAN_SUSPENDED 0x01
289 static const value_string vlan_type_vals[] = {
290 { 0x01, "Ethernet" },
293 { 0x04, "FDDI-net" },
298 #define SR_RING_NUM 0x01
299 #define SR_BRIDGE_NUM 0x02
300 #define STP_TYPE 0x03
301 #define PARENT_VLAN 0x04
302 #define TR_BRIDGED_VLANS 0x05
304 #define BRIDGE_TYPE 0x07
305 #define MAX_ARE_HOP_CNT 0x08
306 #define MAX_STE_HOP_CNT 0x09
307 #define BACKUP_CRF_MODE 0x0A
309 static const value_string vlan_tlv_type_vals[] = {
310 { SR_RING_NUM, "Source-Routing Ring Number" },
311 { SR_BRIDGE_NUM, "Source-Routing Bridge Number" },
312 { STP_TYPE, "Spanning-Tree Protocol Type" },
313 { PARENT_VLAN, "Parent VLAN" },
314 { TR_BRIDGED_VLANS, "Translationally Bridged VLANs" },
315 { PRUNING, "Pruning" },
316 { BRIDGE_TYPE, "Bridge Type" },
317 { MAX_ARE_HOP_CNT, "Max ARE Hop Count" },
318 { MAX_STE_HOP_CNT, "Max STE Hop Count" },
319 { BACKUP_CRF_MODE, "Backup CRF Mode" },
324 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree)
327 proto_tree *vlan_info_tree;
328 proto_tree *status_tree;
329 guint8 vlan_info_len;
332 guint8 vlan_name_len;
335 proto_tree *tlv_tree;
337 vlan_info_len = tvb_get_guint8(tvb, offset);
338 ti = proto_tree_add_text(tree, tvb, offset, vlan_info_len,
340 vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
341 vlan_info_left = vlan_info_len;
343 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, tvb, offset, 1,
348 if (vlan_info_left < 1)
350 status = tvb_get_guint8(tvb, offset);
351 ti = proto_tree_add_text(vlan_info_tree, tvb, offset, 1,
352 "Status: 0x%02x%s", status,
353 (status & VLAN_SUSPENDED) ? "(VLAN suspended)" : "");
354 status_tree = proto_item_add_subtree(ti, ett_vtp_vlan_status);
355 proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, tvb, offset, 1,
360 if (vlan_info_left < 1)
362 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_type, tvb, offset, 1,
367 if (vlan_info_left < 1)
369 vlan_name_len = tvb_get_guint8(tvb, offset);
370 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, tvb, offset, 1,
375 if (vlan_info_left < 2)
377 proto_tree_add_item(vlan_info_tree, hf_vtp_isl_vlan_id, tvb, offset, 2,
382 if (vlan_info_left < 2)
384 proto_tree_add_item(vlan_info_tree, hf_vtp_mtu_size, tvb, offset, 2,
389 if (vlan_info_left < 4)
391 proto_tree_add_item(vlan_info_tree, hf_vtp_802_10_index, tvb, offset, 4,
396 /* VLAN name length appears to be rounded up to a multiple of 4. */
397 vlan_name_len = 4*((vlan_name_len + 3)/4);
398 if (vlan_info_left < vlan_name_len)
400 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_name, tvb, offset,
401 vlan_name_len, FALSE);
402 offset += vlan_name_len;
403 vlan_info_left -= vlan_name_len;
405 while (vlan_info_left > 0) {
406 type = tvb_get_guint8(tvb, offset + 0);
407 length = tvb_get_guint8(tvb, offset + 1);
409 ti = proto_tree_add_text(vlan_info_tree, tvb, offset,
411 val_to_str(type, vlan_tlv_type_vals,
412 "Unknown TLV type: 0x%02x"));
413 tlv_tree = proto_item_add_subtree(ti, ett_vtp_tlv);
414 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, tvb, offset,
416 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, tvb, offset+1,
421 dissect_vlan_info_tlv(tvb, offset, length*2, tlv_tree,
425 vlan_info_left -= length*2;
428 return vlan_info_len;
431 static const value_string stp_type_vals[] = {
438 static const value_string pruning_vals[] = {
444 static const value_string bridge_type_vals[] = {
450 static const value_string backup_crf_mode_vals[] = {
451 { 1, "TrCRF is configured as a backup" },
452 { 2, "TrCRF is not configured as a backup" },
457 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
458 proto_tree *tree, proto_item *ti, guint8 type)
464 proto_item_set_text(ti,
465 "Source-Routing Ring Number: 0x%04x",
466 tvb_get_ntohs(tvb, offset));
467 proto_tree_add_text(tree, tvb, offset, 2,
468 "Source-Routing Ring Number: 0x%04x",
469 tvb_get_ntohs(tvb, offset));
471 proto_item_set_text(ti,
472 "Source-Routing Ring Number: Bad length %u",
474 proto_tree_add_text(tree, tvb, offset, length,
475 "Source-Routing Ring Number: Bad length %u",
482 proto_item_set_text(ti,
483 "Source-Routing Bridge Number: 0x%04x",
484 tvb_get_ntohs(tvb, offset));
485 proto_tree_add_text(tree, tvb, offset, 2,
486 "Source-Routing Bridge Number: 0x%04x",
487 tvb_get_ntohs(tvb, offset));
489 proto_item_set_text(ti,
490 "Source-Routing Bridge Number: Bad length %u",
492 proto_tree_add_text(tree, tvb, offset, length,
493 "Source-Routing Bridge Number: Bad length %u",
500 proto_item_set_text(ti,
501 "Spanning-Tree Protocol Type: %s",
502 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
503 "Unknown (0x%04x)"));
504 proto_tree_add_text(tree, tvb, offset, 2,
505 "Spanning-Tree Protocol Type: %s",
506 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
507 "Unknown (0x%04x)"));
509 proto_item_set_text(ti,
510 "Spanning-Tree Protocol Type: Bad length %u",
512 proto_tree_add_text(tree, tvb, offset, length,
513 "Spanning-Tree Protocol Type: Bad length %u",
520 proto_item_set_text(ti,
521 "Parent VLAN: 0x%04x",
522 tvb_get_ntohs(tvb, offset));
523 proto_tree_add_text(tree, tvb, offset, 2,
524 "Parent VLAN: 0x%04x",
525 tvb_get_ntohs(tvb, offset));
527 proto_item_set_text(ti,
528 "Parent VLAN: Bad length %u",
530 proto_tree_add_text(tree, tvb, offset, length,
531 "Parent VLAN: Bad length %u",
536 case TR_BRIDGED_VLANS:
538 proto_item_set_text(ti,
539 "Translationally Bridged VLANs: 0x%04x",
540 tvb_get_ntohs(tvb, offset));
541 proto_tree_add_text(tree, tvb, offset, 2,
542 "Translationally Bridged VLANs: 0x%04x",
543 tvb_get_ntohs(tvb, offset));
545 proto_item_set_text(ti,
546 "Translationally Bridged VLANs: Bad length %u",
548 proto_tree_add_text(tree, tvb, offset, length,
549 "Translationally Bridged VLANs: Bad length %u",
556 proto_item_set_text(ti,
558 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
559 "Unknown (0x%04x)"));
560 proto_tree_add_text(tree, tvb, offset, 2,
562 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
563 "Unknown (0x%04x)"));
565 proto_item_set_text(ti,
566 "Pruning: Bad length %u",
568 proto_tree_add_text(tree, tvb, offset, length,
569 "Pruning: Bad length %u",
576 proto_item_set_text(ti,
578 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
579 "Unknown (0x%04x)"));
580 proto_tree_add_text(tree, tvb, offset, 2,
582 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
583 "Unknown (0x%04x)"));
585 proto_item_set_text(ti,
586 "Bridge Type: Bad length %u",
588 proto_tree_add_text(tree, tvb, offset, length,
589 "Bridge Type: Bad length %u",
594 case MAX_ARE_HOP_CNT:
596 proto_item_set_text(ti,
597 "Max ARE Hop Count: %u",
598 tvb_get_ntohs(tvb, offset));
599 proto_tree_add_text(tree, tvb, offset, 2,
600 "Max ARE Hop Count: %u",
601 tvb_get_ntohs(tvb, offset));
603 proto_item_set_text(ti,
604 "Max ARE Hop Count: Bad length %u",
606 proto_tree_add_text(tree, tvb, offset, length,
607 "Max ARE Hop Count: Bad length %u",
612 case MAX_STE_HOP_CNT:
614 proto_item_set_text(ti,
615 "Max STE Hop Count: %u",
616 tvb_get_ntohs(tvb, offset));
617 proto_tree_add_text(tree, tvb, offset, 2,
618 "Max STE Hop Count: %u",
619 tvb_get_ntohs(tvb, offset));
621 proto_item_set_text(ti,
622 "Max STE Hop Count: Bad length %u",
624 proto_tree_add_text(tree, tvb, offset, length,
625 "Max STE Hop Count: Bad length %u",
630 case BACKUP_CRF_MODE:
632 proto_item_set_text(ti,
633 "Backup CRF Mode: %s",
634 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
635 "Unknown (0x%04x)"));
636 proto_tree_add_text(tree, tvb, offset, 2,
637 "Backup CRF Mode: %s",
638 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
639 "Unknown (0x%04x)"));
641 proto_item_set_text(ti,
642 "Backup CRF Mode: Bad length %u",
644 proto_tree_add_text(tree, tvb, offset, length,
645 "Backup CRF Mode: Bad length %u",
651 proto_tree_add_text(tree, tvb, offset, length, "Data");
657 proto_register_vtp(void)
659 static hf_register_info hf[] = {
661 { "Version", "vtp.version", FT_UINT8, BASE_HEX, NULL, 0x0,
665 { "Code", "vtp.code", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0,
669 { "Followers", "vtp.followers", FT_UINT8, BASE_DEC, NULL, 0x0,
670 "Number of following Subset-Advert messages", HFILL }},
673 { "Management Domain Length", "vtp.md_len", FT_UINT8, BASE_DEC, NULL, 0x0,
674 "Length of management domain string", HFILL }},
677 { "Management Domain", "vtp.md", FT_STRING, BASE_NONE, NULL, 0,
680 { &hf_vtp_conf_rev_num,
681 { "Configuration Revision Number", "vtp.conf_rev_num", FT_UINT32, BASE_DEC, NULL, 0x0,
682 "Revision number of the configuration information", HFILL }},
685 { "Updater Identity", "vtp.upd_id", FT_IPv4, BASE_NONE, NULL, 0x0,
686 "IP address of the updater", HFILL }},
689 { "Update Timestamp", "vtp.upd_ts", FT_STRING, BASE_NONE, NULL, 0,
690 "Time stamp of the current configuration revision", HFILL }},
692 { &hf_vtp_md5_digest,
693 { "MD5 Digest", "vtp.md5_digest", FT_BYTES, BASE_NONE, NULL, 0x0,
697 { "Sequence Number", "vtp.seq_num", FT_UINT8, BASE_DEC, NULL, 0x0,
698 "Order of this frame in the sequence of Subset-Advert frames", HFILL }},
700 { &hf_vtp_start_value,
701 { "Start Value", "vtp.start_value", FT_UINT16, BASE_HEX, NULL, 0x0,
702 "Virtual LAN ID of first VLAN for which information is requested", HFILL }},
704 { &hf_vtp_vlan_info_len,
705 { "VLAN Information Length", "vtp.vlan_info.len", FT_UINT8, BASE_DEC, NULL, 0x0,
706 "Length of the VLAN information field", HFILL }},
708 { &hf_vtp_vlan_status_vlan_susp,
709 { "VLAN suspended", "vtp.vlan_info.status.vlan_susp", FT_BOOLEAN, 8, NULL, VLAN_SUSPENDED,
713 { "VLAN Type", "vtp.vlan_info.vlan_type", FT_UINT8, BASE_HEX, VALS(vlan_type_vals), 0x0,
714 "Type of VLAN", HFILL }},
716 { &hf_vtp_vlan_name_len,
717 { "VLAN Name Length", "vtp.vlan_info.vlan_name_len", FT_UINT8, BASE_DEC, NULL, 0x0,
718 "Length of VLAN name string", HFILL }},
720 { &hf_vtp_isl_vlan_id,
721 { "ISL VLAN ID", "vtp.vlan_info.isl_vlan_id", FT_UINT16, BASE_HEX, NULL, 0x0,
722 "ID of this VLAN on ISL trunks", HFILL }},
725 { "MTU Size", "vtp.vlan_info.mtu_size", FT_UINT16, BASE_DEC, NULL, 0x0,
726 "MTU for this VLAN", HFILL }},
728 { &hf_vtp_802_10_index,
729 { "802.10 Index", "vtp.vlan_info.802_10_index", FT_UINT32, BASE_HEX, NULL, 0x0,
730 "IEEE 802.10 security association identifier for this VLAN", HFILL }},
733 { "VLAN Name", "vtp.vlan_info.vlan_name", FT_STRING, BASE_NONE, NULL, 0,
736 { &hf_vtp_vlan_tlvtype,
737 { "Type", "vtp.vlan_info.tlv_type", FT_UINT8, BASE_HEX, VALS(vlan_tlv_type_vals), 0x0,
740 { &hf_vtp_vlan_tlvlength,
741 { "Length", "vtp.vlan_info.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0,
744 { &hf_vtp_pruning_first_vid,
745 { "First VLAN ID", "vtp.pruning.first", FT_UINT16, BASE_DEC, NULL, 0x0,
746 "First VLAN ID for which pruning information is present", HFILL }},
748 { &hf_vtp_pruning_last_vid,
749 { "Last VLAN ID", "vtp.pruning.last", FT_UINT16, BASE_DEC, NULL, 0x0,
750 "Last VLAN ID for which pruning information is present", HFILL }},
752 { &hf_vtp_pruning_active_vid,
753 { "VLAN", "vtp.pruning.active", FT_UINT16, BASE_DEC, NULL, 0x0,
754 "Active advertised VLAN ID", HFILL }},
757 static gint *ett[] = {
760 &ett_vtp_vlan_status,
765 proto_vtp = proto_register_protocol("VLAN Trunking Protocol",
767 proto_register_field_array(proto_vtp, hf, array_length(hf));
768 proto_register_subtree_array(ett, array_length(ett));
772 proto_reg_handoff_vtp(void)
774 dissector_handle_t vtp_handle;
776 vtp_handle = create_dissector_handle(dissect_vtp, proto_vtp);
777 dissector_add_uint("llc.cisco_pid", 0x2003, vtp_handle);