rstp_misc.c File Reference

RSTP helper functions. More...

#include "rstp/rstp.h"
#include "rstp/rstp_fsm.h"
#include "rstp/rstp_conditions.h"
#include "rstp/rstp_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   RSTP_TRACE_LEVEL
 

Functions

void rstpLock (RstpBridgeContext *context)
 Acquire exclusive access to the RSTP bridge context. More...
 
void rstpUnlock (RstpBridgeContext *context)
 Release exclusive access to the RSTP bridge context. More...
 
void rstpTick (RstpBridgeContext *context)
 RSTP tick handler. More...
 
RstpBridgePortrstpGetBridgePort (RstpBridgeContext *context, uint16_t portId)
 Retrieve the port that matches the specified port number. More...
 
int_t rstpComparePortNum (uint16_t portId1, uint16_t portId2)
 Compare port numbers. More...
 
int_t rstpCompareBridgeAddr (const MacAddr *addr1, const MacAddr *addr2)
 Compare bridge addresses. More...
 
int_t rstpCompareBridgeId (const StpBridgeId *id1, const StpBridgeId *id2)
 Compare bridge identifiers. More...
 
int_t rstpComparePriority (const RstpPriority *p1, const RstpPriority *p2)
 Compare priority vectors. More...
 
int_t rstpCompareTimes (const RstpTimes *t1, const RstpTimes *t2)
 Compare timer parameter values. More...
 
void rstpUpdateTopologyChangeCount (RstpBridgeContext *context)
 Update the number of topology changes. More...
 
void rstpUpdatePortPathCost (RstpBridgePort *port)
 Update the value of the portPathCost variable. More...
 
void rstpUpdateOperPointToPointMac (RstpBridgePort *port)
 Update the value of the operPointToPointMac variable. More...
 
void rstpUpdatePortState (RstpBridgePort *port, SwitchPortState state)
 Set port state. More...
 
void rstpUpdateAgeingTime (RstpBridgeContext *context, uint32_t ageingTime)
 Set ageing time for dynamic filtering entries. More...
 
void rstpEnableRsvdMcastTable (RstpBridgeContext *context, bool_t enable)
 Enable reserved multicast table. More...
 
error_t rstpAddStaticFdbEntry (RstpBridgeContext *context, const MacAddr *macAddr, bool_t override)
 Add a new entry to the static MAC table. More...
 
error_t rstpDeleteStaticFdbEntry (RstpBridgeContext *context, const MacAddr *macAddr)
 Remove an entry from the static MAC table. More...
 
void rstpRemoveFdbEntries (RstpBridgePort *port)
 Remove filtering database entries (immediately or by rapid ageing) More...
 
void rstpFlushFdbTable (RstpBridgePort *port)
 Remove all the filtering database entries for a given port. More...
 
error_t rstpConfigurePermanentDatabase (RstpBridgeContext *context)
 Configure the permanent database. More...
 
void rstpUnconfigurePermanentDatabase (RstpBridgeContext *context)
 Unconfigure the permanent database. More...
 
void rstpGeneratePortAddr (RstpBridgePort *port)
 Port's MAC address generation. More...
 
bool_t rstpCheckBridgeParams (uint_t maxAge, uint_t helloTime, uint_t forwardDelay)
 Check bridge parameters. More...
 
const char_trstpGetParamName (uint_t value, const RstpParamName *paramList, size_t paramListLen)
 Convert a parameter to string representation. More...
 
void rstpDecrementTimer (uint_t *x)
 Decrement timer value. More...
 

Detailed Description

RSTP helper functions.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneSTP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file rstp_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   RSTP_TRACE_LEVEL

Definition at line 32 of file rstp_misc.c.

Function Documentation

◆ rstpAddStaticFdbEntry()

error_t rstpAddStaticFdbEntry ( RstpBridgeContext context,
const MacAddr macAddr,
bool_t  override 
)

Add a new entry to the static MAC table.

