netif.h

netif API (to be used from TCPIP thread)

Defines

ENABLE_LOOPBACK
NETIF_MAX_HWADDR_LEN

Must be the maximum of all used hardware address lengths across all types of interfaces in use.

This does not have to be changed, normally.

NETIF_NAMESIZE

The size of a fully constructed netif name which the netif can be identified by in APIs.

Composed of 2 chars, 3 (max) digits, and 1 \0

NETIF_ADDR_IDX_MAX
LWIP_NETIF_USE_HINTS
NETIF_CHECKSUM_ENABLED(netif, chksumflag)
NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)
IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
NETIF_FOREACH(netif)
netif_set_flags(netif, set_flags)
netif_clear_flags(netif, clr_flags)
netif_is_flag_set(netif, flag)
netif_is_up(netif)

Ask if an interface is up.

Ask if a link is up.

NETIF_SET_HINTS(netif, netifhint)
NETIF_RESET_HINTS(netif)
netif_get_index(netif)
NETIF_NO_INDEX
LWIP_NSC_NONE
LWIP_NSC_NETIF_ADDED

netif was added.

arg: NULL. Called AFTER netif was added.

LWIP_NSC_NETIF_REMOVED

netif was removed.

arg: NULL. Called BEFORE netif is removed.

link changed

LWIP_NSC_STATUS_CHANGED

netif administrative status changed.

up is called AFTER netif is set up.

down is called BEFORE the netif is actually set down.

LWIP_NSC_IPV4_ADDRESS_CHANGED

IPv4 address has changed.

LWIP_NSC_IPV4_GATEWAY_CHANGED

IPv4 gateway has changed.

LWIP_NSC_IPV4_NETMASK_CHANGED

IPv4 netmask has changed.

LWIP_NSC_IPV4_SETTINGS_CHANGED

called AFTER IPv4 address/gateway/netmask changes have been applied

LWIP_NSC_IPV6_SET

IPv6 address was added.

LWIP_NSC_IPV6_ADDR_STATE_CHANGED

IPv6 address state has changed.

LWIP_NSC_IPV4_ADDR_VALID

IPv4 settings: valid address set, application may start to communicate.

NETIF_DECLARE_EXT_CALLBACK(name)
netif_add_ext_callback(callback, fn)
netif_remove_ext_callback(callback)
netif_invoke_ext_callback(netif, reason, args)

Typedefs

typedef err_t (*netif_init_fn)(struct netif *netif)

Function prototype for netif init functions.

Set up flags and output/linkoutput callback functions in this function.

Param netif:

The netif to initialize

typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp)

Function prototype for netif->input functions.

This function is saved as ‘input’ callback function in the netif struct. Call it when a packet has been received.

Param p:

The received packet, copied into a pbuf

Param inp:

The netif which received the packet

Return:

ERR_OK if the packet was handled != ERR_OK is the packet was NOT handled, in this case, the caller has to free the pbuf

typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)

Function prototype for netif->linkoutput functions.

Only used for ethernet netifs. This function is called by ARP when a packet shall be sent.

Param netif:

The netif which shall send a packet

Param p:

The packet to send (raw ethernet packet)

typedef void (*netif_status_callback_fn)(struct netif *netif)

Function prototype for netif status- or link-callback functions.

typedef u8_t netif_addr_idx_t
typedef u16_t netif_nsc_reason_t

Extended netif status callback (NSC) reasons flags.

May be extended in the future!

typedef void (*netif_ext_callback_fn)(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)

Function used for extended netif status callbacks Note: When parsing reason argument, keep in mind that more reasons may be added in the future!

Param netif:

netif that is affected by change

Param reason:

change reason

Param args:

depends on reason, see reason description

Enums

enum lwip_internal_netif_client_data_index

Values:

enumerator LWIP_NETIF_CLIENT_DATA_INDEX_MAX
enum netif_mac_filter_action

MAC Filter Actions, these are passed to a netif’s igmp_mac_filter or mld_mac_filter callback function.

Values:

enumerator NETIF_DEL_MAC_FILTER

Delete a filter entry.

enumerator NETIF_ADD_MAC_FILTER

Add a filter entry.

Functions

struct netif *netif_add_noaddr(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
struct netif *netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
void netif_remove(struct netif *netif)
struct netif *netif_find(const char *name)
void netif_set_default(struct netif *netif)
void netif_set_up(struct netif *netif)
void netif_set_down(struct netif *netif)
err_t netif_input(struct pbuf *p, struct netif *inp)
u8_t netif_name_to_index(const char *name)
char *netif_index_to_name(u8_t idx, char *name)
struct netif *netif_get_by_index(u8_t idx)

Variables

struct netif *netif_list

The list of network interfaces.

struct netif *netif_default

The default network interface.

struct netif
#include <netif.h>

Generic data structure used for all lwIP network interfaces.

The following fields should be filled in by the initialization function for the device driver: hwaddr_len, hwaddr[], mtu, flags

Public Members

struct netif *next

pointer to next in linked list

netif_input_fn input

This function is called by the network device driver to pass a packet up the TCP/IP stack.

netif_linkoutput_fn linkoutput

This function is called by ethernet_output() when it wants to send a packet on the interface.

This function outputs the pbuf as-is on the link medium.

void *state

This field can be set by the device driver and could point to state information for the device.

u16_t mtu

maximum transfer unit (in bytes)

u8_t hwaddr[NETIF_MAX_HWADDR_LEN]

link level hardware address of this interface

u8_t hwaddr_len

number of bytes used in hwaddr

u8_t flags

flags (

See also

Flags)

char name[2]

descriptive abbreviation

u8_t num

number of this interface.

Used for if_api and netifapi_netif, as well as for IPv6 zones

union netif_ext_callback_args_t
#include <netif.h>

Argument supplied to netif_ext_callback_fn.

struct ipv4_changed_s
#include <netif.h>

Args to LWIP_NSC_IPV4_ADDRESS_CHANGED|LWIP_NSC_IPV4_GATEWAY_CHANGED|LWIP_NSC_IPV4_NETMASK_CHANGED|LWIP_NSC_IPV4_SETTINGS_CHANGED callback.

Public Members

const ip_addr_t *old_address

Old IPv4 address.

const ip_addr_t *old_netmask
const ip_addr_t *old_gw
struct ipv6_addr_state_changed_s
#include <netif.h>

Args to LWIP_NSC_IPV6_ADDR_STATE_CHANGED callback.

Public Members

s8_t addr_index

Index of affected IPv6 address.

u8_t old_state

Old IPv6 address state.

const ip_addr_t *address

Affected IPv6 address.

struct ipv6_set_s
#include <netif.h>

Args to LWIP_NSC_IPV6_SET callback.

Public Members

s8_t addr_index

Index of changed IPv6 address.

const ip_addr_t *old_address

Old IPv6 address.

#include <netif.h>

Args to LWIP_NSC_LINK_CHANGED callback.

Public Members

1: up; 0: down

struct status_changed_s
#include <netif.h>

Args to LWIP_NSC_STATUS_CHANGED callback.

Public Members

u8_t state

1: up; 0: down