stp.c File Reference

STP (Spanning Tree Protocol) More...

#include "stp/stp.h"
#include "stp/stp_mgmt.h"
#include "stp/stp_procedures.h"
#include "stp/stp_conditions.h"
#include "stp/stp_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   STP_TRACE_LEVEL
 

Functions

void stpGetDefaultSettings (StpBridgeSettings *settings)
 Initialize settings with default values. More...
 
error_t stpInit (StpBridgeContext *context, StpBridgeSettings *settings)
 Initialize STP bridge context. More...
 
error_t stpStart (StpBridgeContext *context)
 Start STP bridge operation. More...
 
error_t stpStop (StpBridgeContext *context)
 Stop STP bridge operation. More...
 
error_t stpSetBridgePriority (StpBridgeContext *context, uint16_t value)
 Set bridge priority. More...
 
error_t stpSetBridgeMaxAge (StpBridgeContext *context, uint_t value)
 Set Bridge Max Age parameter. More...
 
error_t stpSetBridgeHelloTime (StpBridgeContext *context, uint_t value)
 Set Bridge Hello Time parameter. More...
 
error_t stpSetBridgeForwardDelay (StpBridgeContext *context, uint_t value)
 Set Bridge Forward Delay parameter. More...
 
error_t stpSetAgeingTime (StpBridgeContext *context, uint_t value)
 Set Ageing Time parameter. More...
 
error_t stpGetNumPorts (StpBridgeContext *context, uint_t *value)
 Get the number of ports. More...
 
error_t stpGetBridgeAddr (StpBridgeContext *context, MacAddr *value)
 Get the MAC address assigned to the bridge. More...
 
error_t stpGetBridgePriority (StpBridgeContext *context, uint16_t *value)
 Get the assigned bridge priority. More...
 
error_t stpGetBridgeMaxAge (StpBridgeContext *context, uint_t *value)
 Get the assigned value of the Bridge Max Age parameter. More...
 
error_t stpGetBridgeHelloTime (StpBridgeContext *context, uint_t *value)
 Get the assigned value of the Bridge Hello Time parameter. More...
 
error_t stpGetBridgeForwardDelay (StpBridgeContext *context, uint_t *value)
 Get the assigned value of the Bridge Forward Delay parameter. More...
 
error_t stpGetHoldTime (StpBridgeContext *context, uint_t *value)
 Get the assigned value of the Hold Time parameter. More...
 
error_t stpGetAgeingTime (StpBridgeContext *context, uint_t *value)
 Get the assigned value of the Ageing Time parameter. More...
 
error_t stpGetDesignatedRoot (StpBridgeContext *context, StpBridgeId *value)
 Get the bridge identifier of the root of the spanning tree. More...
 
error_t stpGetRootPathCost (StpBridgeContext *context, uint32_t *value)
 Get the current cost of the path to the root. More...
 
error_t stpGetRootPort (StpBridgeContext *context, uint16_t *value)
 Get the current root port. More...
 
error_t stpGetMaxAge (StpBridgeContext *context, uint_t *value)
 Get the current Max Age value. More...
 
error_t stpGetHelloTime (StpBridgeContext *context, uint_t *value)
 Get the current Hello Time value. More...
 
error_t stpGetForwardDelay (StpBridgeContext *context, uint_t *value)
 Get the current Forward Delay value. More...
 
error_t stpGetTopologyChanges (StpBridgeContext *context, uint_t *value)
 Get the number of topology changes. More...
 
error_t stpGetTimeSinceTopologyChange (StpBridgeContext *context, uint_t *value)
 Get the time since a topology change was last detected. More...
 
error_t stpSetPortNum (StpBridgeContext *context, uint_t portIndex, uint16_t value)
 Set port number. More...
 
error_t stpSetPortAddr (StpBridgeContext *context, uint_t portIndex, const MacAddr *value)
 Set port address. More...
 
error_t stpSetPortPriority (StpBridgeContext *context, uint_t portIndex, uint8_t value)
 Set port priority. More...
 
error_t stpSetAdminPortState (StpBridgeContext *context, uint_t portIndex, bool_t value)
 Set administrative bridge port state. More...
 
error_t stpSetPortPathCost (StpBridgeContext *context, uint_t portIndex, uint32_t value)
 Set administrative port path cost. More...
 
error_t stpGetPortNum (StpBridgeContext *context, uint_t portIndex, uint16_t *value)
 Get the port number assigned to the port. More...
 
error_t stpGetPortAddr (StpBridgeContext *context, uint_t portIndex, MacAddr *value)
 Get the MAC address assigned to the port. More...
 
error_t stpGetPortPriority (StpBridgeContext *context, uint_t portIndex, uint8_t *value)
 Get the priority assigned to the port. More...
 
