Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Virtual Network Interface Support Functions

Virtual network interface support functions. More...

Data Structures

struct  virtual_interface_api
 Virtual L2 API operations. More...
 
struct  virtual_interface_context
 Virtual L2 context that is needed to binding to the real network interface. More...
 

Macros

#define NET_VIRTUAL_INTERFACE_INIT(dev_id, name, init_fn, pm, data, config, prio, api, mtu)
 Create a virtual network interface.
 
#define NET_VIRTUAL_INTERFACE_INIT_INSTANCE(dev_id, name, inst, init_fn, pm, data, config, prio, api, mtu)
 Create a virtual network interface.
 

Enumerations

enum  virtual_interface_caps { VIRTUAL_INTERFACE_IPIP = BIT(1) , VIRTUAL_INTERFACE_VLAN = BIT(2) }
 Virtual interface capabilities. More...
 

Functions

int net_virtual_interface_attach (struct net_if *virtual_iface, struct net_if *iface)
 Attach virtual network interface to the given network interface.
 
struct net_ifnet_virtual_get_iface (struct net_if *iface)
 Return network interface related to this virtual network interface.
 
char * net_virtual_get_name (struct net_if *iface, char *buf, size_t len)
 Return the name of the virtual network interface L2.
 
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.
 
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.
 

Detailed Description

Virtual network interface support functions.

Macro Definition Documentation

◆ NET_VIRTUAL_INTERFACE_INIT

#define NET_VIRTUAL_INTERFACE_INIT (   dev_id,
  name,
  init_fn,
  pm,
  data,
  config,
  prio,
  api,
  mtu 
)

#include <include/zephyr/net/virtual.h>

Value:
Z_NET_VIRTUAL_INTERFACE_INIT(DT_INVALID_NODE, dev_id, name, \
init_fn, pm, data, config, prio, \
api, mtu)
#define DT_INVALID_NODE
Name for an invalid node identifier.
Definition devicetree.h:87
static int init_fn(void)
Definition main.c:263
static fdata_t data[2]
Definition test_fifo_contexts.c:15

Create a virtual network interface.

Binding to another interface is done at runtime by calling net_virtual_interface_attach(). The attaching is done automatically when setting up tunneling when peer IP address is set in IP tunneling driver.

Parameters
dev_idNetwork device id.
nameThe name this instance of the driver exposes to the system.
init_fnAddress to the init function of the driver.
pmReference to struct pm_device associated with the device. (optional).
dataPointer to the device's private data.
configThe address to the structure containing the configuration information for this instance of the driver.
prioThe initialization level at which configuration occurs.
apiProvides an initial pointer to the API function struct used by the driver. Can be NULL.
mtuMaximum transfer unit in bytes for this network interface. This is the default value and its value can be tweaked at runtime.

◆ NET_VIRTUAL_INTERFACE_INIT_INSTANCE

#define NET_VIRTUAL_INTERFACE_INIT_INSTANCE (   dev_id,
  name,
  inst,
  init_fn,
  pm,
  data,
  config,
  prio,
  api,
  mtu 
)

#include <include/zephyr/net/virtual.h>

Value:
Z_NET_VIRTUAL_INTERFACE_INIT_INSTANCE(DT_INVALID_NODE, dev_id, \
name, inst, \
init_fn, pm, data, config, \
prio, api, mtu)

Create a virtual network interface.

Binding to another interface is done at runtime by calling net_virtual_interface_attach(). The attaching is done automatically when setting up tunneling when peer IP address is set in IP tunneling driver.

Parameters
dev_idNetwork device id.
nameThe name this instance of the driver exposes to the system.
instinstance number
init_fnAddress to the init function of the driver.
pmReference to struct pm_device associated with the device. (optional).
dataPointer to the device's private data.
configThe address to the structure containing the configuration information for this instance of the driver.
prioThe initialization level at which configuration occurs.
apiProvides an initial pointer to the API function struct used by the driver. Can be NULL.
mtuMaximum transfer unit in bytes for this network interface. This is the default value and its value can be tweaked at runtime.

Enumeration Type Documentation

◆ virtual_interface_caps

#include <include/zephyr/net/virtual.h>

Virtual interface capabilities.

Enumerator
VIRTUAL_INTERFACE_IPIP 

IPIP tunnel.

VIRTUAL_INTERFACE_VLAN 

Virtual LAN interface (VLAN)

Function Documentation

◆ net_virtual_get_iface()

struct net_if * net_virtual_get_iface ( struct net_if iface)

#include <include/zephyr/net/virtual.h>

Return network interface related to this virtual network interface.

The returned network interface is below this virtual network interface.

Parameters
ifaceVirtual network interface.
Returns
Network interface related to this virtual interface or NULL if no such interface exists.

◆ net_virtual_get_name()

char * net_virtual_get_name ( struct net_if iface,
char *  buf,
size_t  len 
)

#include <include/zephyr/net/virtual.h>

Return the name of the virtual network interface L2.

Parameters
ifaceVirtual network interface.
bufBuffer to store the name
lenMax buffer length
Returns
Name of the virtual network interface.

◆ net_virtual_input()

enum net_verdict net_virtual_input ( struct net_if input_iface,
struct net_addr *  remote_addr,
struct net_pkt pkt 
)

#include <include/zephyr/net/virtual.h>

Feed the IP pkt to stack if tunneling is enabled.

Parameters
input_ifaceNetwork interface receiving the pkt.
remote_addrIP address of the sender.
pktNetwork packet.
Returns
Verdict what to do with the packet.

◆ net_virtual_interface_attach()

int net_virtual_interface_attach ( struct net_if virtual_iface,
struct net_if iface 
)

#include <include/zephyr/net/virtual.h>

Attach virtual network interface to the given network interface.

Parameters
virtual_ifaceVirtual network interface.
ifaceNetwork interface we are attached to. This can be NULL, if we want to detach.
Returns
0 if ok, <0 if attaching failed

◆ net_virtual_set_flags()

enum net_l2_flags net_virtual_set_flags ( struct net_if iface,
enum net_l2_flags  flags 
)

#include <include/zephyr/net/virtual.h>

Set the L2 flags of the virtual network interface.

Parameters
ifaceVirtual network interface.
flagsL2 flags to set.
Returns
Previous flags that were set.

◆ net_virtual_set_name()

void net_virtual_set_name ( struct net_if iface,
const char *  name 
)

#include <include/zephyr/net/virtual.h>

Set the name of the virtual network interface L2.

Parameters
ifaceVirtual network interface.
nameName of the virtual L2 layer.