New network interface API

Abstraction layer for GNRC's network interfaces. More...

Detailed Description

Abstraction layer for GNRC's network interfaces.

Network interfaces in the context of GNRC are threads for protocols that are below the network layer.

Files

file  6lo.h
 6LoWPAN definitions for New network interface API
 
file  netif2/conf.h
 Configuration macros for New network interface API.
 
file  gnrc/netif2/ethernet.h
 Ethernet adaption for New network interface API.
 
file  flags.h
 Flag definitions for New network interface API.
 
file  sys/include/net/gnrc/netif2/ieee802154.h
 IEEE 802.15.4 adaption for New network interface API.
 
file  gnrc/netif2/ipv6.h
 IPv6 defintions for New network interface API.
 
file  netif2/mac.h
 Common MAC module definitions for New network interface API
 
file  netif2.h
 Definition for GNRC's network interfaces.
 

Data Structures

struct  gnrc_netif2_t
 Representation of a network interface. More...
 
struct  gnrc_netif2_ops
 

Typedefs

typedef struct gnrc_netif2_ops gnrc_netif2_ops_t
 Operations to an interface.
 

Functions

gnrc_netif2_tgnrc_netif2_create (char *stack, int stacksize, char priority, const char *name, netdev_t *dev, const gnrc_netif2_ops_t *ops)
 Creates a network interface. More...
 
unsigned gnrc_netif2_numof (void)
 Get number of network interfaces actually allocated. More...
 
gnrc_netif2_tgnrc_netif2_iter (const gnrc_netif2_t *prev)
 Iterate over all network interfaces. More...
 
gnrc_netif2_tgnrc_netif2_get_by_pid (kernel_pid_t pid)
 Get network interface by PID. More...
 
int gnrc_netif2_get_from_netdev (gnrc_netif2_t *netif, gnrc_netapi_opt_t *opt)
 Default operation for gnrc_netif2_ops_t::get() More...
 
int gnrc_netif2_set_from_netdev (gnrc_netif2_t *netif, const gnrc_netapi_opt_t *opt)
 Default operation for gnrc_netif2_ops_t::set() More...
 
char * gnrc_netif2_addr_to_str (const uint8_t *addr, size_t addr_len, char *out)
 Converts a hardware address to a human readable string. More...
 
size_t gnrc_netif2_addr_from_str (const char *str, uint8_t *out)
 Parses a string of colon-separated hexadecimals to a hardware address. More...
 

Function Documentation

◆ gnrc_netif2_addr_from_str()

size_t gnrc_netif2_addr_from_str ( const char *  str,
uint8_t *  out 
)

Parses a string of colon-separated hexadecimals to a hardware address.

The input format must be like xx:xx:xx:xx where xx will be the bytes of addr in hexadecimal representation.

Precondition
(out != NULL)
out MUST have allocated at least GNRC_NETIF2_L2ADDR_MAXLEN bytes.
Parameters
[in]strA string of colon-separated hexadecimals.
[out]outThe resulting hardware address. Must at least have GNRC_NETIF2_L2ADDR_MAXLEN bytes allocated.
Returns
Actual length of out on success.
0, on failure.

◆ gnrc_netif2_addr_to_str()

char* gnrc_netif2_addr_to_str ( const uint8_t *  addr,
size_t  addr_len,
char *  out 
)

Converts a hardware address to a human readable string.

The format will be like xx:xx:xx:xx where xx are the bytes of addr in hexadecimal representation.

Precondition
(out != NULL) && ((addr != NULL) || (addr_len == 0))
out MUST have allocated at least 3 * addr_len bytes.
Parameters
[in]addrA hardware address.
[in]addr_lenLength of addr.
[out]outA string to store the output in. Must at least have 3 * addr_len bytes allocated.
Returns
out.

◆ gnrc_netif2_create()

gnrc_netif2_t* gnrc_netif2_create ( char *  stack,
int  stacksize,
char  priority,
const char *  name,
netdev_t dev,
const gnrc_netif2_ops_t ops 
)

Creates a network interface.

Parameters
[in]stackThe stack for the network interface's thread.
[in]stacksizeSize of stack.
[in]priorityPriority for the network interface's thread.
[in]nameName for the network interface. May be NULL.
[in]devDevice for the interface.
[in]opsOperations for the network interface.
Note
If DEVELHELP is defined netif_params_t::name is used as the name of the network interface's thread.
Attention
Fails and crashes (assertion error with DEVELHELP or segmentation fault without) if GNRC_NETIF_NUMOF is lower than the number of calls to this function.
Returns
The network interface on success.

◆ gnrc_netif2_get_by_pid()

gnrc_netif2_t* gnrc_netif2_get_by_pid ( kernel_pid_t  pid)

Get network interface by PID.

Parameters
[in]pidA PID of a network interface.
Returns
The network interface on success.
NULL, if no network interface with PID exists.

◆ gnrc_netif2_get_from_netdev()

int gnrc_netif2_get_from_netdev ( gnrc_netif2_t netif,
gnrc_netapi_opt_t opt 
)

Default operation for gnrc_netif2_ops_t::get()

Note
Can also be used to be called after a custom operation.
Parameters
[in]netifThe network interface.
[out]optThe option parameters.
Returns
Return value of netdev_driver_t::get() of gnrc_netif2_t::dev of netif.

◆ gnrc_netif2_iter()

gnrc_netif2_t* gnrc_netif2_iter ( const gnrc_netif2_t prev)

Iterate over all network interfaces.

Parameters
[in]prevprevious interface in iteration. NULL to start iteration.
Returns
The next network interface after prev.
NULL, if prev was the last network interface.

◆ gnrc_netif2_numof()

unsigned gnrc_netif2_numof ( void  )

Get number of network interfaces actually allocated.

Returns
Number of network interfaces actually allocated

◆ gnrc_netif2_set_from_netdev()

int gnrc_netif2_set_from_netdev ( gnrc_netif2_t netif,
const gnrc_netapi_opt_t opt 
)

Default operation for gnrc_netif2_ops_t::set()

Note
Can also be used to be called after a custom operation.
Parameters
[in]netifThe network interface.
[in]optThe option parameters.
Returns
Return value of netdev_driver_t::set() of gnrc_netif2_t::dev of netif.