error_t stpGetAdminPortState (StpBridgeContext *context, uint_t portIndex, bool_t *value)
 Get the administrative port state. More...
 
error_t stpGetMacOperState (StpBridgeContext *context, uint_t portIndex, bool_t *value)
 Get the current MAC operational state. More...
 
error_t stpGetPortPathCost (StpBridgeContext *context, uint_t portIndex, uint32_t *value)
 Get the current value of the port path cost. More...
 
error_t stpGetPortState (StpBridgeContext *context, uint_t portIndex, StpPortState *value)
 Get the current state of the port. More...
 
error_t stpGetPortRole (StpBridgeContext *context, uint_t portIndex, StpPortRole *value)
 Get the assigned role of the port. More...
 
error_t stpGetPortDesignatedRoot (StpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
 Get the bridge identifier of the designated root bridge. More...
 
error_t stpGetPortDesignatedCost (StpBridgeContext *context, uint_t portIndex, uint32_t *value)
 Get the designated cost of the port. More...
 
error_t stpGetPortDesignatedBridge (StpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
 Get the bridge identifier of the designated bridge. More...
 
error_t stpGetPortDesignatedPort (StpBridgeContext *context, uint_t portIndex, uint16_t *value)
 Get the port identifier of the designated bridge. More...
 
error_t stpGetForwardTransitions (StpBridgeContext *context, uint_t portIndex, uint_t *value)
 Get the number of times the port has transitioned to Forwarding state. More...
 
void stpDeinit (StpBridgeContext *context)
 Release STP bridge context. More...
 

Detailed Description

STP (Spanning Tree Protocol)

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.4

Definition in file stp.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   STP_TRACE_LEVEL

Definition at line 32 of file stp.c.

Function Documentation

◆ stpDeinit()

void stpDeinit ( StpBridgeContext context)

Release STP bridge context.

Parameters
[in]contextPointer to the STP bridge context

Definition at line 1646 of file stp.c.

◆ stpGetAdminPortState()

error_t stpGetAdminPortState ( StpBridgeContext context,
uint_t  portIndex,
bool_t value 
)

Get the administrative port state.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueAdministrative port state
Returns
Error code

Definition at line 1309 of file stp.c.

◆ stpGetAgeingTime()

error_t stpGetAgeingTime ( StpBridgeContext context,
uint_t value 
)

Get the assigned value of the Ageing Time parameter.

Parameters
[in]contextPointer to the STP bridge context
[out]valueValue of the Ageing Time parameter
Returns
Error code

Definition at line 689 of file stp.c.

◆ stpGetBridgeAddr()

error_t stpGetBridgeAddr ( StpBridgeContext context,
MacAddr value 
)

Get the MAC address assigned to the bridge.

Parameters
[in]contextPointer to the STP bridge context
[out]valueMAC address of the bridge
Returns
Error code

Definition at line 497 of file stp.c.

◆ stpGetBridgeForwardDelay()

error_t stpGetBridgeForwardDelay ( StpBridgeContext context,
uint_t value 
)

Get the assigned value of the Bridge Forward Delay parameter.

Parameters
[in]contextPointer to the STP bridge context
[out]valueValue of the Bridge Forward Delay parameter, in seconds
Returns
Error code

Definition at line 625 of file stp.c.

◆ stpGetBridgeHelloTime()

error_t stpGetBridgeHelloTime ( StpBridgeContext context,
uint_t value 
)

Get the assigned value of the Bridge Hello Time parameter.

Parameters
[in]contextPointer to the STP bridge context
[out]valueValue of the Bridge Hello Time parameter, in seconds
Returns
Error code

Definition at line 593 of file stp.c.

◆ stpGetBridgeMaxAge()

error_t stpGetBridgeMaxAge ( StpBridgeContext context,
uint_t value 
)

Get the assigned value of the Bridge Max Age parameter.

Parameters
[in]contextPointer to the STP bridge context
[out]valueValue of the Bridge Max Age parameter, in seconds
Returns
Error code

Definition at line 561 of file stp.c.

◆ stpGetBridgePriority()

error_t stpGetBridgePriority ( StpBridgeContext context,
uint16_t *  value 
)

Get the assigned bridge priority.

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

Definition at line 529 of file stp.c.

◆ stpGetDefaultSettings()

void stpGetDefaultSettings ( StpBridgeSettings settings)

Initialize settings with default values.

Parameters
[out]settingsStructure that contains STP bridge settings

Definition at line 51 of file stp.c.

◆ stpGetDesignatedRoot()

error_t stpGetDesignatedRoot ( StpBridgeContext context,
StpBridgeId value 
)

Get the bridge identifier of the root of the spanning tree.

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

Definition at line 721 of file stp.c.

◆ stpGetForwardDelay()

error_t stpGetForwardDelay ( StpBridgeContext context,
uint_t value 
)

Get the current Forward Delay value.

Parameters
[in]contextPointer to the STP bridge context
[out]valueForward Delay value, in seconds
Returns
Error code

Definition at line 881 of file stp.c.

◆ stpGetForwardTransitions()

error_t stpGetForwardTransitions ( StpBridgeContext context,
uint_t  portIndex,
uint_t value 
)

Get the number of times the port has transitioned to Forwarding state.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueNumber of transitions to Forwarding state
Returns
Error code

Definition at line 1615 of file stp.c.

◆ stpGetHelloTime()

error_t stpGetHelloTime ( StpBridgeContext context,
uint_t value 
)

Get the current Hello Time value.

Parameters
[in]contextPointer to the STP bridge context
[out]valueHello Time value, in seconds
Returns
Error code

Definition at line 849 of file stp.c.

◆ stpGetHoldTime()

error_t stpGetHoldTime ( StpBridgeContext context,
uint_t value 
)

Get the assigned value of the Hold Time parameter.

Parameters
[in]contextPointer to the STP bridge context
[out]valueValue of the Transmit Hold Count parameter
Returns
Error code

Definition at line 657 of file stp.c.

◆ stpGetMacOperState()

error_t stpGetMacOperState ( StpBridgeContext context,
uint_t  portIndex,
bool_t value 
)

Get the current MAC operational state.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueMAC operational state
Returns
Error code

Definition at line 1343 of file stp.c.

◆ stpGetMaxAge()

error_t stpGetMaxAge ( StpBridgeContext context,
uint_t value 
)

Get the current Max Age value.

Parameters
[in]contextPointer to the STP bridge context
[out]valueMax Age value, in seconds
Returns
Error code

Definition at line 817 of file stp.c.

◆ stpGetNumPorts()

error_t stpGetNumPorts ( StpBridgeContext context,
uint_t value 
)

Get the number of ports.

Parameters
[in]contextPointer to the STP bridge context
[out]valueNumber of ports
Returns
Error code

Definition at line 465 of file stp.c.

◆ stpGetPortAddr()

error_t stpGetPortAddr ( StpBridgeContext context,
uint_t  portIndex,
MacAddr value 
)

Get the MAC address assigned to the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueMAC address of the individual MAC entity for the port
Returns
Error code

Definition at line 1241 of file stp.c.

◆ stpGetPortDesignatedBridge()

error_t stpGetPortDesignatedBridge ( StpBridgeContext context,
uint_t  portIndex,
StpBridgeId value 
)

Get the bridge identifier of the designated bridge.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueBridge identifier
Returns
Error code

Definition at line 1547 of file stp.c.

◆ stpGetPortDesignatedCost()

error_t stpGetPortDesignatedCost ( StpBridgeContext context,
uint_t  portIndex,
uint32_t *  value 
)

Get the designated cost of the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueDesignated cost of the port
Returns
Error code

Definition at line 1513 of file stp.c.

◆ stpGetPortDesignatedPort()

error_t stpGetPortDesignatedPort ( StpBridgeContext context,
uint_t  portIndex,
uint16_t *  value 
)

Get the port identifier of the designated bridge.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort identifier
Returns
Error code

Definition at line 1581 of file stp.c.

◆ stpGetPortDesignatedRoot()

error_t stpGetPortDesignatedRoot ( StpBridgeContext context,
uint_t  portIndex,
StpBridgeId value 
)

Get the bridge identifier of the designated root bridge.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valueBridge identifier
Returns
Error code

Definition at line 1479 of file stp.c.

◆ stpGetPortNum()

error_t stpGetPortNum ( StpBridgeContext context,
uint_t  portIndex,
uint16_t *  value 
)

Get the port number assigned to the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort number
Returns
Error code

Definition at line 1193 of file stp.c.

◆ stpGetPortPathCost()

error_t stpGetPortPathCost ( StpBridgeContext context,
uint_t  portIndex,
uint32_t *  value 
)

Get the current value of the port path cost.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort path cost
Returns
Error code

Definition at line 1377 of file stp.c.

◆ stpGetPortPriority()

error_t stpGetPortPriority ( StpBridgeContext context,
uint_t  portIndex,
uint8_t *  value 
)

Get the priority assigned to the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort priority
Returns
Error code

Definition at line 1275 of file stp.c.

◆ stpGetPortRole()

error_t stpGetPortRole ( StpBridgeContext context,
uint_t  portIndex,
StpPortRole value 
)

Get the assigned role of the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort role
Returns
Error code

Definition at line 1445 of file stp.c.

◆ stpGetPortState()

error_t stpGetPortState ( StpBridgeContext context,
uint_t  portIndex,
StpPortState value 
)

Get the current state of the port.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[out]valuePort state
Returns
Error code

Definition at line 1411 of file stp.c.

◆ stpGetRootPathCost()

error_t stpGetRootPathCost ( StpBridgeContext context,
uint32_t *  value 
)

Get the current cost of the path to the root.

Parameters
[in]contextPointer to the STP bridge context
[out]valueRoot path cost
Returns
Error code

Definition at line 753 of file stp.c.

◆ stpGetRootPort()

error_t stpGetRootPort ( StpBridgeContext context,
uint16_t *  value 
)

Get the current root port.

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

Definition at line 785 of file stp.c.

◆ stpGetTimeSinceTopologyChange()

error_t stpGetTimeSinceTopologyChange ( StpBridgeContext context,
uint_t value 
)

Get the time since a topology change was last detected.

Parameters
[in]contextPointer to the STP bridge context
[out]valueTime since a topology change was last detected
Returns
Error code

Definition at line 945 of file stp.c.

◆ stpGetTopologyChanges()

error_t stpGetTopologyChanges ( StpBridgeContext context,
uint_t value 
)

Get the number of topology changes.

Parameters
[in]contextPointer to the STP bridge context
[out]valueNumber of topology changes
Returns
Error code

Definition at line 913 of file stp.c.

◆ stpInit()

error_t stpInit ( StpBridgeContext context,
StpBridgeSettings settings 
)

Initialize STP bridge context.

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

Definition at line 70 of file stp.c.

◆ stpSetAdminPortState()

error_t stpSetAdminPortState ( StpBridgeContext context,
uint_t  portIndex,
bool_t  value 
)

Set administrative bridge port state.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[in]valueAdministrative bridge port state
Returns
Error code

Definition at line 1125 of file stp.c.

◆ stpSetAgeingTime()

error_t stpSetAgeingTime ( StpBridgeContext context,
uint_t  value 
)

Set Ageing Time parameter.

Parameters
[in]contextPointer to the STP bridge context
[in]valueValue of the Ageing Time parameter
Returns
Error code

Definition at line 433 of file stp.c.

◆ stpSetBridgeForwardDelay()

error_t stpSetBridgeForwardDelay ( StpBridgeContext context,
uint_t  value 
)

Set Bridge Forward Delay parameter.

Parameters
[in]contextPointer to the STP bridge context
[in]valueValue of the Bridge Forward Delay parameter, in seconds
Returns
Error code

Definition at line 401 of file stp.c.

◆ stpSetBridgeHelloTime()

error_t stpSetBridgeHelloTime ( StpBridgeContext context,
uint_t  value 
)

Set Bridge Hello Time parameter.

Parameters
[in]contextPointer to the STP bridge context
[in]valueValue of the Bridge Hello Time parameter, in seconds
Returns
Error code

Definition at line 369 of file stp.c.

◆ stpSetBridgeMaxAge()

error_t stpSetBridgeMaxAge ( StpBridgeContext context,
uint_t  value 
)

Set Bridge Max Age parameter.

Parameters
[in]contextPointer to the STP bridge context
[in]valueValue of the Bridge Max Age parameter, in seconds
Returns
Error code

Definition at line 337 of file stp.c.

◆ stpSetBridgePriority()

error_t stpSetBridgePriority ( StpBridgeContext context,
uint16_t  value 
)

Set bridge priority.

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

Definition at line 305 of file stp.c.

◆ stpSetPortAddr()

error_t stpSetPortAddr ( StpBridgeContext context,
uint_t  portIndex,
const MacAddr value 
)

Set port address.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[in]valueMAC address of the individual MAC entity for the port
Returns
Error code

Definition at line 1040 of file stp.c.

◆ stpSetPortNum()

error_t stpSetPortNum ( StpBridgeContext context,
uint_t  portIndex,
uint16_t  value 
)

Set port number.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[in]valuePort number
Returns
Error code

Definition at line 979 of file stp.c.

◆ stpSetPortPathCost()

error_t stpSetPortPathCost ( StpBridgeContext context,
uint_t  portIndex,
uint32_t  value 
)

Set administrative port path cost.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[in]valueAdministrative port path cost
Returns
Error code

Definition at line 1159 of file stp.c.

◆ stpSetPortPriority()

error_t stpSetPortPriority ( StpBridgeContext context,
uint_t  portIndex,
uint8_t  value 
)

Set port priority.

Parameters
[in]contextPointer to the STP bridge context
[in]portIndexPort index
[in]valuePort priority
Returns
Error code

Definition at line 1091 of file stp.c.

◆ stpStart()

error_t stpStart ( StpBridgeContext context)

Start STP bridge operation.

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

Definition at line 157 of file stp.c.

◆ stpStop()

error_t stpStop ( StpBridgeContext context)

Stop STP bridge operation.

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

Definition at line 245 of file stp.c.