Replace the types from sys/types.h and netinet/in.h by their glib.h
[obnox/wireshark/wip.git] / packet-vtp.c
1 /* packet-vtp.c
2  * Routines for the disassembly of Cisco's Virtual Trunking Protocol
3  *
4  * $Id: packet-vtp.c,v 1.20 2002/08/02 23:36:04 jmayer Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  * 
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.
14  * 
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.
19  * 
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.
23  */
24  
25 #include "config.h"
26
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include <glib.h>
31 #include <epan/packet.h>
32
33 /*
34  * See
35  *
36  *      http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
37  *
38  * for some information on VTP.
39  *
40  * It's incomplete, and it appears to be inaccurate in a number of places,
41  * but it's all I could find....
42  */
43
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;
66
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;
71
72 static int
73 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree);
74 static void
75 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
76     proto_tree *tree, proto_item *ti, guint8 type);
77
78 #define SUMMARY_ADVERT          0x01
79 #define SUBSET_ADVERT           0x02
80 #define ADVERT_REQUEST          0x03
81
82 static const value_string type_vals[] = {
83         { SUMMARY_ADVERT, "Summary-Advert" },
84         { SUBSET_ADVERT,  "Subset-Advert" },
85         { ADVERT_REQUEST, "Advert-Request" },
86         { 0,              NULL },
87 };
88         
89 static void 
90 dissect_vtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
91 {
92         proto_item *ti; 
93         proto_tree *vtp_tree = NULL;
94         int offset = 0;
95         guint8 code;
96         guint8 md_len;
97         const guint8 *upd_timestamp;
98         int vlan_info_len;
99
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"); 
104
105         if (tree) {
106                 ti = proto_tree_add_item(tree, proto_vtp, tvb, offset, -1,
107                     FALSE);
108                 vtp_tree = proto_item_add_subtree(ti, ett_vtp);
109
110                 proto_tree_add_item(vtp_tree, hf_vtp_version, tvb, offset, 1,
111                     FALSE);
112                 offset += 1;
113
114                 code = tvb_get_guint8(tvb, offset);
115                 proto_tree_add_uint(vtp_tree, hf_vtp_code, tvb, offset, 1,
116                     code);
117                 offset += 1;
118                 
119                 switch (code) {
120
121                 case SUMMARY_ADVERT:
122                         proto_tree_add_item(vtp_tree, hf_vtp_followers, tvb, offset,
123                             1, FALSE);
124                         offset += 1;
125
126                         md_len = tvb_get_guint8(tvb, offset);
127                         proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
128                             1, md_len);
129                         offset += 1;
130
131                         proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
132                             32, FALSE);
133                         offset += 32;
134
135                         proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
136                             offset, 4, FALSE);
137                         offset += 4;
138
139                         proto_tree_add_item(vtp_tree, hf_vtp_upd_id, tvb,
140                             offset, 4, FALSE);
141                         offset += 4;
142
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]);
149                         offset += 12;
150
151                         proto_tree_add_item(vtp_tree, hf_vtp_md5_digest, tvb,
152                             offset, 16, FALSE);
153                         break;
154
155                 case SUBSET_ADVERT:
156                         proto_tree_add_item(vtp_tree, hf_vtp_seq_num, tvb, offset,
157                             1, FALSE);
158                         offset += 1;
159
160                         md_len = tvb_get_guint8(tvb, offset);
161                         proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
162                             1, md_len);
163                         offset += 1;
164
165                         proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
166                             32, FALSE);
167                         offset += 32;
168
169                         proto_tree_add_item(vtp_tree, hf_vtp_conf_rev_num, tvb,
170                             offset, 4, FALSE);
171                         offset += 4;
172
173                         while (tvb_reported_length_remaining(tvb, offset) > 0) {
174                                 vlan_info_len = 
175                                     dissect_vlan_info(tvb, offset, vtp_tree);
176                                 if (vlan_info_len < 0)
177                                         break;
178                                 offset += vlan_info_len;
179                         }
180                         break;
181
182                 case ADVERT_REQUEST:
183                         offset += 1;    /* skip reserved field */
184
185                         md_len = tvb_get_guint8(tvb, offset);
186                         proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
187                             1, md_len);
188                         offset += 1;
189
190                         proto_tree_add_item(vtp_tree, hf_vtp_start_value, tvb,
191                             offset, 2, FALSE);
192                         break;
193
194                 case 0x04:
195                         /*
196                          * Mysterious type, seen a lot.
197                          * Is this some mutant variant of Advert-Request?
198                          */
199                         offset += 1;    /* skip unknown field */
200
201                         md_len = tvb_get_guint8(tvb, offset);
202                         proto_tree_add_uint(vtp_tree, hf_vtp_md_len, tvb, offset,
203                             1, md_len);
204                         offset += 1;
205
206                         proto_tree_add_item(vtp_tree, hf_vtp_md, tvb, offset,
207                             32, FALSE);
208                         offset += 32;
209
210                         offset += 2;    /* skip unknown field */
211
212                         proto_tree_add_text(vtp_tree, tvb, offset, 2,
213                             "VLAN ID of some sort: 0x%04x",
214                             tvb_get_ntohs(tvb, offset));
215                         offset += 2;
216                         break;
217                 }
218         }
219 }
220
221 #define VLAN_SUSPENDED  0x01
222
223 static const value_string vlan_type_vals[] = {
224         { 0x01, "Ethernet" },
225         { 0x02, "FDDI" },
226         { 0x03, "TrCRF" },
227         { 0x04, "FDDI-net" },
228         { 0x05, "TrBRF" },
229         { 0,    NULL },
230 };
231
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
237 #define PRUNING                 0x06
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
242
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" },
254         { 0,                NULL },
255 };
256
257 static int
258 dissect_vlan_info(tvbuff_t *tvb, int offset, proto_tree *tree)
259 {
260         proto_item *ti; 
261         proto_tree *vlan_info_tree;
262         proto_tree *status_tree;
263         guint8 vlan_info_len;
264         int vlan_info_left;
265         guint8 status;
266         guint8 vlan_name_len;
267         guint8 type;
268         int length;
269         proto_tree *tlv_tree;
270
271         vlan_info_len = tvb_get_guint8(tvb, offset);
272         ti = proto_tree_add_text(tree, tvb, offset, vlan_info_len,
273             "VLAN Information");
274         vlan_info_tree = proto_item_add_subtree(ti, ett_vtp_vlan_info);
275         vlan_info_left = vlan_info_len;
276
277         proto_tree_add_uint(vlan_info_tree, hf_vtp_vlan_info_len, tvb, offset, 1,
278             vlan_info_len);
279         offset += 1;
280         vlan_info_left -= 1;
281
282         if (vlan_info_left < 1)
283                 return -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,
290             status);
291         offset += 1;
292         vlan_info_left -= 1;
293
294         if (vlan_info_left < 1)
295                 return -1;
296         proto_tree_add_item(vlan_info_tree, hf_vtp_vlan_type, tvb, offset, 1,
297             FALSE);
298         offset += 1;
299         vlan_info_left -= 1;
300
301         if (vlan_info_left < 1)
302                 return -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,
305             vlan_name_len);
306         offset += 1;
307         vlan_info_left -= 1;
308
309         if (vlan_info_left < 2)
310                 return -1;
311         proto_tree_add_item(vlan_info_tree, hf_vtp_isl_vlan_id, tvb, offset, 2,
312             FALSE);
313         offset += 2;
314         vlan_info_left -= 2;
315
316         if (vlan_info_left < 2)
317                 return -1;
318         proto_tree_add_item(vlan_info_tree, hf_vtp_mtu_size, tvb, offset, 2,
319             FALSE);
320         offset += 2;
321         vlan_info_left -= 2;
322
323         if (vlan_info_left < 4)
324                 return -1;
325         proto_tree_add_item(vlan_info_tree, hf_vtp_802_10_index, tvb, offset, 4,
326             FALSE);
327         offset += 4;
328         vlan_info_left -= 4;
329
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)
333                 return -1;
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;
338
339         while (vlan_info_left > 0) {
340                 type = tvb_get_guint8(tvb, offset + 0);
341                 length = tvb_get_guint8(tvb, offset + 1);
342
343                 ti = proto_tree_add_text(vlan_info_tree, tvb, offset,
344                     2 + length*2, "%s",
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,
349                     1, type);
350                 proto_tree_add_uint(tlv_tree, hf_vtp_vlan_tlvlength, tvb, offset+1,
351                     1, length);
352                 offset += 2;
353                 vlan_info_left -= 2;
354                 if (length > 0) {
355                         dissect_vlan_info_tlv(tvb, offset, length*2, tlv_tree,
356                             ti, type);
357                 }
358                 offset += length*2;
359                 vlan_info_left -= length*2;
360         }
361
362         return vlan_info_len;
363 }
364
365 static const value_string stp_type_vals[] = {
366         { 1, "SRT" },
367         { 2, "SRB" },
368         { 3, "Auto" },
369         { 0, NULL },
370 };
371
372 static const value_string pruning_vals[] = {
373         { 1, "Enabled" },
374         { 2, "Disabled" },
375         { 0, NULL },
376 };
377
378 static const value_string bridge_type_vals[] = {
379         { 1, "SRT" },
380         { 2, "SRB" },
381         { 0, NULL },
382 };
383
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" },
387         { 0, NULL },
388 };
389
390 static void
391 dissect_vlan_info_tlv(tvbuff_t *tvb, int offset, int length,
392     proto_tree *tree, proto_item *ti, guint8 type)
393 {
394         switch (type) {
395
396         case SR_RING_NUM:
397                 if (length == 2) {
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));
404                 } else {
405                         proto_item_set_text(ti,
406                             "Source-Routing Ring Number: Bad length %u",
407                             length);
408                         proto_tree_add_text(tree, tvb, offset, length,
409                             "Source-Routing Ring Number: Bad length %u",
410                             length);
411                 }
412                 break;
413
414         case SR_BRIDGE_NUM:
415                 if (length == 2) {
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));
422                 } else {
423                         proto_item_set_text(ti,
424                             "Source-Routing Bridge Number: Bad length %u",
425                             length);
426                         proto_tree_add_text(tree, tvb, offset, length,
427                             "Source-Routing Bridge Number: Bad length %u",
428                             length);
429                 }
430                 break;
431
432         case STP_TYPE:
433                 if (length == 2) {
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)"));
442                 } else {
443                         proto_item_set_text(ti,
444                             "Spanning-Tree Protocol Type: Bad length %u",
445                             length);
446                         proto_tree_add_text(tree, tvb, offset, length,
447                             "Spanning-Tree Protocol Type: Bad length %u",
448                             length);
449                 }
450                 break;
451
452         case PARENT_VLAN:
453                 if (length == 2) {
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));
460                 } else {
461                         proto_item_set_text(ti,
462                             "Parent VLAN: Bad length %u",
463                             length);
464                         proto_tree_add_text(tree, tvb, offset, length,
465                             "Parent VLAN: Bad length %u",
466                             length);
467                 }
468                 break;
469
470         case TR_BRIDGED_VLANS:
471                 if (length == 2) {
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));
478                 } else {
479                         proto_item_set_text(ti,
480                             "Translationally Bridged VLANs: Bad length %u",
481                             length);
482                         proto_tree_add_text(tree, tvb, offset, length,
483                             "Translationally Bridged VLANs: Bad length %u",
484                             length);
485                 }
486                 break;
487
488         case PRUNING:
489                 if (length == 2) {
490                         proto_item_set_text(ti,
491                             "Pruning: %s",
492                             val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
493                               "Unknown (0x%04x)"));
494                         proto_tree_add_text(tree, tvb, offset, 2,
495                             "Pruning: %s",
496                             val_to_str(tvb_get_ntohs(tvb, offset), pruning_vals,
497                               "Unknown (0x%04x)"));
498                 } else {
499                         proto_item_set_text(ti,
500                             "Pruning: Bad length %u",
501                             length);
502                         proto_tree_add_text(tree, tvb, offset, length,
503                             "Pruning: Bad length %u",
504                             length);
505                 }
506                 break;
507
508         case BRIDGE_TYPE:
509                 if (length == 2) {
510                         proto_item_set_text(ti,
511                             "Bridge Type: %s",
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,
515                             "Bridge Type: %s",
516                             val_to_str(tvb_get_ntohs(tvb, offset), bridge_type_vals,
517                               "Unknown (0x%04x)"));
518                 } else {
519                         proto_item_set_text(ti,
520                             "Bridge Type: Bad length %u",
521                             length);
522                         proto_tree_add_text(tree, tvb, offset, length,
523                             "Bridge Type: Bad length %u",
524                             length);
525                 }
526                 break;
527
528         case MAX_ARE_HOP_CNT:
529                 if (length == 2) {
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));
536                 } else {
537                         proto_item_set_text(ti,
538                             "Max ARE Hop Count: Bad length %u",
539                             length);
540                         proto_tree_add_text(tree, tvb, offset, length,
541                             "Max ARE Hop Count: Bad length %u",
542                             length);
543                 }
544                 break;
545
546         case MAX_STE_HOP_CNT:
547                 if (length == 2) {
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));
554                 } else {
555                         proto_item_set_text(ti,
556                             "Max STE Hop Count: Bad length %u",
557                             length);
558                         proto_tree_add_text(tree, tvb, offset, length,
559                             "Max STE Hop Count: Bad length %u",
560                             length);
561                 }
562                 break;
563
564         case BACKUP_CRF_MODE:
565                 if (length == 2) {
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)"));
574                 } else {
575                         proto_item_set_text(ti,
576                             "Backup CRF Mode: Bad length %u",
577                             length);
578                         proto_tree_add_text(tree, tvb, offset, length,
579                             "Backup CRF Mode: Bad length %u",
580                             length);
581                 }
582                 break;
583
584         default:
585                 proto_tree_add_text(tree, tvb, offset, length, "Data");
586                 break;
587         }
588 }
589
590 void
591 proto_register_vtp(void)
592 {
593         static hf_register_info hf[] = {
594                 { &hf_vtp_version,
595                 { "Version",    "vtp.version", FT_UINT8, BASE_HEX, NULL, 0x0,
596                         "", HFILL }},
597
598                 { &hf_vtp_code,
599                 { "Code",       "vtp.code", FT_UINT8, BASE_HEX, VALS(type_vals), 0x0,
600                         "", HFILL }},
601
602                 { &hf_vtp_followers,
603                 { "Followers",  "vtp.followers", FT_UINT8, BASE_DEC, NULL, 0x0,
604                         "Number of following Subset-Advert messages", HFILL }},
605
606                 { &hf_vtp_md_len,
607                 { "Management Domain Length", "vtp.md_len", FT_UINT8, BASE_DEC, NULL, 0x0,
608                         "Length of management domain string", HFILL }},
609
610                 { &hf_vtp_md,
611                 { "Management Domain", "vtp.md", FT_STRING, BASE_DEC, NULL, 0,
612                         "Management domain", HFILL }},
613
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 }},
617
618                 { &hf_vtp_upd_id,
619                 { "Updater Identity", "vtp.upd_id", FT_IPv4, BASE_NONE, NULL, 0x0,
620                         "IP address of the updater", HFILL }},
621
622                 { &hf_vtp_upd_ts,
623                 { "Update Timestamp", "vtp.upd_ts", FT_STRING, BASE_DEC, NULL, 0,
624                         "Time stamp of the current configuration revision", HFILL }},
625
626                 { &hf_vtp_md5_digest,
627                 { "MD5 Digest", "vtp.md5_digest", FT_BYTES, BASE_HEX, NULL, 0x0,
628                         "", HFILL }},
629
630                 { &hf_vtp_seq_num,
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 }},
633
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 }},
637
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 }},
641
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 }},
645
646                 { &hf_vtp_vlan_type,
647                 { "VLAN Type",  "vtp.vlan_info.vlan_type", FT_UINT8, BASE_HEX, VALS(vlan_type_vals), 0x0,
648                         "Type of VLAN", HFILL }},
649
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 }},
653
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 }},
657
658                 { &hf_vtp_mtu_size,
659                 { "MTU Size",   "vtp.vlan_info.mtu_size", FT_UINT16, BASE_DEC, NULL, 0x0,
660                         "MTU for this VLAN", HFILL }},
661
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 }},
665
666                 { &hf_vtp_vlan_name,
667                 { "VLAN Name", "vtp.vlan_info.vlan_name", FT_STRING, BASE_DEC, NULL, 0,
668                         "VLAN name", HFILL }},
669
670                 { &hf_vtp_vlan_tlvtype,
671                 { "Type",       "vtp.vlan_info.tlv_type", FT_UINT8, BASE_HEX, VALS(vlan_tlv_type_vals), 0x0,
672                         "", HFILL }},
673
674                 { &hf_vtp_vlan_tlvlength,
675                 { "Length",     "vtp.vlan_info.tlv_len", FT_UINT8, BASE_DEC, NULL, 0x0,
676                         "", HFILL }},
677         };
678         static gint *ett[] = {
679                 &ett_vtp,
680                 &ett_vtp_vlan_info,
681                 &ett_vtp_vlan_status,
682                 &ett_vtp_tlv,
683         };
684
685         proto_vtp = proto_register_protocol("Virtual Trunking Protocol",
686             "VTP", "vtp");
687         proto_register_field_array(proto_vtp, hf, array_length(hf));
688         proto_register_subtree_array(ett, array_length(ett));
689 }
690
691 void
692 proto_reg_handoff_vtp(void)
693 {
694         dissector_handle_t vtp_handle;
695
696         vtp_handle = create_dissector_handle(dissect_vtp, proto_vtp);
697         dissector_add("llc.cisco_pid", 0x2003, vtp_handle);
698 }