Zephyr API Documentation  3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ethernet_bridge.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2021 BayLibre SAS
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 */
14
15#ifndef ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
16#define ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
17
18#include <zephyr/sys/slist.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
34struct eth_bridge {
35 struct k_mutex lock;
36 sys_slist_t interfaces;
37 sys_slist_t listeners;
38 bool initialized;
39};
40
41#define ETH_BRIDGE_INITIALIZER(obj) \
42 { \
43 .lock = { }, \
44 .interfaces = SYS_SLIST_STATIC_INIT(&obj.interfaces), \
45 .listeners = SYS_SLIST_STATIC_INIT(&obj.listeners), \
46 }
47
55#define ETH_BRIDGE_INIT(name) \
56 STRUCT_SECTION_ITERABLE(eth_bridge, name) = \
57 ETH_BRIDGE_INITIALIZER(name)
58
61struct eth_bridge_iface_context {
62 sys_snode_t node;
63 struct eth_bridge *instance;
64 bool allow_tx;
65};
66
67struct eth_bridge_listener {
68 sys_snode_t node;
69 struct k_fifo pkt_queue;
70};
71
95int eth_bridge_iface_add(struct eth_bridge *br, struct net_if *iface);
96
105int eth_bridge_iface_remove(struct eth_bridge *br, struct net_if *iface);
106
120int eth_bridge_iface_allow_tx(struct net_if *iface, bool allow);
121
138int eth_bridge_listener_add(struct eth_bridge *br, struct eth_bridge_listener *l);
139
148int eth_bridge_listener_remove(struct eth_bridge *br, struct eth_bridge_listener *l);
149
157int eth_bridge_get_index(struct eth_bridge *br);
158
166struct eth_bridge *eth_bridge_get_by_index(int index);
167
175typedef void (*eth_bridge_cb_t)(struct eth_bridge *br, void *user_data);
176
185void net_eth_bridge_foreach(eth_bridge_cb_t cb, void *user_data);
186
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_ */
int eth_bridge_listener_add(struct eth_bridge *br, struct eth_bridge_listener *l)
Add (register) a listener to the 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_add(struct eth_bridge *br, struct net_if *iface)
Add an Ethernet network interface to a bridge.
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.
void(* eth_bridge_cb_t)(struct eth_bridge *br, void *user_data)
Callback used while iterating over bridge instances.
Definition: ethernet_bridge.h:175
struct eth_bridge * eth_bridge_get_by_index(int index)
Get bridge instance according to index.
int eth_bridge_get_index(struct eth_bridge *br)
Get bridge index according to pointer.
int eth_bridge_iface_allow_tx(struct net_if *iface, bool allow)
Enable/disable transmission mode for a bridged interface.
int eth_bridge_listener_remove(struct eth_bridge *br, struct eth_bridge_listener *l)
Remove (unregister) a listener from the bridge.
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
Definition: kernel.h:2391
Mutex Structure.
Definition: kernel.h:2917
Network Interface structure.
Definition: net_if.h:678