5.6. network_interface — Network interface

The network interface module has a list of all network interfaces and their states.

Network interface modules:

5.6.3. Debug file system commands

One debug file system command is available, located in the directory inet/network_interface/.

Command Description
list Print a list of all registered network interfaces.

Example output from the shell:

$ inet/network_interface/list
NAME            STATE  ADDRESS            TX BYTES    RX BYTES
esp-wlan-ap     up     192.168.4.1               -           -
esp-wlan-sta    up     192.168.0.5               -           -

Source code: src/inet/network_interface.h, src/inet/network_interface.c

Test coverage: src/inet/network_interface.c


Typedefs

typedef
typedef
typedef
typedef
typedef

Functions

int network_interface_module_init(void)

Initialize the network interface module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int network_interface_add(struct network_interface_t *netif_p)

Add given network interface to the global list of network interfaces. Call network_interface_start() to enable the interface.

Return
zero(0) or negative error code.
Parameters
  • netif_p: Network interface to register.

int network_interface_start(struct network_interface_t *netif_p)

Start given network interface. Enables the interface in the IP stack to allow packets to be sent and received. If the interface is a WiFi station interface it will try initiate the connection to its configured access point. Use network_interface_is_up() to check if the interface is connected to its access point.

Return
zero(0) or negative error code.
Parameters
  • netif_p: Network interface to start.

int network_interface_stop(struct network_interface_t *netif_p)

Stop given network interface. Disconnects from any WiFi access points and disables the interface in the IP stack. No packets can be sent or received on this interface after this function is called.

Return
zero(0) or negative error code.
Parameters
  • netif_p: Network interface to stop.

int network_interface_is_up(struct network_interface_t *netif_p)

Get the connection status of given network interface. PAckets can only be sent and received when the interface in up.

Return
true(1) if the network interface is up, false(0) is it is down, and otherwise negative error code.
Parameters
  • netif_p: Network interface to get the connection status of.

struct network_interface_t *network_interface_get_by_name(const char *name_p)

Search the global list of network interfaces for an interface with given name and return it.

Return
Found network interface or NULL if it was not found.
Parameters
  • name_p: Name of the network interface to find.

int network_interface_set_ip_info(struct network_interface_t *netif_p, const struct inet_if_ip_info_t *info_p)

Set the IP information of given network interface.

Return
zero(0) or negative error code.
Parameters
  • netif_p: Network interface to get the IP information of.
  • info_p: IP information to set.

int network_interface_get_ip_info(struct network_interface_t *netif_p, struct inet_if_ip_info_t *info_p)

Get the IP information of given network interface.

Return
zero(0) or negative error code.
Parameters
  • netif_p: Network interface to get the IP information of.
  • info_p: Read IP information.

struct

Public Members

const char *network_interface_t::name_p
struct inet_if_ip_info_t network_interface_t::info
network_interface_start_t network_interface_t::start
network_interface_stop_t network_interface_t::stop
network_interface_is_up_t network_interface_t::is_up
network_interface_set_ip_info_t network_interface_t::set_ip_info
network_interface_get_ip_info_t network_interface_t::get_ip_info
void *network_interface_t::netif_p
struct network_interface_t *network_interface_t::next_p