xref: /illumos-gate/usr/src/lib/librstp/common/stp_bpdu.h (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
1 /************************************************************************
2  * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3  * Copyright (C) 2001-2003 Optical Access
4  * Author: Alex Rozin
5  *
6  * This file is part of RSTP library.
7  *
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
11  *
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.
16  *
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
20  * 02111-1307, USA.
21  **********************************************************************/
22 
23 /* BPDU formats: 9.1 - 9.3, 17.28 */
24 
25 #ifndef _STP_BPDU_H__
26 #define _STP_BPDU_H__
27 
28 #define MIN_BPDU                7
29 #define BPDU_L_SAP              0x42
30 #define LLC_UI                  0x03
31 #define BPDU_PROTOCOL_ID        0x0000
32 #define BPDU_VERSION_ID         0x00
33 #define BPDU_VERSION_RAPID_ID   0x02
34 
35 #define BPDU_TOPO_CHANGE_TYPE   0x80
36 #define BPDU_CONFIG_TYPE        0x00
37 #define BPDU_RSTP               0x02
38 
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
47 
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
52 
53 typedef struct mac_header_t {
54   unsigned char dst_mac[6];
55   unsigned char src_mac[6];
56 } MAC_HEADER_T;
57 
58 typedef struct eth_header_t {
59   unsigned char len8023[2];
60   unsigned char dsap;
61   unsigned char ssap;
62   unsigned char llc;
63 } ETH_HEADER_T;
64 
65 typedef struct bpdu_header_t {
66   unsigned char protocol[2];
67   unsigned char version;
68   unsigned char bpdu_type;
69 } BPDU_HEADER_T;
70 
71 typedef struct bpdu_body_t {
72   unsigned char flags;
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];
81 } BPDU_BODY_T;
82 
83 typedef struct stp_bpdu_t {
84   ETH_HEADER_T  eth;
85   BPDU_HEADER_T hdr;
86   BPDU_BODY_T   body;
87   unsigned char ver_1_len[2];
88 } BPDU_T;
89 
90 #endif /* _STP_BPDU_H__ */
91