Documentation

Documentation

Includes

lwip/opt.h

#include "lwip/opt.h"
#include "lwip/opt.h"

lwip/err.h

#include "lwip/err.h"
#include "lwip/err.h"

lwip/ip_addr.h

#include "lwip/ip_addr.h"
#include "lwip/ip_addr.h"

lwip/def.h

#include "lwip/def.h"
#include "lwip/def.h"

lwip/pbuf.h

#include "lwip/pbuf.h"
#include "lwip/pbuf.h"

lwip/stats.h

#include "lwip/stats.h"
#include "lwip/stats.h"

Macros

Marco LWIP_HDR_NETIF_H

#define LWIP_HDR_NETIF_H


      

Marco ENABLE_LOOPBACK

#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)


      

Marco NETIF_MAX_HWADDR_LEN

#define NETIF_MAX_HWADDR_LEN 6U


      

Marco 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
 */

Marco NETIF_FLAG_UP

#define NETIF_FLAG_UP          0x01U
/** Whether the network interface is 'up'. This is
 * a software flag used to control whether this network
 * interface is enabled and processes traffic.
 * It must be set by the startup code before this netif can be used
 * (also for dhcp/autoip).
 */

Marco NETIF_FLAG_BROADCAST

#define NETIF_FLAG_BROADCAST   0x02U
/** If set, the netif has broadcast capability.
 * Set by the netif driver in its init function. */
#define NETIF_FLAG_LINK_UP     0x04U
/** If set, the interface has an active link
 *  (set by the network interface driver).
 * Either set by the netif driver in its init function (if the link
 * is up at that time) or at a later point once the link comes up
 * (if link detection is supported by the hardware). */

Marco NETIF_FLAG_ETHARP

#define NETIF_FLAG_ETHARP      0x08U
/** If set, the netif is an ethernet device using ARP.
 * Set by the netif driver in its init function.
 * Used to check input packet types and use of DHCP. */

Marco NETIF_FLAG_ETHERNET

#define NETIF_FLAG_ETHERNET    0x10U
/** If set, the netif is an ethernet device. It might not use
 * ARP or TCP/IP if it is used for PPPoE only.
 */

Marco NETIF_FLAG_IGMP

#define NETIF_FLAG_IGMP        0x20U
/** If set, the netif has IGMP capability.
 * Set by the netif driver in its init function. */

Marco NETIF_FLAG_MLD6

#define NETIF_FLAG_MLD6        0x40U
/** If set, the netif has MLD6 capability.
 * Set by the netif driver in its init function. */

Marco NETIF_CHECKSUM_GEN_IP

#define NETIF_CHECKSUM_GEN_IP      1


      

Marco NETIF_CHECKSUM_GEN_UDP

#define NETIF_CHECKSUM_GEN_UDP     2


      

Marco NETIF_CHECKSUM_GEN_TCP

#define NETIF_CHECKSUM_GEN_TCP     4


      

Marco NETIF_CHECKSUM_GEN_ICMP

#define NETIF_CHECKSUM_GEN_ICMP    8


      

Marco NETIF_CHECKSUM_GEN_ICMP6

#define NETIF_CHECKSUM_GEN_ICMP6   16


      

Marco NETIF_CHECKSUM_CHECK_IP

#define NETIF_CHECKSUM_CHECK_IP    256


      

Marco NETIF_CHECKSUM_CHECK_UDP

#define NETIF_CHECKSUM_CHECK_UDP   512


      

Marco NETIF_CHECKSUM_CHECK_TCP

#define NETIF_CHECKSUM_CHECK_TCP   1024


      

Marco NETIF_CHECKSUM_CHECK_ICMP

#define NETIF_CHECKSUM_CHECK_ICMP  2048


      

Marco NETIF_CHECKSUM_CHECK_ICMP6

#define NETIF_CHECKSUM_CHECK_ICMP6 4096


      

Marco NETIF_CHECKSUM_ENABLE_ALL

#define NETIF_CHECKSUM_ENABLE_ALL  65535


      

Marco NETIF_CHECKSUM_DISABLE_ALL

#define NETIF_CHECKSUM_DISABLE_ALL 0


      

Marco netif_set_client_data(netif, id, data)

#define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
/** @ingroup netif_cd
 * Set client data. Obtain ID from netif_alloc_client_data_id().
 */

