#include "lwip/opt.h"
#include "lwip/err.h"
#include "lwip/ip_addr.h"
#include "lwip/ip6_addr.h"
#include "lwip/def.h"
#include "lwip/pbuf.h"
Data Structures | |
struct | netif |
Generic data structure used for all lwIP network interfaces. More... | |
Macros | |
#define | ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) |
#define | NETIF_FLAG_BROADCAST 0x02U |
If set, the netif has broadcast capability. More... | |
#define | NETIF_FLAG_DHCP 0x08U |
If set, the interface is configured using DHCP. More... | |
#define | NETIF_FLAG_ETHARP 0x20U |
If set, the netif is an ethernet device using ARP. More... | |
#define | NETIF_FLAG_ETHERNET 0x40U |
If set, the netif is an ethernet device. More... | |
#define | NETIF_FLAG_IGMP 0x80U |
If set, the netif has IGMP capability. More... | |
#define | NETIF_FLAG_LINK_UP 0x10U |
If set, the interface has an active link (set by the network interface driver). More... | |
#define | NETIF_FLAG_POINTTOPOINT 0x04U |
If set, the netif is one end of a point-to-point connection. More... | |
#define | NETIF_FLAG_UP 0x01U |
Whether the network interface is 'up'. More... | |
#define | NETIF_INIT_SNMP(netif, type, speed) |
#define | netif_ip6_addr(netif, i) (&((netif)->ip6_addr[(i)])) |
#define | netif_ip6_addr_set_state(netif, i, state) ((netif)->ip6_addr_state[(i)] = (state)) |
#define | netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[(i)]) |
#define | netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) |
Ask if a link is up. More... | |
#define | netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) |
Ask if an interface is up. More... | |
#define | NETIF_MAX_HWADDR_LEN 6U |
Must be the maximum of all used hardware address lengths across all types of interfaces in use. More... | |
#define | NETIF_SET_HWADDRHINT(netif, hint) |
Typedefs | |
typedef err_t(* | netif_igmp_mac_filter_fn )(struct netif *netif, ip_addr_t *group, u8_t action) |
Function prototype for netif igmp_mac_filter functions. More... | |
typedef err_t(* | netif_init_fn )(struct netif *netif) |
Function prototype for netif init functions. More... | |
typedef err_t(* | netif_input_fn )(struct pbuf *p, struct netif *inp) |
Function prototype for netif->input functions. More... | |
typedef err_t(* | netif_linkoutput_fn )(struct netif *netif, struct pbuf *p) |
Function prototype for netif->linkoutput functions. More... | |
typedef err_t(* | netif_mld_mac_filter_fn )(struct netif *netif, ip6_addr_t *group, u8_t action) |
Function prototype for netif mld_mac_filter functions. More... | |
typedef err_t(* | netif_output_fn )(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) |
Function prototype for netif->output functions. More... | |
typedef err_t(* | netif_output_ip6_fn )(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) |
Function prototype for netif->output_ip6 functions. More... | |
typedef void(* | netif_status_callback_fn )(struct netif *netif) |
Function prototype for netif status- or link-callback functions. More... | |
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... | |
void | netif_create_ip6_linklocal_address (struct netif *netif, u8_t from_mac_48bit) |
struct netif * | netif_find (char *name) |
Find a network interface by searching for its name. More... | |
s8_t | netif_get_ip6_addr_match (struct netif *netif, ip6_addr_t *ip6addr) |
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... | |
#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) |
#define NETIF_FLAG_BROADCAST 0x02U |
If set, the netif has broadcast capability.
Set by the netif driver in its init function.
Referenced by ip4_addr_isbroadcast(), and winc_netif_low_level_init().
#define NETIF_FLAG_DHCP 0x08U |
If set, the interface is configured using DHCP.
Set by the DHCP code when starting or stopping DHCP.
Referenced by dhcp_start(), and dhcp_stop().
#define NETIF_FLAG_ETHARP 0x20U |
If set, the netif is an ethernet device using ARP.
Set by the netif driver in its init function. Used to check input packet types and use of DHCP.
Referenced by dhcp_start(), ethernet_input(), netif_set_down(), netif_set_link_up(), netif_set_up(), tcpip_input(), tcpip_thread(), and winc_netif_low_level_init().
#define NETIF_FLAG_ETHERNET 0x40U |
If set, the netif is an ethernet device.
It might not use ARP or TCP/IP if it is used for PPPoE only.
Referenced by tcpip_input(), and tcpip_thread().
#define NETIF_FLAG_IGMP 0x80U |
If set, the netif has IGMP capability.
Set by the netif driver in its init function.
Referenced by ip_input(), netif_add(), netif_remove(), netif_set_link_up(), netif_set_up(), and winc_netif_low_level_init().
#define NETIF_FLAG_LINK_UP 0x10U |
If set, the interface has an active link (set by the network interface driver).
Either set by the netif driver in its init function (if the link is up at that time) or at a later point once the link comes up (if link detection is supported by the hardware).
Referenced by netif_set_link_down(), netif_set_link_up(), and netif_set_up().
#define NETIF_FLAG_POINTTOPOINT 0x04U |
If set, the netif is one end of a point-to-point connection.
Set by the netif driver in its init function.
#define NETIF_FLAG_UP 0x01U |
Whether the network interface is 'up'.
This is a software flag used to control whether this network interface is enabled and processes traffic. It is set by the startup code (for static IP configuration) or by dhcp/autoip when an address has been assigned.
Referenced by nd6_tmr(), netif_set_down(), netif_set_link_up(), and netif_set_up().
#define NETIF_INIT_SNMP | ( | netif, | |
type, | |||
speed | |||
) |
Referenced by winc_netif_init().
Referenced by nd6_input(), nd6_tmr(), and netif_add().
Ask if a link is up.
Referenced by dhcp_start().
Ask if an interface is up.
Referenced by autoip_start(), ip6_input(), ip_input(), ip_route(), netif_remove(), and status_callback().
#define NETIF_MAX_HWADDR_LEN 6U |
Must be the maximum of all used hardware address lengths across all types of interfaces in use.
This does not have to be changed, normally.
Referenced by dhcp_create_msg(), and dhcp_recv().
#define NETIF_SET_HWADDRHINT | ( | netif, | |
hint | |||
) |
Referenced by netif_add(), and raw_sendto().
Function prototype for netif igmp_mac_filter functions.
Function prototype for netif init functions.
Set up flags and output/linkoutput callback functions in this function.
netif | The netif to initialize |
Function prototype for netif->input functions.
This function is saved as 'input' callback function in the netif struct. Call it when a packet has been received.
p | The received packet, copied into a pbuf |
inp | The netif which received the packet |
Function prototype for netif->linkoutput functions.
Only used for ethernet netifs. This function is called by ARP when a packet shall be sent.
netif | The netif which shall send a packet |
p | The packet to send (raw ethernet packet) |
typedef err_t(* netif_mld_mac_filter_fn)(struct netif *netif, ip6_addr_t *group, u8_t action) |
Function prototype for netif mld_mac_filter functions.
Function prototype for netif->output functions.
Called by lwIP when a packet shall be sent. For ethernet netif, set this to 'etharp_output' and set 'linkoutput'.
netif | The netif which shall send a packet |
p | The packet to send (p->payload points to IP header) |
ipaddr | The IP address to which the packet shall be sent |
typedef err_t(* netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) |
Function prototype for netif->output_ip6 functions.
Called by lwIP when a packet shall be sent. For ethernet netif, set this to 'ethip6_output' and set 'linkoutput'.
netif | The netif which shall send a packet |
p | The packet to send (p->payload points to IP header) |
ipaddr | The IPv6 address to which the packet shall be sent |
Function prototype for netif status- or link-callback 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.
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 netif::autoip, netif::dhcp, ERR_OK, netif::flags, netif::gw, netif::input, netif::ip6_addr, IP6_ADDR_INVALID, ip6_addr_set_zero, netif::ip6_autoconfig_enabled, netif::ip_addr, ip_addr_debug_print, ip_addr_set_zero, LWIP_ASSERT, LWIP_DEBUGF, netif::mld_mac_filter, netif::name, NETIF_DEBUG, NETIF_FLAG_IGMP, netif_ip6_addr_set_state, netif_list, netif_null_output_ip6(), netif_num, netif_set_addr(), NETIF_SET_HWADDRHINT, netif::netmask, netif::next, NULL, netif::num, netif::output_ip6, netif::rs_count, snmp_inc_iflist, netif::state, and netif::status_callback.
Referenced by net_add_winc_netif(), and netif_init().
References htonl, netif::hwaddr, netif::hwaddr_len, netif::ip6_addr, IP6_ADDR_PREFERRED, netif::ip6_addr_state, IP6_ADDR_TENTATIVE, and PP_HTONL.
Referenced by net_add_winc_netif().
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.
s8_t netif_get_ip6_addr_match | ( | struct netif * | netif, |
ip6_addr_t * | ip6addr | ||
) |
References ip6_addr_cmp, and netif_ip6_addr.
Referenced by udp_input().
References IP4_ADDR, IP6_ADDR_VALID, ip_input(), netif_add(), netif_set_up(), NULL, PP_HTONL, and tcpip_input().
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, mld6_stop(), 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.
Referenced by net_remove_winc_netif().
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 net_add_winc_netif(), 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 autoip_network_changed(), autoip_start(), autoip_stop(), dhcp_handle_nak(), dhcp_network_changed(), dhcp_release(), net_interface_down_imp(), and 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 autoip_bind(), dhcp_bind(), dhcp_handle_nak(), dhcp_release(), and 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, ipX_2_ip, tcp_listen_pcbs_t::listen_pcbs, LWIP_AUTOIP, 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 autoip_bind(), dhcp_bind(), dhcp_handle_nak(), dhcp_release(), and netif_set_addr().
Called by a driver when its link goes down.
References netif::flags, NETIF_FLAG_LINK_UP, and NETIF_LINK_CALLBACK.
Referenced by net_interface_down_imp().
Called by a driver when its link goes up.
References netif::autoip, autoip_network_changed(), netif::dhcp, dhcp_network_changed(), etharp_gratuitous, netif::flags, mld6_report_groups(), NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, NETIF_FLAG_LINK_UP, NETIF_FLAG_UP, and NETIF_LINK_CALLBACK.
Referenced by net_interface_up_imp().
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 autoip_bind(), dhcp_bind(), dhcp_handle_nak(), dhcp_release(), and 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 status_callback(), and netif::status_callback.
Referenced by net_add_winc_netif().
Bring an interface up, available for processing traffic.
References etharp_gratuitous, netif::flags, mld6_report_groups(), NETIF_FLAG_ETHARP, NETIF_FLAG_IGMP, NETIF_FLAG_LINK_UP, NETIF_FLAG_UP, NETIF_STATUS_CALLBACK, netif::rs_count, and snmp_get_sysuptime.
Referenced by autoip_bind(), dhcp_bind(), net_interface_up_imp(), and netif_init().
struct netif* netif_default |
The default network interface.
Referenced by ip6_route(), and ip_route().
struct netif* netif_list |
The list of network interfaces.
Referenced by autoip_tmr(), dhcp_coarse_tmr(), dhcp_fine_tmr(), ip6_input(), ip6_route(), ip_input(), ip_route(), mld6_joingroup(), mld6_leavegroup(), nd6_tmr(), and netif_add().