Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
IEEE 802.1D bridge
[NETIFs]
This file implements an IEEE 802.1D bridge by using a multilayer netif approach (one hardware-independent netif for the bridge that uses hardware netifs for its ports). More...
Data Structures | |
struct | bridgeif_initdata_s |
Initialisation data for bridgeif_init. More... | |
Modules | |
Options | |
FDB example code | |
This file implements an example for an FDB (Forwarding DataBase) | |
Typedefs | |
typedef struct bridgeif_initdata_s | bridgeif_initdata_t |
Initialisation data for bridgeif_init. | |
Functions | |
err_t | bridgeif_fdb_add (struct netif *bridgeif, const struct eth_addr *addr, bridgeif_portmask_t ports) |
Add a static entry to the forwarding database. | |
err_t | bridgeif_fdb_remove (struct netif *bridgeif, const struct eth_addr *addr) |
Remove a static entry from the forwarding database. | |
err_t | bridgeif_init (struct netif *netif) |
Initialization function passed to netif_add(). | |
err_t | bridgeif_add_port (struct netif *bridgeif, struct netif *portif) |
Add a port to the bridge. |
Detailed Description
This file implements an IEEE 802.1D bridge by using a multilayer netif approach (one hardware-independent netif for the bridge that uses hardware netifs for its ports).
On transmit, the bridge selects the outgoing port(s). On receive, the port netif calls into the bridge (via its netif->input function) and the bridge selects the port(s) (and/or its netif->input function) to pass the received pbuf to.
Usage:
- add the port netifs just like you would when using them as dedicated netif without a bridge
- only NETIF_FLAG_ETHARP/NETIF_FLAG_ETHERNET netifs are supported as bridge ports
- add the bridge port netifs without IPv4 addresses (i.e. pass 'NULL, NULL, NULL')
- don't add IPv6 addresses to the port netifs!
- set up the bridge configuration in a global variable of type 'bridgeif_initdata_t' that contains
- the MAC address of the bridge
- some configuration options controlling the memory consumption (maximum number of ports and FDB entries)
- e.g. for a bridge MAC address 00-01-02-03-04-05, 2 bridge ports, 1024 FDB entries + 16 static MAC entries: bridgeif_initdata_t mybridge_initdata = BRIDGEIF_INITDATA1(2, 1024, 16, ETH_ADDR(0, 1, 2, 3, 4, 5));
- add the bridge netif (with IPv4 config): struct netif bridge_netif; netif_add(&bridge_netif, &my_ip, &my_netmask, &my_gw, &mybridge_initdata, bridgeif_init, tcpip_input); NOTE: the passed 'input' function depends on BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT setting, which controls where the forwarding is done (netif low level input context vs. tcpip_thread)
- set up all ports netifs and the bridge netif
- When adding a port netif, NETIF_FLAG_ETHARP flag will be removed from a port to prevent ETHARP working on that port netif (we only want one IP per bridge not per port).
- When adding a port netif, its input function is changed to call into the bridge.
Typedef Documentation
typedef struct bridgeif_initdata_s bridgeif_initdata_t |
Initialisation data for bridgeif_init.
An instance of this type must be passed as parameter 'state' to netif_add when the bridge is added.
Function Documentation
Add a port to the bridge.
Definition at line 524 of file lwip_bridgeif.c.
err_t bridgeif_fdb_add | ( | struct netif * | bridgeif, |
const struct eth_addr * | addr, | ||
bridgeif_portmask_t | ports | ||
) |
Add a static entry to the forwarding database.
A static entry marks where frames to a specific eth address (unicast or group address) are forwarded. bits [0..(BRIDGEIF_MAX_PORTS-1)]: hw ports bit [BRIDGEIF_MAX_PORTS]: cpu port 0: drop
Definition at line 135 of file lwip_bridgeif.c.
Remove a static entry from the forwarding database.
Definition at line 168 of file lwip_bridgeif.c.
Initialization function passed to netif_add().
ATTENTION: A pointer to a bridgeif_initdata_t must be passed as 'state' to netif_add when adding the bridge. I supplies MAC address and controls memory allocation (number of ports, FDB size).
- Parameters:
-
netif the lwip network interface structure for this ethernetif
- Returns:
- ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error
Definition at line 413 of file lwip_bridgeif.c.
Generated on Tue Jul 12 2022 13:55:24 by
