A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Embed: (wiki syntax)

« Back to documentation index

netif.c File Reference

netif.c File Reference

lwIP network interface abstraction More...

Go to the source code of this file.

Functions

struct netifnetif_add (struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw, void *state, err_t(*init)(struct netif *netif), err_t(*input)(struct pbuf *p, struct netif *netif))
 Add a network interface to the list of lwIP netifs.
void netif_set_addr (struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *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 (char *name)
 Find a network interface by searching for its name.
void netif_set_ipaddr (struct netif *netif, struct ip_addr *ipaddr)
 Change the IP address of a network interface.
void netif_set_gw (struct netif *netif, struct ip_addr *gw)
 Change the default gateway for a network interface.
void netif_set_netmask (struct netif *netif, struct ip_addr *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.
u8_t netif_is_up (struct netif *netif)
 Ask if an interface is up.
void netif_set_status_callback (struct netif *netif, void(*status_callback)(struct netif *netif))
 Set callback to be called when interface is brought up/down.
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.
u8_t netif_is_link_up (struct netif *netif)
 Ask if a link is up.
void netif_set_link_callback (struct netif *netif, void(*link_callback)(struct netif *netif))
 Set callback to be called when link is brought up/down.
err_t netif_loop_output (struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
 Send an IP packet to be received on the same netif (loopif-like).
void netif_poll (struct netif *netif)
 Call netif_poll() in the main loop of your application.
void netif_poll_all (void)
 Calls netif_poll() for every netif on the netif_list.

Variables

struct netifnetif_list
 The list of network interfaces.
struct netifnetif_default
 The default network interface.

Detailed Description

lwIP network interface abstraction

Definition in file tag/13/Core/lwIP/core/netif.c.


Function Documentation

struct netif* netif_add ( struct netif netif,
struct ip_addr *  ipaddr,
struct ip_addr *  netmask,
struct ip_addr *  gw,
void *  state,
err_t(*)(struct netif *netif init,
err_t(*)(struct pbuf *p, struct netif *netif 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.
Returns:
netif, or NULL if failed.

Definition at line 85 of file tag/13/Core/lwIP/core/netif.c.

struct netif* netif_find ( 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 229 of file tag/13/Core/lwIP/core/netif.c.

u8_t netif_is_link_up ( struct netif netif )

Ask if a link is up.

Definition at line 499 of file tag/13/Core/lwIP/core/netif.c.

u8_t netif_is_up ( struct netif netif )

Ask if an interface is up.

Definition at line 442 of file tag/13/Core/lwIP/core/netif.c.

err_t netif_loop_output ( struct netif netif,
struct pbuf *  p,
struct ip_addr *  ipaddr 
)

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'
ipaddrthe ip address to send the packet to (not used)
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 531 of file tag/13/Core/lwIP/core/netif.c.

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

Definition at line 599 of file tag/13/Core/lwIP/core/netif.c.

void netif_poll_all ( void   )

Calls netif_poll() for every netif on the netif_list.

Definition at line 652 of file tag/13/Core/lwIP/core/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 184 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_addr ( struct netif netif,
struct ip_addr *  ipaddr,
struct ip_addr *  netmask,
struct ip_addr *  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 171 of file tag/13/Core/lwIP/core/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 365 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_down ( struct netif netif )

Bring an interface down, disabling any traffic processing.

Note:
: Enabling DHCP on a down interface will make it come up once configured.
See also:
dhcp_start()

Definition at line 425 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_gw ( struct netif netif,
struct ip_addr *  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 323 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_ipaddr ( struct netif netif,
struct ip_addr *  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 262 of file tag/13/Core/lwIP/core/netif.c.

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

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

Definition at line 507 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_link_down ( struct netif netif )

Called by a driver when its link goes down.

Definition at line 490 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_link_up ( struct netif netif )

Called by a driver when its link goes up.

For Ethernet network interfaces, we would like to send a "gratuitous ARP"; this is an ARP packet sent by a node in order to spontaneously cause other nodes to update an entry in their ARP cache. From RFC 3220 "IP Mobility Support for IPv4" section 4.6.

Definition at line 462 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_netmask ( struct netif netif,
struct ip_addr *  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 344 of file tag/13/Core/lwIP/core/netif.c.

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

Set callback to be called when interface is brought up/down.

Definition at line 451 of file tag/13/Core/lwIP/core/netif.c.

void netif_set_up ( struct netif netif )

Bring an interface up, available for processing traffic.

Note:
: Enabling DHCP on a down interface will make it come up once configured.
See also:
dhcp_start()

For Ethernet network interfaces, we would like to send a "gratuitous ARP"; this is an ARP packet sent by a node in order to spontaneously cause other nodes to update an entry in their ARP cache. From RFC 3220 "IP Mobility Support for IPv4" section 4.6.

Definition at line 391 of file tag/13/Core/lwIP/core/netif.c.


Variable Documentation

The default network interface.

Definition at line 68 of file tag/13/Core/lwIP/core/netif.c.

struct netif* netif_list

The list of network interfaces.

Definition at line 67 of file tag/13/Core/lwIP/core/netif.c.