Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Ethernet Bridging API

Ethernet Bridging API. More...

Macros

#define ETH_BRIDGE_INIT(name)
 Statically define and initialize a bridge instance.
 

Typedefs

typedef void(* eth_bridge_cb_t) (struct eth_bridge *br, void *user_data)
 Callback used while iterating over bridge instances.
 

Functions

int eth_bridge_iface_add (struct eth_bridge *br, struct net_if *iface)
 Add an Ethernet network interface to a bridge.
 
int eth_bridge_iface_remove (struct eth_bridge *br, struct net_if *iface)
 Remove an Ethernet network interface from a bridge.
 
int eth_bridge_iface_allow_tx (struct net_if *iface, bool allow)
 Enable/disable transmission mode for a bridged interface.
 
int eth_bridge_listener_add (struct eth_bridge *br, struct eth_bridge_listener *l)
 Add (register) a listener to the bridge.
 
int eth_bridge_listener_remove (struct eth_bridge *br, struct eth_bridge_listener *l)
 Remove (unregister) a listener from the bridge.
 
int eth_bridge_get_index (struct eth_bridge *br)
 Get bridge index according to pointer.
 
struct eth_bridge * eth_bridge_get_by_index (int index)
 Get bridge instance according to index.
 
void net_eth_bridge_foreach (eth_bridge_cb_t cb, void *user_data)
 Go through all the bridge instances in order to get information about them.
 

Detailed Description

Ethernet Bridging API.

Macro Definition Documentation

◆ ETH_BRIDGE_INIT

#define ETH_BRIDGE_INIT (   name)

#include <zephyr/net/ethernet_bridge.h>

Value:
STRUCT_SECTION_ITERABLE(eth_bridge, name) = \
ETH_BRIDGE_INITIALIZER(name)
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition: iterable_sections.h:216

Statically define and initialize a bridge instance.

Parameters
nameName of the bridge object

Typedef Documentation

◆ eth_bridge_cb_t

eth_bridge_cb_t

#include <zephyr/net/ethernet_bridge.h>

Callback used while iterating over bridge instances.

Parameters
brPointer to bridge instance
user_dataUser supplied data

Function Documentation

◆ eth_bridge_get_by_index()

struct eth_bridge * eth_bridge_get_by_index ( int  index)

#include <zephyr/net/ethernet_bridge.h>

Get bridge instance according to index.

Parameters
indexBridge instance index
Returns
Pointer to bridge instance or NULL if not found.

◆ eth_bridge_get_index()

int eth_bridge_get_index ( struct eth_bridge *  br)

#include <zephyr/net/ethernet_bridge.h>

Get bridge index according to pointer.

Parameters
brPointer to bridge instance
Returns
Bridge index

◆ eth_bridge_iface_add()

int eth_bridge_iface_add ( struct eth_bridge *  br,
struct net_if iface 
)

#include <zephyr/net/ethernet_bridge.h>

Add an Ethernet network interface to a bridge.

This adds a network interface to a bridge. The interface is then put into promiscuous mode, all packets received by this interface are sent to the bridge, and any other packets sent to the bridge (with some exceptions) are transmitted via this interface.

For transmission from the bridge to occur via this interface, it is necessary to enable TX mode with eth_bridge_iface_tx(). TX mode is initially disabled.

Once an interface is added to a bridge, all its incoming traffic is diverted to the bridge. However, packets sent out with net_if_queue_tx() via this interface are not subjected to the bridge.

Parameters
brA pointer to an initialized bridge object
ifaceInterface to add
Returns
0 if OK, negative error code otherwise.

◆ eth_bridge_iface_allow_tx()

int eth_bridge_iface_allow_tx ( struct net_if iface,
bool  allow 
)

#include <zephyr/net/ethernet_bridge.h>

Enable/disable transmission mode for a bridged interface.

When TX mode is off, the interface may receive packets and send them to the bridge but no packets coming from the bridge will be sent through this interface. When TX mode is on, both incoming and outgoing packets are allowed.

Parameters
ifaceInterface to configure
allowtrue to activate TX mode, false otherwise
Returns
0 if OK, negative error code otherwise.

◆ eth_bridge_iface_remove()

int eth_bridge_iface_remove ( struct eth_bridge *  br,
struct net_if iface 
)

#include <zephyr/net/ethernet_bridge.h>

Remove an Ethernet network interface from a bridge.

Parameters
brA pointer to an initialized bridge object
ifaceInterface to remove
Returns
0 if OK, negative error code otherwise.

◆ eth_bridge_listener_add()

int eth_bridge_listener_add ( struct eth_bridge *  br,
struct eth_bridge_listener *  l 
)

#include <zephyr/net/ethernet_bridge.h>

Add (register) a listener to the bridge.

This lets a software listener register a pointer to a provided FIFO for receiving packets sent to the bridge. The listener is responsible for emptying the FIFO with k_fifo_get() which will return a struct net_pkt pointer, and releasing the packet with net_pkt_unref() when done with it.

The listener wishing not to receive any more packets should simply unregister itself with eth_bridge_listener_remove().

Parameters
brA pointer to an initialized bridge object
lA pointer to an initialized listener instance.
Returns
0 if OK, negative error code otherwise.

◆ eth_bridge_listener_remove()

int eth_bridge_listener_remove ( struct eth_bridge *  br,
struct eth_bridge_listener *  l 
)

#include <zephyr/net/ethernet_bridge.h>

Remove (unregister) a listener from the bridge.

Parameters
brA pointer to an initialized bridge object
lA pointer to the listener instance to be removed.
Returns
0 if OK, negative error code otherwise.

◆ net_eth_bridge_foreach()

void net_eth_bridge_foreach ( eth_bridge_cb_t  cb,
void *  user_data 
)

#include <zephyr/net/ethernet_bridge.h>

Go through all the bridge instances in order to get information about them.

This is mainly useful in net-shell to print data about currently active bridges.

Parameters
cbCallback to call for each bridge instance
user_dataUser supplied data