32 #ifndef __LWIP_NETIF_H__
33 #define __LWIP_NETIF_H__
37 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
41 #include "lwip/ip_addr.h"
44 #include "lwip/pbuf.h"
61 #define NETIF_MAX_HWADDR_LEN 6U
69 #define NETIF_FLAG_UP 0x01U
72 #define NETIF_FLAG_BROADCAST 0x02U
75 #define NETIF_FLAG_POINTTOPOINT 0x04U
78 #define NETIF_FLAG_DHCP 0x08U
84 #define NETIF_FLAG_LINK_UP 0x10U
88 #define NETIF_FLAG_ETHARP 0x20U
92 #define NETIF_FLAG_ETHERNET 0x40U
95 #define NETIF_FLAG_IGMP 0x80U
102 typedef err_t (*netif_init_fn)(
struct netif *
netif);
109 typedef err_t (*netif_input_fn)(
struct pbuf *p,
struct netif *inp);
118 typedef err_t (*netif_output_fn)(
struct netif *
netif,
struct pbuf *p,
126 typedef err_t (*netif_linkoutput_fn)(
struct netif *netif,
struct pbuf *p);
128 typedef void (*netif_status_callback_fn)(
struct netif *netif);
130 typedef err_t (*netif_igmp_mac_filter_fn)(
struct netif *netif,
131 ip_addr_t *group, u8_t action);
156 #if LWIP_NETIF_STATUS_CALLBACK
159 netif_status_callback_fn status_callback;
161 #if LWIP_NETIF_LINK_CALLBACK
164 netif_status_callback_fn link_callback;
175 struct autoip *autoip;
177 #if LWIP_NETIF_HOSTNAME
203 u32_t ifinnucastpkts;
206 u32_t ifoutucastpkts;
207 u32_t ifoutnucastpkts;
213 netif_igmp_mac_filter_fn igmp_mac_filter;
215 #if LWIP_NETIF_HWADDRHINT
220 struct pbuf *loop_first;
221 struct pbuf *loop_last;
222 #if LWIP_LOOPBACK_MAX_PBUFS
223 u16_t loop_cnt_current;
229 #define NETIF_INIT_SNMP(netif, type, speed) \
231 (netif)->link_type = (type); \
233 (netif)->link_speed = (speed); \
235 (netif)->ifinoctets = 0; \
236 (netif)->ifinucastpkts = 0; \
237 (netif)->ifinnucastpkts = 0; \
238 (netif)->ifindiscards = 0; \
239 (netif)->ifoutoctets = 0; \
240 (netif)->ifoutucastpkts = 0; \
241 (netif)->ifoutnucastpkts = 0; \
242 (netif)->ifoutdiscards = 0
244 #define NETIF_INIT_SNMP(netif, type, speed)
249 extern struct netif *netif_list;
251 extern struct netif *netif_default;
253 void netif_init(
void)ICACHE_FLASH_ATTR;
255 struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *
netmask,
256 ip_addr_t *
gw,
void *
state, netif_init_fn init, netif_input_fn
input)ICACHE_FLASH_ATTR;
259 netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask,
260 ip_addr_t *gw)ICACHE_FLASH_ATTR;
261 void netif_remove(struct netif * netif)ICACHE_FLASH_ATTR;
267 struct netif *netif_find(
char *
name)ICACHE_FLASH_ATTR;
269 void netif_set_default(struct netif *netif)ICACHE_FLASH_ATTR;
271 void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR;
272 void netif_set_netmask(struct netif *netif, ip_addr_t *netmask)ICACHE_FLASH_ATTR;
273 void netif_set_gw(struct netif *netif, ip_addr_t *gw)ICACHE_FLASH_ATTR;
275 void netif_set_up(struct netif *netif)ICACHE_FLASH_ATTR;
276 void netif_set_down(struct netif *netif)ICACHE_FLASH_ATTR;
278 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
280 #if LWIP_NETIF_STATUS_CALLBACK
281 void netif_set_status_callback(
struct netif *netif, netif_status_callback_fn status_callback)ICACHE_FLASH_ATTR;
284 void netif_set_link_up(
struct netif *netif)ICACHE_FLASH_ATTR;
285 void netif_set_link_down(
struct netif *netif)ICACHE_FLASH_ATTR;
287 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
289 #if LWIP_NETIF_LINK_CALLBACK
290 void netif_set_link_callback(
struct netif *netif, netif_status_callback_fn link_callback)ICACHE_FLASH_ATTR;
293 #if LWIP_NETIF_HOSTNAME
294 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
295 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
299 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
300 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)
304 err_t netif_loop_output(
struct netif *netif,
struct pbuf *p, ip_addr_t *dest_ip)ICACHE_FLASH_ATTR;
305 void netif_poll(
struct netif *netif)ICACHE_FLASH_ATTR;
306 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
307 void netif_poll_all(
void)ICACHE_FLASH_ATTR;
u8_t hwaddr[6U]
Definition: netif.h:186
netif_output_fn output
Definition: netif.h:151
u8_t num
Definition: netif.h:192
u8_t hwaddr_len
Definition: netif.h:184
ip_addr_t gw
Definition: netif.h:143
struct netif * next
Definition: netif.h:138
u8_t flags
Definition: netif.h:188
ip_addr_t ip_addr
Definition: netif.h:141
u16_t mtu
Definition: netif.h:182
void * state
Definition: netif.h:168
netif_input_fn input
Definition: netif.h:147
char name[2]
Definition: netif.h:190
ip_addr_t netmask
Definition: netif.h:142
netif_linkoutput_fn linkoutput
Definition: netif.h:155