Parameters
[in]contextPointer to the RSTP bridge context
[in]macAddrMAC address to be added
[in]overrideThis flag specifies whether packets received with a destination address that matches the MAC address will be forwarded regardless of the port state
Returns
Error code

Definition at line 584 of file rstp_misc.c.

◆ rstpCheckBridgeParams()

bool_t rstpCheckBridgeParams ( uint_t  maxAge,
uint_t  helloTime,
uint_t  forwardDelay 
)

Check bridge parameters.

Parameters
[in]maxAgeValue of the Bridge Max Age parameter
[in]helloTimeValue of the Bridge Hello Time parameter
[in]forwardDelayValue of the Bridge Forward Delay parameter
Returns
TRUE if the set of parameters is valid, else FALSE

Definition at line 854 of file rstp_misc.c.

◆ rstpCompareBridgeAddr()

int_t rstpCompareBridgeAddr ( const MacAddr addr1,
const MacAddr addr2 
)

Compare bridge addresses.

Parameters
[in]addr1First bridge address
[in]addr2Second bridge address
Returns
The function returns 1 if addr1 is greater than addr2, 0 if addr1 is the same as addr2 and -1 if addr1 is less than addr2

Definition at line 256 of file rstp_misc.c.

◆ rstpCompareBridgeId()

int_t rstpCompareBridgeId ( const StpBridgeId id1,
const StpBridgeId id2 
)

Compare bridge identifiers.

Parameters
[in]id1First bridge identifier
[in]id2Second bridge identifier
Returns
The function returns 1 if id1 is greater than id2, 0 if id1 is the same as id2 and -1 if id1 is less than id2

Definition at line 271 of file rstp_misc.c.

◆ rstpComparePortNum()

int_t rstpComparePortNum ( uint16_t  portId1,
uint16_t  portId2 
)

Compare port numbers.

Parameters
[in]portId1First port identifier
[in]portId2Second port identifier
Returns
The function returns zero if the port numbers are the same and a non-zero value if the port numbers are different

Definition at line 219 of file rstp_misc.c.

◆ rstpComparePriority()

int_t rstpComparePriority ( const RstpPriority p1,
const RstpPriority p2 
)

Compare priority vectors.

Parameters
[in]p1First priority vector
[in]p2Second priority vector
Returns
The function returns 1 if p1 priority is better than p2, 0 if p1 priority is the same as p2 and -1 if p1 priority is worse than p2

Definition at line 302 of file rstp_misc.c.

◆ rstpCompareTimes()

int_t rstpCompareTimes ( const RstpTimes t1,
const RstpTimes t2 
)

Compare timer parameter values.

Parameters
[in]t1First set of timer values
[in]t2Second set of timer values
Returns
The function returns 1 if t1 differs from t2 and 0 if t1 is the same as t2

Definition at line 367 of file rstp_misc.c.

◆ rstpConfigurePermanentDatabase()

error_t rstpConfigurePermanentDatabase ( RstpBridgeContext context)

Configure the permanent database.

Parameters
[in]contextPointer to the RSTP bridge context
Returns
Error code

Definition at line 743 of file rstp_misc.c.

◆ rstpDecrementTimer()

void rstpDecrementTimer ( uint_t x)

Decrement timer value.

Parameters
[in,out]xActual timer value

Definition at line 910 of file rstp_misc.c.

◆ rstpDeleteStaticFdbEntry()

error_t rstpDeleteStaticFdbEntry ( RstpBridgeContext context,
const MacAddr macAddr 
)

Remove an entry from the static MAC table.

Parameters
[in]contextPointer to the RSTP bridge context
[in]macAddrMAC address to be removed from the table
Returns
Error code

Definition at line 623 of file rstp_misc.c.

◆ rstpEnableRsvdMcastTable()

void rstpEnableRsvdMcastTable ( RstpBridgeContext context,
bool_t  enable 
)

Enable reserved multicast table.

Parameters
[in]contextPointer to the RSTP bridge context
[in]enableEnable or disable reserved group addresses

Definition at line 557 of file rstp_misc.c.