Marco netif_get_client_data(netif, id)

#define netif_get_client_data(netif, id)      (netif)->client_data[(id)]
/** @ingroup netif_cd
 * Get client data. Obtain ID from netif_alloc_client_data_id().
 */

Marco LWIP_NETIF_USE_HINTS

#define LWIP_NETIF_USE_HINTS             1


      

Marco LWIP_NETIF_USE_HINTS

#define LWIP_NETIF_USE_HINTS             0


      

Marco NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)

#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \
 (netif)->chksum_flags = chksumflags; } while(0)


      

Marco IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)

#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0))


      

Marco NETIF_SET_CHECKSUM_CTRL

#define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)


      

Marco IF__NETIF_CHECKSUM_ENABLED

#define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)


      

Marco NETIF_FOREACH(netif)

#define NETIF_FOREACH(netif) if (((netif) = netif_default) != NULL)


      

Marco NETIF_FOREACH(netif)

#define NETIF_FOREACH(netif) for ((netif) = netif_list; (netif) != NULL; (netif) = (netif)->next)


      

Marco netif_ip4_addr(netif)

#define netif_ip4_addr(netif)   ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
/** @ingroup netif_ip4 */

Marco netif_ip4_netmask(netif)

#define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
/** @ingroup netif_ip4 */

Marco netif_ip4_gw(netif)

#define netif_ip4_gw(netif)     ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
/** @ingroup netif_ip4 */

Marco netif_ip_addr4(netif)

#define netif_ip_addr4(netif)   ((const ip_addr_t*)&((netif)->ip_addr))
/** @ingroup netif_ip4 */

Marco netif_ip_netmask4(netif)

#define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask))
/** @ingroup netif_ip4 */

Marco netif_ip_gw4(netif)

#define netif_ip_gw4(netif)     ((const ip_addr_t*)&((netif)->gw))
/** @ingroup netif_ip4 */

Marco netif_set_flags(netif, set_flags)

#define netif_set_flags(netif, set_flags)    do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0)


      

Marco netif_clear_flags(netif, clr_flags)

#define netif_clear_flags(netif, clr_flags)  do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 255)); } while(0)


      

Marco netif_is_flag_set(nefif, flag)

#define netif_is_flag_set(nefif, flag)       (((netif)->flags & (flag)) != 0)


      

Marco netif_is_up(netif)

#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
/** @ingroup netif
 * Ask if an interface is 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 */

Marco netif_set_hostname(netif, name)

#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
/** @ingroup netif */

Marco netif_get_hostname(netif)

#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
/** @ingroup netif */

Marco netif_set_igmp_mac_filter(netif, function)

#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
/** @ingroup netif */

Marco netif_get_igmp_mac_filter(netif)

#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)


      

Marco netif_set_mld_mac_filter(netif, function)

#define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0)
/** @ingroup netif */

Marco netif_get_mld_mac_filter(netif)

#define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL)


      

Marco netif_mld_mac_filter(netif, addr, action)

#define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0)


      

Marco netif_ip_addr6(netif, i)

#define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
/** @ingroup netif_ip6 */

Marco netif_ip6_addr(netif, i)

#define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i])))
/** @ingroup netif_ip6 */

Marco netif_ip6_addr_state(netif, i)

#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i])


      

Marco netif_set_ip6_autoconfig_enabled(netif, action)

#define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0)


      

Marco netif_ip6_addr_valid_life(netif, i)

#define netif_ip6_addr_valid_life(netif, i) \
   (((netif) != NULL) ? ((netif)->ip6_addr_valid_life[i]) : IP6_ADDR_LIFE_STATIC)


      

Marco netif_ip6_addr_set_valid_life(netif, i, secs)

#define netif_ip6_addr_set_valid_life(netif, i, secs) \
   do { if (netif != NULL) { (netif)->ip6_addr_valid_life[i] = (secs); }} while (0)


      

Marco netif_ip6_addr_pref_life(netif, i)

#define netif_ip6_addr_pref_life(netif, i) \
   (((netif) != NULL) ? ((netif)->ip6_addr_pref_life[i]) : IP6_ADDR_LIFE_STATIC)


      

Marco netif_ip6_addr_set_pref_life(netif, i, secs)

