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 * Copyright (c) 2024 Nordic Semiconductor
12 *
13 * SPDX-License-Identifier: Apache-2.0
14 */
15
16#ifndef ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
17#define ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
18
19#include <zephyr/sys/slist.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
37#if defined(CONFIG_NET_ETHERNET_BRIDGE)
38#define NET_ETHERNET_BRIDGE_ETH_INTERFACE_COUNT CONFIG_NET_ETHERNET_BRIDGE_ETH_INTERFACE_COUNT
39#else
40#define NET_ETHERNET_BRIDGE_ETH_INTERFACE_COUNT 1
41#endif
42
43struct eth_bridge_iface_context {
44 /* Lock to protect access to interface array below */
45 struct k_mutex lock;
46
47 /* The actual bridge virtual interface */
48 struct net_if *iface;
49
50 /* What Ethernet interfaces are bridged together */
51 struct net_if *eth_iface[NET_ETHERNET_BRIDGE_ETH_INTERFACE_COUNT];
52
53 /* How many interfaces are bridged atm */
54 size_t count;
55
56 /* Bridge instance id */
57 int id;
58
59 /* Is the bridge interface initialized */
60 bool is_init : 1;
61
62 /* Has user configured the bridge */
63 bool is_setup : 1;
64
65 /* Is the interface enabled or not */
66 bool status : 1;
67};
68
85int eth_bridge_iface_add(struct net_if *br, struct net_if *iface);
86
100int eth_bridge_iface_remove(struct net_if *br, struct net_if *iface);
101
110
119
127typedef void (*eth_bridge_cb_t)(struct eth_bridge_iface_context *br, void *user_data);
128
137void net_eth_bridge_foreach(eth_bridge_cb_t cb, void *user_data);
138
143#ifdef __cplusplus
144}
145#endif
146
147#endif /* ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_ */
int eth_bridge_iface_add(struct net_if *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 context instances in order to get information about them.
int eth_bridge_iface_remove(struct net_if *br, struct net_if *iface)
Remove an Ethernet network interface from a bridge.
struct net_if * eth_bridge_get_by_index(int index)
Get bridge instance according to index.
void(* eth_bridge_cb_t)(struct eth_bridge_iface_context *br, void *user_data)
Callback used while iterating over bridge instances.
Definition ethernet_bridge.h:127
int eth_bridge_get_index(struct net_if *br)
Get bridge index according to pointer.
Mutex Structure.
Definition kernel.h:2994
Network Interface structure.
Definition net_if.h:680