Network interfaces¶
Common network interface API.
This allows access to network interfaces regardless of the network stack implementation.The network stack must provide
- Both a definition for the type
netif_t
and the valueNETIF_INVALID
of typenetif_t
in a filenetif_types.h
and - implementation of all the functions defined in net/netif.h
-
netif_types.h::netif_t
netif_iter
(netif_types.h::netif_t
last)¶ Iterator for the interfaces.
Returns interface after
last
. To start uselast == NETIF_INVALID
.Parameters
last: The previous interface. Usen NETIF_INVALID
to start iteration.Note
Supposed to be implemented by the networking module
Return values
-
int
netif_get_name
(netif_types.h::netif_t
netif, char * name)¶ Gets name of an interface.
Note
Supposed to be implemented by the networking module.
name
must be zero-terminated in the result!Parameters
netif: A network interface. name: The name of the interface. Must not be NULL
. Must at least holdnetif.h::NETIF_NAMELENMAX
bytes.Return values
- length of
name
on success - 0, if
netif
was not a valid interface.
- length of
-
netif_types.h::netif_t
netif_get_by_name
(const char * name)¶ Gets interface by name.
Note
Supposed to be implemented by the networking module.
Parameters
name: The name of an interface as a zero-terminated. Must not be NULL
.Return values
-
int
netif_get_opt
(netif_types.h::netif_t
netif,netopt.h::netopt_t
opt, uint16_t context, void * value,msp430_types.h::size_t
max_len)¶ Gets option from an interface.
Note
Supposed to be implemented by the networking module
Parameters
netif: A network interface. opt: Option type. context: (Optional) context to the given option value: Pointer to store the option’s value in. max_len: Maximal amount of byte that fit into value
.Return values
- Number of bytes written to
value
. < 0
on error, 0 on success.
- Number of bytes written to
-
int
netif_set_opt
(netif_types.h::netif_t
netif,netopt.h::netopt_t
opt, uint16_t context, void * value,msp430_types.h::size_t
value_len)¶ Sets option to an interface.
Note
Supposed to be implemented by the networking module
Parameters
netif: A network interface. opt: Option type. context: (Optional) context to the given option value: Pointer to store the option’s value in. value_len: The length of value
.Return values
- Number of bytes used from
value
. < 0
on error, 0 on success.
- Number of bytes used from
-
NETIF_NAMELENMAX
¶ Maximum length for an interface name.
1
(8U)