2 * Routines for the disassembly of Cisco's Virtual Trunking Protocol
4 * $Id: packet-vtp.c,v 1.21 2002/08/28 21:00:36 jmayer Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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.
31 #include <epan/packet.h>
36 * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
38 * for some information on VTP.
40 * It's incomplete, and it appears to be inaccurate in a number of places,
41 * but it's all I could find....
44 static int proto_vtp = -1;
45 static int hf_vtp_version = -1;
46 static int hf_vtp_code = -1;
47 static int hf_vtp_followers = -1;
48 static int hf_vtp_md_len = -1;
49 static int hf_vtp_md = -1;
50 static int hf_vtp_conf_rev_num = -1;
51 static int hf_vtp_upd_id = -1;
52 static int hf_vtp_upd_ts = -1;
53 static int hf_vtp_md5_digest = -1;
54 static int hf_vtp_seq_num = -1;
55 static int hf_vtp_start_value = -1;
56 static int hf_vtp_vlan_info_len = -1;
57 static int hf_vtp_vlan_status_vlan_susp = -1;
58 static int hf_vtp_vlan_type = -1;
59 static int hf_vtp_vlan_name_len = -1;
60 static int hf_vtp_isl_vlan_id = -1;
61 static int hf_vtp_mtu_size = -1;
62 static int hf_vtp_802_10_index = -1;
63 static int hf_vtp_vlan_name = -1;
64 static int hf_vtp_vlan_tlvtype = -1;
65 static int hf_vtp_vlan_tlvlength = -1;
67 static gint ett_vtp = -1;
68 static gint ett_vtp_vlan_info = -1;
69 static gint ett_vtp_vlan_status = -1;
70 static gint ett_vtp_tlv = -1;
73 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree);
75 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
76 proto_tree *tree, proto_item *ti, guint8 type);
78 #define SUMMARY_ADVERT 0x01
79 #define SUBSET_ADVERT 0x02
80 #define ADVERT_REQUEST 0x03
82 static const value_string type_vals[] = {
83 { SUMMARY_ADVERT, "Summary-Advert" },
84 { SUBSET_ADVERT, "Subset-Advert" },
85 { ADVERT_REQUEST, "Advert-Request" },
90 dissect_vtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
93 proto_tree *vtp_tree = NULL;
97 const guint8 *upd_timestamp;
100 if (check_col(pinfo->cinfo, COL_PROTOCOL))
101 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VTP");
102 if (check_col(pinfo->cinfo, COL_INFO))
103 col_set_str(pinfo->cinfo, COL_INFO, "Virtual Trunking Protocol");
106 ti = proto_tree_add_item(tree, proto_vtp, tvb, offset, -1,
108 vtp_tree = proto_item_add_subtree(ti, ett_vtp);
110 proto_tree_add_item(vtp_tree, hf_vtp_version, tvb, offset, 1,
114 code = tvb_get_guint8(tvb, offset);
115 proto_tree_add_uint(vtp_tree, hf_vtp_code, tvb, offset, 1,
122 proto_tree_add_item(vtp_tree, hf_vtp_followers, tvb, offset,
126 md_len = tvb_get_guint8(tvb, offset);
127 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
131 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
135 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
139 proto_tree_add_item(vtp_tree, hf_vtp_upd_id, tvb,
143 upd_timestamp = tvb_get_ptr(tvb, offset, 12);
144 proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, tvb,
145 offset, 12, upd_timestamp,
146 "Update Timestamp: %.2s-%.2s-%.2s %.2s:%.2s:%.2s",
147 &upd_timestamp[0], &upd_timestamp[2], &upd_timestamp[4],
148 &upd_timestamp[6], &upd_timestamp[8], &upd_timestamp[10]);
151 proto_tree_add_item(vtp_tree, hf_vtp_md5_digest, tvb,
156 proto_tree_add_item(vtp_tree, hf_vtp_seq_num, tvb, offset,
160 md_len = tvb_get_guint8(tvb, offset);
161 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
165 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
169 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
173 while (tvb_reported_length_remaining(tvb, offset) > 0) {
175 dissect_vlan_info(tvb, offset, vtp_tree);
176 if (vlan_info_len < 0)
178 offset += vlan_info_len;
183 offset += 1; /* skip reserved field */
185 md_len = tvb_get_guint8(tvb, offset);
186 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
190 proto_tree_add_item(vtp_tree, hf_vtp_start_value, tvb,
196 * Mysterious type, seen a lot.
197 * Is this some mutant variant of Advert-Request?
199 offset += 1; /* skip unknown field */
201 md_len = tvb_get_guint8(tvb, offset);
202 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
206 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
210 offset += 2; /* skip unknown field */
212 proto_tree_add_text(vtp_tree, tvb, offset, 2,
213 "VLAN ID of some sort: 0x%04x",
214 tvb_get_ntohs(tvb, offset));
221 #define VLAN_SUSPENDED 0x01
223 static const value_string vlan_type_vals[] = {
224 { 0x01, "Ethernet" },
227 { 0x04, "FDDI-net" },
232 #define SR_RING_NUM 0x01
233 #define SR_BRIDGE_NUM 0x02
234 #define STP_TYPE 0x03
235 #define PARENT_VLAN 0x04
236 #define TR_BRIDGED_VLANS 0x05
238 #define BRIDGE_TYPE 0x07
239 #define MAX_ARE_HOP_CNT 0x08
240 #define MAX_STE_HOP_CNT 0x09
241 #define BACKUP_CRF_MODE 0x0A
243 static const value_string vlan_tlv_type_vals[] = {
244 { SR_RING_NUM, "Source-Routing Ring Number" },
245 { SR_BRIDGE_NUM, "Source-Routing Bridge Number" },
246 { STP_TYPE, "Spanning-Tree Protocol Type" },
247 { PARENT_VLAN, "Parent VLAN" },
248 { TR_BRIDGED_VLANS, "Translationally Bridged VLANs" },
249 { PRUNING, "Pruning" },
250 { BRIDGE_TYPE, "Bridge Type" },
251 { MAX_ARE_HOP_CNT, "Max ARE Hop Count" },
252 { MAX_STE_HOP_CNT, "Max STE Hop Count" },
253 { BACKUP_CRF_MODE, "Backup CRF Mode" },
258 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree)
261 proto_tree *vlan_info_tree;
262 proto_tree *status_tree;
263 guint8 vlan_info_len;
266 guint8 vlan_name_len;
269 proto_tree *tlv_tree;
271 vlan_info_len = tvb_get_guint8(tvb, offset);
272 ti = proto_tree_add_text(tree, tvb, offset, vlan_info_len,
274 vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
275 vlan_info_left = vlan_info_len;
277 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, tvb, offset, 1,
282 if (vlan_info_left < 1)
284 status = tvb_get_guint8(tvb, offset);
285 ti = proto_tree_add_text(vlan_info_tree, tvb, offset, 1,
286 "Status: 0x%02x%s", status,
287 (status & VLAN_SUSPENDED) ? "(VLAN suspended)" : "");
288 status_tree = proto_item_add_subtree(ti, ett_vtp_vlan_status);
289 proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, tvb, offset, 1,
294 if (vlan_info_left < 1)
296 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_type, tvb, offset, 1,
301 if (vlan_info_left < 1)
303 vlan_name_len = tvb_get_guint8(tvb, offset);
304 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, tvb, offset, 1,
309 if (vlan_info_left < 2)
311 proto_tree_add_item(vlan_info_tree, hf_vtp_isl_vlan_id, tvb, offset, 2,
316 if (vlan_info_left < 2)
318 proto_tree_add_item(vlan_info_tree, hf_vtp_mtu_size, tvb, offset, 2,
323 if (vlan_info_left < 4)
325 proto_tree_add_item(vlan_info_tree, hf_vtp_802_10_index, tvb, offset, 4,
330 /* VLAN name length appears to be rounded up to a multiple of 4. */
331 vlan_name_len = 4*((vlan_name_len + 3)/4);
332 if (vlan_info_left < vlan_name_len)
334 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_name, tvb, offset,
335 vlan_name_len, FALSE);
336 offset += vlan_name_len;
337 vlan_info_left -= vlan_name_len;
339 while (vlan_info_left > 0) {
340 type = tvb_get_guint8(tvb, offset + 0);
341 length = tvb_get_guint8(tvb, offset + 1);
343 ti = proto_tree_add_text(vlan_info_tree, tvb, offset,
345 val_to_str(type, vlan_tlv_type_vals,
346 "Unknown TLV type: 0x%02x"));
347 tlv_tree = proto_item_add_subtree(ti, ett_vtp_tlv);
348 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, tvb, offset,
350 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, tvb, offset+1,
355 dissect_vlan_info_tlv(tvb, offset, length*2, tlv_tree,
359 vlan_info_left -= length*2;
362 return vlan_info_len;
365 static const value_string stp_type_vals[] = {
372 static const value_string pruning_vals[] = {
378 static const value_string bridge_type_vals[] = {
384 static const value_string backup_crf_mode_vals[] = {
385 { 1, "TrCRF is configured as a backup" },
386 { 2, "TrCRF is not configured as a backup" },
391 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
392 proto_tree *tree, proto_item *ti, guint8 type)
398 proto_item_set_text(ti,
399 "Source-Routing Ring Number: 0x%04x",
400 tvb_get_ntohs(tvb, offset));
401 proto_tree_add_text(tree, tvb, offset, 2,
402 "Source-Routing Ring Number: 0x%04x",
403 tvb_get_ntohs(tvb, offset));
405 proto_item_set_text(ti,
406 "Source-Routing Ring Number: Bad length %u",
408 proto_tree_add_text(tree, tvb, offset, length,
409 "Source-Routing Ring Number: Bad length %u",
416 proto_item_set_text(ti,
417 "Source-Routing Bridge Number: 0x%04x",
418 tvb_get_ntohs(tvb, offset));
419 proto_tree_add_text(tree, tvb, offset, 2,
420 "Source-Routing Bridge Number: 0x%04x",
421 tvb_get_ntohs(tvb, offset));
423 proto_item_set_text(ti,
424 "Source-Routing Bridge Number: Bad length %u",
426 proto_tree_add_text(tree, tvb, offset, length,
427 "Source-Routing Bridge Number: Bad length %u",
434 proto_item_set_text(ti,
435 "Spanning-Tree Protocol Type: %s",
436 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
437 "Unknown (0x%04x)"));
438 proto_tree_add_text(tree, tvb, offset, 2,
439 "Spanning-Tree Protocol Type: %s",
440 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
441 "Unknown (0x%04x)"));
443 proto_item_set_text(ti,
444 "Spanning-Tree Protocol Type: Bad length %u",
446 proto_tree_add_text(tree, tvb, offset, length,
447 "Spanning-Tree Protocol Type: Bad length %u",
454 proto_item_set_text(ti,
455 "Parent VLAN: 0x%04x",
456 tvb_get_ntohs(tvb, offset));
457 proto_tree_add_text(tree, tvb, offset, 2,
458 "Parent VLAN: 0x%04x",
459 tvb_get_ntohs(tvb, offset));
461 proto_item_set_text(ti,
462 "Parent VLAN: Bad length %u",
464 proto_tree_add_text(tree, tvb, offset, length,
465 "Parent VLAN: Bad length %u",
470 case TR_BRIDGED_VLANS:
472 proto_item_set_text(ti,
473 "Translationally Bridged VLANs: 0x%04x",
474 tvb_get_ntohs(tvb, offset));
475 proto_tree_add_text(tree, tvb, offset, 2,
476 "Translationally Bridged VLANs: 0x%04x",
477 tvb_get_ntohs(tvb, offset));
479 proto_item_set_text(ti,
480 "Translationally Bridged VLANs: Bad length %u",
482 proto_tree_add_text(tree, tvb, offset, length,
483 "Translationally Bridged VLANs: Bad length %u",
490 proto_item_set_text(ti,
492 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
493 "Unknown (0x%04x)"));
494 proto_tree_add_text(tree, tvb, offset, 2,
496 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
497 "Unknown (0x%04x)"));
499 proto_item_set_text(ti,
500 "Pruning: Bad length %u",
502 proto_tree_add_text(tree, tvb, offset, length,
503 "Pruning: Bad length %u",
510 proto_item_set_text(ti,
512 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
513 "Unknown (0x%04x)"));
514 proto_tree_add_text(tree, tvb, offset, 2,
516 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
517 "Unknown (0x%04x)"));
519 proto_item_set_text(ti,
520 "Bridge Type: Bad length %u",
522 proto_tree_add_text(tree, tvb, offset, length,
523 "Bridge Type: Bad length %u",
528 case MAX_ARE_HOP_CNT:
530 proto_item_set_text(ti,
531 "Max ARE Hop Count: %u",
532 tvb_get_ntohs(tvb, offset));
533 proto_tree_add_text(tree, tvb, offset, 2,
534 "Max ARE Hop Count: %u",
535 tvb_get_ntohs(tvb, offset));
537 proto_item_set_text(ti,
538 "Max ARE Hop Count: Bad length %u",
540 proto_tree_add_text(tree, tvb, offset, length,
541 "Max ARE Hop Count: Bad length %u",
546 case MAX_STE_HOP_CNT:
548 proto_item_set_text(ti,
549 "Max STE Hop Count: %u",
550 tvb_get_ntohs(tvb, offset));
551 proto_tree_add_text(tree, tvb, offset, 2,
552 "Max STE Hop Count: %u",
553 tvb_get_ntohs(tvb, offset));
555 proto_item_set_text(ti,
556 "Max STE Hop Count: Bad length %u",
558 proto_tree_add_text(tree, tvb, offset, length,
559 "Max STE Hop Count: Bad length %u",
564 case BACKUP_CRF_MODE:
566 proto_item_set_text(ti,
567 "Backup CRF Mode: %s",
568 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
569 "Unknown (0x%04x)"));
570 proto_tree_add_text(tree, tvb, offset, 2,
571 "Backup CRF Mode: %s",
572 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
573 "Unknown (0x%04x)"));
575 proto_item_set_text(ti,
576 "Backup CRF Mode: Bad length %u",
578 proto_tree_add_text(tree, tvb, offset, length,
579 "Backup CRF Mode: Bad length %u",
585 proto_tree_add_text(tree, tvb, offset, length, "Data");
591 proto_register_vtp(void)
593 static hf_register_info hf[] = {
595 { "Version", "vtp.version", FT_UINT8, BASE_HEX, NULL, 0x0,
599 { "Code", "vtp.code", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0,
603 { "Followers", "vtp.followers", FT_UINT8, BASE_DEC, NULL, 0x0,
604 "Number of following Subset-Advert messages", HFILL }},
607 { "Management Domain Length", "vtp.md_len", FT_UINT8, BASE_DEC, NULL, 0x0,
608 "Length of management domain string", HFILL }},
611 { "Management Domain", "vtp.md", FT_STRING, BASE_DEC, NULL, 0,
612 "Management domain", HFILL }},
614 { &hf_vtp_conf_rev_num,
615 { "Configuration Revision Number", "vtp.conf_rev_num", FT_UINT32, BASE_DEC, NULL, 0x0,
616 "Revision number of the configuration information", HFILL }},
619 { "Updater Identity", "vtp.upd_id", FT_IPv4, BASE_NONE, NULL, 0x0,
620 "IP address of the updater", HFILL }},
623 { "Update Timestamp", "vtp.upd_ts", FT_STRING, BASE_DEC, NULL, 0,
624 "Time stamp of the current configuration revision", HFILL }},
626 { &hf_vtp_md5_digest,
627 { "MD5 Digest", "vtp.md5_digest", FT_BYTES, BASE_HEX, NULL, 0x0,
631 { "Sequence Number", "vtp.seq_num", FT_UINT8, BASE_DEC, NULL, 0x0,
632 "Order of this frame in the sequence of Subset-Advert frames", HFILL }},
634 { &hf_vtp_start_value,
635 { "Start Value", "vtp.start_value", FT_UINT16, BASE_HEX, NULL, 0x0,
636 "Virtual LAN ID of first VLAN for which information is requested", HFILL }},
638 { &hf_vtp_vlan_info_len,
639 { "VLAN Information Length", "vtp.vlan_info.len", FT_UINT8, BASE_DEC, NULL, 0x0,
640 "Length of the VLAN information field", HFILL }},
642 { &hf_vtp_vlan_status_vlan_susp,
643 { "VLAN suspended", "vtp.vlan_info.status.vlan_susp", FT_BOOLEAN, 8, NULL, VLAN_SUSPENDED,
644 "VLAN suspended", HFILL }},
647 { "VLAN Type", "vtp.vlan_info.vlan_type", FT_UINT8, BASE_HEX, VALS(vlan_type_vals), 0x0,
648 "Type of VLAN", HFILL }},
650 { &hf_vtp_vlan_name_len,
651 { "VLAN Name Length", "vtp.vlan_info.vlan_name_len", FT_UINT8, BASE_DEC, NULL, 0x0,
652 "Length of VLAN name string", HFILL }},
654 { &hf_vtp_isl_vlan_id,
655 { "ISL VLAN ID", "vtp.vlan_info.isl_vlan_id", FT_UINT16, BASE_HEX, NULL, 0x0,
656 "ID of this VLAN on ISL trunks", HFILL }},
659 { "MTU Size", "vtp.vlan_info.mtu_size", FT_UINT16, BASE_DEC, NULL, 0x0,
660 "MTU for this VLAN", HFILL }},
662 { &hf_vtp_802_10_index,
663 { "802.10 Index", "vtp.vlan_info.802_10_index", FT_UINT32, BASE_HEX, NULL, 0x0,
664 "IEEE 802.10 security association identifier for this VLAN", HFILL }},
667 { "VLAN Name", "vtp.vlan_info.vlan_name", FT_STRING, BASE_DEC, NULL, 0,
668 "VLAN name", HFILL }},
670 { &hf_vtp_vlan_tlvtype,
671 { "Type", "vtp.vlan_info.tlv_type", FT_UINT8, BASE_HEX, VALS(vlan_tlv_type_vals), 0x0,
674 { &hf_vtp_vlan_tlvlength,
675 { "Length", "vtp.vlan_info.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0,
678 static gint *ett[] = {
681 &ett_vtp_vlan_status,
685 proto_vtp = proto_register_protocol("Virtual Trunking Protocol",
687 proto_register_field_array(proto_vtp, hf, array_length(hf));
688 proto_register_subtree_array(ett, array_length(ett));
692 proto_reg_handoff_vtp(void)
694 dissector_handle_t vtp_handle;
696 vtp_handle = create_dissector_handle(dissect_vtp, proto_vtp);
697 dissector_add("llc.cisco_pid", 0x2003, vtp_handle);