print-stp.c revision 1.7 1 /*
2 * Copyright (c) 2000 Lennert Buytenhek
3 *
4 * This software may be distributed either under the terms of the
5 * BSD-style license that accompanies tcpdump or the GNU General
6 * Public License
7 *
8 * Contributed by Lennert Buytenhek <buytenh (at) gnu.org>
9 */
10
11 /* \summary: IEEE 802.1d Spanning Tree Protocol (STP) printer */
12
13 #include <sys/cdefs.h>
14 #ifndef lint
15 __RCSID("$NetBSD: print-stp.c,v 1.7 2017/02/05 04:05:05 spz Exp $");
16 #endif
17
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include <netdissect-stdinc.h>
23
24 #include <stdio.h>
25
26 #include "netdissect.h"
27 #include "extract.h"
28
29 #define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
30 /* STP timers are expressed in multiples of 1/256th second */
31 #define STP_TIME_BASE 256
32 #define STP_BPDU_MSTP_MIN_LEN 102
33
34 struct stp_bpdu_ {
35 uint8_t protocol_id[2];
36 uint8_t protocol_version;
37 uint8_t bpdu_type;
38 uint8_t flags;
39 uint8_t root_id[8];
40 uint8_t root_path_cost[4];
41 uint8_t bridge_id[8];
42 uint8_t port_id[2];
43 uint8_t message_age[2];
44 uint8_t max_age[2];
45 uint8_t hello_time[2];
46 uint8_t forward_delay[2];
47 uint8_t v1_length;
48 };
49
50 #define STP_PROTO_REGULAR 0x00
51 #define STP_PROTO_RAPID 0x02
52 #define STP_PROTO_MSTP 0x03
53 #define STP_PROTO_SPB 0x04
54
55 static const struct tok stp_proto_values[] = {
56 { STP_PROTO_REGULAR, "802.1d" },
57 { STP_PROTO_RAPID, "802.1w" },
58 { STP_PROTO_MSTP, "802.1s" },
59 { STP_PROTO_SPB, "802.1aq" },
60 { 0, NULL}
61 };
62
63 #define STP_BPDU_TYPE_CONFIG 0x00
64 #define STP_BPDU_TYPE_RSTP 0x02
65 #define STP_BPDU_TYPE_TOPO_CHANGE 0x80
66
67 static const struct tok stp_bpdu_flag_values[] = {
68 { 0x01, "Topology change" },
69 { 0x02, "Proposal" },
70 { 0x10, "Learn" },
71 { 0x20, "Forward" },
72 { 0x40, "Agreement" },
73 { 0x80, "Topology change ACK" },
74 { 0, NULL}
75 };
76
77 static const struct tok stp_bpdu_type_values[] = {
78 { STP_BPDU_TYPE_CONFIG, "Config" },
79 { STP_BPDU_TYPE_RSTP, "Rapid STP" },
80 { STP_BPDU_TYPE_TOPO_CHANGE, "Topology Change" },
81 { 0, NULL}
82 };
83
84 static const struct tok rstp_obj_port_role_values[] = {
85 { 0x00, "Unknown" },
86 { 0x01, "Alternate" },
87 { 0x02, "Root" },
88 { 0x03, "Designated" },
89 { 0, NULL}
90 };
91
92 #define ND_TCHECK_BRIDGE_ID(p) ND_TCHECK2(*(p), 8)
93
94 static char *
95 stp_print_bridge_id(const u_char *p)
96 {
97 static char bridge_id_str[sizeof("pppp.aa:bb:cc:dd:ee:ff")];
98
99 snprintf(bridge_id_str, sizeof(bridge_id_str),
100 "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
101 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
102
103 return bridge_id_str;
104 }
105
106 static int
107 stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
108 u_int length)
109 {
110 ND_TCHECK(stp_bpdu->flags);
111 ND_PRINT((ndo, ", Flags [%s]",
112 bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags)));
113
114 ND_TCHECK(stp_bpdu->port_id);
115 ND_PRINT((ndo, ", bridge-id %s.%04x, length %u",
116 stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
117 EXTRACT_16BITS(&stp_bpdu->port_id), length));
118
119 /* in non-verbose mode just print the bridge-id */
120 if (!ndo->ndo_vflag) {
121 return 1;
122 }
123
124 ND_TCHECK(stp_bpdu->forward_delay);
125 ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
126 ", hello-time %.2fs, forwarding-delay %.2fs",
127 (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
128 (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
129 (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
130 (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
131
132 ND_PRINT((ndo, "\n\troot-id %s, root-pathcost %u",
133 stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
134 EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
135
136 /* Port role is only valid for 802.1w */
137 if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
138 ND_PRINT((ndo, ", port-role %s",
139 tok2str(rstp_obj_port_role_values, "Unknown",
140 RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
141 }
142 return 1;
143
144 trunc:
145 return 0;
146 }
147
148 /*
149 * MSTP packet format
150 * Ref. IEEE 802.1Q 2003 Ed. Section 14
151 *
152 * MSTP BPDU
153 *
154 * 2 - bytes Protocol Id
155 * 1 - byte Protocol Ver.
156 * 1 - byte BPDU tye
157 * 1 - byte Flags
158 * 8 - bytes CIST Root Identifier
159 * 4 - bytes CIST External Path Cost
160 * 8 - bytes CIST Regional Root Identifier
161 * 2 - bytes CIST Port Identifier
162 * 2 - bytes Message Age
163 * 2 - bytes Max age
164 * 2 - bytes Hello Time
165 * 2 - bytes Forward delay
166 * 1 - byte Version 1 length. Must be 0
167 * 2 - bytes Version 3 length
168 * 1 - byte Config Identifier
169 * 32 - bytes Config Name
170 * 2 - bytes Revision level
171 * 16 - bytes Config Digest [MD5]
172 * 4 - bytes CIST Internal Root Path Cost
173 * 8 - bytes CIST Bridge Identifier
174 * 1 - byte CIST Remaining Hops
175 * 16 - bytes MSTI information [Max 64 MSTI, each 16 bytes]
176 *
177 *
178 * SPB BPDU
179 * Ref. IEEE 802.1aq. Section 14
180 *
181 * 2 - bytes Version 4 length
182 * 1 - byte Aux Config Identifier
183 * 32 - bytes Aux Config Name
184 * 2 - bytes Aux Revision level
185 * 16 - bytes Aux Config Digest [MD5]
186 * 1 - byte (1 - 2) Agreement Number
187 * (3 - 4) Discarded Agreement Number
188 * (5) Agreement Valid Flag
189 * (6) Restricted Role Flag
190 * (7 - 8) Unused sent zero
191 * 1 - byte Unused
192 * 1 - byte (1 - 4) Agreement Digest Format Identifier
193 * (5 - 8) Agreement Digest Format Capabilities
194 * 1 - byte (1 - 4) Agreement Digest Convention Identifier
195 * (5 - 8) Agreement Digest Convention Capabilities
196 * 2 - bytes Agreement Digest Edge Count
197 * 8 - byte Reserved Set
198 * 20 - bytes Computed Topology Digest
199 *
200 *
201 * MSTI Payload
202 *
203 * 1 - byte MSTI flag
204 * 8 - bytes MSTI Regional Root Identifier
205 * 4 - bytes MSTI Regional Path Cost
206 * 1 - byte MSTI Bridge Priority
207 * 1 - byte MSTI Port Priority
208 * 1 - byte MSTI Remaining Hops
209 *
210 */
211
212 #define MST_BPDU_MSTI_LENGTH 16
213 #define MST_BPDU_CONFIG_INFO_LENGTH 64
214
215 /* Offsets of fields from the begginning for the packet */
216 #define MST_BPDU_VER3_LEN_OFFSET 36
217 #define MST_BPDU_CONFIG_NAME_OFFSET 39
218 #define MST_BPDU_CONFIG_DIGEST_OFFSET 73
219 #define MST_BPDU_CIST_INT_PATH_COST_OFFSET 89
220 #define MST_BPDU_CIST_BRIDGE_ID_OFFSET 93
221 #define MST_BPDU_CIST_REMAIN_HOPS_OFFSET 101
222 #define MST_BPDU_MSTI_OFFSET 102
223 /* Offsets within an MSTI */
224 #define MST_BPDU_MSTI_ROOT_PRIO_OFFSET 1
225 #define MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET 9
226 #define MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET 13
227 #define MST_BPDU_MSTI_PORT_PRIO_OFFSET 14
228 #define MST_BPDU_MSTI_REMAIN_HOPS_OFFSET 15
229
230 #define SPB_BPDU_MIN_LEN 87
231 #define SPB_BPDU_CONFIG_NAME_OFFSET 3
232 #define SPB_BPDU_CONFIG_REV_OFFSET SPB_BPDU_CONFIG_NAME_OFFSET + 32
233 #define SPB_BPDU_CONFIG_DIGEST_OFFSET SPB_BPDU_CONFIG_REV_OFFSET + 2
234 #define SPB_BPDU_AGREEMENT_OFFSET SPB_BPDU_CONFIG_DIGEST_OFFSET + 16
235 #define SPB_BPDU_AGREEMENT_UNUSED_OFFSET SPB_BPDU_AGREEMENT_OFFSET + 1
236 #define SPB_BPDU_AGREEMENT_FORMAT_OFFSET SPB_BPDU_AGREEMENT_UNUSED_OFFSET + 1
237 #define SPB_BPDU_AGREEMENT_CON_OFFSET SPB_BPDU_AGREEMENT_FORMAT_OFFSET + 1
238 #define SPB_BPDU_AGREEMENT_EDGE_OFFSET SPB_BPDU_AGREEMENT_CON_OFFSET + 1
239 #define SPB_BPDU_AGREEMENT_RES1_OFFSET SPB_BPDU_AGREEMENT_EDGE_OFFSET + 2
240 #define SPB_BPDU_AGREEMENT_RES2_OFFSET SPB_BPDU_AGREEMENT_RES1_OFFSET + 4
241 #define SPB_BPDU_AGREEMENT_DIGEST_OFFSET SPB_BPDU_AGREEMENT_RES2_OFFSET + 4
242
243 static int
244 stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
245 u_int length)
246 {
247 const u_char *ptr;
248 uint16_t v3len;
249 uint16_t len;
250 uint16_t msti;
251 u_int offset;
252
253 ptr = (const u_char *)stp_bpdu;
254 ND_PRINT((ndo, ", CIST Flags [%s], length %u",
255 bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length));
256
257 /*
258 * in non-verbose mode just print the flags.
259 */
260 if (!ndo->ndo_vflag) {
261 return 1;
262 }
263
264 ND_PRINT((ndo, "\n\tport-role %s, ",
265 tok2str(rstp_obj_port_role_values, "Unknown",
266 RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
267
268 ND_TCHECK(stp_bpdu->root_path_cost);
269 ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u",
270 stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
271 EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
272
273 ND_TCHECK(stp_bpdu->bridge_id);
274 ND_PRINT((ndo, "\n\tCIST regional-root-id %s, ",
275 stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id)));
276
277 ND_TCHECK(stp_bpdu->port_id);
278 ND_PRINT((ndo, "CIST port-id %04x,", EXTRACT_16BITS(&stp_bpdu->port_id)));
279
280 ND_TCHECK(stp_bpdu->forward_delay);
281 ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
282 ", hello-time %.2fs, forwarding-delay %.2fs",
283 (float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
284 (float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
285 (float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
286 (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
287
288 ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
289 ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET)));
290 ND_TCHECK_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12);
291 ND_PRINT((ndo, "MCID Name "));
292 if (fn_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend))
293 goto trunc;
294 ND_PRINT((ndo, ", rev %u,"
295 "\n\t\tdigest %08x%08x%08x%08x, ",
296 EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32),
297 EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
298 EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
299 EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8),
300 EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12)));
301
302 ND_TCHECK_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET);
303 ND_PRINT((ndo, "CIST int-root-pathcost %u,",
304 EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET)));
305
306 ND_TCHECK_BRIDGE_ID(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET);
307 ND_PRINT((ndo, "\n\tCIST bridge-id %s, ",
308 stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET)));
309
310 ND_TCHECK(ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
311 ND_PRINT((ndo, "CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]));
312
313 /* Dump all MSTI's */
314 ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
315 v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
316 if (v3len > MST_BPDU_CONFIG_INFO_LENGTH) {
317 len = v3len - MST_BPDU_CONFIG_INFO_LENGTH;
318 offset = MST_BPDU_MSTI_OFFSET;
319 while (len >= MST_BPDU_MSTI_LENGTH) {
320 ND_TCHECK2(*(ptr + offset), MST_BPDU_MSTI_LENGTH);
321
322 msti = EXTRACT_16BITS(ptr + offset +
323 MST_BPDU_MSTI_ROOT_PRIO_OFFSET);
324 msti = msti & 0x0FFF;
325
326 ND_PRINT((ndo, "\n\tMSTI %d, Flags [%s], port-role %s",
327 msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]),
328 tok2str(rstp_obj_port_role_values, "Unknown",
329 RSTP_EXTRACT_PORT_ROLE(ptr[offset]))));
330 ND_PRINT((ndo, "\n\t\tMSTI regional-root-id %s, pathcost %u",
331 stp_print_bridge_id(ptr + offset +
332 MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
333 EXTRACT_32BITS(ptr + offset +
334 MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET)));
335 ND_PRINT((ndo, "\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
336 ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4,
337 ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4,
338 ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]));
339
340 len -= MST_BPDU_MSTI_LENGTH;
341 offset += MST_BPDU_MSTI_LENGTH;
342 }
343 }
344 return 1;
345
346 trunc:
347 return 0;
348 }
349
350 static int
351 stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
352 u_int offset)
353 {
354 const u_char *ptr;
355
356 /*
357 * in non-verbose mode don't print anything.
358 */
359 if (!ndo->ndo_vflag) {
360 return 1;
361 }
362
363 ptr = (const u_char *)stp_bpdu;
364 ND_TCHECK_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET + 16);
365
366 ND_PRINT((ndo, "\n\tv4len %d, ", EXTRACT_16BITS (ptr + offset)));
367 ND_PRINT((ndo, "AUXMCID Name "));
368 if (fn_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32,
369 ndo->ndo_snapend))
370 goto trunc;
371 ND_PRINT((ndo, ", Rev %u,\n\t\tdigest %08x%08x%08x%08x",
372 EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
373 EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
374 EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
375 EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
376 EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12)));
377
378 ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
379 "flag %d,\n\tRestricted role-flag: %d, Format id %d cap %d, "
380 "Convention id %d cap %d,\n\tEdge count %d, "
381 "Agreement digest %08x%08x%08x%08x%08x\n",
382 ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
383 ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
384 ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
385 ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
386 ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
387 ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
388 ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
389 ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
390 EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),
391 EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET),
392 EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+4),
393 EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+8),
394 EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+12),
395 EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+16)));
396 return 1;
397
398 trunc:
399 return 0;
400 }
401
402 /*
403 * Print 802.1d / 802.1w / 802.1q (mstp) / 802.1aq (spb) packets.
404 */
405 void
406 stp_print(netdissect_options *ndo, const u_char *p, u_int length)
407 {
408 const struct stp_bpdu_ *stp_bpdu;
409 u_int mstp_len;
410 u_int spb_len;
411
412 stp_bpdu = (const struct stp_bpdu_*)p;
413
414 /* Minimum STP Frame size. */
415 if (length < 4)
416 goto trunc;
417
418 ND_TCHECK(stp_bpdu->protocol_id);
419 if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) {
420 ND_PRINT((ndo, "unknown STP version, length %u", length));
421 return;
422 }
423
424 ND_TCHECK(stp_bpdu->protocol_version);
425 ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
426 stp_bpdu->protocol_version)));
427
428 switch (stp_bpdu->protocol_version) {
429 case STP_PROTO_REGULAR:
430 case STP_PROTO_RAPID:
431 case STP_PROTO_MSTP:
432 case STP_PROTO_SPB:
433 break;
434 default:
435 return;
436 }
437
438 ND_TCHECK(stp_bpdu->bpdu_type);
439 ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
440 stp_bpdu->bpdu_type)));
441
442 switch (stp_bpdu->bpdu_type) {
443 case STP_BPDU_TYPE_CONFIG:
444 if (length < sizeof(struct stp_bpdu_) - 1) {
445 goto trunc;
446 }
447 if (!stp_print_config_bpdu(ndo, stp_bpdu, length))
448 goto trunc;
449 break;
450
451 case STP_BPDU_TYPE_RSTP:
452 if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
453 if (length < sizeof(struct stp_bpdu_)) {
454 goto trunc;
455 }
456 if (!stp_print_config_bpdu(ndo, stp_bpdu, length))
457 goto trunc;
458 } else if (stp_bpdu->protocol_version == STP_PROTO_MSTP ||
459 stp_bpdu->protocol_version == STP_PROTO_SPB) {
460 if (length < STP_BPDU_MSTP_MIN_LEN) {
461 goto trunc;
462 }
463
464 ND_TCHECK(stp_bpdu->v1_length);
465 if (stp_bpdu->v1_length != 0) {
466 /* FIX ME: Emit a message here ? */
467 goto trunc;
468 }
469
470 /* Validate v3 length */
471 ND_TCHECK_16BITS(p + MST_BPDU_VER3_LEN_OFFSET);
472 mstp_len = EXTRACT_16BITS(p + MST_BPDU_VER3_LEN_OFFSET);
473 mstp_len += 2; /* length encoding itself is 2 bytes */
474 if (length < (sizeof(struct stp_bpdu_) + mstp_len)) {
475 goto trunc;
476 }
477 if (!stp_print_mstp_bpdu(ndo, stp_bpdu, length))
478 goto trunc;
479
480 if (stp_bpdu->protocol_version == STP_PROTO_SPB)
481 {
482 /* Validate v4 length */
483 spb_len = EXTRACT_16BITS (p + MST_BPDU_VER3_LEN_OFFSET + mstp_len);
484 spb_len += 2;
485 if (length < (sizeof(struct stp_bpdu_) + mstp_len + spb_len) ||
486 spb_len < SPB_BPDU_MIN_LEN) {
487 goto trunc;
488 }
489 if (!stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len)))
490 goto trunc;
491 }
492 }
493 break;
494
495 case STP_BPDU_TYPE_TOPO_CHANGE:
496 /* always empty message - just break out */
497 break;
498
499 default:
500 break;
501 }
502
503 return;
504 trunc:
505 ND_PRINT((ndo, "[|stp %d]", length));
506 }
507
508 /*
509 * Local Variables:
510 * c-style: whitesmith
511 * c-basic-offset: 4
512 * End:
513 */
514