lwIP 2.1.0 Lightweight IP stack

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
netif.h File Reference
`#include "lwip/opt.h"`
`#include "lwip/err.h"`
`#include "lwip/ip_addr.h"`
`#include "lwip/def.h"`
`#include "lwip/pbuf.h"`
`#include "lwip/stats.h"`

## Data Structures
struct | netif
union | netif_ext_callback_args_t
struct | netif_ext_callback_args_t::link_changed_s
struct | netif_ext_callback_args_t::status_changed_s
struct | netif_ext_callback_args_t::ipv4_changed_s
struct | netif_ext_callback_args_t::ipv6_set_s
struct | netif_ext_callback_args_t::ipv6_addr_state_changed_s

## Macros
#define | NETIF_MAX_HWADDR_LEN 6U
#define | NETIF_NAMESIZE 6
#define | NETIF_FLAG_UP 0x01U
#define | NETIF_FLAG_BROADCAST 0x02U
#define | NETIF_FLAG_LINK_UP 0x04U
#define | NETIF_FLAG_ETHARP 0x08U
#define | NETIF_FLAG_ETHERNET 0x10U
#define | NETIF_FLAG_IGMP 0x20U
#define | NETIF_FLAG_MLD6 0x40U
#define | netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
#define | netif_get_client_data(netif, id) (netif)->client_data[(id)]
#define | netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
#define | netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
#define | netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
#define | netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr))
#define | netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask))
#define | netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw))
#define | netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
#define | netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
#define | netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
#define | netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
#define | netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
#define | netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0)
#define | netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
#define | netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i])))
#define | LWIP_NSC_NETIF_ADDED 0x0001
#define | LWIP_NSC_NETIF_REMOVED 0x0002
#define | LWIP_NSC_LINK_CHANGED 0x0004
#define | LWIP_NSC_STATUS_CHANGED 0x0008
#define | LWIP_NSC_IPV4_ADDRESS_CHANGED 0x0010
#define | LWIP_NSC_IPV4_GATEWAY_CHANGED 0x0020
#define | LWIP_NSC_IPV4_NETMASK_CHANGED 0x0040
#define | LWIP_NSC_IPV4_SETTINGS_CHANGED 0x0080
#define | LWIP_NSC_IPV6_SET 0x0100
#define | LWIP_NSC_IPV6_ADDR_STATE_CHANGED 0x0200

## Typedefs
typedef err_t(* | netif_init_fn) (struct netif *netif)
typedef err_t(* | netif_input_fn) (struct pbuf *p, struct netif *inp)
typedef err_t(* | netif_output_fn) (struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
typedef err_t(* | netif_output_ip6_fn) (struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr)
typedef err_t(* | netif_linkoutput_fn) (struct netif *netif, struct pbuf *p)
typedef void(* | netif_status_callback_fn) (struct netif *netif)
typedef err_t(* | netif_igmp_mac_filter_fn) (struct netif *netif, const ip4_addr_t *group, enum netif_mac_filter_action action)
typedef err_t(* | netif_mld_mac_filter_fn) (struct netif *netif, const ip6_addr_t *group, enum netif_mac_filter_action action)
typedef u16_t | netif_nsc_reason_t
typedef void(* | netif_ext_callback_fn) (struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)

## Enumerations
enum | netif_mac_filter_action { NETIF_DEL_MAC_FILTER = 0, NETIF_ADD_MAC_FILTER = 1 }

## Functions
u8_t | netif_alloc_client_data_id (void)
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, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input)
void | netif_set_addr (struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw)
void | netif_remove (struct netif *netif)
struct netif * | netif_find (const char *name)
void | netif_set_default (struct netif *netif)
void | netif_set_ipaddr (struct netif *netif, const ip4_addr_t *ipaddr)
void | netif_set_netmask (struct netif *netif, const ip4_addr_t *netmask)
void | netif_set_gw (struct netif *netif, const ip4_addr_t *gw)
void | netif_set_up (struct netif *netif)
void | netif_set_down (struct netif *netif)
void | netif_set_status_callback (struct netif *netif, netif_status_callback_fn status_callback)
void | netif_set_remove_callback (struct netif *netif, netif_status_callback_fn remove_callback)
void | netif_set_link_up (struct netif *netif)
void | netif_set_link_down (struct netif *netif)
void | netif_set_link_callback (struct netif *netif, netif_status_callback_fn link_callback)
err_t | netif_loop_output (struct netif *netif, struct pbuf *p)
void | netif_poll (struct netif *netif)
err_t | netif_input (struct pbuf *p, struct netif *inp)
void | netif_ip6_addr_set (struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6)
void | netif_ip6_addr_set_state (struct netif *netif, s8_t addr_idx, u8_t state)
s8_t | netif_get_ip6_addr_match (struct netif *netif, const ip6_addr_t *ip6addr)
void | netif_create_ip6_linklocal_address (struct netif *netif, u8_t from_mac_48bit)
err_t | netif_add_ip6_address (struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
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)
void | netif_add_ext_callback (netif_ext_callback_t *callback, netif_ext_callback_fn fn)
void | netif_remove_ext_callback (netif_ext_callback_t *callback)
void | netif_invoke_ext_callback (struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)

## Variables
struct netif * | netif_list
struct netif * | netif_default

## Detailed Description

netif API (to be used from TCPIP thread)

## Macro Definition Documentation

## ◆ LWIP_NSC_IPV4_ADDRESS_CHANGED

#define LWIP_NSC_IPV4_ADDRESS_CHANGED 0x0010

