stp_bpdu.h File Reference

BPDU processing. More...

#include "stp/stp.h"

Go to the source code of this file.

Macros

#define STP_TCN_BPDU_SIZE   4
 
#define STP_CONFIG_BPDU_SIZE   35
 
#define STP_PORT_PRIORITY_MASK   0xFF00
 
#define STP_PORT_NUM_MASK   0x00FF
 

Enumerations

enum  StpBpduTypes { STP_BPDU_TYPE_CONFIG = 0x00, STP_BPDU_TYPE_TCN = 0x80 }
 BPDU types. More...
 
enum  StpBpduFlags { STP_BPDU_FLAG_TC = 0x01, STP_BPDU_FLAG_TC_ACK = 0x80 }
 BPDU flags. More...
 

Functions

void stpProcessLlcFrame (NetInterface *interface, EthHeader *ethHeader, const uint8_t *data, size_t length, NetRxAncillary *ancillary, void *param)
 Process incoming LLC frame. More...
 
error_t stpProcessBpdu (StpBridgePort *port, const StpBpdu *bpdu, size_t length)
 Process incoming bridge protocol data unit. More...
 
error_t stpSendBpdu (StpBridgePort *port, const StpBpdu *bpdu, size_t length)
 Send bridge protocol data unit. More...
 
error_t stpDumpBpdu (const StpBpdu *bpdu, size_t length)
 Dump BPDU for debugging purpose. More...
 
void stpDumpFlags (uint8_t flags)
 Dump Flags field for debugging purpose. More...
 

Variables

typedef __packed_struct
 Spanning Tree BPDU. More...
 
uint8_t protocolVersionId
 
uint8_t bpduType
 
uint8_t flags
 
StpBridgeId rootId
 
uint32_t rootPathCost
 
StpBridgeId bridgeId
 
uint16_t portId
 
uint16_t messageAge
 
uint16_t maxAge
 
uint16_t helloTime
 
uint16_t forwardDelay
 
 StpBpdu
 
const MacAddr STP_BRIDGE_GROUP_ADDR
 

Detailed Description

BPDU processing.

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_bpdu.h.

Macro Definition Documentation

◆ STP_CONFIG_BPDU_SIZE

#define STP_CONFIG_BPDU_SIZE   35

Definition at line 39 of file stp_bpdu.h.

◆ STP_PORT_NUM_MASK

#define STP_PORT_NUM_MASK   0x00FF

Definition at line 43 of file stp_bpdu.h.

◆ STP_PORT_PRIORITY_MASK

#define STP_PORT_PRIORITY_MASK   0xFF00

Definition at line 42 of file stp_bpdu.h.

◆ STP_TCN_BPDU_SIZE

#define STP_TCN_BPDU_SIZE   4

Definition at line 38 of file stp_bpdu.h.

Enumeration Type Documentation

◆ StpBpduFlags

BPDU flags.

Enumerator
STP_BPDU_FLAG_TC 
STP_BPDU_FLAG_TC_ACK 

Definition at line 66 of file stp_bpdu.h.

◆ StpBpduTypes

BPDU types.

Enumerator
STP_BPDU_TYPE_CONFIG 
STP_BPDU_TYPE_TCN 

Definition at line 55 of file stp_bpdu.h.

Function Documentation

◆ stpDumpBpdu()

error_t stpDumpBpdu ( const StpBpdu bpdu,
size_t  length 
)

Dump BPDU for debugging purpose.

Parameters
[in]bpduPointer to the BPDU to dump
[in]lengthLength of the BPDU, in bytes
Returns
Error code

Definition at line 267 of file stp_bpdu.c.

◆ stpDumpFlags()

void stpDumpFlags ( uint8_t  flags)

Dump Flags field for debugging purpose.

Parameters
[in]flagsValue of the Flags field

Definition at line 337 of file stp_bpdu.c.

◆ stpProcessBpdu()

error_t stpProcessBpdu ( StpBridgePort port,
const StpBpdu bpdu,
size_t  length 
)

Process incoming bridge protocol data unit.

Parameters
[in]portPointer to the bridge port context
[in]bpduPointer to the received BPDU
[in]lengthLength of the BPDU, in bytes
Returns
Error code

Definition at line 130 of file stp_bpdu.c.

◆ stpProcessLlcFrame()

void stpProcessLlcFrame ( NetInterface interface,
EthHeader ethHeader,
const uint8_t *  data,
size_t  length,
NetRxAncillary ancillary,
void *  param 
)

Process incoming LLC frame.

Parameters
[in]interfaceUnderlying network interface
[in]ethHeaderPointer to the Ethernet header
[in]dataPointer to the LLC frame
[in]lengthLength of the LLC frame, in bytes
[in]ancillaryAdditional options passed to the stack along with the packet
[in]paramPointer to the STP bridge context

Definition at line 72 of file stp_bpdu.c.

◆ stpSendBpdu()

error_t stpSendBpdu ( StpBridgePort port,
const StpBpdu bpdu,
size_t  length 
)

Send bridge protocol data unit.

Parameters
[in]portPointer to the bridge port context
[in]bpduPointer to the BPDU to be transmitted
[in]lengthLength of the BPDU, in bytes
Returns
Error code

Definition at line 186 of file stp_bpdu.c.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint16_t protocolId

Spanning Tree BPDU.

Definition at line 85 of file stp_bpdu.h.

◆ bpduType

uint8_t bpduType

Definition at line 89 of file stp_bpdu.h.

◆ bridgeId

StpBridgeId bridgeId

Definition at line 93 of file stp_bpdu.h.

◆ flags

uint8_t flags

Definition at line 90 of file stp_bpdu.h.

◆ forwardDelay

uint16_t forwardDelay

Definition at line 98 of file stp_bpdu.h.

◆ helloTime

uint16_t helloTime

Definition at line 97 of file stp_bpdu.h.

◆ maxAge

uint16_t maxAge

Definition at line 96 of file stp_bpdu.h.

◆ messageAge

uint16_t messageAge

Definition at line 95 of file stp_bpdu.h.

◆ portId

uint16_t portId

Definition at line 94 of file stp_bpdu.h.

◆ protocolVersionId

uint8_t protocolVersionId

Definition at line 88 of file stp_bpdu.h.

◆ rootId

StpBridgeId rootId

Definition at line 91 of file stp_bpdu.h.

◆ rootPathCost

uint32_t rootPathCost

Definition at line 92 of file stp_bpdu.h.

◆ STP_BRIDGE_GROUP_ADDR

const MacAddr STP_BRIDGE_GROUP_ADDR
extern

Definition at line 45 of file stp_bpdu.c.

◆ StpBpdu

StpBpdu

Definition at line 99 of file stp_bpdu.h.

uint8_t protocolId[]