Atmel Software Framework

lwip-1.3.2/src/core/netif.c File Reference

lwIP network interface abstraction

#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/tcp.h"
#include "lwip/snmp.h"
#include "lwip/igmp.h"
#include "netif/etharp.h"

Macros

#define NETIF_LINK_CALLBACK(n)   { /* NOP */ }
 
#define NETIF_STATUS_CALLBACK(n)   { /* NOP */ }
 

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. More...
 
struct netifnetif_find (char *name)
 Find a network interface by searching for its name. More...
 
u8_t netif_is_up (struct netif *netif)
 Ask if an interface is up. More...
 
void netif_remove (struct netif *netif)
 Remove a network interface from the list of lwIP netifs. More...
 
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). More...
 
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) More...
 
void netif_set_down (struct netif *netif)
 Bring an interface down, disabling any traffic processing. More...
 
void netif_set_gw (struct netif *netif, struct ip_addr *gw)
 Change the default gateway for a network interface. More...
 
void netif_set_ipaddr (struct netif *netif, struct ip_addr *ipaddr)
 Change the IP address of a network interface. More...
 
void netif_set_netmask (struct netif *netif, struct ip_addr *netmask)
 Change the netmask of a network interface. More...
 
void netif_set_up (struct netif *netif)
 Bring an interface up, available for processing traffic. More...
 

Variables

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

#define NETIF_LINK_CALLBACK (   n)    { /* NOP */ }

Referenced by netif_set_down(), and netif_set_up().

#define NETIF_STATUS_CALLBACK (   n)    { /* NOP */ }

Referenced by netif_set_down(), and netif_set_up().

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 
)

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.

References ERR_OK, netif::flags, netif::gw, init, input, netif::input, netif::ip_addr, LWIP_DEBUGF, netif::name, NETIF_DEBUG, NETIF_FLAG_IGMP, netif_list, netif_set_addr(), netif::netmask, netif::next, NULL, netif::num, snmp_inc_iflist, state, and netif::state.

struct netif* netif_find ( char *  name)

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

References LWIP_DEBUGF, netif::name, NETIF_DEBUG, netif::next, NULL, num, and netif::num.

u8_t netif_is_up ( struct netif netif)

Ask if an interface is up.

References netif::flags, and NETIF_FLAG_UP.

void netif_remove ( struct netif netif)

Remove a network interface from the list of lwIP netifs.

Parameters
netifthe network interface to remove

References netif::flags, LWIP_DEBUGF, NETIF_DEBUG, NETIF_FLAG_IGMP, netif_set_default(), netif::next, NULL, snmp_dec_iflist, and snmp_delete_ipaddridx_tree.

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

References netif_set_gw(), netif_set_ipaddr(), and netif_set_netmask().

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

References LWIP_DEBUGF, netif::name, NETIF_DEBUG, NULL, snmp_delete_iprteidx_tree, and snmp_insert_iprteidx_tree.

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

References netif::flags, NETIF_FLAG_UP, NETIF_LINK_CALLBACK, NETIF_STATUS_CALLBACK, and snmp_get_sysuptime.

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

References netif::gw, LWIP_DBG_STATE, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_DEBUG, and U16_F.

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

References netif::ip_addr, LWIP_DBG_STATE, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_DEBUG, NULL, pcb, snmp_delete_ipaddridx_tree, snmp_delete_iprteidx_tree, snmp_insert_ipaddridx_tree, snmp_insert_iprteidx_tree, and U16_F.

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

References LWIP_DBG_STATE, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_DEBUG, netif::netmask, snmp_delete_iprteidx_tree, snmp_insert_iprteidx_tree, and U16_F.

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

References netif::flags, NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, NETIF_FLAG_UP, NETIF_LINK_CALLBACK, NETIF_STATUS_CALLBACK, and snmp_get_sysuptime.

struct netif* netif_default

The default network interface.

struct netif* netif_list

The list of network interfaces.