xref: /titanic_41/usr/src/lib/librstp/common/stp_bpdu.h (revision 4eaa471005973e11a6110b69fe990530b3b95a38)
1*4eaa4710SRishi Srivatsavai /************************************************************************
2*4eaa4710SRishi Srivatsavai  * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3*4eaa4710SRishi Srivatsavai  * Copyright (C) 2001-2003 Optical Access
4*4eaa4710SRishi Srivatsavai  * Author: Alex Rozin
5*4eaa4710SRishi Srivatsavai  *
6*4eaa4710SRishi Srivatsavai  * This file is part of RSTP library.
7*4eaa4710SRishi Srivatsavai  *
8*4eaa4710SRishi Srivatsavai  * RSTP library is free software; you can redistribute it and/or modify it
9*4eaa4710SRishi Srivatsavai  * under the terms of the GNU Lesser General Public License as published by the
10*4eaa4710SRishi Srivatsavai  * Free Software Foundation; version 2.1
11*4eaa4710SRishi Srivatsavai  *
12*4eaa4710SRishi Srivatsavai  * RSTP library is distributed in the hope that it will be useful, but
13*4eaa4710SRishi Srivatsavai  * WITHOUT ANY WARRANTY; without even the implied warranty of
14*4eaa4710SRishi Srivatsavai  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
15*4eaa4710SRishi Srivatsavai  * General Public License for more details.
16*4eaa4710SRishi Srivatsavai  *
17*4eaa4710SRishi Srivatsavai  * You should have received a copy of the GNU Lesser General Public License
18*4eaa4710SRishi Srivatsavai  * along with RSTP library; see the file COPYING.  If not, write to the Free
19*4eaa4710SRishi Srivatsavai  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20*4eaa4710SRishi Srivatsavai  * 02111-1307, USA.
21*4eaa4710SRishi Srivatsavai  **********************************************************************/
22*4eaa4710SRishi Srivatsavai 
23*4eaa4710SRishi Srivatsavai /* BPDU formats: 9.1 - 9.3, 17.28 */
24*4eaa4710SRishi Srivatsavai 
25*4eaa4710SRishi Srivatsavai #ifndef _STP_BPDU_H__
26*4eaa4710SRishi Srivatsavai #define _STP_BPDU_H__
27*4eaa4710SRishi Srivatsavai 
28*4eaa4710SRishi Srivatsavai #define MIN_BPDU                7
29*4eaa4710SRishi Srivatsavai #define BPDU_L_SAP              0x42
30*4eaa4710SRishi Srivatsavai #define LLC_UI                  0x03
31*4eaa4710SRishi Srivatsavai #define BPDU_PROTOCOL_ID        0x0000
32*4eaa4710SRishi Srivatsavai #define BPDU_VERSION_ID         0x00
33*4eaa4710SRishi Srivatsavai #define BPDU_VERSION_RAPID_ID   0x02
34*4eaa4710SRishi Srivatsavai 
35*4eaa4710SRishi Srivatsavai #define BPDU_TOPO_CHANGE_TYPE   0x80
36*4eaa4710SRishi Srivatsavai #define BPDU_CONFIG_TYPE        0x00
37*4eaa4710SRishi Srivatsavai #define BPDU_RSTP               0x02
38*4eaa4710SRishi Srivatsavai 
39*4eaa4710SRishi Srivatsavai #define TOPOLOGY_CHANGE_BIT     0x01
40*4eaa4710SRishi Srivatsavai #define PROPOSAL_BIT            0x02
41*4eaa4710SRishi Srivatsavai #define PORT_ROLE_OFFS          2   /* 0x04 & 0x08 */
42*4eaa4710SRishi Srivatsavai #define PORT_ROLE_MASK          (0x03 << PORT_ROLE_OFFS)
43*4eaa4710SRishi Srivatsavai #define LEARN_BIT               0x10
44*4eaa4710SRishi Srivatsavai #define FORWARD_BIT             0x20
45*4eaa4710SRishi Srivatsavai #define AGREEMENT_BIT           0x40
46*4eaa4710SRishi Srivatsavai #define TOPOLOGY_CHANGE_ACK_BIT 0x80
47*4eaa4710SRishi Srivatsavai 
48*4eaa4710SRishi Srivatsavai #define RSTP_PORT_ROLE_UNKN     0x00
49*4eaa4710SRishi Srivatsavai #define RSTP_PORT_ROLE_ALTBACK  0x01
50*4eaa4710SRishi Srivatsavai #define RSTP_PORT_ROLE_ROOT     0x02
51*4eaa4710SRishi Srivatsavai #define RSTP_PORT_ROLE_DESGN    0x03
52*4eaa4710SRishi Srivatsavai 
53*4eaa4710SRishi Srivatsavai typedef struct mac_header_t {
54*4eaa4710SRishi Srivatsavai   unsigned char dst_mac[6];
55*4eaa4710SRishi Srivatsavai   unsigned char src_mac[6];
56*4eaa4710SRishi Srivatsavai } MAC_HEADER_T;
57*4eaa4710SRishi Srivatsavai 
58*4eaa4710SRishi Srivatsavai typedef struct eth_header_t {
59*4eaa4710SRishi Srivatsavai   unsigned char len8023[2];
60*4eaa4710SRishi Srivatsavai   unsigned char dsap;
61*4eaa4710SRishi Srivatsavai   unsigned char ssap;
62*4eaa4710SRishi Srivatsavai   unsigned char llc;
63*4eaa4710SRishi Srivatsavai } ETH_HEADER_T;
64*4eaa4710SRishi Srivatsavai 
65*4eaa4710SRishi Srivatsavai typedef struct bpdu_header_t {
66*4eaa4710SRishi Srivatsavai   unsigned char protocol[2];
67*4eaa4710SRishi Srivatsavai   unsigned char version;
68*4eaa4710SRishi Srivatsavai   unsigned char bpdu_type;
69*4eaa4710SRishi Srivatsavai } BPDU_HEADER_T;
70*4eaa4710SRishi Srivatsavai 
71*4eaa4710SRishi Srivatsavai typedef struct bpdu_body_t {
72*4eaa4710SRishi Srivatsavai   unsigned char flags;
73*4eaa4710SRishi Srivatsavai   unsigned char root_id[8];
74*4eaa4710SRishi Srivatsavai   unsigned char root_path_cost[4];
75*4eaa4710SRishi Srivatsavai   unsigned char bridge_id[8];
76*4eaa4710SRishi Srivatsavai   unsigned char port_id[2];
77*4eaa4710SRishi Srivatsavai   unsigned char message_age[2];
78*4eaa4710SRishi Srivatsavai   unsigned char max_age[2];
79*4eaa4710SRishi Srivatsavai   unsigned char hello_time[2];
80*4eaa4710SRishi Srivatsavai   unsigned char forward_delay[2];
81*4eaa4710SRishi Srivatsavai } BPDU_BODY_T;
82*4eaa4710SRishi Srivatsavai 
83*4eaa4710SRishi Srivatsavai typedef struct stp_bpdu_t {
84*4eaa4710SRishi Srivatsavai   ETH_HEADER_T  eth;
85*4eaa4710SRishi Srivatsavai   BPDU_HEADER_T hdr;
86*4eaa4710SRishi Srivatsavai   BPDU_BODY_T   body;
87*4eaa4710SRishi Srivatsavai   unsigned char ver_1_len[2];
88*4eaa4710SRishi Srivatsavai } BPDU_T;
89*4eaa4710SRishi Srivatsavai 
90*4eaa4710SRishi Srivatsavai #endif /* _STP_BPDU_H__ */
91