37 #ifndef LWIP_HDR_NETIF_H
38 #define LWIP_HDR_NETIF_H
42 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF)
62 #ifndef NETIF_MAX_HWADDR_LEN
63 #define NETIF_MAX_HWADDR_LEN 6U
70 #define NETIF_NAMESIZE 6
84 #define NETIF_FLAG_UP 0x01U
87 #define NETIF_FLAG_BROADCAST 0x02U
93 #define NETIF_FLAG_LINK_UP 0x04U
97 #define NETIF_FLAG_ETHARP 0x08U
101 #define NETIF_FLAG_ETHERNET 0x10U
104 #define NETIF_FLAG_IGMP 0x20U
107 #define NETIF_FLAG_MLD6 0x40U
117 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
120 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
123 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
128 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6,
131 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
137 #if LWIP_CHECKSUM_CTRL_PER_NETIF
138 #define NETIF_CHECKSUM_GEN_IP 0x0001
139 #define NETIF_CHECKSUM_GEN_UDP 0x0002
140 #define NETIF_CHECKSUM_GEN_TCP 0x0004
141 #define NETIF_CHECKSUM_GEN_ICMP 0x0008
142 #define NETIF_CHECKSUM_GEN_ICMP6 0x0010
143 #define NETIF_CHECKSUM_CHECK_IP 0x0100
144 #define NETIF_CHECKSUM_CHECK_UDP 0x0200
145 #define NETIF_CHECKSUM_CHECK_TCP 0x0400
146 #define NETIF_CHECKSUM_CHECK_ICMP 0x0800
147 #define NETIF_CHECKSUM_CHECK_ICMP6 0x1000
148 #define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF
149 #define NETIF_CHECKSUM_DISABLE_ALL 0x0000
190 const ip4_addr_t *ipaddr);
203 const ip6_addr_t *ipaddr);
215 #if LWIP_IPV4 && LWIP_IGMP
220 #if LWIP_IPV6 && LWIP_IPV6_MLD
226 #if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || LWIP_IPV6_DHCP6 || (LWIP_NUM_NETIF_CLIENT_DATA > 0)
227 #if LWIP_NUM_NETIF_CLIENT_DATA > 0
228 u8_t netif_alloc_client_data_id(
void);
233 #define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data)
237 #define netif_get_client_data(netif, id) (netif)->client_data[(id)]
240 #if (LWIP_IPV4 && LWIP_ARP && (ARP_TABLE_SIZE > 0x7f)) || (LWIP_IPV6 && (LWIP_ND6_NUM_DESTINATIONS > 0x7f))
242 #define NETIF_ADDR_IDX_MAX 0x7FFF
245 #define NETIF_ADDR_IDX_MAX 0x7F
248 #if LWIP_NETIF_HWADDRHINT
249 #define LWIP_NETIF_USE_HINTS 1
254 #define LWIP_NETIF_USE_HINTS 0
261 #if !LWIP_SINGLE_NETIF
278 #if LWIP_IPV6_ADDRESS_LIFETIMES
294 netif_output_fn output;
305 netif_output_ip6_fn output_ip6;
307 #if LWIP_NETIF_STATUS_CALLBACK
312 #if LWIP_NETIF_LINK_CALLBACK
317 #if LWIP_NETIF_REMOVE_CALLBACK
324 #ifdef netif_get_client_data
327 #if LWIP_NETIF_HOSTNAME
329 const char* hostname;
331 #if LWIP_CHECKSUM_CTRL_PER_NETIF
336 #if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES
351 #if LWIP_IPV6_AUTOCONFIG
353 u8_t ip6_autoconfig_enabled;
355 #if LWIP_IPV6_SEND_ROUTER_SOLICIT
367 struct stats_mib2_netif_ctrs mib2_counters;
369 #if LWIP_IPV4 && LWIP_IGMP
372 netif_igmp_mac_filter_fn igmp_mac_filter;
374 #if LWIP_IPV6 && LWIP_IPV6_MLD
377 netif_mld_mac_filter_fn mld_mac_filter;
379 #if LWIP_NETIF_USE_HINTS
380 struct netif_hint *hints;
384 struct pbuf *loop_first;
385 struct pbuf *loop_last;
386 #if LWIP_LOOPBACK_MAX_PBUFS
387 u16_t loop_cnt_current;
392 #if LWIP_CHECKSUM_CTRL_PER_NETIF
393 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \
394 (netif)->chksum_flags = chksumflags; } while(0)
395 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0))
397 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags)
398 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag)
401 #if LWIP_SINGLE_NETIF
402 #define NETIF_FOREACH(netif) if (((netif) = netif_default) != NULL)
406 #define NETIF_FOREACH(netif) for ((netif) = netif_list; (netif) != NULL; (netif) = (netif)->next)
417 const ip4_addr_t *ipaddr,
const ip4_addr_t *netmask,
const ip4_addr_t *gw,
419 void netif_set_addr(
struct netif *
netif,
const ip4_addr_t *ipaddr,
const ip4_addr_t *netmask,
420 const ip4_addr_t *gw);
435 void netif_set_ipaddr(
struct netif *
netif,
const ip4_addr_t *ipaddr);
436 void netif_set_netmask(
struct netif *
netif,
const ip4_addr_t *netmask);
437 void netif_set_gw(
struct netif *
netif,
const ip4_addr_t *gw);
439 #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr)))
441 #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask)))
443 #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw)))
445 #define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr))
447 #define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask))
449 #define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw))
452 #define netif_set_flags(netif, set_flags) do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0)
453 #define netif_clear_flags(netif, clr_flags) do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)
454 #define netif_is_flag_set(nefif, flag) (((netif)->flags & (flag)) != 0)
461 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0)
463 #if LWIP_NETIF_STATUS_CALLBACK
466 #if LWIP_NETIF_REMOVE_CALLBACK
473 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0)
475 #if LWIP_NETIF_LINK_CALLBACK
479 #if LWIP_NETIF_HOSTNAME
481 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0)
483 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL)
488 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0)
489 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL)
492 #if LWIP_IPV6 && LWIP_IPV6_MLD
494 #define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0)
495 #define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL)
496 #define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0)
502 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
503 void netif_poll_all(
void);
511 #define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i])))
513 #define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i])))
514 void netif_ip6_addr_set(
struct netif *
netif,
s8_t addr_idx,
const ip6_addr_t *addr6);
516 #define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i])
518 s8_t netif_get_ip6_addr_match(
struct netif *
netif,
const ip6_addr_t *ip6addr);
519 void netif_create_ip6_linklocal_address(
struct netif *
netif,
u8_t from_mac_48bit);
520 err_t netif_add_ip6_address(
struct netif *
netif,
const ip6_addr_t *ip6addr,
s8_t *chosen_idx);
521 #define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0)
522 #if LWIP_IPV6_ADDRESS_LIFETIMES
523 #define netif_ip6_addr_valid_life(netif, i) \
524 (((netif) != NULL) ? ((netif)->ip6_addr_valid_life[i]) : IP6_ADDR_LIFE_STATIC)
525 #define netif_ip6_addr_set_valid_life(netif, i, secs) \
526 do { if (netif != NULL) { (netif)->ip6_addr_valid_life[i] = (secs); }} while (0)
527 #define netif_ip6_addr_pref_life(netif, i) \
528 (((netif) != NULL) ? ((netif)->ip6_addr_pref_life[i]) : IP6_ADDR_LIFE_STATIC)
529 #define netif_ip6_addr_set_pref_life(netif, i, secs) \
530 do { if (netif != NULL) { (netif)->ip6_addr_pref_life[i] = (secs); }} while (0)
531 #define netif_ip6_addr_isstatic(netif, i) \
532 (netif_ip6_addr_valid_life((netif), (i)) == IP6_ADDR_LIFE_STATIC)
534 #define netif_ip6_addr_isstatic(netif, i) (1)
536 #if LWIP_ND6_ALLOW_RA_UPDATES
537 #define netif_mtu6(netif) ((netif)->mtu6)
539 #define netif_mtu6(netif) ((netif)->mtu)
543 #if LWIP_NETIF_USE_HINTS
544 #define NETIF_SET_HINTS(netif, netifhint) (netif)->hints = (netifhint)
545 #define NETIF_RESET_HINTS(netif) (netif)->hints = NULL
547 #define NETIF_SET_HINTS(netif, netifhint)
548 #define NETIF_RESET_HINTS(netif)
556 #define netif_get_index(netif) ((u8_t)((netif)->num + 1))
557 #define NETIF_NO_INDEX (0)
567 #define LWIP_NSC_NONE 0x0000
569 #define LWIP_NSC_NETIF_ADDED 0x0001
571 #define LWIP_NSC_NETIF_REMOVED 0x0002
573 #define LWIP_NSC_LINK_CHANGED 0x0004
577 #define LWIP_NSC_STATUS_CHANGED 0x0008
579 #define LWIP_NSC_IPV4_ADDRESS_CHANGED 0x0010
581 #define LWIP_NSC_IPV4_GATEWAY_CHANGED 0x0020
583 #define LWIP_NSC_IPV4_NETMASK_CHANGED 0x0040
585 #define LWIP_NSC_IPV4_SETTINGS_CHANGED 0x0080
587 #define LWIP_NSC_IPV6_SET 0x0100
589 #define LWIP_NSC_IPV6_ADDR_STATE_CHANGED 0x0200
633 } ipv6_addr_state_changed;
646 #if LWIP_NETIF_EXT_STATUS_CALLBACK
647 struct netif_ext_callback;
648 typedef struct netif_ext_callback
651 struct netif_ext_callback* next;
652 } netif_ext_callback_t;
654 #define NETIF_DECLARE_EXT_CALLBACK(name) static netif_ext_callback_t name;
659 #define NETIF_DECLARE_EXT_CALLBACK(name)
660 #define netif_add_ext_callback(callback, fn)
661 #define netif_remove_ext_callback(callback)
662 #define netif_invoke_ext_callback(netif, reason, args)
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
int8_t s8_t
Definition: arch.h:126
s8_t err_t
Definition: err.h:96
#define LWIP_IPV6_NUM_ADDRESSES
Definition: opt.h:2420
#define LWIP_NUM_NETIF_CLIENT_DATA
Definition: opt.h:1666
void netif_set_link_down(struct netif *netif)
Definition: netif.c:1026
char * netif_index_to_name(u8_t idx, char *name)
Definition: netif.c:1656
void(* netif_ext_callback_fn)(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
Definition: netif.h:644
void netif_set_down(struct netif *netif)
Definition: netif.c:919
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
Definition: netif.c:276
struct netif * netif_find(const char *name)
Definition: netif.c:1701
void netif_remove(struct netif *netif)
Definition: netif.c:737
u16_t netif_nsc_reason_t
Definition: netif.h:564
struct netif * netif_add_noaddr(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
Definition: netif.c:239
u8_t netif_name_to_index(const char *name)
Definition: netif.c:1637
void netif_set_default(struct netif *netif)
Definition: netif.c:822
void netif_set_link_up(struct netif *netif)
Definition: netif.c:988
struct netif * netif_get_by_index(u8_t idx)
Definition: netif.c:1676
void netif_set_up(struct netif *netif)
Definition: netif.c:844
ip6_addr_t ip_addr_t
Definition: ip_addr.h:318
void netif_init(void)
Definition: netif.c:177
struct netif * netif_list
Definition: netif.c:110
err_t(* netif_init_fn)(struct netif *netif)
Definition: netif.h:168
struct netif * netif_default
Definition: netif.c:112
void(* netif_status_callback_fn)(struct netif *netif)
Definition: netif.h:214
lwip_internal_netif_client_data_index
Definition: netif.h:114
@ LWIP_NETIF_CLIENT_DATA_INDEX_MAX
Definition: netif.h:134
err_t netif_input(struct pbuf *p, struct netif *inp)
Definition: netif.c:217
#define netif_invoke_ext_callback(netif, reason, args)
Definition: netif.h:662
#define netif_add_ext_callback(callback, fn)
Definition: netif.h:660
netif_mac_filter_action
Definition: netif.h:156
@ NETIF_ADD_MAC_FILTER
Definition: netif.h:160
@ NETIF_DEL_MAC_FILTER
Definition: netif.h:158
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Definition: netif.h:178
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
Definition: netif.h:212
#define NETIF_MAX_HWADDR_LEN
Definition: netif.h:63
u8_t netif_addr_idx_t
Definition: netif.h:244
#define netif_remove_ext_callback(callback)
Definition: netif.h:661
const ip_addr_t * old_address
Definition: netif.h:612
const ip_addr_t * old_gw
Definition: netif.h:614
const ip_addr_t * old_netmask
Definition: netif.h:613
u8_t old_state
Definition: netif.h:630
const ip_addr_t * address
Definition: netif.h:632
s8_t addr_index
Definition: netif.h:628
const ip_addr_t * old_address
Definition: netif.h:622
s8_t addr_index
Definition: netif.h:620
u8_t state
Definition: netif.h:600
u8_t state
Definition: netif.h:606
u8_t flags
Definition: netif.h:345
char name[2]
Definition: netif.h:347
void * state
Definition: netif.h:323
netif_input_fn input
Definition: netif.h:288
u8_t num
Definition: netif.h:350
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
Definition: netif.h:341
u16_t mtu
Definition: netif.h:335
netif_linkoutput_fn linkoutput
Definition: netif.h:299
struct netif * next
Definition: netif.h:263
u8_t hwaddr_len
Definition: netif.h:343