#define netif_ip6_addr_set_pref_life(netif, i, secs) \
   do { if (netif != NULL) { (netif)->ip6_addr_pref_life[i] = (secs); }} while (0)


      

Marco netif_ip6_addr_isstatic(netif, i)

#define netif_ip6_addr_isstatic(netif, i) \
   (netif_ip6_addr_valid_life((netif), (i)) == IP6_ADDR_LIFE_STATIC)


      

Marco netif_ip6_addr_isstatic(netif, i)

#define netif_ip6_addr_isstatic(netif, i) (1) /* all addresses are static */


      

Marco netif_mtu6(netif)

#define netif_mtu6(netif) ((netif)->mtu6)


      

Marco netif_mtu6(netif)

#define netif_mtu6(netif) ((netif)->mtu)


      

Marco NETIF_SET_HINTS(netif, netifhint)

#define NETIF_SET_HINTS(netif, netifhint) (netif)->hints = (netifhint)


      

Marco NETIF_RESET_HINTS(netif)

#define NETIF_RESET_HINTS(netif)     (netif)->hints = NULL


      

Marco NETIF_SET_HINTS

#define NETIF_SET_HINTS(netif, netifhint)


      

Marco NETIF_RESET_HINTS

#define NETIF_RESET_HINTS(netif)


      

Marco netif_get_index(netif)

#define netif_get_index(netif)     ((u8_t)((netif)->num + 1))
/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 (internal index is 0..254)*/

Marco NETIF_NO_INDEX

#define NETIF_NO_INDEX             (0)


      

Marco LWIP_NSC_NONE

#define LWIP_NSC_NONE                    0
/* used for initialization only */

Marco LWIP_NSC_NETIF_ADDED

#define LWIP_NSC_NETIF_ADDED             1
/** netif was added. arg: NULL. Called AFTER netif was added. */

Marco LWIP_NSC_NETIF_REMOVED

#define LWIP_NSC_NETIF_REMOVED           2
/** netif was removed. arg: NULL. Called BEFORE netif is removed. */
#define LWIP_NSC_LINK_CHANGED            4
/** link changed */

Marco LWIP_NSC_STATUS_CHANGED

#define LWIP_NSC_STATUS_CHANGED          8
/** netif administrative status changed.\n
  * up is called AFTER netif is set up.\n
  * down is called BEFORE the netif is actually set down. */

Marco LWIP_NSC_IPV4_ADDRESS_CHANGED

#define LWIP_NSC_IPV4_ADDRESS_CHANGED    16
/** IPv4 address has changed */

Marco LWIP_NSC_IPV4_GATEWAY_CHANGED

#define LWIP_NSC_IPV4_GATEWAY_CHANGED    32
/** IPv4 gateway has changed */

Marco LWIP_NSC_IPV4_NETMASK_CHANGED

#define LWIP_NSC_IPV4_NETMASK_CHANGED    64
/** IPv4 netmask has changed */

Marco LWIP_NSC_IPV4_SETTINGS_CHANGED

#define LWIP_NSC_IPV4_SETTINGS_CHANGED   128
/** called AFTER IPv4 address/gateway/netmask changes have been applied */

Marco LWIP_NSC_IPV6_SET

#define LWIP_NSC_IPV6_SET                256
/** IPv6 address was added */

Marco LWIP_NSC_IPV6_ADDR_STATE_CHANGED

#define LWIP_NSC_IPV6_ADDR_STATE_CHANGED 512
/** IPv6 address state has changed */

Marco NETIF_DECLARE_EXT_CALLBACK(name)

#define NETIF_DECLARE_EXT_CALLBACK(name) static netif_ext_callback_t name;


      

Marco NETIF_DECLARE_EXT_CALLBACK

#define NETIF_DECLARE_EXT_CALLBACK(name)


      

Marco netif_add_ext_callback

#define netif_add_ext_callback(callback, fn)


      

Marco netif_remove_ext_callback

#define netif_remove_ext_callback(callback)


      

Marco netif_invoke_ext_callback

#define netif_invoke_ext_callback(netif, reason, args)

      

Functions

Func netif_alloc_client_data_id

u8_t netif_alloc_client_data_id(void);


      

Func netif_init

void netif_init(void);


      

Func netif_set_addr

void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask,
                   const ip4_addr_t *gw);


      

Func netif_remove

void netif_remove(struct netif * netif);


      

