stp_misc.h File Reference

STP helper functions. More...

#include "stp/stp.h"

Go to the source code of this file.

Data Structures

struct  StpParamName
 Parameter value/name binding. More...
 

Functions

void stpLock (StpBridgeContext *context)
 Acquire exclusive access to the STP bridge context. More...
 
void stpUnlock (StpBridgeContext *context)
 Release exclusive access to the STP bridge context. More...
 
void stpTick (StpBridgeContext *context)
 STP tick handler. More...
 
StpBridgePortstpGetBridgePort (StpBridgeContext *context, uint16_t portId)
 Retrieve the port that matches the specified port number. More...
 
int_t stpComparePortNum (uint16_t portId1, uint16_t portId2)
 Compare port numbers. More...
 
int_t stpCompareBridgeAddr (const MacAddr *addr1, const MacAddr *addr2)
 Compare bridge addresses. More...
 
int_t stpCompareBridgeId (const StpBridgeId *id1, const StpBridgeId *id2)
 Compare bridge identifiers. More...
 
void stpUpdateTopologyChange (StpBridgeContext *context, bool_t value)
 Set the Topology Change flag. More...
 
void stpUpdatePortState (StpBridgePort *port, StpPortState state)
 Set port state. More...
 
void stpUpdateAgeingTime (StpBridgeContext *context, uint32_t ageingTime)
 Set ageing time for dynamic filtering entries. More...
 
void stpEnableRsvdMcastTable (StpBridgeContext *context, bool_t enable)
 Enable reserved multicast table. More...
 
error_t stpAddStaticFdbEntry (StpBridgeContext *context, const MacAddr *macAddr, bool_t override)
 Add a new entry to the static MAC table. More...
 
error_t stpDeleteStaticFdbEntry (StpBridgeContext *context, const MacAddr *macAddr)
 Remove an entry from the static MAC table. More...
 
error_t stpConfigurePermanentDatabase (StpBridgeContext *context)
 Configure the permanent database. More...
 
void stpUnconfigurePermanentDatabase (StpBridgeContext *context)
 Unconfigure the permanent database. More...
 
void stpGeneratePortAddr (StpBridgePort *port)
 Port's MAC address generation. More...
 
bool_t stpCheckBridgeParams (uint_t maxAge, uint_t helloTime, uint_t forwardDelay)
 Check bridge parameters. More...
 
const char_tstpGetParamName (uint_t value, const StpParamName *paramList, size_t paramListLen)
 Convert a parameter to string representation. More...
 
void stpStartTimer (StpTimer *timer, uint_t value)
 Start timer. More...
 
void stpStopTimer (StpTimer *timer)
 Stop timer. More...
 
bool_t stpIncrementTimer (StpTimer *timer, uint_t timeout)
 Increment the timer and check for expiration. More...
 

Detailed Description

STP 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 stp_misc.h.

Function Documentation

◆ stpAddStaticFdbEntry()

error_t stpAddStaticFdbEntry ( StpBridgeContext context,
const MacAddr macAddr,
bool_t  override 
)

Add a new entry to the static MAC table.

Parameters
[in]contextPointer to the STP 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 484 of file stp_misc.c.

◆ stpCheckBridgeParams()

bool_t stpCheckBridgeParams ( 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 672 of file stp_misc.c.

◆ stpCompareBridgeAddr()

int_t stpCompareBridgeAddr ( 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 281 of file stp_misc.c.

◆ stpCompareBridgeId()

int_t stpCompareBridgeId ( 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 296 of file stp_misc.c.

◆ stpComparePortNum()

int_t stpComparePortNum ( 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 244 of file stp_misc.c.

◆ stpConfigurePermanentDatabase()

error_t stpConfigurePermanentDatabase ( StpBridgeContext context)

Configure the permanent database.

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

Definition at line 561 of file stp_misc.c.

◆ stpDeleteStaticFdbEntry()

error_t stpDeleteStaticFdbEntry ( StpBridgeContext context,
const MacAddr macAddr 
)

Remove an entry from the static MAC table.

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

Definition at line 523 of file stp_misc.c.

◆ stpEnableRsvdMcastTable()

void stpEnableRsvdMcastTable ( StpBridgeContext context,
bool_t  enable 
)

Enable reserved multicast table.

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

Definition at line 457 of file stp_misc.c.

◆ stpGeneratePortAddr()

void stpGeneratePortAddr ( StpBridgePort port)

Port's MAC address generation.

Parameters
[in]portPointer to the bridge port context

Definition at line 633 of file stp_misc.c.

◆ stpGetBridgePort()

StpBridgePort* stpGetBridgePort ( StpBridgeContext context,
uint16_t  portId 
)

Retrieve the port that matches the specified port number.

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

Definition at line 212 of file stp_misc.c.

◆ stpGetParamName()

const char_t* stpGetParamName ( uint_t  value,
const StpParamName 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 701 of file stp_misc.c.

◆ stpIncrementTimer()

bool_t stpIncrementTimer ( StpTimer timer,
uint_t  timeout 
)

Increment the timer and check for expiration.

Parameters
[in]timerPointer the timer to increment
[in]timeoutTimeout value
Returns
TRUE if the timer has expired, else FALSE

Definition at line 757 of file stp_misc.c.

◆ stpLock()

void stpLock ( StpBridgeContext context)

Acquire exclusive access to the STP bridge context.

Parameters
[in]contextPointer to the STP bridge context

Definition at line 59 of file stp_misc.c.

◆ stpStartTimer()

void stpStartTimer ( StpTimer timer,
uint_t  value 
)

Start timer.

Parameters
[in]timerPointer the timer to start (or restart)
[in]valueInitial value of the timer

Definition at line 729 of file stp_misc.c.

◆ stpStopTimer()

void stpStopTimer ( StpTimer timer)

Stop timer.

Parameters
[in]timerPointer the timer to stop

Definition at line 743 of file stp_misc.c.

◆ stpTick()

void stpTick ( StpBridgeContext context)

STP tick handler.

This routine must be called at one second intervals

Parameters
[in]contextPointer to the STP bridge context

Definition at line 86 of file stp_misc.c.

◆ stpUnconfigurePermanentDatabase()

void stpUnconfigurePermanentDatabase ( StpBridgeContext context)

Unconfigure the permanent database.

Parameters
[in]contextPointer to the STP bridge context

Definition at line 606 of file stp_misc.c.

◆ stpUnlock()

void stpUnlock ( StpBridgeContext context)

Release exclusive access to the STP bridge context.

Parameters
[in]contextPointer to the STP bridge context

Definition at line 71 of file stp_misc.c.

◆ stpUpdateAgeingTime()

void stpUpdateAgeingTime ( StpBridgeContext context,
uint32_t  ageingTime 
)

Set ageing time for dynamic filtering entries.

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

Definition at line 427 of file stp_misc.c.

◆ stpUpdatePortState()

void stpUpdatePortState ( StpBridgePort port,
StpPortState  state 
)

Set port state.

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

Definition at line 358 of file stp_misc.c.

◆ stpUpdateTopologyChange()

void stpUpdateTopologyChange ( StpBridgeContext context,
bool_t  value 
)

Set the Topology Change flag.

Parameters
[in]contextPointer to the STP bridge context
[in]valueValue of the Topology Change flag

Definition at line 325 of file stp_misc.c.