lwIP network interface abstraction
#include "lwip/opt.h"
#include "lwip/def.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/tcp_impl.h"
#include "lwip/snmp.h"
#include "lwip/igmp.h"
#include "netif/etharp.h"
#include "lwip/stats.h"
Macros | |
#define | NETIF_LINK_CALLBACK(n) |
#define | NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) |
Functions | |
struct netif * | netif_add (struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) |
Add a network interface to the list of lwIP netifs. More... | |
struct netif * | netif_find (char *name) |
Find a network interface by searching for its name. More... | |
void | netif_init (void) |
void | netif_remove (struct netif *netif) |
Remove a network interface from the list of lwIP netifs. More... | |
void | netif_set_addr (struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *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, ip_addr_t *gw) |
Change the default gateway for a network interface. More... | |
void | netif_set_ipaddr (struct netif *netif, ip_addr_t *ipaddr) |
Change the IP address of a network interface. More... | |
void | netif_set_link_down (struct netif *netif) |
Called by a driver when its link goes down. More... | |
void | netif_set_link_up (struct netif *netif) |
Called by a driver when its link goes up. More... | |
void | netif_set_netmask (struct netif *netif, ip_addr_t *netmask) |
Change the netmask of a network interface. More... | |
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. More... | |
void | netif_set_up (struct netif *netif) |
Bring an interface up, available for processing traffic. More... | |
Variables | |
struct netif * | netif_default |
The default network interface. More... | |
struct netif * | netif_list |
The list of network interfaces. More... | |
static u8_t | netif_num |
#define NETIF_LINK_CALLBACK | ( | n | ) |
Referenced by netif_set_link_down(), and netif_set_link_up().
#define NETIF_STATUS_CALLBACK | ( | n | ) | do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) |
Referenced by netif_set_down(), and netif_set_up().
struct netif* netif_add | ( | struct netif * | netif, |
ip_addr_t * | ipaddr, | ||
ip_addr_t * | netmask, | ||
ip_addr_t * | gw, | ||
void * | state, | ||
netif_init_fn | init, | ||
netif_input_fn | input | ||
) |
Add a network interface to the list of lwIP netifs.
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. |
References ERR_OK, netif::flags, netif::gw, netif::input, netif::ip_addr, ip_addr_debug_print, ip_addr_set_zero, LWIP_ASSERT, LWIP_DEBUGF, netif::name, NETIF_DEBUG, NETIF_FLAG_IGMP, netif_list, netif_num, netif_set_addr(), NETIF_SET_HWADDRHINT, netif::netmask, netif::next, NULL, netif::num, snmp_inc_iflist, netif::state, and netif::status_callback.
Referenced by ethernet_configure_interface(), and netif_init().
struct netif* netif_find | ( | char * | name | ) |
Find a network interface by searching for its name.
name | the 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, and netif::num.
References IP4_ADDR, ip_input(), netif_add(), netif_set_up(), and NULL.
Referenced by lwip_init().
Remove a network interface from the list of lwIP netifs.
netif | the network interface to remove |
References netif::flags, LWIP_DEBUGF, NETIF_DEBUG, NETIF_FLAG_IGMP, netif_is_up, netif_set_default(), netif_set_down(), netif::next, NULL, snmp_dec_iflist, and snmp_delete_ipaddridx_tree.
void netif_set_addr | ( | struct netif * | netif, |
ip_addr_t * | ipaddr, | ||
ip_addr_t * | netmask, | ||
ip_addr_t * | gw | ||
) |
Change IP address configuration for a network interface (including netmask and default gateway).
netif | the network interface to change |
ipaddr | the new IP address |
netmask | the new netmask |
gw | the new default gateway |
References netif_set_gw(), netif_set_ipaddr(), and netif_set_netmask().
Referenced by netif_add().
Set a network interface as the default network interface (used to output all packets for which no specific route is found)
netif | the default network interface |
References LWIP_DEBUGF, netif::name, NETIF_DEBUG, NULL, snmp_delete_iprteidx_tree, and snmp_insert_iprteidx_tree.
Referenced by ethernet_configure_interface(), and netif_remove().
Bring an interface down, disabling any traffic processing.
References etharp_cleanup_netif(), netif::flags, NETIF_FLAG_ETHARP, NETIF_FLAG_UP, NETIF_STATUS_CALLBACK, and snmp_get_sysuptime.
Referenced by netif_remove().
Change the default gateway for a network interface.
netif | the network interface to change |
gw | the new default gateway |
References netif::gw, ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, ip_addr_set, LWIP_DBG_STATE, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_DEBUG, and U16_F.
Referenced by netif_set_addr().
Change the IP address of a network interface.
netif | the network interface to change |
ipaddr | the new IP address |
References ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, netif::ip_addr, ip_addr_cmp, ip_addr_isany, ip_addr_islinklocal, ip_addr_set, tcp_listen_pcbs_t::listen_pcbs, LWIP_DBG_STATE, LWIP_DBG_TRACE, LWIP_DEBUGF, netif::name, NETIF_DEBUG, next, NULL, snmp_delete_ipaddridx_tree, snmp_delete_iprteidx_tree, snmp_insert_ipaddridx_tree, snmp_insert_iprteidx_tree, tcp_abort(), tcp_active_pcbs, tcp_listen_pcbs, and U16_F.
Referenced by netif_set_addr().
Called by a driver when its link goes down.
References netif::flags, NETIF_FLAG_LINK_UP, and NETIF_LINK_CALLBACK.
Called by a driver when its link goes up.
References etharp_gratuitous, netif::flags, NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, NETIF_FLAG_LINK_UP, NETIF_FLAG_UP, and NETIF_LINK_CALLBACK.
Change the netmask of a network interface.
netif | the network interface to change |
netmask | the new netmask |
References ip4_addr1_16, ip4_addr2_16, ip4_addr3_16, ip4_addr4_16, ip_addr_set, 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.
Referenced by netif_set_addr().
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.
References netif::status_callback, and status_callback().
Referenced by ethernet_configure_interface().
Bring an interface up, available for processing traffic.
References etharp_gratuitous, netif::flags, NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, NETIF_FLAG_LINK_UP, NETIF_FLAG_UP, NETIF_STATUS_CALLBACK, and snmp_get_sysuptime.
Referenced by ethernet_configure_interface(), and netif_init().
struct netif* netif_default |
The default network interface.
Referenced by ip_route().
struct netif* netif_list |
The list of network interfaces.
Referenced by ip_input(), ip_route(), and netif_add().
|
static |
Referenced by netif_add().