◆ rstpFlushFdbTable()

void rstpFlushFdbTable ( RstpBridgePort port)

Remove all the filtering database entries for a given port.

Parameters
[in]portPointer to the bridge port context

Definition at line 711 of file rstp_misc.c.

◆ rstpGeneratePortAddr()

void rstpGeneratePortAddr ( RstpBridgePort port)

Port's MAC address generation.

Parameters
[in]portPointer to the bridge port context

Definition at line 815 of file rstp_misc.c.

◆ rstpGetBridgePort()

RstpBridgePort* rstpGetBridgePort ( RstpBridgeContext context,
uint16_t  portId 
)

Retrieve the port that matches the specified port number.

Parameters
[in]contextPointer to the RSTP bridge context
[in]portIdPort identifier
Returns
Pointer to the matching port, if any

Definition at line 187 of file rstp_misc.c.

◆ rstpGetParamName()

const char_t* rstpGetParamName ( uint_t  value,
const RstpParamName paramList,
size_t  paramListLen 
)

Convert a parameter to string representation.

Parameters
[in]valueParameter value
[in]paramListList of acceptable parameters
[in]paramListLenNumber of entries in the list
Returns
NULL-terminated string describing the parameter

Definition at line 883 of file rstp_misc.c.

◆ rstpLock()

void rstpLock ( RstpBridgeContext context)

Acquire exclusive access to the RSTP bridge context.

Parameters
[in]contextPointer to the RSTP bridge context

Definition at line 50 of file rstp_misc.c.

◆ rstpRemoveFdbEntries()

void rstpRemoveFdbEntries ( RstpBridgePort port)

Remove filtering database entries (immediately or by rapid ageing)

Parameters
[in]portPointer to the bridge port context

Definition at line 660 of file rstp_misc.c.

◆ rstpTick()

void rstpTick ( RstpBridgeContext context)

RSTP tick handler.

This routine must be called at one second intervals

Parameters
[in]contextPointer to the RSTP bridge context

Definition at line 77 of file rstp_misc.c.

◆ rstpUnconfigurePermanentDatabase()

void rstpUnconfigurePermanentDatabase ( RstpBridgeContext context)

Unconfigure the permanent database.

Parameters
[in]contextPointer to the RSTP bridge context

Definition at line 788 of file rstp_misc.c.

◆ rstpUnlock()

void rstpUnlock ( RstpBridgeContext context)

Release exclusive access to the RSTP bridge context.

Parameters
[in]contextPointer to the RSTP bridge context

Definition at line 62 of file rstp_misc.c.

◆ rstpUpdateAgeingTime()

void rstpUpdateAgeingTime ( RstpBridgeContext context,
uint32_t  ageingTime 
)

Set ageing time for dynamic filtering entries.

Parameters
[in]contextPointer to the RSTP bridge context
[in]ageingTimeAging time, in seconds

Definition at line 527 of file rstp_misc.c.

◆ rstpUpdateOperPointToPointMac()

void rstpUpdateOperPointToPointMac ( RstpBridgePort port)

Update the value of the operPointToPointMac variable.

Parameters
[in]portPointer to the bridge port context

Definition at line 455 of file rstp_misc.c.

◆ rstpUpdatePortPathCost()

void rstpUpdatePortPathCost ( RstpBridgePort port)

Update the value of the portPathCost variable.

Parameters
[in]portPointer to the bridge port context

Definition at line 425 of file rstp_misc.c.

◆ rstpUpdatePortState()

void rstpUpdatePortState ( RstpBridgePort port,
SwitchPortState  state 
)

Set port state.

Parameters
[in]portPointer to the bridge port context
[in]statePort state (disabled, learning or forwarding)

Definition at line 495 of file rstp_misc.c.

◆ rstpUpdateTopologyChangeCount()

void rstpUpdateTopologyChangeCount ( RstpBridgeContext context)

Update the number of topology changes.

Parameters
[in]contextPointer to the RSTP bridge context

Definition at line 394 of file rstp_misc.c.