Network interfaces

Common network interface API. More...

Detailed Description

Common network interface API.

This allows access to network interfaces regardless of the network stack implementation.The network stack must provide

Files

file  netif.h
 Common network interface API definitions.
 
file  netif_types.h
 GNRC-specfic type definitions for Network interfaces.
 

Macros

#define NETIF_NAMELENMAX   (8U)
 Maximum length for an interface name.
 

Functions

netif_t netif_iter (netif_t last)
 Iterator for the interfaces. More...
 
int netif_get_name (netif_t netif, char *name)
 Gets name of an interface. More...
 
netif_t netif_get_by_name (const char *name)
 Gets interface by name. More...
 
int netif_get_opt (netif_t netif, netopt_t opt, uint16_t context, void *value, size_t max_len)
 Gets option from an interface. More...
 
int netif_set_opt (netif_t netif, netopt_t opt, uint16_t context, void *value, size_t value_len)
 Sets option to an interface. More...
 

Function Documentation

◆ netif_get_by_name()

netif_t netif_get_by_name ( const char *  name)

Gets interface by name.

Precondition
name != NULL
Note
Supposed to be implemented by the networking module.
Parameters
[in]nameThe name of an interface as a zero-terminated. Must not be NULL.
Returns
The identifier of the interface on success.
NETIF_INVALID if no interface is named name.

◆ netif_get_name()

int netif_get_name ( netif_t  netif,
char *  name 
)

Gets name of an interface.

Precondition
name != NULL
name holds at least NETIF_NAMELENMAX characters
Note
Supposed to be implemented by the networking module. name must be zero-terminated in the result!
Parameters
[in]netifA network interface.
[out]nameThe name of the interface. Must not be NULL. Must at least hold NETIF_NAMELENMAX bytes.
Returns
length of name on success
0, if netif was not a valid interface.

◆ netif_get_opt()

int netif_get_opt ( netif_t  netif,
netopt_t  opt,
uint16_t  context,
void *  value,
size_t  max_len 
)

Gets option from an interface.

Note
Supposed to be implemented by the networking module
Parameters
[in]netifA network interface.
[in]optOption type.
[in]context(Optional) context to the given option
[out]valuePointer to store the option's value in.
[in]max_lenMaximal amount of byte that fit into value.
Returns
Number of bytes written to value.
< 0 on error, 0 on success.

◆ netif_iter()

netif_t netif_iter ( netif_t  last)

Iterator for the interfaces.

Returns interface after last. To start use last == NETIF_INVALID.

Parameters
[in]lastThe previous interface. Usen NETIF_INVALID to start iteration.
Note
Supposed to be implemented by the networking module
Returns
next network interface.
NETIF_INVALID, if there is no interface after last

◆ netif_set_opt()

int netif_set_opt ( netif_t  netif,
netopt_t  opt,
uint16_t  context,
void *  value,
size_t  value_len 
)

Sets option to an interface.

Note
Supposed to be implemented by the networking module
Parameters
[in]netifA network interface.
[in]optOption type.
[in]context(Optional) context to the given option
[in]valuePointer to store the option's value in.
[in]value_lenThe length of value.
Returns
Number of bytes used from value.
< 0 on error, 0 on success.