rstp_misc.h
Go to the documentation of this file.
1 /**
2  * @file rstp_misc.h
3  * @brief RSTP helper functions
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.4
29  **/
30 
31 #ifndef _RSTP_MISC_H
32 #define _RSTP_MISC_H
33 
34 //Dependencies
35 #include "rstp/rstp.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /**
44  * @brief Parameter value/name binding
45  **/
46 
47 typedef struct
48 {
50  const char_t *name;
52 
53 
54 //RSTP related functions
55 void rstpLock(RstpBridgeContext *context);
56 void rstpUnlock(RstpBridgeContext *context);
57 void rstpTick(RstpBridgeContext *context);
58 
60 
61 int_t rstpComparePortNum(uint16_t portId1, uint16_t portId2);
62 int_t rstpCompareBridgeAddr(const MacAddr *addr1, const MacAddr *addr2);
63 int_t rstpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2);
66 
71 void rstpUpdateAgeingTime(RstpBridgeContext *context, uint32_t ageingTime);
73 
75  bool_t override);
76 
78  const MacAddr *macAddr);
79 
82 
85 
87 
90 
91 const char_t *rstpGetParamName(uint_t value, const RstpParamName *paramList,
92  size_t paramListLen);
93 
95 
96 //C++ guard
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif
int_t rstpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2)
Compare bridge identifiers.
Definition: rstp_misc.c:271
int bool_t
Definition: compiler_port.h:53
error_t rstpAddStaticFdbEntry(RstpBridgeContext *context, const MacAddr *macAddr, bool_t override)
Add a new entry to the static MAC table.
Definition: rstp_misc.c:584
uint8_t portId[]
Definition: lldp_tlv.h:254
signed int int_t
Definition: compiler_port.h:49
uint8_t x
Definition: lldp_ext_med.h:211
void rstpUnconfigurePermanentDatabase(RstpBridgeContext *context)
Unconfigure the permanent database.
Definition: rstp_misc.c:788
void rstpEnableRsvdMcastTable(RstpBridgeContext *context, bool_t enable)
Enable reserved multicast table.
Definition: rstp_misc.c:557
error_t rstpDeleteStaticFdbEntry(RstpBridgeContext *context, const MacAddr *macAddr)
Remove an entry from the static MAC table.
Definition: rstp_misc.c:623
void rstpFlushFdbTable(RstpBridgePort *port)
Remove all the filtering database entries for a given port.
Definition: rstp_misc.c:711
Spanning Tree priority vector.
Definition: rstp.h:280
RstpBridgePort * rstpGetBridgePort(RstpBridgeContext *context, uint16_t portId)
Retrieve the port that matches the specified port number.
Definition: rstp_misc.c:187
RSTP timer parameter values.
Definition: rstp.h:267
#define RstpBridgeContext
Definition: rstp.h:36
void rstpUnlock(RstpBridgeContext *context)
Release exclusive access to the RSTP bridge context.
Definition: rstp_misc.c:62
uint16_t forwardDelay
Definition: rstp_bpdu.h:109
int_t rstpComparePriority(const RstpPriority *p1, const RstpPriority *p2)
Compare priority vectors.
Definition: rstp_misc.c:302
error_t
Error codes.
Definition: error.h:43
void rstpDecrementTimer(uint_t *x)
Decrement timer value.
Definition: rstp_misc.c:910
RSTP (Rapid Spanning Tree Protocol)
void rstpUpdateOperPointToPointMac(RstpBridgePort *port)
Update the value of the operPointToPointMac variable.
Definition: rstp_misc.c:455
int_t rstpCompareTimes(const RstpTimes *t1, const RstpTimes *t2)
Compare timer parameter values.
Definition: rstp_misc.c:367
SwitchPortState
Switch port state.
Definition: nic.h:134
uint32_t t2
MacAddr
Definition: ethernet.h:195
int_t rstpCompareBridgeAddr(const MacAddr *addr1, const MacAddr *addr2)
Compare bridge addresses.
Definition: rstp_misc.c:256
uint16_t port
Definition: dns_common.h:267
const char_t * name
Definition: rstp_misc.h:50
char char_t
Definition: compiler_port.h:48
void rstpGeneratePortAddr(RstpBridgePort *port)
Port's MAC address generation.
Definition: rstp_misc.c:815
void rstpUpdateTopologyChangeCount(RstpBridgeContext *context)
Update the number of topology changes.
Definition: rstp_misc.c:394
uint32_t t1
uint16_t maxAge
Definition: rstp_bpdu.h:107
const char_t * rstpGetParamName(uint_t value, const RstpParamName *paramList, size_t paramListLen)
Convert a parameter to string representation.
Definition: rstp_misc.c:883
StpBridgeId
Definition: stp_common.h:148
uint_t value
Definition: rstp_misc.h:49
uint8_t value[]
Definition: tcp.h:369
void rstpLock(RstpBridgeContext *context)
Acquire exclusive access to the RSTP bridge context.
Definition: rstp_misc.c:50
Parameter value/name binding.
Definition: rstp_misc.h:48
void rstpTick(RstpBridgeContext *context)
RSTP tick handler.
Definition: rstp_misc.c:77
void rstpUpdateAgeingTime(RstpBridgeContext *context, uint32_t ageingTime)
Set ageing time for dynamic filtering entries.
Definition: rstp_misc.c:527
unsigned int uint_t
Definition: compiler_port.h:50
int_t rstpComparePortNum(uint16_t portId1, uint16_t portId2)
Compare port numbers.
Definition: rstp_misc.c:219
void rstpUpdatePortState(RstpBridgePort *port, SwitchPortState state)
Set port state.
Definition: rstp_misc.c:495
uint16_t helloTime
Definition: rstp_bpdu.h:108
void rstpUpdatePortPathCost(RstpBridgePort *port)
Update the value of the portPathCost variable.
Definition: rstp_misc.c:425
bool_t rstpCheckBridgeParams(uint_t maxAge, uint_t helloTime, uint_t forwardDelay)
Check bridge parameters.
Definition: rstp_misc.c:854
#define RstpBridgePort
Definition: rstp.h:40
void rstpRemoveFdbEntries(RstpBridgePort *port)
Remove filtering database entries (immediately or by rapid ageing)
Definition: rstp_misc.c:660
error_t rstpConfigurePermanentDatabase(RstpBridgeContext *context)
Configure the permanent database.
Definition: rstp_misc.c:743