MeterLogger
netif.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 #ifndef __LWIP_NETIF_H__
33 #define __LWIP_NETIF_H__
34 
35 #include "lwip/opt.h"
36 
37 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
38 
39 #include "lwip/err.h"
40 
41 #include "lwip/ip_addr.h"
42 
43 #include "lwip/def.h"
44 #include "lwip/pbuf.h"
45 #if LWIP_DHCP
46 struct dhcp;
47 #endif
48 #if LWIP_AUTOIP
49 struct autoip;
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /* Throughout this file, IP addresses are expected to be in
57  * the same byte order as in IP_PCB. */
58 
59 /** must be the maximum of all used hardware address lengths
60  across all types of interfaces in use */
61 #define NETIF_MAX_HWADDR_LEN 6U
62 
63 /** Whether the network interface is 'up'. This is
64  * a software flag used to control whether this network
65  * interface is enabled and processes traffic.
66  * It is set by the startup code (for static IP configuration) or
67  * by dhcp/autoip when an address has been assigned.
68  */
69 #define NETIF_FLAG_UP 0x01U
70 /** If set, the netif has broadcast capability.
71  * Set by the netif driver in its init function. */
72 #define NETIF_FLAG_BROADCAST 0x02U
73 /** If set, the netif is one end of a point-to-point connection.
74  * Set by the netif driver in its init function. */
75 #define NETIF_FLAG_POINTTOPOINT 0x04U
76 /** If set, the interface is configured using DHCP.
77  * Set by the DHCP code when starting or stopping DHCP. */
78 #define NETIF_FLAG_DHCP 0x08U
79 /** If set, the interface has an active link
80  * (set by the network interface driver).
81  * Either set by the netif driver in its init function (if the link
82  * is up at that time) or at a later point once the link comes up
83  * (if link detection is supported by the hardware). */
84 #define NETIF_FLAG_LINK_UP 0x10U
85 /** If set, the netif is an ethernet device using ARP.
86  * Set by the netif driver in its init function.
87  * Used to check input packet types and use of DHCP. */
88 #define NETIF_FLAG_ETHARP 0x20U
89 /** If set, the netif is an ethernet device. It might not use
90  * ARP or TCP/IP if it is used for PPPoE only.
91  */
92 #define NETIF_FLAG_ETHERNET 0x40U
93 /** If set, the netif has IGMP capability.
94  * Set by the netif driver in its init function. */
95 #define NETIF_FLAG_IGMP 0x80U
96 
97 /** Function prototype for netif init functions. Set up flags and output/linkoutput
98  * callback functions in this function.
99  *
100  * @param netif The netif to initialize
101  */
102 typedef err_t (*netif_init_fn)(struct netif *netif);
103 /** Function prototype for netif->input functions. This function is saved as 'input'
104  * callback function in the netif struct. Call it when a packet has been received.
105  *
106  * @param p The received packet, copied into a pbuf
107  * @param inp The netif which received the packet
108  */
109 typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp);
110 /** Function prototype for netif->output functions. Called by lwIP when a packet
111  * shall be sent. For ethernet netif, set this to 'etharp_output' and set
112  * 'linkoutput'.
113  *
114  * @param netif The netif which shall send a packet
115  * @param p The packet to send (p->payload points to IP header)
116  * @param ipaddr The IP address to which the packet shall be sent
117  */
118 typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p,
119  ip_addr_t *ipaddr);
120 /** Function prototype for netif->linkoutput functions. Only used for ethernet
121  * netifs. This function is called by ARP when a packet shall be sent.
122  *
123  * @param netif The netif which shall send a packet
124  * @param p The packet to send (raw ethernet packet)
125  */
126 typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p);
127 /** Function prototype for netif status- or link-callback functions. */
128 typedef void (*netif_status_callback_fn)(struct netif *netif);
129 /** Function prototype for netif igmp_mac_filter functions */
130 typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif,
131  ip_addr_t *group, u8_t action);
132 
133 /*add DHCP event processing by LiuHan*/
134 typedef void (*dhcp_event_fn)(void);
135 
136 /** Generic data structure used for all lwIP network interfaces.
137  * The following fields should be filled in by the initialization
138  * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */
139 struct netif {
140  /** pointer to next in linked list */
141  struct netif *next;
142 
143  /** IP address configuration in network byte order */
147 
148  /** This function is called by the network device driver
149  * to pass a packet up the TCP/IP stack. 向IP层输入数据包/ netif_input_fn input; /** This function is called by the IP module when it wants * to send a packet on the interface. This function typically * first resolves the hardware address, then sends the packet. 发送IP数据包*/ netif_output_fn output; /** This function is called by the ARP module when it wants * to send a packet on the interface. This function outputs * the pbuf as-is on the link medium. 底层数据包发送*/ netif_linkoutput_fn linkoutput; #if LWIP_NETIF_STATUS_CALLBACK /** This function is called when the netif state is set to up or down */ netif_status_callback_fn status_callback; #endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK /** This function is called when the netif link is set to up or down */ netif_status_callback_fn link_callback; #endif /* LWIP_NETIF_LINK_CALLBACK */ /** This field can be set by the device driver and could point * to state information for the device. 自由设置字段,比如指向底层设备相关信息*/ void *state; #if LWIP_DHCP /** the DHCP client state information for this netif */ struct dhcp *dhcp; struct udp_pcb *dhcps_pcb; //dhcps dhcp_event_fn dhcp_event; #endif /* LWIP_DHCP */ #if LWIP_AUTOIP /** the AutoIP client state information for this netif */ struct autoip *autoip; #endif #if LWIP_NETIF_HOSTNAME /* the hostname for this netif, NULL is a valid value */ char* hostname; #endif /* LWIP_NETIF_HOSTNAME */ /** maximum transfer unit (in bytes) 该接口允许的最大数据包长度,多是1500*/ u16_t mtu; /** number of bytes used in hwaddr该接口物理地址长度 */ u8_t hwaddr_len; /** link level hardware address of this interface 该接口物理地址*/ u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; /** flags (see NETIF_FLAG_ above) 该接口状态、属性字段*/ u8_t flags; /** descriptive abbreviation 该接口的名字*/ char name[2]; /** number of this interface 该接口的编号*/ u8_t num; #if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; /** timestamp at last change made (up/down) */ u32_t ts; /** counters */ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards; #endif /* LWIP_SNMP */ #if LWIP_IGMP /** This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ netif_igmp_mac_filter_fn igmp_mac_filter; #endif /* LWIP_IGMP */ #if LWIP_NETIF_HWADDRHINT u8_t *addr_hint; #endif /* LWIP_NETIF_HWADDRHINT */ #if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/ struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */ */
151  /** This function is called by the IP module when it wants
152  * to send a packet on the interface. This function typically
153  * first resolves the hardware address, then sends the packet. 发送IP数据包/ netif_output_fn output; /** This function is called by the ARP module when it wants * to send a packet on the interface. This function outputs * the pbuf as-is on the link medium. 底层数据包发送*/ netif_linkoutput_fn linkoutput; #if LWIP_NETIF_STATUS_CALLBACK /** This function is called when the netif state is set to up or down */ netif_status_callback_fn status_callback; #endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK /** This function is called when the netif link is set to up or down */ netif_status_callback_fn link_callback; #endif /* LWIP_NETIF_LINK_CALLBACK */ /** This field can be set by the device driver and could point * to state information for the device. 自由设置字段,比如指向底层设备相关信息*/ void *state; #if LWIP_DHCP /** the DHCP client state information for this netif */ struct dhcp *dhcp; struct udp_pcb *dhcps_pcb; //dhcps dhcp_event_fn dhcp_event; #endif /* LWIP_DHCP */ #if LWIP_AUTOIP /** the AutoIP client state information for this netif */ struct autoip *autoip; #endif #if LWIP_NETIF_HOSTNAME /* the hostname for this netif, NULL is a valid value */ char* hostname; #endif /* LWIP_NETIF_HOSTNAME */ /** maximum transfer unit (in bytes) 该接口允许的最大数据包长度,多是1500*/ u16_t mtu; /** number of bytes used in hwaddr该接口物理地址长度 */ u8_t hwaddr_len; /** link level hardware address of this interface 该接口物理地址*/ u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; /** flags (see NETIF_FLAG_ above) 该接口状态、属性字段*/ u8_t flags; /** descriptive abbreviation 该接口的名字*/ char name[2]; /** number of this interface 该接口的编号*/ u8_t num; #if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; /** timestamp at last change made (up/down) */ u32_t ts; /** counters */ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards; #endif /* LWIP_SNMP */ #if LWIP_IGMP /** This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ netif_igmp_mac_filter_fn igmp_mac_filter; #endif /* LWIP_IGMP */ #if LWIP_NETIF_HWADDRHINT u8_t *addr_hint; #endif /* LWIP_NETIF_HWADDRHINT */ #if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/ struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */ */
155  /** This function is called by the ARP module when it wants
156  * to send a packet on the interface. This function outputs
157  * the pbuf as-is on the link medium. 底层数据包发送*/
159 #if LWIP_NETIF_STATUS_CALLBACK
160  /** This function is called when the netif state is set to up or down
161  */
162  netif_status_callback_fn status_callback;
163 #endif /* LWIP_NETIF_STATUS_CALLBACK */
164 #if LWIP_NETIF_LINK_CALLBACK
165  /** This function is called when the netif link is set to up or down
166  */
167  netif_status_callback_fn link_callback;
168 #endif /* LWIP_NETIF_LINK_CALLBACK */
169  /** This field can be set by the device driver and could point
170  * to state information for the device. 自由设置字段,比如指向底层设备相关信息*/
171  void *state;
172 #if LWIP_DHCP
173  /** the DHCP client state information for this netif */
174  struct dhcp *dhcp;
175  struct udp_pcb *dhcps_pcb; //dhcps
176  dhcp_event_fn dhcp_event;
177 #endif /* LWIP_DHCP */
178 #if LWIP_AUTOIP
179  /** the AutoIP client state information for this netif */
180  struct autoip *autoip;
181 #endif
182 #if LWIP_NETIF_HOSTNAME
183  /* the hostname for this netif, NULL is a valid value */
184  char* hostname;
185 #endif /* LWIP_NETIF_HOSTNAME */
186  /** maximum transfer unit (in bytes) 该接口允许的最大数据包长度,多是1500*/
188  /** number of bytes used in hwaddr该接口物理地址长度 */
190  /** link level hardware address of this interface 该接口物理地址*/
192  /** flags (see NETIF_FLAG_ above) 该接口状态、属性字段/ u8_t flags; /** descriptive abbreviation 该接口的名字*/ char name[2]; /** number of this interface 该接口的编号*/ u8_t num; #if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; /** timestamp at last change made (up/down) */ u32_t ts; /** counters */ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards; #endif /* LWIP_SNMP */ #if LWIP_IGMP /** This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ netif_igmp_mac_filter_fn igmp_mac_filter; #endif /* LWIP_IGMP */ #if LWIP_NETIF_HWADDRHINT u8_t *addr_hint; #endif /* LWIP_NETIF_HWADDRHINT */ #if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/ struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */ */
194  /** descriptive abbreviation 该接口的名字/ char name[2]; /** number of this interface 该接口的编号*/ u8_t num; #if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; /** timestamp at last change made (up/down) */ u32_t ts; /** counters */ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards; #endif /* LWIP_SNMP */ #if LWIP_IGMP /** This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ netif_igmp_mac_filter_fn igmp_mac_filter; #endif /* LWIP_IGMP */ #if LWIP_NETIF_HWADDRHINT u8_t *addr_hint; #endif /* LWIP_NETIF_HWADDRHINT */ #if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/ struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */ */
195  char name[2];
196  /** number of this interface 该接口的编号/ u8_t num; #if LWIP_SNMP /** link type (from "snmp_ifType" enum from snmp.h) */ u8_t link_type; /** (estimate) link speed */ u32_t link_speed; /** timestamp at last change made (up/down) */ u32_t ts; /** counters */ u32_t ifinoctets; u32_t ifinucastpkts; u32_t ifinnucastpkts; u32_t ifindiscards; u32_t ifoutoctets; u32_t ifoutucastpkts; u32_t ifoutnucastpkts; u32_t ifoutdiscards; #endif /* LWIP_SNMP */ #if LWIP_IGMP /** This function could be called to add or delete a entry in the multicast filter table of the ethernet MAC.*/ netif_igmp_mac_filter_fn igmp_mac_filter; #endif /* LWIP_IGMP */ #if LWIP_NETIF_HWADDRHINT u8_t *addr_hint; #endif /* LWIP_NETIF_HWADDRHINT */ #if ENABLE_LOOPBACK /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/ struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */ */
198 #if LWIP_SNMP
199  /** link type (from "snmp_ifType" enum from snmp.h) */
200  u8_t link_type;
201  /** (estimate) link speed */
202  u32_t link_speed;
203  /** timestamp at last change made (up/down) */
204  u32_t ts;
205  /** counters */
206  u32_t ifinoctets;
207  u32_t ifinucastpkts;
208  u32_t ifinnucastpkts;
209  u32_t ifindiscards;
210  u32_t ifoutoctets;
211  u32_t ifoutucastpkts;
212  u32_t ifoutnucastpkts;
213  u32_t ifoutdiscards;
214 #endif /* LWIP_SNMP */
215 #if LWIP_IGMP
216  /** This function could be called to add or delete a entry in the multicast
217  filter table of the ethernet MAC.*/
218  netif_igmp_mac_filter_fn igmp_mac_filter;
219 #endif /* LWIP_IGMP */
220 #if LWIP_NETIF_HWADDRHINT
221  u8_t *addr_hint;
222 #endif /* LWIP_NETIF_HWADDRHINT */
223 #if ENABLE_LOOPBACK
224  /* List of packets to be queued for ourselves. 指向发送给自己的数据包的pbuf*/
225  struct pbuf *loop_first;//第一个 struct pbuf *loop_last;//最后一个 #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */
226  struct pbuf *loop_last;//最后一个#if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ #endif /* ENABLE_LOOPBACK */ #if IP_NAPT u8_t napt; #endif }; #if LWIP_SNMP #define NETIF_INIT_SNMP(netif, type, speed) \ /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ (netif)->link_type = (type); \ /* your link speed here (units: bits per second) */ \ (netif)->link_speed = (speed); \ (netif)->ts = 0; \ (netif)->ifinoctets = 0; \ (netif)->ifinucastpkts = 0; \ (netif)->ifinnucastpkts = 0; \ (netif)->ifindiscards = 0; \ (netif)->ifoutoctets = 0; \ (netif)->ifoutucastpkts = 0; \ (netif)->ifoutnucastpkts = 0; \ (netif)->ifoutdiscards = 0 #else /* LWIP_SNMP */ #define NETIF_INIT_SNMP(netif, type, speed) #endif /* LWIP_SNMP */ /** The list of network interfaces. */ extern struct netif *netif_list; /** The default network interface. */ extern struct netif *netif_default; void netif_init(void)ICACHE_FLASH_ATTR; 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)ICACHE_FLASH_ATTR; void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR; /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(char *name)ICACHE_FLASH_ATTR; void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR; void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR; void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if an interface is up */ #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_STATUS_CALLBACK void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_STATUS_CALLBACK */ void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR; void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR; /** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR; #endif /* LWIP_NETIF_LINK_CALLBACK */ #if LWIP_NETIF_HOSTNAME #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) #endif /* LWIP_NETIF_HOSTNAME */ #if LWIP_IGMP #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) #endif /* LWIP_IGMP */ #if ENABLE_LOOPBACK err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR; void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR; #if !LWIP_NETIF_LOOPBACK_MULTITHREADING void netif_poll_all(void)ICACHE_FLASH_ATTR; #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #ifdef __cplusplus } #endif #endif /* __LWIP_NETIF_H__ */
227 #if LWIP_LOOPBACK_MAX_PBUFS
228  u16_t loop_cnt_current;
229 #endif /* LWIP_LOOPBACK_MAX_PBUFS */
230 #endif /* ENABLE_LOOPBACK */
231 #if IP_NAPT
232  u8_t napt;
233 #endif
234 };
235 
236 #if LWIP_SNMP
237 #define NETIF_INIT_SNMP(netif, type, speed) \
238  /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \
239  (netif)->link_type = (type); \
240  /* your link speed here (units: bits per second) */ \
241  (netif)->link_speed = (speed); \
242  (netif)->ts = 0; \
243  (netif)->ifinoctets = 0; \
244  (netif)->ifinucastpkts = 0; \
245  (netif)->ifinnucastpkts = 0; \
246  (netif)->ifindiscards = 0; \
247  (netif)->ifoutoctets = 0; \
248  (netif)->ifoutucastpkts = 0; \
249  (netif)->ifoutnucastpkts = 0; \
250  (netif)->ifoutdiscards = 0
251 #else /* LWIP_SNMP */
252 #define NETIF_INIT_SNMP(netif, type, speed)
253 #endif /* LWIP_SNMP */
254 
255 
256 /** The list of network interfaces. */
257 extern struct netif *netif_list;
258 /** The default network interface. */
259 extern struct netif *netif_default;
260 
261 void netif_init(void)ICACHE_FLASH_ATTR;
262 
263 struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
265 
266 void
267 netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
269 void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR;
270 
271 /* Returns a network interface given its name. The name is of the form
272  "et0", where the first two letters are the "name" field in the
273  netif structure, and the digit is in the num field in the same
274  structure. */
275 struct netif *netif_find(char *name)ICACHE_FLASH_ATTR;
276 
277 void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR;
278 
279 void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR;
280 void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR;
281 void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR;
282 
283 void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR;
284 void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR;
285 /** Ask if an interface is up */
286 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
287 
288 #if LWIP_NETIF_STATUS_CALLBACK
289 void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR;
290 #endif /* LWIP_NETIF_STATUS_CALLBACK */
291 
292 void netif_set_link_up(struct netif *netif)ICACHE_FLASH_ATTR;
293 void netif_set_link_down(struct netif *netif)ICACHE_FLASH_ATTR;
294 /** Ask if a link is up */
295 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
296 
297 #if LWIP_NETIF_LINK_CALLBACK
298 void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR;
299 #endif /* LWIP_NETIF_LINK_CALLBACK */
300 
301 #if LWIP_NETIF_HOSTNAME
302 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
303 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
304 #endif /* LWIP_NETIF_HOSTNAME */
305 
306 #if LWIP_IGMP
307 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
308 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)
309 #endif /* LWIP_IGMP */
310 
311 #if ENABLE_LOOPBACK
312 err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR;
313 void netif_poll(struct netif *netif)ICACHE_FLASH_ATTR;
314 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
315 void netif_poll_all(void)ICACHE_FLASH_ATTR;
316 #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
317 #endif /* ENABLE_LOOPBACK */
318 
319 #ifdef __cplusplus
320 }
321 #endif
322 
323 #endif /* __LWIP_NETIF_H__ */
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition: netif.h:109
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
Definition: netif.h:191
void(* netif_status_callback_fn)(struct netif *netif)
Definition: netif.h:128
void netif_set_link_down(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:562
err_t(* netif_igmp_mac_filter_fn)(struct netif *netif, ip_addr_t *group, u8_t action)
Definition: netif.h:130
void netif_set_link_up(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:523
struct netif * netif_list
Definition: netif.c:75
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) ICACHE_FLASH_ATTR
Definition: netif.c:137
netif_output_fn output
Definition: netif.h:154
#define ICACHE_FLASH_ATTR
Definition: c_types.h:99
u8_t num
Definition: netif.h:197
void netif_set_up(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:454
void netif_set_netmask(struct netif *netif, ip_addr_t *netmask) ICACHE_FLASH_ATTR
Definition: netif.c:410
struct netif * netif_find(char *name) ICACHE_FLASH_ATTR
Definition: netif.c:291
void netif_set_gw(struct netif *netif, ip_addr_t *gw) ICACHE_FLASH_ATTR
Definition: netif.c:389
#define NETIF_MAX_HWADDR_LEN
Definition: netif.h:61
u8_t hwaddr_len
Definition: netif.h:189
void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr) ICACHE_FLASH_ATTR
Definition: netif.c:324
ip_addr_t gw
Definition: netif.h:146
unsigned long u32_t
Definition: cc.h:56
void netif_set_default(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:431
struct netif * next
Definition: netif.h:141
Definition: pbuf.h:76
struct netif * netif_default
Definition: netif.c:76
u8_t flags
Definition: netif.h:193
s8_t err_t
Definition: err.h:47
typedefPACK_STRUCT_END struct ip_addr ip_addr_t
Definition: ip_addr.h:64
Definition: netif.h:139
err_t(* netif_init_fn)(struct netif *netif)
Definition: netif.h:102
void(* dhcp_event_fn)(void)
Definition: netif.h:134
ip_addr_t ip_addr
Definition: netif.h:144
u16_t mtu
Definition: netif.h:187
err_t(* netif_output_fn)(struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr)
Definition: netif.h:118
void * state
Definition: netif.h:171
void netif_init(void) ICACHE_FLASH_ATTR
Definition: netif.c:104
unsigned char u8_t
Definition: cc.h:52
netif_input_fn input
Definition: netif.h:150
void netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw) ICACHE_FLASH_ATTR
Definition: netif.c:227
char name[2]
Definition: netif.h:195
ip_addr_t netmask
Definition: netif.h:145
netif_linkoutput_fn linkoutput
Definition: netif.h:158
void netif_set_down(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:491
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
Definition: netif.h:126
unsigned short u16_t
Definition: cc.h:54
void netif_remove(struct netif *netif) ICACHE_FLASH_ATTR
Definition: netif.c:241