123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #ifndef ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
- #define ZEPHYR_INCLUDE_NET_ETHERNET_BRIDGE_H_
- #include <sys/slist.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct eth_bridge {
- struct k_mutex lock;
- sys_slist_t interfaces;
- sys_slist_t listeners;
- };
- #define ETH_BRIDGE_INITIALIZER(obj) \
- { \
- .lock = { }, \
- .interfaces = SYS_SLIST_STATIC_INIT(&obj.interfaces), \
- .listeners = SYS_SLIST_STATIC_INIT(&obj.listeners), \
- }
- #define ETH_BRIDGE_INIT(name) \
- STRUCT_SECTION_ITERABLE(eth_bridge, name) = \
- ETH_BRIDGE_INITIALIZER(name)
- struct eth_bridge_iface_context {
- sys_snode_t node;
- struct eth_bridge *instance;
- bool allow_tx;
- };
- struct eth_bridge_listener {
- sys_snode_t node;
- struct k_fifo pkt_queue;
- };
- int eth_bridge_iface_add(struct eth_bridge *br, struct net_if *iface);
- int eth_bridge_iface_remove(struct eth_bridge *br, struct net_if *iface);
- int eth_bridge_iface_allow_tx(struct net_if *iface, bool allow);
- int eth_bridge_listener_add(struct eth_bridge *br, struct eth_bridge_listener *l);
- int eth_bridge_listener_remove(struct eth_bridge *br, struct eth_bridge_listener *l);
- int eth_bridge_get_index(struct eth_bridge *br);
- struct eth_bridge *eth_bridge_get_by_index(int index);
- typedef void (*eth_bridge_cb_t)(struct eth_bridge *br, void *user_data);
- void net_eth_bridge_foreach(eth_bridge_cb_t cb, void *user_data);
- #ifdef __cplusplus
- }
- #endif
- #endif
|