11#ifndef ZEPHYR_INCLUDE_NET_VIRTUAL_H_
12#define ZEPHYR_INCLUDE_NET_VIRTUAL_H_
48 VIRTUAL_INTERFACE_NUM_CAPS
54enum virtual_interface_config_type {
55 VIRTUAL_INTERFACE_CONFIG_TYPE_PEER_ADDRESS,
56 VIRTUAL_INTERFACE_CONFIG_TYPE_MTU,
57 VIRTUAL_INTERFACE_CONFIG_TYPE_LINK_TYPE,
60struct virtual_interface_link_types {
63 (CONFIG_NET_CAPTURE_COOKED_MODE_MAX_LINK_TYPES),
67struct virtual_interface_config {
73 struct virtual_interface_link_types link_types;
77#if defined(CONFIG_NET_L2_VIRTUAL)
78#define VIRTUAL_MAX_NAME_LEN CONFIG_NET_L2_VIRTUAL_MAX_NAME_LEN
80#define VIRTUAL_MAX_NAME_LEN 0
117 enum virtual_interface_config_type type,
118 const struct virtual_interface_config *config);
122 enum virtual_interface_config_type type,
123 struct virtual_interface_config *config);
139 struct net_if *virtual_iface;
161 char name[VIRTUAL_MAX_NAME_LEN];
227 struct net_addr *remote_addr,
238#if defined(CONFIG_NET_L2_VIRTUAL)
239void net_virtual_init(
struct net_if *iface);
241static inline void net_virtual_init(
struct net_if *iface)
253#if defined(CONFIG_NET_L2_VIRTUAL)
254void net_virtual_disable(
struct net_if *iface);
256static inline void net_virtual_disable(
struct net_if *iface)
268#if defined(CONFIG_NET_L2_VIRTUAL)
269void net_virtual_enable(
struct net_if *iface);
271static inline void net_virtual_enable(
struct net_if *iface)
277#define VIRTUAL_L2_CTX_TYPE struct virtual_interface_context
287net_virtual_get_iface_capabilities(
struct net_if *iface)
299#define Z_NET_VIRTUAL_INTERFACE_INIT(node_id, dev_id, name, init_fn, \
300 pm, data, config, prio, api, mtu) \
301 Z_NET_DEVICE_INIT(node_id, dev_id, name, init_fn, pm, data, \
302 config, prio, api, VIRTUAL_L2, \
303 NET_L2_GET_CTX_TYPE(VIRTUAL_L2), mtu)
305#define Z_NET_VIRTUAL_INTERFACE_INIT_INSTANCE(node_id, dev_id, name, \
306 inst, init_fn, pm, data, \
307 config, prio, api, mtu) \
308 Z_NET_DEVICE_INIT_INSTANCE(node_id, dev_id, name, inst, \
310 config, prio, api, VIRTUAL_L2, \
311 NET_L2_GET_CTX_TYPE(VIRTUAL_L2), mtu)
335#define NET_VIRTUAL_INTERFACE_INIT(dev_id, name, init_fn, pm, data, \
336 config, prio, api, mtu) \
337 Z_NET_VIRTUAL_INTERFACE_INIT(DT_INVALID_NODE, dev_id, name, \
338 init_fn, pm, data, config, prio, \
363#define NET_VIRTUAL_INTERFACE_INIT_INSTANCE(dev_id, name, inst, \
365 config, prio, api, mtu) \
366 Z_NET_VIRTUAL_INTERFACE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, \
368 init_fn, pm, data, config, \
unsigned short int sa_family_t
Socket address family type.
Definition: net_ip.h:164
net_verdict
Net Verdict.
Definition: net_core.h:100
static const struct device * net_if_get_device(struct net_if *iface)
Get an network interface's device.
Definition: net_if.h:941
net_l2_flags
L2 flags.
Definition: net_l2.h:34
struct _snode sys_snode_t
Single-linked list node structure.
Definition: slist.h:39
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition: util_macro.h:179
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
void net_virtual_set_name(struct net_if *iface, const char *name)
Set the name of the virtual network interface L2.
enum net_l2_flags net_virtual_set_flags(struct net_if *iface, enum net_l2_flags flags)
Set the L2 flags of the virtual network interface.
int net_virtual_interface_attach(struct net_if *virtual_iface, struct net_if *iface)
Attach virtual network interface to the given network interface.
enum net_verdict net_virtual_input(struct net_if *input_iface, struct net_addr *remote_addr, struct net_pkt *pkt)
Feed the IP pkt to stack if tunneling is enabled.
virtual_interface_caps
Virtual interface capabilities.
Definition: virtual.h:37
char * net_virtual_get_name(struct net_if *iface, char *buf, size_t len)
Return the name of the virtual network interface L2.
struct net_if * net_virtual_get_iface(struct net_if *iface)
Return network interface related to this virtual network interface.
@ VIRTUAL_INTERFACE_IPIP
IPIP tunnel.
Definition: virtual.h:39
@ VIRTUAL_INTERFACE_VLAN
Virtual LAN interface (VLAN)
Definition: virtual.h:42
Public API for network interface.
IPv6 and IPv4 definitions.
Network packet buffer descriptor API.
flags
Definition: parser.h:96
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:409
IPv6 address struct.
Definition: net_ip.h:139
IPv4 address struct.
Definition: net_ip.h:151
Network Interface structure.
Definition: net_if.h:678
Hardware link address structure.
Definition: net_linkaddr.h:88
Network packet.
Definition: net_pkt.h:67
Virtual L2 API operations.
Definition: virtual.h:85
int(* stop)(const struct device *dev)
Stop the device.
Definition: virtual.h:99
int(* get_config)(struct net_if *iface, enum virtual_interface_config_type type, struct virtual_interface_config *config)
Get specific L2 configuration.
Definition: virtual.h:121
int(* set_config)(struct net_if *iface, enum virtual_interface_config_type type, const struct virtual_interface_config *config)
Set specific L2 configuration.
Definition: virtual.h:116
enum net_verdict(* recv)(struct net_if *iface, struct net_pkt *pkt)
Receive a network packet.
Definition: virtual.h:110
int(* send)(struct net_if *iface, struct net_pkt *pkt)
Send a network packet.
Definition: virtual.h:102
int(* attach)(struct net_if *virtual_iface, struct net_if *iface)
Pass the attachment information to virtual interface.
Definition: virtual.h:113
enum virtual_interface_caps(* get_capabilities)(struct net_if *iface)
Get the virtual interface capabilities.
Definition: virtual.h:93
struct net_if_api iface_api
The net_if_api must be placed in first position in this struct so that we are compatible with network...
Definition: virtual.h:90
int(* start)(const struct device *dev)
Start the device.
Definition: virtual.h:96
Virtual L2 context that is needed to binding to the real network interface.
Definition: virtual.h:133
enum net_l2_flags virtual_l2_flags
This tells what L2 features does virtual support.
Definition: virtual.h:152
struct net_if * iface
Other network interface this virtual network interface is attached to.
Definition: virtual.h:147
char name[VIRTUAL_MAX_NAME_LEN]
User friendly name of this L2 layer.
Definition: virtual.h:161
bool is_init
Is this context already initialized.
Definition: virtual.h:155
struct net_linkaddr_storage lladdr
Link address for this network interface.
Definition: virtual.h:158