lwIP 2.0.0  lwIP 2.0.0
LightweightIPstack
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_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_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, u8_t action)
 
typedef err_t(* netif_mld_mac_filter_fn) (struct netif *netif, const ip6_addr_t *group, u8_t action)
 

Functions

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

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

Ask if a link is up

#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

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

Function prototype for netif igmp_mac_filter functions

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
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
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)
typedef err_t(* netif_mld_mac_filter_fn) (struct netif *netif, const ip6_addr_t *group, u8_t action)

Function prototype for netif mld_mac_filter functions

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
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
typedef void(* netif_status_callback_fn) (struct netif *netif)

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

Function Documentation

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

struct netif* netif_default

The default network interface.

struct netif* netif_list

The list of network interfaces.