rstp_bpdu.h File Reference

BPDU processing. More...

#include "rstp/rstp.h"

Go to the source code of this file.

Macros

#define RSTP_TCN_BPDU_SIZE   4
 
#define RSTP_CONFIG_BPDU_SIZE   35
 
#define RSTP_RST_BPDU_SIZE   36
 
#define RSTP_PORT_PRIORITY_MASK   0xF000
 
#define RSTP_PORT_NUM_MASK   0x0FFF
 

Enumerations

enum  RstpBpduTypes { RSTP_BPDU_TYPE_CONFIG = 0x00, RSTP_BPDU_TYPE_TCN = 0x80, RSTP_BPDU_TYPE_RST = 0x02 }
 BPDU types. More...
 
enum  RstpBpduFlags {
  RSTP_BPDU_FLAG_TC = 0x01, RSTP_BPDU_FLAG_PROPOSAL = 0x02, RSTP_BPDU_FLAG_PORT_ROLE = 0x0C, RSTP_BPDU_FLAG_PORT_ROLE_UNKNOWN = 0x00,
  RSTP_BPDU_FLAG_PORT_ROLE_ALT_BACKUP = 0x04, RSTP_BPDU_FLAG_PORT_ROLE_ROOT = 0x08, RSTP_BPDU_FLAG_PORT_ROLE_DESIGNATED = 0x0C, RSTP_BPDU_FLAG_LEARNING = 0x10,
  RSTP_BPDU_FLAG_FORWARDING = 0x20, RSTP_BPDU_FLAG_AGREEMENT = 0x40, RSTP_BPDU_FLAG_TC_ACK = 0x80
}
 BPDU flags. More...
 

Functions

void rstpProcessLlcFrame (NetInterface *interface, EthHeader *ethHeader, const uint8_t *data, size_t length, NetRxAncillary *ancillary, void *param)
 Process incoming LLC frame. More...
 
error_t rstpProcessBpdu (RstpBridgePort *port, const RstpBpdu *bpdu, size_t length)
 Process incoming bridge protocol data unit. More...
 
error_t rstpValidateConfigBpdu (RstpBridgePort *port, const RstpBpdu *bpdu, size_t length)
 Validate Configuration BPDU. More...
 
error_t rstpSendBpdu (RstpBridgePort *port, const RstpBpdu *bpdu, size_t length)
 Send bridge protocol data unit. More...
 
error_t rstpDumpBpdu (const RstpBpdu *bpdu, size_t length)
 Dump BPDU for debugging purpose. More...
 
void rstpDumpFlags (uint8_t flags)
 Dump Flags field for debugging purpose. More...
 

Variables

typedef __packed_struct
 Rapid 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
 
uint8_t version1Length
 
 RstpBpdu
 
const MacAddr RSTP_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 rstp_bpdu.h.

Macro Definition Documentation

◆ RSTP_CONFIG_BPDU_SIZE

#define RSTP_CONFIG_BPDU_SIZE   35

Definition at line 39 of file rstp_bpdu.h.

◆ RSTP_PORT_NUM_MASK

#define RSTP_PORT_NUM_MASK   0x0FFF

Definition at line 44 of file rstp_bpdu.h.

◆ RSTP_PORT_PRIORITY_MASK

#define RSTP_PORT_PRIORITY_MASK   0xF000

Definition at line 43 of file rstp_bpdu.h.

◆ RSTP_RST_BPDU_SIZE

#define RSTP_RST_BPDU_SIZE   36

Definition at line 40 of file rstp_bpdu.h.

◆ RSTP_TCN_BPDU_SIZE

#define RSTP_TCN_BPDU_SIZE   4

Definition at line 38 of file rstp_bpdu.h.

Enumeration Type Documentation

◆ RstpBpduFlags

BPDU flags.

Enumerator
RSTP_BPDU_FLAG_TC 
RSTP_BPDU_FLAG_PROPOSAL 
RSTP_BPDU_FLAG_PORT_ROLE 
RSTP_BPDU_FLAG_PORT_ROLE_UNKNOWN 
RSTP_BPDU_FLAG_PORT_ROLE_ALT_BACKUP 
RSTP_BPDU_FLAG_PORT_ROLE_ROOT 
RSTP_BPDU_FLAG_PORT_ROLE_DESIGNATED 
RSTP_BPDU_FLAG_LEARNING 
RSTP_BPDU_FLAG_FORWARDING 
RSTP_BPDU_FLAG_AGREEMENT 
RSTP_BPDU_FLAG_TC_ACK 

Definition at line 68 of file rstp_bpdu.h.

◆ RstpBpduTypes

BPDU types.

Enumerator
RSTP_BPDU_TYPE_CONFIG 
RSTP_BPDU_TYPE_TCN 
RSTP_BPDU_TYPE_RST 

Definition at line 56 of file rstp_bpdu.h.

Function Documentation

◆ rstpDumpBpdu()

error_t rstpDumpBpdu ( const RstpBpdu 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 389 of file rstp_bpdu.c.

◆ rstpDumpFlags()

void rstpDumpFlags ( uint8_t  flags)

Dump Flags field for debugging purpose.

Parameters
[in]flagsValue of the Flags field

Definition at line 466 of file rstp_bpdu.c.

◆ rstpProcessBpdu()

error_t rstpProcessBpdu ( RstpBridgePort port,
const RstpBpdu 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 134 of file rstp_bpdu.c.

◆ rstpProcessLlcFrame()

void rstpProcessLlcFrame ( 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 RSTP bridge context

Definition at line 75 of file rstp_bpdu.c.

◆ rstpSendBpdu()

error_t rstpSendBpdu ( RstpBridgePort port,
const RstpBpdu 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 308 of file rstp_bpdu.c.

◆ rstpValidateConfigBpdu()

error_t rstpValidateConfigBpdu ( RstpBridgePort port,
const RstpBpdu bpdu,
size_t  length 
)

Validate Configuration BPDU.

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

Definition at line 271 of file rstp_bpdu.c.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint16_t protocolId

Rapid Spanning Tree BPDU.

Definition at line 96 of file rstp_bpdu.h.

◆ bpduType

uint8_t bpduType

Definition at line 100 of file rstp_bpdu.h.

◆ bridgeId

StpBridgeId bridgeId

Definition at line 104 of file rstp_bpdu.h.

◆ flags

uint8_t flags

Definition at line 101 of file rstp_bpdu.h.

◆ forwardDelay

uint16_t forwardDelay

Definition at line 109 of file rstp_bpdu.h.

◆ helloTime

uint16_t helloTime

Definition at line 108 of file rstp_bpdu.h.

◆ maxAge

uint16_t maxAge

Definition at line 107 of file rstp_bpdu.h.

◆ messageAge

uint16_t messageAge

Definition at line 106 of file rstp_bpdu.h.

◆ portId

uint16_t portId

Definition at line 105 of file rstp_bpdu.h.

◆ protocolVersionId

uint8_t protocolVersionId

Definition at line 99 of file rstp_bpdu.h.

◆ rootId

StpBridgeId rootId

Definition at line 102 of file rstp_bpdu.h.

◆ rootPathCost

uint32_t rootPathCost

Definition at line 103 of file rstp_bpdu.h.

◆ RSTP_BRIDGE_GROUP_ADDR

const MacAddr RSTP_BRIDGE_GROUP_ADDR
extern

Definition at line 46 of file rstp_bpdu.c.

◆ RstpBpdu

RstpBpdu

Definition at line 111 of file rstp_bpdu.h.

◆ version1Length

uint8_t version1Length

Definition at line 110 of file rstp_bpdu.h.

uint8_t protocolId[]