2 * Routines for the disassembly of Cisco's Virtual Trunking Protocol
4 * $Id: packet-vtp.c,v 1.6 2000/08/13 14:09:08 deniel 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(const u_char *pd, int offset, proto_tree *tree);
80 dissect_vlan_info_tlv(const u_char *pd, 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(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
98 proto_tree *vtp_tree = NULL;
104 OLD_CHECK_DISPLAY_AS_DATA(proto_vtp, pd, offset, fd, tree);
106 if (check_col(fd, COL_PROTOCOL))
107 col_add_str(fd, COL_PROTOCOL, "VTP");
108 if (check_col(fd, COL_INFO))
109 col_add_str(fd, COL_INFO, "Virtual Trunking Protocol");
112 ti = proto_tree_add_item(tree, proto_vtp, NullTVB, offset, END_OF_FRAME,
114 vtp_tree = proto_item_add_subtree(ti, ett_vtp);
116 proto_tree_add_uint(vtp_tree, hf_vtp_version, NullTVB, offset, 1,
121 proto_tree_add_uint(vtp_tree, hf_vtp_code, NullTVB, offset, 1,
128 proto_tree_add_uint(vtp_tree, hf_vtp_followers, NullTVB, offset,
133 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
137 proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
138 32, &pd[offset], "Management Domain: %.32s",
142 proto_tree_add_uint(vtp_tree, hf_vtp_conf_rev_num, NullTVB,
143 offset, 4, pntohl(&pd[offset]));
146 memcpy(&upd_id, &pd[offset], sizeof upd_id);
147 proto_tree_add_ipv4(vtp_tree, hf_vtp_upd_id, NullTVB,
151 proto_tree_add_string_format(vtp_tree, hf_vtp_upd_ts, NullTVB,
152 offset, 12, &pd[offset],
153 "Update Timestamp: %.2s-%.2s-%.2s %.2s:%.2s:%.2s",
154 &pd[offset], &pd[offset+2], &pd[offset+4],
155 &pd[offset+6], &pd[offset+8], &pd[offset+10]);
158 proto_tree_add_bytes(vtp_tree, hf_vtp_md5_digest, NullTVB,
159 offset, 16, &pd[offset]);
163 proto_tree_add_uint(vtp_tree, hf_vtp_seq_num, NullTVB, offset,
168 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
172 proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
173 32, &pd[offset], "Management Domain: %.32s",
177 proto_tree_add_uint(vtp_tree, hf_vtp_conf_rev_num, NullTVB,
178 offset, 4, pntohl(&pd[offset]));
183 dissect_vlan_info(pd, offset, vtp_tree);
184 if (vlan_info_len < 0)
186 offset += vlan_info_len;
191 offset += 1; /* skip reserved field */
194 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
198 proto_tree_add_uint(vtp_tree, hf_vtp_start_value, NullTVB,
199 offset, 2, pntohs(&pd[offset]));
204 * Mysterious type, seen a lot.
205 * Is this some mutant variant of Advert-Request?
207 offset += 1; /* skip unknown field */
210 proto_tree_add_uint(vtp_tree, hf_vtp_md_len, NullTVB, offset,
214 proto_tree_add_string_format(vtp_tree, hf_vtp_md, NullTVB, offset,
215 32, &pd[offset], "Management Domain: %.32s",
219 offset += 2; /* skip unknown field */
221 proto_tree_add_text(vtp_tree, NullTVB, offset, 2,
222 "VLAN ID of some sort: 0x%04x",
223 pntohs(&pd[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(const u_char *pd, 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 if (!BYTES_ARE_IN_FRAME(offset, 1))
283 vlan_info_len = pd[offset];
284 ti = proto_tree_add_text(tree, NullTVB, offset, vlan_info_len,
286 vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
287 vlan_info_left = vlan_info_len;
289 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, NullTVB, offset, 1,
294 if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
297 ti = proto_tree_add_text(vlan_info_tree, NullTVB, offset, 1,
298 "Status: 0x%02x%s", status,
299 (status & VLAN_SUSPENDED) ? "(VLAN suspended)" : "");
300 status_tree = proto_item_add_subtree(ti, ett_vtp_vlan_status);
301 proto_tree_add_boolean(status_tree, hf_vtp_vlan_status_vlan_susp, NullTVB, offset, 1,
306 if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
308 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_type, NullTVB, offset, 1,
313 if (!BYTES_ARE_IN_FRAME(offset, 1) || vlan_info_left < 1)
315 vlan_name_len = pd[offset];
316 proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_name_len, NullTVB, offset, 1,
321 if (!BYTES_ARE_IN_FRAME(offset, 2) || vlan_info_left < 2)
323 proto_tree_add_uint(vlan_info_tree, hf_vtp_isl_vlan_id, NullTVB, offset, 2,
324 pntohs(&pd[offset]));
328 if (!BYTES_ARE_IN_FRAME(offset, 2) || vlan_info_left < 2)
330 proto_tree_add_uint(vlan_info_tree, hf_vtp_mtu_size, NullTVB, offset, 2,
331 pntohs(&pd[offset]));
335 if (!BYTES_ARE_IN_FRAME(offset, 4) || vlan_info_left < 4)
337 proto_tree_add_uint(vlan_info_tree, hf_vtp_802_10_index, NullTVB, offset, 4,
338 pntohl(&pd[offset]));
342 /* VLAN name length appears to be rounded up to a multiple of
344 vlan_name_len = 4*((vlan_name_len + 3)/4);
345 if (!BYTES_ARE_IN_FRAME(offset, vlan_name_len)
346 || vlan_info_left < vlan_name_len)
348 proto_tree_add_string_format(vlan_info_tree, hf_vtp_vlan_name, NullTVB, offset,
349 vlan_name_len, &pd[offset], "VLAN Name: %.*s", vlan_name_len,
351 offset += vlan_name_len;
352 vlan_info_left -= vlan_name_len;
354 while (IS_DATA_IN_FRAME(offset) && vlan_info_left > 0) {
355 type = pd[offset + 0];
356 length = pd[offset + 1];
357 type_str = val_to_str(type, vlan_tlv_type_vals,
360 ti = proto_tree_add_notext(vlan_info_tree, NullTVB, offset,
362 tlv_tree = proto_item_add_subtree(ti, ett_vtp_tlv);
363 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvtype, NullTVB, offset,
365 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, NullTVB, offset+1,
370 dissect_vlan_info_tlv(pd, offset, length*2, tlv_tree,
374 vlan_info_left -= length*2;
377 return vlan_info_len;
380 static const value_string stp_type_vals[] = {
387 static const value_string pruning_vals[] = {
393 static const value_string bridge_type_vals[] = {
399 static const value_string backup_crf_mode_vals[] = {
400 { 1, "TrCRF is configured as a backup" },
401 { 2, "TrCRF is not configured as a backup" },
406 dissect_vlan_info_tlv(const u_char *pd, int offset, int length,
407 proto_tree *tree, proto_item *ti, guint8 type)
413 proto_item_set_text(ti,
414 "Source-Routing Ring Number: 0x%04x",
415 pntohs(&pd[offset]));
416 proto_tree_add_text(tree, NullTVB, offset, 2,
417 "Source-Routing Ring Number: 0x%04x",
418 pntohs(&pd[offset]));
420 proto_item_set_text(ti,
421 "Source-Routing Ring Number: Bad length %u",
423 proto_tree_add_text(tree, NullTVB, offset, length,
424 "Source-Routing Ring Number: Bad length %u",
431 proto_item_set_text(ti,
432 "Source-Routing Bridge Number: 0x%04x",
433 pntohs(&pd[offset]));
434 proto_tree_add_text(tree, NullTVB, offset, 2,
435 "Source-Routing Bridge Number: 0x%04x",
436 pntohs(&pd[offset]));
438 proto_item_set_text(ti,
439 "Source-Routing Bridge Number: Bad length %u",
441 proto_tree_add_text(tree, NullTVB, offset, length,
442 "Source-Routing Bridge Number: Bad length %u",
449 proto_item_set_text(ti,
450 "Spanning-Tree Protocol Type: %s",
451 val_to_str(pntohs(&pd[offset]), stp_type_vals,
452 "Unknown (0x%04x)"));
453 proto_tree_add_text(tree, NullTVB, offset, 2,
454 "Spanning-Tree Protocol Type: %s",
455 val_to_str(pntohs(&pd[offset]), stp_type_vals,
456 "Unknown (0x%04x)"));
458 proto_item_set_text(ti,
459 "Spanning-Tree Protocol Type: Bad length %u",
461 proto_tree_add_text(tree, NullTVB, offset, length,
462 "Spanning-Tree Protocol Type: Bad length %u",
469 proto_item_set_text(ti,
470 "Parent VLAN: 0x%04x",
471 pntohs(&pd[offset]));
472 proto_tree_add_text(tree, NullTVB, offset, 2,
473 "Parent VLAN: 0x%04x",
474 pntohs(&pd[offset]));
476 proto_item_set_text(ti,
477 "Parent VLAN: Bad length %u",
479 proto_tree_add_text(tree, NullTVB, offset, length,
480 "Parent VLAN: Bad length %u",
485 case TR_BRIDGED_VLANS:
487 proto_item_set_text(ti,
488 "Translationally Bridged VLANs: 0x%04x",
489 pntohs(&pd[offset]));
490 proto_tree_add_text(tree, NullTVB, offset, 2,
491 "Translationally Bridged VLANs: 0x%04x",
492 pntohs(&pd[offset]));
494 proto_item_set_text(ti,
495 "Translationally Bridged VLANs: Bad length %u",
497 proto_tree_add_text(tree, NullTVB, offset, length,
498 "Translationally Bridged VLANs: Bad length %u",
505 proto_item_set_text(ti,
507 val_to_str(pntohs(&pd[offset]), pruning_vals,
508 "Unknown (0x%04x)"));
509 proto_tree_add_text(tree, NullTVB, offset, 2,
511 val_to_str(pntohs(&pd[offset]), pruning_vals,
512 "Unknown (0x%04x)"));
514 proto_item_set_text(ti,
515 "Pruning: Bad length %u",
517 proto_tree_add_text(tree, NullTVB, offset, length,
518 "Pruning: Bad length %u",
525 proto_item_set_text(ti,
527 val_to_str(pntohs(&pd[offset]), bridge_type_vals,
528 "Unknown (0x%04x)"));
529 proto_tree_add_text(tree, NullTVB, offset, 2,
531 val_to_str(pntohs(&pd[offset]), bridge_type_vals,
532 "Unknown (0x%04x)"));
534 proto_item_set_text(ti,
535 "Bridge Type: Bad length %u",
537 proto_tree_add_text(tree, NullTVB, offset, length,
538 "Bridge Type: Bad length %u",
543 case MAX_ARE_HOP_CNT:
545 proto_item_set_text(ti,
546 "Max ARE Hop Count: %u",
547 pntohs(&pd[offset]));
548 proto_tree_add_text(tree, NullTVB, offset, 2,
549 "Max ARE Hop Count: %u",
550 pntohs(&pd[offset]));
552 proto_item_set_text(ti,
553 "Max ARE Hop Count: Bad length %u",
555 proto_tree_add_text(tree, NullTVB, offset, length,
556 "Max ARE Hop Count: Bad length %u",
561 case MAX_STE_HOP_CNT:
563 proto_item_set_text(ti,
564 "Max STE Hop Count: %u",
565 pntohs(&pd[offset]));
566 proto_tree_add_text(tree, NullTVB, offset, 2,
567 "Max STE Hop Count: %u",
568 pntohs(&pd[offset]));
570 proto_item_set_text(ti,
571 "Max STE Hop Count: Bad length %u",
573 proto_tree_add_text(tree, NullTVB, offset, length,
574 "Max STE Hop Count: Bad length %u",
579 case BACKUP_CRF_MODE:
581 proto_item_set_text(ti,
582 "Backup CRF Mode: %s",
583 val_to_str(pntohs(&pd[offset]), backup_crf_mode_vals,
584 "Unknown (0x%04x)"));
585 proto_tree_add_text(tree, NullTVB, offset, 2,
586 "Backup CRF Mode: %s",
587 val_to_str(pntohs(&pd[offset]), backup_crf_mode_vals,
588 "Unknown (0x%04x)"));
590 proto_item_set_text(ti,
591 "Backup CRF Mode: Bad length %u",
593 proto_tree_add_text(tree, NullTVB, offset, length,
594 "Backup CRF Mode: Bad length %u",
600 proto_item_set_text(ti, "Unknown TLV type: 0x%02x", type);
601 proto_tree_add_text(tree, NullTVB, offset, length, "Data");
607 proto_register_vtp(void)
609 static hf_register_info hf[] = {
611 { "Version", "vtp.version", FT_UINT8, BASE_HEX, NULL, 0x0,
615 { "Code", "vtp.code", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0,
619 { "Followers", "vtp.followers", FT_UINT8, BASE_DEC, NULL, 0x0,
620 "Number of following Subset-Advert messages" }},
623 { "Management Domain Length", "vtp.md_len", FT_UINT8, BASE_DEC, NULL, 0x0,
624 "Length of management domain string" }},
627 { "Management Domain", "vtp.md", FT_STRING, BASE_DEC, NULL, 0,
628 "Management domain" }},
630 { &hf_vtp_conf_rev_num,
631 { "Configuration Revision Number", "vtp.conf_rev_num", FT_UINT32, BASE_DEC, NULL, 0x0,
632 "Revision number of the configuration information" }},
635 { "Updater Identity", "vtp.upd_id", FT_IPv4, BASE_NONE, NULL, 0x0,
636 "IP address of the updater" }},
639 { "Update Timestamp", "vtp.upd_ts", FT_STRING, BASE_DEC, NULL, 0,
640 "Time stamp of the current configuration revision" }},
642 { &hf_vtp_md5_digest,
643 { "MD5 Digest", "vtp.md5_digest", FT_BYTES, BASE_HEX, NULL, 0x0,
647 { "Sequence Number", "vtp.seq_num", FT_UINT8, BASE_DEC, NULL, 0x0,
648 "Order of this frame in the sequence of Subset-Advert frames" }},
650 { &hf_vtp_start_value,
651 { "Start Value", "vtp.start_value", FT_UINT16, BASE_HEX, NULL, 0x0,
652 "Virtual LAN ID of first VLAN for which information is requested" }},
654 { &hf_vtp_vlan_info_len,
655 { "VLAN Information Length", "vtp.vlan_info.len", FT_UINT8, BASE_DEC, NULL, 0x0,
656 "Length of the VLAN information field" }},
658 { &hf_vtp_vlan_status_vlan_susp,
659 { "VLAN suspended", "vtp.vlan_info.status.vlan_susp", FT_BOOLEAN, 8, NULL, VLAN_SUSPENDED,
663 { "VLAN Type", "vtp.vlan_info.vlan_type", FT_UINT8, BASE_HEX, VALS(vlan_type_vals), 0x0,
666 { &hf_vtp_vlan_name_len,
667 { "VLAN Name Length", "vtp.vlan_info.vlan_name_len", FT_UINT8, BASE_DEC, NULL, 0x0,
668 "Length of VLAN name string" }},
670 { &hf_vtp_isl_vlan_id,
671 { "ISL VLAN ID", "vtp.vlan_info.isl_vlan_id", FT_UINT16, BASE_HEX, NULL, 0x0,
672 "ID of this VLAN on ISL trunks" }},
675 { "MTU Size", "vtp.vlan_info.mtu_size", FT_UINT16, BASE_DEC, NULL, 0x0,
676 "MTU for this VLAN" }},
678 { &hf_vtp_802_10_index,
679 { "802.10 Index", "vtp.vlan_info.802_10_index", FT_UINT32, BASE_HEX, NULL, 0x0,
680 "IEEE 802.10 security association identifier for this VLAN" }},
683 { "VLAN Name", "vtp.vlan_info.vlan_name", FT_STRING, BASE_DEC, NULL, 0,
686 { &hf_vtp_vlan_tlvtype,
687 { "Type", "vtp.vlan_info.tlv_type", FT_UINT8, BASE_HEX, VALS(vlan_tlv_type_vals), 0x0,
690 { &hf_vtp_vlan_tlvlength,
691 { "Length", "vtp.vlan_info.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0,
694 static gint *ett[] = {
697 &ett_vtp_vlan_status,
701 proto_vtp = proto_register_protocol("Virtual Trunking Protocol", "vtp");
702 proto_register_field_array(proto_vtp, hf, array_length(hf));
703 proto_register_subtree_array(ett, array_length(ett));