1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 **********************************************************************/
23 /* BPDU formats: 9.1 - 9.3, 17.28 */
29 #define BPDU_L_SAP 0x42
31 #define BPDU_PROTOCOL_ID 0x0000
32 #define BPDU_VERSION_ID 0x00
33 #define BPDU_VERSION_RAPID_ID 0x02
35 #define BPDU_TOPO_CHANGE_TYPE 0x80
36 #define BPDU_CONFIG_TYPE 0x00
37 #define BPDU_RSTP 0x02
39 #define TOPOLOGY_CHANGE_BIT 0x01
40 #define PROPOSAL_BIT 0x02
41 #define PORT_ROLE_OFFS 2 /* 0x04 & 0x08 */
42 #define PORT_ROLE_MASK (0x03 << PORT_ROLE_OFFS)
43 #define LEARN_BIT 0x10
44 #define FORWARD_BIT 0x20
45 #define AGREEMENT_BIT 0x40
46 #define TOPOLOGY_CHANGE_ACK_BIT 0x80
48 #define RSTP_PORT_ROLE_UNKN 0x00
49 #define RSTP_PORT_ROLE_ALTBACK 0x01
50 #define RSTP_PORT_ROLE_ROOT 0x02
51 #define RSTP_PORT_ROLE_DESGN 0x03
53 typedef struct mac_header_t
{
54 unsigned char dst_mac
[6];
55 unsigned char src_mac
[6];
58 typedef struct eth_header_t
{
59 unsigned char len8023
[2];
65 typedef struct bpdu_header_t
{
66 unsigned char protocol
[2];
67 unsigned char version
;
68 unsigned char bpdu_type
;
71 typedef struct bpdu_body_t
{
73 unsigned char root_id
[8];
74 unsigned char root_path_cost
[4];
75 unsigned char bridge_id
[8];
76 unsigned char port_id
[2];
77 unsigned char message_age
[2];
78 unsigned char max_age
[2];
79 unsigned char hello_time
[2];
80 unsigned char forward_delay
[2];
83 typedef struct stp_bpdu_t
{
87 unsigned char ver_1_len
[2];
90 #endif /* _STP_BPDU_H__ */