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 value NETIF_INVALID of type netif_t in a file netif_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 use last == NETIF_INVALID.

Parameters

last:The previous interface. Usen NETIF_INVALID to start iteration.

Note

Supposed to be implemented by the networking module

Return values

  • next network interface.
  • , if there is no interface after last
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 hold netif.h::NETIF_NAMELENMAX bytes.

Return values

  • length of name on success
  • 0, if netif was not a valid interface.
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

  • The identifier of the interface on success.
  • if no interface is named name.
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.
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.
NETIF_NAMELENMAX

Maximum length for an interface name.

1
(8U)