Rizky Ardi Maulana / mbed-os
Embed: (wiki syntax)

« Back to documentation index

Network interface (NETIF)

Network interface (NETIF)
[Callback-style APIs]

Modules

 Flags
 MIB2 statistics

Functions

struct netifnetif_add (struct netif *netif,#if LWIP_IPV4 const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,#endifvoid *state, netif_init_fn init, netif_input_fn input)
 Add a network interface to the list of lwIP netifs.
void netif_set_addr (struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw)
 Change IP address configuration for a network interface (including netmask and default gateway).
void netif_remove (struct netif *netif)
 Remove a network interface from the list of lwIP netifs.
struct netifnetif_find (const char *name)
 Find a network interface by searching for its name.
void netif_set_ipaddr (struct netif *netif, const ip4_addr_t *ipaddr)
 Change the IP address of a network interface.
void netif_set_gw (struct netif *netif, const ip4_addr_t *gw)
 Change the default gateway for a network interface.
void netif_set_netmask (struct netif *netif, const ip4_addr_t *netmask)
 Change the netmask of a network interface.
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)
void netif_set_up (struct netif *netif)
 Bring an interface up, available for processing traffic.
void netif_set_down (struct netif *netif)
 Bring an interface down, disabling any traffic processing.
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.
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.
void netif_set_link_up (struct netif *netif)
 Called by a driver when its link goes up.
void netif_set_link_down (struct netif *netif)
 Called by a driver when its link goes down.
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.
err_t netif_loop_output (struct netif *netif, struct pbuf *p)
 Send an IP packet to be received on the same netif (loopif-like).
void netif_create_ip6_linklocal_address (struct netif *netif, u8_t from_mac_48bit)
 Create a link-local IPv6 address on a netif (stored in slot 0)
err_t netif_add_ip6_address (struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
 This function allows for the easy addition of a new IPv6 address to an interface.

Function Documentation

struct netif* netif_add ( struct netif netif,
#if LWIP_IPV4 const ip4_addr_t ipaddr,
const ip4_addr_t netmask,
const ip4_addr_t gw,
#endif void *  state,
netif_init_fn  init,
netif_input_fn  input 
) [read]

Add a network interface to the list of lwIP netifs.

Parameters:
netifa pre-allocated netif structure
ipaddrIP address for the new netif
netmasknetwork mask for the new netif
gwdefault gateway IP address for the new netif
stateopaque data passed to the new netif
initcallback function that initializes the interface
inputcallback 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!
Returns:
netif, or NULL if failed.

Definition at line 218 of file lwip_netif.c.

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

This function allows for the easy addition of a new IPv6 address to an interface.

It takes care of finding an empty slot and then sets the address tentative (to make sure that all the subsequent processing happens).

Parameters:
netifnetif to add the address on
ip6addraddress to add
chosen_idxif != NULL, the chosen IPv6 address index will be stored here

Definition at line 1111 of file lwip_netif.c.

void netif_create_ip6_linklocal_address ( struct netif netif,
u8_t  from_mac_48bit 
)

Create a link-local IPv6 address on a netif (stored in slot 0)

Parameters:
netifthe netif to create the address on
from_mac_48bitif != 0, assume hwadr is a 48-bit MAC address (std conversion) if == 0, use hwaddr directly as interface ID

Definition at line 1057 of file lwip_netif.c.

struct netif* netif_find ( const char *  name ) [read]

Find a network interface by searching for its name.

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

Definition at line 434 of file lwip_netif.c.

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 simply copied and handed back to netif->input. In multithreaded mode, this is done directly since netif->input must put the packet on a queue. In callback mode, the packet is put on an internal queue and is fed to netif->input by netif_poll().

Parameters:
netifthe lwip network interface structure
pthe (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

Definition at line 758 of file lwip_netif.c.

void netif_remove ( struct netif netif )

Remove a network interface from the list of lwIP netifs.

Parameters:
netifthe network interface to remove

Definition at line 363 of file lwip_netif.c.

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

Change IP address configuration for a network interface (including netmask and default gateway).

Parameters:
netifthe network interface to change
ipaddrthe new IP address
netmaskthe new netmask
gwthe new default gateway

Definition at line 338 of file lwip_netif.c.

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:
netifthe default network interface

Definition at line 560 of file lwip_netif.c.

void netif_set_down ( struct netif netif )

Bring an interface down, disabling any traffic processing.

Definition at line 638 of file lwip_netif.c.

void netif_set_gw ( struct netif netif,
const ip4_addr_t gw 
)

Change the default gateway for a network interface.

Parameters:
netifthe network interface to change
gwthe new default gateway
Note:
call netif_set_addr() if you also want to change ip address and netmask

Definition at line 513 of file lwip_netif.c.

void netif_set_ipaddr ( struct netif netif,
const ip4_addr_t ipaddr 
)

Change the IP address of a network interface.

Parameters:
netifthe network interface to change
ipaddrthe new IP address
Note:
call netif_set_addr() if you also want to change netmask and default gateway

Definition at line 469 of file lwip_netif.c.

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.

Definition at line 734 of file lwip_netif.c.

void netif_set_link_down ( struct netif netif )

Called by a driver when its link goes down.

Definition at line 720 of file lwip_netif.c.

void netif_set_link_up ( struct netif netif )

Called by a driver when its link goes up.

Definition at line 691 of file lwip_netif.c.

void netif_set_netmask ( struct netif netif,
const ip4_addr_t netmask 
)

Change the netmask of a network interface.

Parameters:
netifthe network interface to change
netmaskthe new netmask
Note:
call netif_set_addr() if you also want to change ip address and default gateway

Definition at line 536 of file lwip_netif.c.

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.

Definition at line 678 of file lwip_netif.c.

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.

Definition at line 664 of file lwip_netif.c.

void netif_set_up ( struct netif netif )

Bring an interface up, available for processing traffic.

Definition at line 580 of file lwip_netif.c.