Func netif_set_default

void netif_set_default(struct netif *netif);


      

Func netif_set_ipaddr

void netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr);


      

Func netif_set_netmask

void netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask);


      

Func netif_set_gw

void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);


      

Func netif_set_up

void netif_set_up(struct netif *netif);


      

Func netif_set_down

void netif_set_down(struct netif *netif);


      

Func netif_set_status_callback

void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback);


      

Func netif_set_remove_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);


      

Func netif_loop_output

err_t netif_loop_output(struct netif *netif, struct pbuf *p);


      

Func netif_poll

void netif_poll(struct netif *netif);


      

Func netif_poll_all

void netif_poll_all(void);


      

Func netif_input

err_t netif_input(struct pbuf *p, struct netif *inp);


      

Func netif_ip6_addr_set

void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, const ip6_addr_t *addr6);


      

Func netif_ip6_addr_set_parts

void netif_ip6_addr_set_parts(struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3);


      

Func netif_ip6_addr_set_state

void netif_ip6_addr_set_state(struct netif* netif, s8_t addr_idx, u8_t state);


      

Func netif_get_ip6_addr_match

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


      

Func netif_create_ip6_linklocal_address

void netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit);


      

Func netif_add_ip6_address

err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx);


      

Func netif_name_to_index

u8_t netif_name_to_index(const char *name);


      

Func netif_add_ext_callback

void netif_add_ext_callback(netif_ext_callback_t* callback, netif_ext_callback_fn fn);


      

Func netif_remove_ext_callback

void netif_remove_ext_callback(netif_ext_callback_t* callback);


      

Func netif_invoke_ext_callback

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

      

Vars

Variable netif

struct netif;


      

Variable netif

struct netif *netif_add_noaddr(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input);


      

Variable netif

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


      

Variable netif

struct netif *netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input);


      

Variable netif

struct netif *netif_find(const char *name);
/* Returns a network interface given its name. The name is of the form
   "et0", where the first two letters are the "name" field in the
   netif structure, and the digit is in the num field in the same
   structure. */

Variable char

char * netif_index_to_name(u8_t idx, char *name);


      

Variable netif

struct netif* netif_get_by_index(u8_t idx);


      

Variable netif_ext_callback

struct netif_ext_callback;

      

Consts

Types

Typedefs

Typedef 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.
 *
 * @param netif The netif to initialize
 */

Typedef 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.
 *
 * @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 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'.
 *
 * @param netif The netif which shall send a packet
 * @param p The packet to send (p->payload points to IP header)
 * @param ipaddr The IP address to which the packet shall be sent
 */

Typedef 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'.
 *
 * @param netif The netif which shall send a packet
 * @param p The packet to send (p->payload points to IP header)
 * @param ipaddr The IPv6 address to which the packet shall be sent
 */

Typedef 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.
 *
 * @param netif The netif which shall send a packet
 * @param p The packet to send (raw ethernet packet)
 */

Typedef netif_status_callback_fn

typedef void (*netif_status_callback_fn)(struct netif *netif);
#if LWIP_IPV4 && LWIP_IGMP
/** Function prototype for netif igmp_mac_filter functions */
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 status- or link-callback functions. */

Typedef 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 */

Typedef netif_addr_idx_t

typedef u16_t netif_addr_idx_t;
#define NETIF_ADDR_IDX_MAX 32767
#else
typedef u8_t netif_addr_idx_t;
#define NETIF_ADDR_IDX_MAX 127


      

Typedef netif_nsc_reason_t

typedef u16_t netif_nsc_reason_t;
/**
 * @ingroup netif
 * Extended netif status callback (NSC) reasons flags.
 * May be extended in the future!
 */
typedef union
{
 /** Args to LWIP_NSC_LINK_CHANGED callback */
 struct link_changed_s
 {
   /** 1: up; 0: down */
   u8_t state;
 } link_changed;
/** @ingroup netif
 * Argument supplied to netif_ext_callback_fn.
 */

Typedef netif_ext_callback_fn

typedef void (*netif_ext_callback_fn)(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args);
/**
 * @ingroup netif
 * 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
 */

Typedef netif_ext_callback_t;

typedef struct netif_ext_callback
{
 netif_ext_callback_fn callback_fn;
 struct netif_ext_callback* next;
} netif_ext_callback_t;