IPv4 address has changed

## ◆ LWIP_NSC_IPV4_GATEWAY_CHANGED

#define LWIP_NSC_IPV4_GATEWAY_CHANGED 0x0020

IPv4 gateway has changed

## ◆ LWIP_NSC_IPV4_NETMASK_CHANGED

#define LWIP_NSC_IPV4_NETMASK_CHANGED 0x0040

IPv4 netmask has changed

## ◆ LWIP_NSC_IPV4_SETTINGS_CHANGED

#define LWIP_NSC_IPV4_SETTINGS_CHANGED 0x0080

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

## ◆ LWIP_NSC_IPV6_ADDR_STATE_CHANGED

#define LWIP_NSC_IPV6_ADDR_STATE_CHANGED 0x0200

IPv6 address state has changed

## ◆ LWIP_NSC_IPV6_SET

#define LWIP_NSC_IPV6_SET 0x0100

IPv6 address was added

## ◆ LWIP_NSC_LINK_CHANGED

#define LWIP_NSC_LINK_CHANGED 0x0004

link changed

## ◆ LWIP_NSC_NETIF_ADDED

#define LWIP_NSC_NETIF_ADDED 0x0001

netif was added. arg: NULL. Called AFTER netif was added.

## ◆ LWIP_NSC_NETIF_REMOVED

#define LWIP_NSC_NETIF_REMOVED 0x0002

netif was removed. arg: NULL. Called BEFORE netif is removed.

## ◆ LWIP_NSC_STATUS_CHANGED

#define LWIP_NSC_STATUS_CHANGED 0x0008

netif administrative status changed.
up is called AFTER netif is set up.
down is called BEFORE the netif is actually set down.

## ◆ netif_is_link_up

#define netif_is_link_up | ( |  | netif | ) | (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)

Ask if a link is up

## ◆ NETIF_MAX_HWADDR_LEN

#define NETIF_MAX_HWADDR_LEN 6U

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

#define NETIF_NAMESIZE 6

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

## Typedef Documentation

## ◆ netif_igmp_mac_filter_fn

typedef err_t(* netif_igmp_mac_filter_fn) (struct netif *netif, const ip4_addr_t *group, enum netif_mac_filter_action action)

Function prototype for netif igmp_mac_filter functions

## ◆ netif_init_fn

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.

Parameters

  netif | The netif to initialize

## ◆ netif_input_fn

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.

Parameters

  p | The received packet, copied into a pbuf
  inp | The netif which received the packet

Returns
  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

## ◆ netif_linkoutput_fn

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.

Parameters

  netif | The netif which shall send a packet
  p | The packet to send (raw ethernet packet)

## ◆ netif_mld_mac_filter_fn

typedef err_t(* netif_mld_mac_filter_fn) (struct netif *netif, const ip6_addr_t *group, enum netif_mac_filter_action action)

Function prototype for netif mld_mac_filter functions

## ◆ netif_output_fn

typedef err_t(* netif_output_fn) (struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)

Function prototype for netif->output functions. Called by lwIP when a packet shall be sent. For ethernet netif, set this to 'etharp_output' and set 'linkoutput'.

Parameters

  netif | The netif which shall send a packet
  p | The packet to send (p->payload points to IP header)
  ipaddr | The IP address to which the packet shall be sent

## ◆ netif_output_ip6_fn

typedef err_t(* netif_output_ip6_fn) (struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr)

Function prototype for netif->output_ip6 functions. Called by lwIP when a packet shall be sent. For ethernet netif, set this to 'ethip6_output' and set 'linkoutput'.

Parameters

  netif | The netif which shall send a packet
  p | The packet to send (p->payload points to IP header)
  ipaddr | The IPv6 address to which the packet shall be sent

## ◆ netif_status_callback_fn

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

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

## Enumeration Type Documentation

## ◆ netif_mac_filter_action

enum netif_mac_filter_action

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

Enumerator
NETIF_DEL_MAC_FILTER | Delete a filter entry
NETIF_ADD_MAC_FILTER | Add a filter entry

## Function Documentation

## ◆ netif_get_ip6_addr_match()

s8_t netif_get_ip6_addr_match | ( | struct netif * | netif,
|  | const ip6_addr_t * | ip6addr
| ) |  |

Checks if a specific local address is present on the netif and returns its index. Depending on its state, it may or may not be assigned to the interface (as per RFC terminology).

The given address may or may not be zoned (i.e., have a zone index other than IP6_NO_ZONE). If the address is zoned, it must have the correct zone for the given netif, or no match will be found.

Parameters

  netif | the netif to check
  ip6addr | the IPv6 address to find

Returns
  >= 0: address found, this is its index -1: address not found on this netif

## ◆ netif_invoke_ext_callback()

void netif_invoke_ext_callback | ( | struct netif * | netif,
|  | netif_nsc_reason_t | reason,
|  | const netif_ext_callback_args_t * | args
| ) |  |

Invoke extended netif status event

Parameters

  netif | netif that is affected by change
  reason | change reason
  args | depends on reason, see reason description

## ◆ netif_poll()

void netif_poll | ( | struct netif * | netif | ) |

Call netif_poll() in the main loop of your application. This is to prevent reentering non-reentrant functions like tcp_input(). Packets passed to netif_loop_output() are put on a list that is passed to netif->input() by netif_poll().

## Variable Documentation

## ◆ netif_default

struct netif* netif_default

The default network interface.

## ◆ netif_list

struct netif* netif_list

The list of network interfaces.