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 */
30 #define BPDU_L_SAP 0x42
32 #define BPDU_PROTOCOL_ID 0x0000
33 #define BPDU_VERSION_ID 0x00
34 #define BPDU_VERSION_RAPID_ID 0x02
36 #define BPDU_TOPO_CHANGE_TYPE 0x80
37 #define BPDU_CONFIG_TYPE 0x00
38 #define BPDU_RSTP 0x02
40 #define TOLPLOGY_CHANGE_BIT 0x01
41 #define PROPOSAL_BIT 0x02
42 #define PORT_ROLE_OFFS 2 /* 0x04 & 0x08 */
43 #define PORT_ROLE_MASK (0x03 << PORT_ROLE_OFFS)
44 #define LEARN_BIT 0x10
45 #define FORWARD_BIT 0x20
46 #define AGREEMENT_BIT 0x40
47 #define TOLPLOGY_CHANGE_ACK_BIT 0x80
49 #define RSTP_PORT_ROLE_UNKN 0x00
50 #define RSTP_PORT_ROLE_ALTBACK 0x01
51 #define RSTP_PORT_ROLE_ROOT 0x02
52 #define RSTP_PORT_ROLE_DESGN 0x03
54 typedef struct mac_header_t
{
55 unsigned char dst_mac
[6];
56 unsigned char src_mac
[6];
59 typedef struct eth_header_t
{
60 unsigned char len8023
[2];
66 typedef struct bpdu_header_t
{
67 unsigned char protocol
[2];
68 unsigned char version
;
69 unsigned char bpdu_type
;
72 typedef struct bpdu_body_t
{
74 unsigned char root_id
[8];
75 unsigned char root_path_cost
[4];
76 unsigned char bridge_id
[8];
77 unsigned char port_id
[2];
78 unsigned char message_age
[2];
79 unsigned char max_age
[2];
80 unsigned char hello_time
[2];
81 unsigned char forward_delay
[2];
84 typedef struct stp_bpdu_t
{
88 unsigned char ver_1_len
[2];
91 typedef struct rstp_bpdu_t
{
96 unsigned char ver_1_len
[2];
99 #endif /* _STP_BPDU_H__ */