Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
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. | |
Ethernet Bridging API.
#define ETH_BRIDGE_INIT | ( | name | ) |
#include <zephyr/net/ethernet_bridge.h>
Statically define and initialize a bridge instance.
name | Name of the bridge object |
eth_bridge_cb_t |
#include <zephyr/net/ethernet_bridge.h>
Callback used while iterating over bridge instances.
br | Pointer to bridge instance |
user_data | User supplied data |
struct eth_bridge * eth_bridge_get_by_index | ( | int | index | ) |
#include <zephyr/net/ethernet_bridge.h>
Get bridge instance according to index.
index | Bridge instance index |
int eth_bridge_get_index | ( | struct eth_bridge * | br | ) |
#include <zephyr/net/ethernet_bridge.h>
Get bridge index according to pointer.
br | Pointer to bridge instance |
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.
br | A pointer to an initialized bridge object |
iface | Interface to add |
#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.
iface | Interface to configure |
allow | true to activate TX mode, false otherwise |
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.
br | A pointer to an initialized bridge object |
iface | Interface to remove |
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().
br | A pointer to an initialized bridge object |
l | A pointer to an initialized listener instance. |
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.
br | A pointer to an initialized bridge object |
l | A pointer to the listener instance to be removed. |
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.
cb | Callback to call for each bridge instance |
user_data | User supplied data |