stp_common.h
Go to the documentation of this file.
1 /**
2  * @file stp_common.h
3  * @brief STP common definitions
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSTP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _STP_COMMON_H
32 #define _STP_COMMON_H
33 
34 //Dependencies
35 #include "stp_config.h"
36 #include "core/net.h"
37 
38 
39 /*
40  * CycloneSTP Open is licensed under GPL version 2. In particular:
41  *
42  * - If you link your program to CycloneSTP Open, the result is a derivative
43  * work that can only be distributed under the same GPL license terms.
44  *
45  * - If additions or changes to CycloneSTP Open are made, the result is a
46  * derivative work that can only be distributed under the same license terms.
47  *
48  * - The GPL license requires that you make the source code available to
49  * whoever you make the binary available to.
50  *
51  * - If you sell or distribute a hardware product that runs CycloneSTP Open,
52  * the GPL license requires you to provide public and full access to all
53  * source code on a nondiscriminatory basis.
54  *
55  * If you fully understand and accept the terms of the GPL license, then edit
56  * the os_port_config.h header and add the following directive:
57  *
58  * #define GPL_LICENSE_TERMS_ACCEPTED
59  */
60 
61 #ifndef GPL_LICENSE_TERMS_ACCEPTED
62  #error Before compiling CycloneSTP Open, you must accept the terms of the GPL license
63 #endif
64 
65 //Version string
66 #define CYCLONE_STP_VERSION_STRING "2.4.0"
67 //Major version
68 #define CYCLONE_STP_MAJOR_VERSION 2
69 //Minor version
70 #define CYCLONE_STP_MINOR_VERSION 4
71 //Revision number
72 #define CYCLONE_STP_REV_NUMBER 0
73 
74 //C++ guard
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 //Protocol identifier
80 #define STP_PROTOCOL_ID 0
81 
82 //LLC header fields
83 #define STP_LLC_DSAP 0x42
84 #define STP_LLC_SSAP 0x42
85 #define STP_LLC_CTRL 0x03
86 
87 //Minimum size of BPDUs
88 #define STP_MIN_BPDU_SIZE 4
89 
90 
91 /**
92  * @brief Protocol versions
93  **/
94 
95 typedef enum
96 {
97  STP_PROTOCOL_VERSION = 0, ///<STP version
98  RSTP_PROTOCOL_VERSION = 2, ///<RSTP version
99  MSTP_PROTOCOL_VERSION = 3 ///<MSTP version
101 
102 
103 /**
104  * @brief Port states
105  **/
106 
107 typedef enum
108 {
116 
117 
118 /**
119  * @brief Port role values
120  **/
121 
122 typedef enum
123 {
130 
131 
132 //CC-RX, CodeWarrior or Win32 compiler?
133 #if defined(__CCRX__)
134  #pragma pack
135 #elif defined(__CWCC__) || defined(_WIN32)
136  #pragma pack(push, 1)
137 #endif
138 
139 
140 /**
141  * @brief Bridge identifier
142  **/
143 
145 {
146  uint16_t priority; //0-1
147  MacAddr addr; //2-7
149 
150 
151 //CC-RX, CodeWarrior or Win32 compiler?
152 #if defined(__CCRX__)
153  #pragma unpack
154 #elif defined(__CWCC__) || defined(_WIN32)
155  #pragma pack(pop)
156 #endif
157 
158 //C++ guard
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif
uint16_t priority
Definition: dns_common.h:265
MacAddr
Definition: ethernet.h:195
TCP/IP stack core.
StpBridgeId
Definition: stp_common.h:148
MacAddr addr
Definition: stp_common.h:147
StpProtocolVersion
Protocol versions.
Definition: stp_common.h:96
@ MSTP_PROTOCOL_VERSION
MSTP version.
Definition: stp_common.h:99
@ STP_PROTOCOL_VERSION
STP version.
Definition: stp_common.h:97
@ RSTP_PROTOCOL_VERSION
RSTP version.
Definition: stp_common.h:98
StpPortRole
Port role values.
Definition: stp_common.h:123
@ STP_PORT_ROLE_BACKUP
Definition: stp_common.h:128
@ STP_PORT_ROLE_ALTERNATE
Definition: stp_common.h:127
@ STP_PORT_ROLE_ROOT
Definition: stp_common.h:125
@ STP_PORT_ROLE_DESIGNATED
Definition: stp_common.h:126
@ STP_PORT_ROLE_DISABLED
Definition: stp_common.h:124
typedef __packed_struct
Bridge identifier.
Definition: stp_common.h:145
StpPortState
Port states.
Definition: stp_common.h:108
@ STP_PORT_STATE_BLOCKING
Definition: stp_common.h:111
@ STP_PORT_STATE_LEARNING
Definition: stp_common.h:113
@ STP_PORT_STATE_LISTENING
Definition: stp_common.h:112
@ STP_PORT_STATE_BROKEN
Definition: stp_common.h:110
@ STP_PORT_STATE_FORWARDING
Definition: stp_common.h:114
@ STP_PORT_STATE_DISABLED
Definition: stp_common.h:109