2 * Copyright (c) 1998-2007 The TCPDUMP project
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that: (1) source code
6 * distributions retain the above copyright notice and this paragraph
7 * in its entirety, and (2) distributions including binary code include
8 * the above copyright notice and this paragraph in its entirety in
9 * the documentation or other materials provided with the distribution.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
11 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
12 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
13 * FOR A PARTICULAR PURPOSE.
15 * VLAN TRUNKING PROTOCOL (VTP)
17 * Reference documentation:
18 * http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml
19 * http://www.cisco.com/warp/public/473/21.html
21 * Original code ode by Carles Kishimoto <carles.kishimoto@gmail.com>
28 #include <tcpdump-stdinc.h>
33 #include "interface.h"
34 #include "addrtoname.h"
38 #define VTP_HEADER_LEN 36
39 #define VTP_DOMAIN_NAME_LEN 32
40 #define VTP_MD5_DIGEST_LEN 16
41 #define VTP_UPDATE_TIMESTAMP_LEN 12
42 #define VTP_VLAN_INFO_OFFSET 12
44 #define VTP_SUMMARY_ADV 0x01
45 #define VTP_SUBSET_ADV 0x02
46 #define VTP_ADV_REQUEST 0x03
47 #define VTP_JOIN_MESSAGE 0x04
59 static struct tok vtp_message_type_values
[] = {
60 { VTP_SUMMARY_ADV
, "Summary advertisement"},
61 { VTP_SUBSET_ADV
, "Subset advertisement"},
62 { VTP_ADV_REQUEST
, "Advertisement request"},
63 { VTP_JOIN_MESSAGE
, "Join message"},
67 static struct tok vtp_header_values
[] = {
68 { 0x01, "Followers"}, /* On Summary advertisement, 3rd byte is Followers */
69 { 0x02, "Seq number"}, /* On Subset advertisement, 3rd byte is Sequence number */
70 { 0x03, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */
71 { 0x04, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */
75 static struct tok vtp_vlan_type_values
[] = {
84 static struct tok vtp_vlan_status
[] = {
85 { 0x00, "Operational"},
91 vtp_print (const u_char
*pptr
, u_int length
)
95 const struct vtp_vlan_
*vtp_vlan
;
97 if (length
< VTP_HEADER_LEN
)
102 if (!TTEST2(*tptr
, VTP_HEADER_LEN
))
106 printf("VTPv%u, Message %s (0x%02x), length %u",
108 tok2str(vtp_message_type_values
,"Unknown message type", type
),
112 /* In non-verbose mode, just print version and message type */
117 /* verbose mode print all fields */
118 printf("\n\tDomain name: %s, Flags [%s] %u",
120 tok2str(vtp_header_values
,"Unknown",*(tptr
+1)),
123 tptr
+= VTP_HEADER_LEN
;
127 case VTP_SUMMARY_ADV
:
130 * SUMMARY ADVERTISEMENT
132 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
133 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
134 * | Version | Code | Followers | MmgtD Len |
135 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 * | Management Domain Name |
137 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
138 * | Configuration revision number |
139 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 * | Updater Identity IP address |
141 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
142 * | Update Timestamp (12 bytes) |
143 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
144 * | MD5 digest (16 bytes) |
145 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149 printf("\n\t Config Rev %x, Updater %s",
150 EXTRACT_32BITS(tptr
),
151 ipaddr_string(tptr
+4));
153 printf(", Timestamp 0x%08x 0x%08x 0x%08x",
154 EXTRACT_32BITS(tptr
),
155 EXTRACT_32BITS(tptr
+ 4),
156 EXTRACT_32BITS(tptr
+ 8));
157 tptr
+= VTP_UPDATE_TIMESTAMP_LEN
;
158 printf(", MD5 digest: %08x%08x%08x%08x",
159 EXTRACT_32BITS(tptr
),
160 EXTRACT_32BITS(tptr
+ 4),
161 EXTRACT_32BITS(tptr
+ 8),
162 EXTRACT_32BITS(tptr
+ 12));
163 tptr
+= VTP_MD5_DIGEST_LEN
;
169 * SUBSET ADVERTISEMENT
171 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
172 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
173 * | Version | Code | Seq number | MmgtD Len |
174 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
175 * | Management Domain Name |
176 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
177 * | Configuration revision number |
178 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
179 * | VLAN info field 1 |
180 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
181 * | ................ |
182 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
183 * | VLAN info field N |
184 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
188 printf(", Config Rev %x", EXTRACT_32BITS(tptr
));
192 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
193 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
194 * | V info len | Status | VLAN type | VLAN name len |
195 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
196 * | ISL vlan id | MTU size |
197 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
198 * | 802.10 index (SAID) |
199 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
201 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
206 while (tptr
< (pptr
+length
)) {
212 if (!TTEST2(*tptr
, len
))
215 vtp_vlan
= (struct vtp_vlan_
*)tptr
;
216 printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
217 tok2str(vtp_vlan_status
,"Unknown",vtp_vlan
->status
),
218 tok2str(vtp_vlan_type_values
,"Unknown",vtp_vlan
->type
),
219 EXTRACT_16BITS(&vtp_vlan
->vlanid
),
220 EXTRACT_16BITS(&vtp_vlan
->mtu
),
221 EXTRACT_32BITS(&vtp_vlan
->index
),
222 (tptr
+ VTP_VLAN_INFO_OFFSET
));
225 /* FIXME: TLV dissector missing */
227 /* The following URL:
228 http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
229 talks about type (2 bytes) and length (2 bytes), that is not true...
234 case VTP_ADV_REQUEST
:
237 * ADVERTISEMENT REQUEST
239 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
240 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
241 * | Version | Code | Reserved | MmgtD Len |
242 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
243 * | Management Domain Name |
244 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
246 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
250 printf("\n\tStart value: %u", EXTRACT_32BITS(tptr
));
253 case VTP_JOIN_MESSAGE
:
255 /* FIXME - Could not find message format */
270 * c-style: whitesmith