lwIP  2.0.2
Lightweight IP stack
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
 

Macros

#define NETIF_MAX_HWADDR_LEN   6U
 
#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])))
 

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)
 

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

Variables

struct netifnetif_list
 
struct netifnetif_default
 

Detailed Description

netif API (to be used from TCPIP thread)

Macro Definition Documentation

◆ 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.

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
netifThe 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
pThe received packet, copied into a pbuf
inpThe netif which received the packet

◆ 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
netifThe netif which shall send a packet
pThe 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
netifThe netif which shall send a packet
pThe packet to send (p->payload points to IP header)
ipaddrThe 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
netifThe netif which shall send a packet
pThe packet to send (p->payload points to IP header)
ipaddrThe 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

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 address is assigned to the netif and returns its index.

Parameters
netifthe netif to check
ip6addrthe IPv6 address to find
Returns
>= 0: address found, this is its index -1: address not found on this netif

◆ 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.