stp_misc.h
Go to the documentation of this file.
1 /**
2  * @file stp_misc.h
3  * @brief STP 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 _STP_MISC_H
32 #define _STP_MISC_H
33 
34 //Dependencies
35 #include "stp/stp.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;
51 } StpParamName;
52 
53 
54 //STP related functions
55 void stpLock(StpBridgeContext *context);
56 void stpUnlock(StpBridgeContext *context);
57 void stpTick(StpBridgeContext *context);
58 
60 
61 int_t stpComparePortNum(uint16_t portId1, uint16_t portId2);
62 int_t stpCompareBridgeAddr(const MacAddr *addr1, const MacAddr *addr2);
63 int_t stpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2);
64 
67 void stpUpdateAgeingTime(StpBridgeContext *context, uint32_t ageingTime);
68 void stpEnableRsvdMcastTable(StpBridgeContext *context, bool_t enable);
69 
70 error_t stpAddStaticFdbEntry(StpBridgeContext *context, const MacAddr *macAddr,
71  bool_t override);
72 
74  const MacAddr *macAddr);
75 
78 
80 
83 
84 const char_t *stpGetParamName(uint_t value, const StpParamName *paramList,
85  size_t paramListLen);
86 
87 void stpStartTimer(StpTimer *timer, uint_t value);
88 void stpStopTimer(StpTimer *timer);
89 bool_t stpIncrementTimer(StpTimer *timer, uint_t timeout);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
int bool_t
Definition: compiler_port.h:53
uint8_t portId[]
Definition: lldp_tlv.h:254
signed int int_t
Definition: compiler_port.h:49
void stpUpdatePortState(StpBridgePort *port, StpPortState state)
Set port state.
Definition: stp_misc.c:358
int_t stpComparePortNum(uint16_t portId1, uint16_t portId2)
Compare port numbers.
Definition: stp_misc.c:244
error_t stpAddStaticFdbEntry(StpBridgeContext *context, const MacAddr *macAddr, bool_t override)
Add a new entry to the static MAC table.
Definition: stp_misc.c:484
void stpStopTimer(StpTimer *timer)
Stop timer.
Definition: stp_misc.c:743
STP timer.
Definition: stp.h:204
void stpUpdateTopologyChange(StpBridgeContext *context, bool_t value)
Set the Topology Change flag.
Definition: stp_misc.c:325
#define StpBridgePort
Definition: stp.h:40
STP (Spanning Tree Protocol)
bool_t stpIncrementTimer(StpTimer *timer, uint_t timeout)
Increment the timer and check for expiration.
Definition: stp_misc.c:757
error_t stpConfigurePermanentDatabase(StpBridgeContext *context)
Configure the permanent database.
Definition: stp_misc.c:561
#define StpBridgeContext
Definition: stp.h:36
uint16_t forwardDelay
Definition: rstp_bpdu.h:109
int_t stpCompareBridgeId(const StpBridgeId *id1, const StpBridgeId *id2)
Compare bridge identifiers.
Definition: stp_misc.c:296
error_t
Error codes.
Definition: error.h:43
void stpGeneratePortAddr(StpBridgePort *port)
Port's MAC address generation.
Definition: stp_misc.c:633
error_t stpDeleteStaticFdbEntry(StpBridgeContext *context, const MacAddr *macAddr)
Remove an entry from the static MAC table.
Definition: stp_misc.c:523
const char_t * name
Definition: stp_misc.h:50
int_t stpCompareBridgeAddr(const MacAddr *addr1, const MacAddr *addr2)
Compare bridge addresses.
Definition: stp_misc.c:281
void stpStartTimer(StpTimer *timer, uint_t value)
Start timer.
Definition: stp_misc.c:729
Parameter value/name binding.
Definition: stp_misc.h:48
MacAddr
Definition: ethernet.h:195
void stpEnableRsvdMcastTable(StpBridgeContext *context, bool_t enable)
Enable reserved multicast table.
Definition: stp_misc.c:457
uint16_t port
Definition: dns_common.h:267
char char_t
Definition: compiler_port.h:48
StpBridgePort * stpGetBridgePort(StpBridgeContext *context, uint16_t portId)
Retrieve the port that matches the specified port number.
Definition: stp_misc.c:212
uint16_t maxAge
Definition: rstp_bpdu.h:107
StpBridgeId
Definition: stp_common.h:148
uint8_t value[]
Definition: tcp.h:369
StpPortState
Port states.
Definition: stp_common.h:108
const char_t * stpGetParamName(uint_t value, const StpParamName *paramList, size_t paramListLen)
Convert a parameter to string representation.
Definition: stp_misc.c:701
uint_t value
Definition: stp_misc.h:49
bool_t stpCheckBridgeParams(uint_t maxAge, uint_t helloTime, uint_t forwardDelay)
Check bridge parameters.
Definition: stp_misc.c:672
unsigned int uint_t
Definition: compiler_port.h:50
void stpTick(StpBridgeContext *context)
STP tick handler.
Definition: stp_misc.c:86
void stpUnconfigurePermanentDatabase(StpBridgeContext *context)
Unconfigure the permanent database.
Definition: stp_misc.c:606
uint16_t helloTime
Definition: rstp_bpdu.h:108
void stpUpdateAgeingTime(StpBridgeContext *context, uint32_t ageingTime)
Set ageing time for dynamic filtering entries.
Definition: stp_misc.c:427
void stpUnlock(StpBridgeContext *context)
Release exclusive access to the STP bridge context.
Definition: stp_misc.c:71
void stpLock(StpBridgeContext *context)
Acquire exclusive access to the STP bridge context.
Definition: stp_misc.c:59