2 * Routines for the disassembly of Cisco's Virtual Trunking Protocol
4 * $Id: packet-vtp.c,v 1.9 2001/01/03 06:55:34 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
41 * http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
43 * for some information on VTP.
45 * It's incomplete, and it appears to be inaccurate in a number of places,
46 * but it's all I could find....
49 static int proto_vtp = -1;
50 static int hf_vtp_version = -1;
51 static int hf_vtp_code = -1;
52 static int hf_vtp_followers = -1;
53 static int hf_vtp_md_len = -1;
54 static int hf_vtp_md = -1;
55 static int hf_vtp_conf_rev_num = -1;
56 static int hf_vtp_upd_id = -1;
57 static int hf_vtp_upd_ts = -1;
58 static int hf_vtp_md5_digest = -1;
59 static int hf_vtp_seq_num = -1;
60 static int hf_vtp_start_value = -1;
61 static int hf_vtp_vlan_info_len = -1;
62 static int hf_vtp_vlan_status_vlan_susp = -1;
63 static int hf_vtp_vlan_type = -1;
64 static int hf_vtp_vlan_name_len = -1;
65 static int hf_vtp_isl_vlan_id = -1;
66 static int hf_vtp_mtu_size = -1;
67 static int hf_vtp_802_10_index = -1;
68 static int hf_vtp_vlan_name = -1;
69 static int hf_vtp_vlan_tlvtype = -1;
70 static int hf_vtp_vlan_tlvlength = -1;
72 static gint ett_vtp = -1;
73 static gint ett_vtp_vlan_info = -1;
74 static gint ett_vtp_vlan_status = -1;
75 static gint ett_vtp_tlv = -1;
78 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree);
80 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
81 proto_tree *tree, proto_item *ti, guint8 type);
83 #define SUMMARY_ADVERT 0x01
84 #define SUBSET_ADVERT 0x02
85 #define ADVERT_REQUEST 0x03
87 static const value_string type_vals[] = {
88 { SUMMARY_ADVERT, "Summary-Advert" },
89 { SUBSET_ADVERT, "Subset-Advert" },
90 { ADVERT_REQUEST, "Advert-Request" },
95 dissect_vtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
98 proto_tree *vtp_tree = NULL;
102 guint8 *upd_timestamp;
105 CHECK_DISPLAY_AS_DATA(proto_vtp, tvb, pinfo, tree);
107 pinfo->current_proto = "VTP";
109 if (check_col(pinfo->fd, COL_PROTOCOL))
110 col_set_str(pinfo->fd, COL_PROTOCOL, "VTP");
111 if (check_col(pinfo->fd, COL_INFO))
112 col_set_str(pinfo->fd, COL_INFO, "Virtual Trunking Protocol");
115 ti = proto_tree_add_item(tree, proto_vtp, tvb, offset,
116 tvb_length_remaining(tvb, offset), FALSE);
117 vtp_tree = proto_item_add_subtree(ti, ett_vtp);
119 proto_tree_add_item(vtp_tree, hf_vtp_version, tvb, offset, 1,
123 code = tvb_get_guint8(tvb, offset);
124 proto_tree_add_uint(vtp_tree, hf_vtp_code, tvb, offset, 1,
131 proto_tree_add_item(vtp_tree, hf_vtp_followers, tvb, offset,
135 md_len = tvb_get_guint8(tvb, offset);
136 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
140 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
144 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
148 proto_tree_add_item(vtp_tree, hf_vtp_upd_id, tvb,
152 upd_timestamp = tvb_get_ptr(tvb, offset, 12);
153 proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, tvb,
154 offset, 12, upd_timestamp,
155 "Update Timestamp: %.2s-%.2s-%.2s %.2s:%.2s:%.2s",
156 &upd_timestamp[0], &upd_timestamp[2], &upd_timestamp[4],
157 &upd_timestamp[6], &upd_timestamp[8], &upd_timestamp[10]);
160 proto_tree_add_item(vtp_tree, hf_vtp_md5_digest, tvb,
165 proto_tree_add_item(vtp_tree, hf_vtp_seq_num, tvb, offset,
169 md_len = tvb_get_guint8(tvb, offset);
170 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
174 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
178 proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
182 while (tvb_reported_length_remaining(tvb, offset) > 0) {
184 dissect_vlan_info(tvb, offset, vtp_tree);
185 if (vlan_info_len < 0)
187 offset += vlan_info_len;
192 offset += 1; /* skip reserved field */
194 md_len = tvb_get_guint8(tvb, offset);
195 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
199 proto_tree_add_item(vtp_tree, hf_vtp_start_value, tvb,
205 * Mysterious type, seen a lot.
206 * Is this some mutant variant of Advert-Request?
208 offset += 1; /* skip unknown field */
210 md_len = tvb_get_guint8(tvb, offset);
211 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
215 proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
219 offset += 2; /* skip unknown field */
221 proto_tree_add_text(vtp_tree, tvb, offset, 2,
222 "VLAN ID of some sort: 0x%04x",
223 tvb_get_ntohs(tvb, offset));
230 #define VLAN_SUSPENDED 0x01
232 static const value_string vlan_type_vals[] = {
233 { 0x01, "Ethernet" },
236 { 0x04, "FDDI-net" },
241 #define SR_RING_NUM 0x01
242 #define SR_BRIDGE_NUM 0x02
243 #define STP_TYPE 0x03
244 #define PARENT_VLAN 0x04
245 #define TR_BRIDGED_VLANS 0x05
247 #define BRIDGE_TYPE 0x07
248 #define MAX_ARE_HOP_CNT 0x08
249 #define MAX_STE_HOP_CNT 0x09
250 #define BACKUP_CRF_MODE 0x0A
252 static const value_string vlan_tlv_type_vals[] = {
253 { SR_RING_NUM, "Source-Routing Ring Number" },
254 { SR_BRIDGE_NUM, "Source-Routing Bridge Number" },
255 { STP_TYPE, "Spanning-Tree Protocol Type" },
256 { PARENT_VLAN, "Parent VLAN" },
257 { TR_BRIDGED_VLANS, "Translationally Bridged VLANs" },
258 { PRUNING, "Pruning" },
259 { BRIDGE_TYPE, "Bridge Type" },
260 { MAX_ARE_HOP_CNT, "Max ARE Hop Count" },
261 { MAX_STE_HOP_CNT, "Max STE Hop Count" },
262 { BACKUP_CRF_MODE, "Backup CRF Mode" },
267 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree)
270 proto_tree *vlan_info_tree;
271 proto_tree *status_tree;
272 guint8 vlan_info_len;
275 guint8 vlan_name_len;
279 proto_tree *tlv_tree;
281 vlan_info_len = tvb_get_guint8(tvb, offset);
282 ti = proto_tree_add_text(tree, tvb, offset, vlan_info_len,
284 vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
285 vlan_info_left = vlan_info_len;
287 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, tvb, offset, 1,
292 if (vlan_info_left < 1)
294 status = tvb_get_guint8(tvb, offset);
295 ti = proto_tree_add_text(vlan_info_tree, tvb, offset, 1,
296 "Status: 0x%02x%s", status,
297 (status & VLAN_SUSPENDED) ? "(VLAN suspended)" : "");
298 status_tree = proto_item_add_subtree(ti, ett_vtp_vlan_status);
299 proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, tvb, offset, 1,
304 if (vlan_info_left < 1)
306 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_type, tvb, offset, 1,
311 if (vlan_info_left < 1)
313 vlan_name_len = tvb_get_guint8(tvb, offset);
314 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, tvb, offset, 1,
319 if (vlan_info_left < 2)
321 proto_tree_add_item(vlan_info_tree, hf_vtp_isl_vlan_id, tvb, offset, 2,
326 if (vlan_info_left < 2)
328 proto_tree_add_item(vlan_info_tree, hf_vtp_mtu_size, tvb, offset, 2,
333 if (vlan_info_left < 4)
335 proto_tree_add_item(vlan_info_tree, hf_vtp_802_10_index, tvb, offset, 4,
340 /* VLAN name length appears to be rounded up to a multiple of 4. */
341 vlan_name_len = 4*((vlan_name_len + 3)/4);
342 if (vlan_info_left < vlan_name_len)
344 proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_name, tvb, offset,
345 vlan_name_len, FALSE);
346 offset += vlan_name_len;
347 vlan_info_left -= vlan_name_len;
349 while (vlan_info_left > 0) {
350 type = tvb_get_guint8(tvb, offset + 0);
351 length = tvb_get_guint8(tvb, offset + 1);
352 type_str = val_to_str(type, vlan_tlv_type_vals,
355 ti = proto_tree_add_notext(vlan_info_tree, tvb, offset,
357 tlv_tree = proto_item_add_subtree(ti, ett_vtp_tlv);
358 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, tvb, offset,
360 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, tvb, offset+1,
365 dissect_vlan_info_tlv(tvb, offset, length*2, tlv_tree,
369 vlan_info_left -= length*2;
372 return vlan_info_len;
375 static const value_string stp_type_vals[] = {
382 static const value_string pruning_vals[] = {
388 static const value_string bridge_type_vals[] = {
394 static const value_string backup_crf_mode_vals[] = {
395 { 1, "TrCRF is configured as a backup" },
396 { 2, "TrCRF is not configured as a backup" },
401 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
402 proto_tree *tree, proto_item *ti, guint8 type)
408 proto_item_set_text(ti,
409 "Source-Routing Ring Number: 0x%04x",
410 tvb_get_ntohs(tvb, offset));
411 proto_tree_add_text(tree, tvb, offset, 2,
412 "Source-Routing Ring Number: 0x%04x",
413 tvb_get_ntohs(tvb, offset));
415 proto_item_set_text(ti,
416 "Source-Routing Ring Number: Bad length %u",
418 proto_tree_add_text(tree, tvb, offset, length,
419 "Source-Routing Ring Number: Bad length %u",
426 proto_item_set_text(ti,
427 "Source-Routing Bridge Number: 0x%04x",
428 tvb_get_ntohs(tvb, offset));
429 proto_tree_add_text(tree, tvb, offset, 2,
430 "Source-Routing Bridge Number: 0x%04x",
431 tvb_get_ntohs(tvb, offset));
433 proto_item_set_text(ti,
434 "Source-Routing Bridge Number: Bad length %u",
436 proto_tree_add_text(tree, tvb, offset, length,
437 "Source-Routing Bridge Number: Bad length %u",
444 proto_item_set_text(ti,
445 "Spanning-Tree Protocol Type: %s",
446 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
447 "Unknown (0x%04x)"));
448 proto_tree_add_text(tree, tvb, offset, 2,
449 "Spanning-Tree Protocol Type: %s",
450 val_to_str(tvb_get_ntohs(tvb, offset), stp_type_vals,
451 "Unknown (0x%04x)"));
453 proto_item_set_text(ti,
454 "Spanning-Tree Protocol Type: Bad length %u",
456 proto_tree_add_text(tree, tvb, offset, length,
457 "Spanning-Tree Protocol Type: Bad length %u",
464 proto_item_set_text(ti,
465 "Parent VLAN: 0x%04x",
466 tvb_get_ntohs(tvb, offset));
467 proto_tree_add_text(tree, tvb, offset, 2,
468 "Parent VLAN: 0x%04x",
469 tvb_get_ntohs(tvb, offset));
471 proto_item_set_text(ti,
472 "Parent VLAN: Bad length %u",
474 proto_tree_add_text(tree, tvb, offset, length,
475 "Parent VLAN: Bad length %u",
480 case TR_BRIDGED_VLANS:
482 proto_item_set_text(ti,
483 "Translationally Bridged VLANs: 0x%04x",
484 tvb_get_ntohs(tvb, offset));
485 proto_tree_add_text(tree, tvb, offset, 2,
486 "Translationally Bridged VLANs: 0x%04x",
487 tvb_get_ntohs(tvb, offset));
489 proto_item_set_text(ti,
490 "Translationally Bridged VLANs: Bad length %u",
492 proto_tree_add_text(tree, tvb, offset, length,
493 "Translationally Bridged VLANs: Bad length %u",
500 proto_item_set_text(ti,
502 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
503 "Unknown (0x%04x)"));
504 proto_tree_add_text(tree, tvb, offset, 2,
506 val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
507 "Unknown (0x%04x)"));
509 proto_item_set_text(ti,
510 "Pruning: Bad length %u",
512 proto_tree_add_text(tree, tvb, offset, length,
513 "Pruning: Bad length %u",
520 proto_item_set_text(ti,
522 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
523 "Unknown (0x%04x)"));
524 proto_tree_add_text(tree, tvb, offset, 2,
526 val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
527 "Unknown (0x%04x)"));
529 proto_item_set_text(ti,
530 "Bridge Type: Bad length %u",
532 proto_tree_add_text(tree, tvb, offset, length,
533 "Bridge Type: Bad length %u",
538 case MAX_ARE_HOP_CNT:
540 proto_item_set_text(ti,
541 "Max ARE Hop Count: %u",
542 tvb_get_ntohs(tvb, offset));
543 proto_tree_add_text(tree, tvb, offset, 2,
544 "Max ARE Hop Count: %u",
545 tvb_get_ntohs(tvb, offset));
547 proto_item_set_text(ti,
548 "Max ARE Hop Count: Bad length %u",
550 proto_tree_add_text(tree, tvb, offset, length,
551 "Max ARE Hop Count: Bad length %u",
556 case MAX_STE_HOP_CNT:
558 proto_item_set_text(ti,
559 "Max STE Hop Count: %u",
560 tvb_get_ntohs(tvb, offset));
561 proto_tree_add_text(tree, tvb, offset, 2,
562 "Max STE Hop Count: %u",
563 tvb_get_ntohs(tvb, offset));
565 proto_item_set_text(ti,
566 "Max STE Hop Count: Bad length %u",
568 proto_tree_add_text(tree, tvb, offset, length,
569 "Max STE Hop Count: Bad length %u",
574 case BACKUP_CRF_MODE:
576 proto_item_set_text(ti,
577 "Backup CRF Mode: %s",
578 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
579 "Unknown (0x%04x)"));
580 proto_tree_add_text(tree, tvb, offset, 2,
581 "Backup CRF Mode: %s",
582 val_to_str(tvb_get_ntohs(tvb, offset), backup_crf_mode_vals,
583 "Unknown (0x%04x)"));
585 proto_item_set_text(ti,
586 "Backup CRF Mode: Bad length %u",
588 proto_tree_add_text(tree, tvb, offset, length,
589 "Backup CRF Mode: Bad length %u",
595 proto_item_set_text(ti, "Unknown TLV type: 0x%02x", type);
596 proto_tree_add_text(tree, tvb, offset, length, "Data");
602 proto_register_vtp(void)
604 static hf_register_info hf[] = {
606 { "Version", "vtp.version", FT_UINT8, BASE_HEX, NULL, 0x0,
610 { "Code", "vtp.code", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0,
614 { "Followers", "vtp.followers", FT_UINT8, BASE_DEC, NULL, 0x0,
615 "Number of following Subset-Advert messages" }},
618 { "Management Domain Length", "vtp.md_len", FT_UINT8, BASE_DEC, NULL, 0x0,
619 "Length of management domain string" }},
622 { "Management Domain", "vtp.md", FT_STRING, BASE_DEC, NULL, 0,
623 "Management domain" }},
625 { &hf_vtp_conf_rev_num,
626 { "Configuration Revision Number", "vtp.conf_rev_num", FT_UINT32, BASE_DEC, NULL, 0x0,
627 "Revision number of the configuration information" }},
630 { "Updater Identity", "vtp.upd_id", FT_IPv4, BASE_NONE, NULL, 0x0,
631 "IP address of the updater" }},
634 { "Update Timestamp", "vtp.upd_ts", FT_STRING, BASE_DEC, NULL, 0,
635 "Time stamp of the current configuration revision" }},
637 { &hf_vtp_md5_digest,
638 { "MD5 Digest", "vtp.md5_digest", FT_BYTES, BASE_HEX, NULL, 0x0,
642 { "Sequence Number", "vtp.seq_num", FT_UINT8, BASE_DEC, NULL, 0x0,
643 "Order of this frame in the sequence of Subset-Advert frames" }},
645 { &hf_vtp_start_value,
646 { "Start Value", "vtp.start_value", FT_UINT16, BASE_HEX, NULL, 0x0,
647 "Virtual LAN ID of first VLAN for which information is requested" }},
649 { &hf_vtp_vlan_info_len,
650 { "VLAN Information Length", "vtp.vlan_info.len", FT_UINT8, BASE_DEC, NULL, 0x0,
651 "Length of the VLAN information field" }},
653 { &hf_vtp_vlan_status_vlan_susp,
654 { "VLAN suspended", "vtp.vlan_info.status.vlan_susp", FT_BOOLEAN, 8, NULL, VLAN_SUSPENDED,
658 { "VLAN Type", "vtp.vlan_info.vlan_type", FT_UINT8, BASE_HEX, VALS(vlan_type_vals), 0x0,
661 { &hf_vtp_vlan_name_len,
662 { "VLAN Name Length", "vtp.vlan_info.vlan_name_len", FT_UINT8, BASE_DEC, NULL, 0x0,
663 "Length of VLAN name string" }},
665 { &hf_vtp_isl_vlan_id,
666 { "ISL VLAN ID", "vtp.vlan_info.isl_vlan_id", FT_UINT16, BASE_HEX, NULL, 0x0,
667 "ID of this VLAN on ISL trunks" }},
670 { "MTU Size", "vtp.vlan_info.mtu_size", FT_UINT16, BASE_DEC, NULL, 0x0,
671 "MTU for this VLAN" }},
673 { &hf_vtp_802_10_index,
674 { "802.10 Index", "vtp.vlan_info.802_10_index", FT_UINT32, BASE_HEX, NULL, 0x0,
675 "IEEE 802.10 security association identifier for this VLAN" }},
678 { "VLAN Name", "vtp.vlan_info.vlan_name", FT_STRING, BASE_DEC, NULL, 0,
681 { &hf_vtp_vlan_tlvtype,
682 { "Type", "vtp.vlan_info.tlv_type", FT_UINT8, BASE_HEX, VALS(vlan_tlv_type_vals), 0x0,
685 { &hf_vtp_vlan_tlvlength,
686 { "Length", "vtp.vlan_info.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0,
689 static gint *ett[] = {
692 &ett_vtp_vlan_status,
696 proto_vtp = proto_register_protocol("Virtual Trunking Protocol",
698 proto_register_field_array(proto_vtp, hf, array_length(hf));
699 proto_register_subtree_array(ett, array_length(ett));
703 proto_reg_handoff_vtp(void)
705 dissector_add("llc.cisco_pid", 0x2003, dissect_vtp);