lwIP 2.1.3 Lightweight IP stack

Modules | Data Structures | Macros | Typedefs | Functions
Network interface (NETIF)
APIs » "raw" APIs

## Modules
| IPv4 address handling
| IPv6 address handling
| Client data handling
| Flags
| MIB2 statistics

## Data Structures
union | netif_ext_callback_args_t

## Macros
#define | netif_is_up(netif) (((netif)->flags & NETIF_FLAG_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)

## Typedefs
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)

## 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, 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_remove (struct netif *netif)
void | netif_set_default (struct netif *netif)
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)
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)
struct netif * | netif_find (const char *name)
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)

## Detailed Description

## Macro Definition Documentation

## ◆ netif_get_hostname

#define netif_get_hostname | ( |  | netif | ) | (((netif) != NULL) ? ((netif)->hostname) : NULL)

## ◆ netif_is_up

#define netif_is_up | ( |  | netif | ) | (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)

Ask if an interface is up

## ◆ netif_set_hostname

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

## ◆ netif_set_igmp_mac_filter

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

## ◆ netif_set_mld_mac_filter

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

## Typedef Documentation

## ◆ 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)

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

Parameters

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

## ◆ netif_nsc_reason_t

typedef u16_t netif_nsc_reason_t

Extended netif status callback (NSC) reasons flags. May be extended in the future!

## Function Documentation

## ◆ netif_add()

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

Add a network interface to the list of lwIP netifs.

Parameters

  netif | a pre-allocated netif structure
  ipaddr | IP address for the new netif
  netmask | network mask for the new netif
  gw | default gateway IP address for the new netif
  state | opaque data passed to the new netif
  init | callback function that initializes the interface
  input | callback function that is called to pass ingress packets up in the protocol layer stack. It is recommended to use a function that passes the input directly to the stack (netif_input(), NO_SYS=1 mode) or via sending a message to TCPIP thread (tcpip_input(), NO_SYS=0 mode). These functions use netif flags NETIF_FLAG_ETHARP and NETIF_FLAG_ETHERNET to decide whether to forward to ethernet_input() or ip_input(). In other words, the functions only work when the netif driver is implemented correctly! Most members of struct netif should be be initialized by the netif init function = netif driver (init parameter of this function). IPv6: Don't forget to call netif_create_ip6_linklocal_address() after setting the MAC address in struct netif.hwaddr (IPv6 requires a link-local address).

Returns
  netif, or NULL if failed.

## ◆ netif_add_ext_callback()

void netif_add_ext_callback | ( | netif_ext_callback_t * | callback,
|  | netif_ext_callback_fn | fn
| ) |  |

Add extended netif events listener

Parameters

  callback | pointer to listener structure
  fn | callback function

## ◆ netif_add_noaddr()

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

Add a network interface to the list of lwIP netifs.

Same as netif_add but without IPv4 addresses

## ◆ netif_find()

struct netif* netif_find | ( | const char * | name | ) |

Find a network interface by searching for its name

Parameters

  name | the name of the netif (like netif->name) plus concatenated number in ascii representation (e.g. 'en0')

## ◆ netif_get_by_index()

struct netif* netif_get_by_index | ( | u8_t | idx | ) |

Return the interface for the netif index

Parameters

  idx | index of netif to find

## ◆ netif_index_to_name()

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

Return the interface name for the netif matching index or NULL if not found/on error

Parameters

  idx | the interface index of the netif
  name | char buffer of at least NETIF_NAMESIZE bytes

## ◆ netif_loop_output()

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

Send an IP packet to be received on the same netif (loopif-like). The pbuf is copied and added to an internal queue which is fed to netif->input by netif_poll(). In multithreaded mode, the call to netif_poll() is queued to be done on the TCP/IP thread. In callback mode, the user has the responsibility to call netif_poll() in the main loop of their application.

Parameters

  netif | the lwip network interface structure
  p | the (IP) packet to 'send'

Returns
  ERR_OK if the packet has been sent ERR_MEM if the pbuf used to copy the packet couldn't be allocated

## ◆ netif_name_to_index()

u8_t netif_name_to_index | ( | const char * | name | ) |

Return the interface index for the netif with name or NETIF_NO_INDEX if not found/on error

Parameters

  name | the name of the netif

## ◆ netif_remove()

void netif_remove | ( | struct netif * | netif | ) |

Remove a network interface from the list of lwIP netifs.

Parameters

  netif | the network interface to remove

## ◆ netif_remove_ext_callback()

void netif_remove_ext_callback | ( | netif_ext_callback_t * | callback | ) |

Remove extended netif events listener

Parameters

  callback | pointer to listener structure

## ◆ netif_set_default()

void netif_set_default | ( | struct netif * | netif | ) |

Set a network interface as the default network interface (used to output all packets for which no specific route is found)

Parameters

  netif | the default network interface

## ◆ netif_set_down()

void netif_set_down | ( | struct netif * | netif | ) |

Bring an interface down, disabling any traffic processing.

## ◆ netif_set_link_callback()

void netif_set_link_callback | ( | struct netif * | netif,
|  | netif_status_callback_fn | link_callback
| ) |  |

Set callback to be called when link is brought up/down

## ◆ netif_set_link_down()

void netif_set_link_down | ( | struct netif * | netif | ) |

Called by a driver when its link goes down

## ◆ netif_set_link_up()

void netif_set_link_up | ( | struct netif * | netif | ) |

Called by a driver when its link goes up

## ◆ netif_set_remove_callback()

void netif_set_remove_callback | ( | struct netif * | netif,
|  | netif_status_callback_fn | remove_callback
| ) |  |

Set callback to be called when the interface has been removed

## ◆ netif_set_status_callback()

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

Set callback to be called when interface is brought up/down or address is changed while up

## ◆ netif_set_up()

void netif_set_up | ( | struct netif * | netif | ) |

Bring an interface up, available for processing traffic.