Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
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 <sys/slist.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
33struct eth_bridge {
34 struct k_mutex lock;
35 sys_slist_t interfaces;
36 sys_slist_t listeners;
37};
38
39#define ETH_BRIDGE_INITIALIZER(obj) \
40 { \
41 .lock = { }, \
42 .interfaces = SYS_SLIST_STATIC_INIT(&obj.interfaces), \
43 .listeners = SYS_SLIST_STATIC_INIT(&obj.listeners), \
44 }
45
53#define ETH_BRIDGE_INIT(name) \
54 STRUCT_SECTION_ITERABLE(eth_bridge, name) = \
55 ETH_BRIDGE_INITIALIZER(name)
56
59 struct eth_bridge *instance;
61};
62
66};
67
89int eth_bridge_iface_add(struct eth_bridge *br, struct net_if *iface);
90
99int eth_bridge_iface_remove(struct eth_bridge *br, struct net_if *iface);
100
114int eth_bridge_iface_allow_tx(struct net_if *iface, bool allow);
115
132int eth_bridge_listener_add(struct eth_bridge *br, struct eth_bridge_listener *l);
133
142int eth_bridge_listener_remove(struct eth_bridge *br, struct eth_bridge_listener *l);
143
151int eth_bridge_get_index(struct eth_bridge *br);
152
160struct eth_bridge *eth_bridge_get_by_index(int index);
161
169typedef void (*eth_bridge_cb_t)(struct eth_bridge *br, void *user_data);
170
180
185#ifdef __cplusplus
186}
187#endif
188
189#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_ */
ZTEST_BMEM int index[(3)]
Definition: main.c:32
void
Definition: eswifi_shell.c:15
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. This is mainly useful in ...
void(* eth_bridge_cb_t)(struct eth_bridge *br, void *user_data)
Callback used while iterating over bridge instances.
Definition: ethernet_bridge.h:169
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.
Single-linked list implementation.
struct _slist sys_slist_t
Definition: slist.h:40
struct _snode sys_snode_t
Definition: slist.h:33
static struct k_spinlock lock
Definition: spinlock_error_case.c:12
Definition: ethernet_bridge.h:57
bool allow_tx
Definition: ethernet_bridge.h:60
struct eth_bridge * instance
Definition: ethernet_bridge.h:59
sys_snode_t node
Definition: ethernet_bridge.h:58
Definition: ethernet_bridge.h:63
struct k_fifo pkt_queue
Definition: ethernet_bridge.h:65
sys_snode_t node
Definition: ethernet_bridge.h:64
Definition: kernel.h:2153
Definition: kernel.h:2680
Network Interface structure.
Definition: net_if.h:468
static const intptr_t user_data[5]
Definition: main.c:590