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 int(* network_interface_start_t)(struct network_interface_t *netif_p)
typedef int(* network_interface_stop_t)(struct network_interface_t *netif_p)
typedef int(* network_interface_is_up_t)(struct network_interface_t *netif_p)
typedef int(* network_interface_set_ip_info_t)(struct network_interface_t *netif_p, const struct inet_if_ip_info_t *info_p)
typedef int(* network_interface_get_ip_info_t)(struct network_interface_t *netif_p, struct inet_if_ip_info_t *info_p)

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 IP stack.

Return
zero(0) or negative error code.
Parameters
  • netif_p -

    Network interface to add.

int network_interface_start(struct network_interface_t *netif_p)

Enable given network interface. Use network_interface_is_up() to check if the interface is connected.

Return
zero(0) or negative error code.
Parameters
  • netif_p -

    Network interface to enable.

int network_interface_is_up(struct network_interface_t *netif_p)

Get the connection status of given network interface.

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 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)

Get the ip address of given network interface.

Return
zero(0) or negative error code.
Parameters
  • netif_p -

    Network interface to get the ip address of.

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

Get the ip address of given network interface.

Return
zero(0) or negative error code.
Parameters
  • netif_p -

    Network interface to get the ip address of.

struct network_interface_t

Public Members

struct netif netif
const char *name_p
struct inet_if_ip_info_t info
netif_init_fn init
network_interface_start_t start
network_interface_stop_t stop
network_interface_is_up_t is_up
network_interface_set_ip_info_t set_ip_info
network_interface_get_ip_info_t get_ip_info
struct network_interface_t *next_p