]>
The Tcpdump Group git mirrors - tcpdump/blob - print-stp.c
2 * Copyright (c) 2000 Lennert Buytenhek
4 * This software may be distributed either under the terms of the
5 * BSD-style license that accompanies tcpdump or the GNU General
8 * Format and print IEEE 802.1d spanning tree protocol packets.
9 * Contributed by Lennert Buytenhek <buytenh@gnu.org>
13 static const char rcsid
[] =
14 "@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.3 2000-07-01 03:39:10 assar Exp $";
21 #include <sys/param.h>
23 #include <sys/socket.h>
25 #include <netinet/in.h>
26 #include <netinet/in_systm.h>
27 #include <netinet/ip.h>
28 #include <netinet/ip_var.h>
29 #include <netinet/udp.h>
30 #include <netinet/udp_var.h>
31 #include <netinet/tcp.h>
32 #include <netinet/tcpip.h>
38 #include "interface.h"
39 #include "addrtoname.h"
43 stp_print_bridge_id(const u_char
*p
)
45 printf("%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
46 p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], p
[6], p
[7]);
50 stp_print_config_bpdu(const u_char
*p
, u_int length
)
54 printf("TOP_CHANGE ");
56 printf("TOP_CHANGE_ACK ");
58 stp_print_bridge_id(p
+20);
59 printf(".%.2x%.2x ", p
[28], p
[29]);
62 stp_print_bridge_id(p
+8);
64 printf(" pathcost %i ", (p
[16] << 24) | (p
[17] << 16) | (p
[18] << 8) | p
[19]);
66 printf("age %i ", p
[30]);
67 printf("max %i ", p
[32]);
68 printf("hello %i ", p
[34]);
69 printf("fdelay %i ", p
[36]);
73 stp_print_tcn_bpdu(const u_char
*p
, u_int length
)
79 * Print 802.1d packets.
82 stp_print(const u_char
*p
, u_int length
)
88 if (p
[2] != 0x03 || p
[3] || p
[4] || p
[5]) {
89 printf("unknown version");
98 stp_print_config_bpdu(p
, length
);
102 stp_print_tcn_bpdu(p
, length
);
106 printf("unknown type %i\n", p
[6]);
112 printf("[|stp %d]", length
);