37 #ifndef LWIP_HDR_NETIF_H 38 #define LWIP_HDR_NETIF_H 43 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 63 #ifndef NETIF_MAX_HWADDR_LEN 64 #define NETIF_MAX_HWADDR_LEN 6U 71 #define NETIF_NAMESIZE 6 85 #define NETIF_FLAG_UP 0x01U 88 #define NETIF_FLAG_BROADCAST 0x02U 94 #define NETIF_FLAG_LINK_UP 0x04U 98 #define NETIF_FLAG_ETHARP 0x08U 102 #define NETIF_FLAG_ETHERNET 0x10U 105 #define NETIF_FLAG_IGMP 0x20U 108 #define NETIF_FLAG_MLD6 0x40U 114 enum lwip_internal_netif_client_data_index
118 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP,
121 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
124 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
129 LWIP_NETIF_CLIENT_DATA_INDEX_DHCP6,
132 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
135 LWIP_NETIF_CLIENT_DATA_INDEX_MAX
138 #if LWIP_CHECKSUM_CTRL_PER_NETIF 139 #define NETIF_CHECKSUM_GEN_IP 0x0001 140 #define NETIF_CHECKSUM_GEN_UDP 0x0002 141 #define NETIF_CHECKSUM_GEN_TCP 0x0004 142 #define NETIF_CHECKSUM_GEN_ICMP 0x0008 143 #define NETIF_CHECKSUM_GEN_ICMP6 0x0010 144 #define NETIF_CHECKSUM_CHECK_IP 0x0100 145 #define NETIF_CHECKSUM_CHECK_UDP 0x0200 146 #define NETIF_CHECKSUM_CHECK_TCP 0x0400 147 #define NETIF_CHECKSUM_CHECK_ICMP 0x0800 148 #define NETIF_CHECKSUM_CHECK_ICMP6 0x1000 149 #define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF 150 #define NETIF_CHECKSUM_DISABLE_ALL 0x0000 203 typedef err_t (*netif_output_ip6_fn)(
struct netif *netif,
struct pbuf *p,
216 #if LWIP_IPV4 && LWIP_IGMP 218 typedef err_t (*netif_igmp_mac_filter_fn)(
struct netif *netif,
221 #if LWIP_IPV6 && LWIP_IPV6_MLD 223 typedef err_t (*netif_mld_mac_filter_fn)(
struct netif *netif,
227 #if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || LWIP_IPV6_DHCP6 || (LWIP_NUM_NETIF_CLIENT_DATA > 0) 228 #if LWIP_NUM_NETIF_CLIENT_DATA > 0 229 u8_t netif_alloc_client_data_id(
void);
234 #define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data) 238 #define netif_get_client_data(netif, id) (netif)->client_data[(id)] 241 #if (LWIP_IPV4 && LWIP_ARP && (ARP_TABLE_SIZE > 0x7f)) || (LWIP_IPV6 && (LWIP_ND6_NUM_DESTINATIONS > 0x7f)) 242 typedef u16_t netif_addr_idx_t;
243 #define NETIF_ADDR_IDX_MAX 0x7FFF 245 typedef u8_t netif_addr_idx_t;
246 #define NETIF_ADDR_IDX_MAX 0x7F 249 #if LWIP_NETIF_HWADDRHINT 250 #define LWIP_NETIF_USE_HINTS 1 252 netif_addr_idx_t addr_hint;
255 #define LWIP_NETIF_USE_HINTS 0 262 #if !LWIP_SINGLE_NETIF 279 #if LWIP_IPV6_ADDRESS_LIFETIMES 295 netif_output_fn output;
306 netif_output_ip6_fn output_ip6;
308 #if LWIP_NETIF_STATUS_CALLBACK 313 #if LWIP_NETIF_LINK_CALLBACK 318 #if LWIP_NETIF_REMOVE_CALLBACK 325 #ifdef netif_get_client_data 328 #if LWIP_NETIF_HOSTNAME 330 const char* hostname;
332 #if LWIP_CHECKSUM_CTRL_PER_NETIF 337 #if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES 352 #if LWIP_IPV6_AUTOCONFIG 354 u8_t ip6_autoconfig_enabled;
356 #if LWIP_IPV6_SEND_ROUTER_SOLICIT 368 struct stats_mib2_netif_ctrs mib2_counters;
370 #if LWIP_IPV4 && LWIP_IGMP 373 netif_igmp_mac_filter_fn igmp_mac_filter;
375 #if LWIP_IPV6 && LWIP_IPV6_MLD 378 netif_mld_mac_filter_fn mld_mac_filter;
380 #if LWIP_NETIF_USE_HINTS 381 struct netif_hint *hints;
385 struct pbuf *loop_first;
386 struct pbuf *loop_last;
387 #if LWIP_LOOPBACK_MAX_PBUFS 388 u16_t loop_cnt_current;
393 #if LWIP_CHECKSUM_CTRL_PER_NETIF 394 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \ 395 (netif)->chksum_flags = chksumflags; } while(0) 396 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0)) 398 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) 399 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) 402 #if LWIP_SINGLE_NETIF 403 #define NETIF_FOREACH(netif) if (((netif) = netif_default) != NULL) 407 #define NETIF_FOREACH(netif) for ((netif) = netif_list; (netif) != NULL; (netif) = (netif)->next) 412 void netif_init(
void);
417 struct netif *netif_add(
struct netif *netif,
425 void netif_remove(
struct netif * netif);
431 struct netif *netif_find(
const char *
name);
437 const char *netif_get_name(
struct netif *netif);
439 void netif_set_default(
struct netif *netif);
440 bool netif_check_default(
struct netif *netif);
444 void netif_set_ipaddr(
struct netif *netif,
const ip4_addr_t *ipaddr);
445 void netif_set_netmask(
struct netif *netif,
const ip4_addr_t *netmask);
446 void netif_set_gw(
struct netif *netif,
const ip4_addr_t *gw);
448 #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) 450 #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) 452 #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) 454 #define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr)) 456 #define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask)) 458 #define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw)) 461 #define netif_set_flags(netif, set_flags) do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0) 462 #define netif_clear_flags(netif, clr_flags) do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0) 463 #define netif_is_flag_set(nefif, flag) (((netif)->flags & (flag)) != 0) 465 void netif_set_up(
struct netif *netif);
466 void netif_set_down(
struct netif *netif);
470 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) 472 #if LWIP_NETIF_STATUS_CALLBACK 475 #if LWIP_NETIF_REMOVE_CALLBACK 479 void netif_set_link_up(
struct netif *netif);
480 void netif_set_link_down(
struct netif *netif);
482 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) 484 #if LWIP_NETIF_LINK_CALLBACK 488 #if LWIP_NETIF_HOSTNAME 490 #define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) 492 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) 497 #define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) 498 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) 501 #if LWIP_IPV6 && LWIP_IPV6_MLD 503 #define netif_set_mld_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->mld_mac_filter = function; }}while(0) 504 #define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL) 505 #define netif_mld_mac_filter(netif, addr, action) do { if((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); }}while(0) 509 err_t netif_loop_output(
struct netif *netif,
struct pbuf *p);
510 void netif_poll(
struct netif *netif);
511 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING 512 void netif_poll_all(
void);
516 err_t netif_input(
struct pbuf *p,
struct netif *inp);
520 #define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i]))) 522 #define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i]))) 523 void netif_ip6_addr_set(
struct netif *netif, s8_t addr_idx,
const ip6_addr_t *addr6);
524 void netif_ip6_addr_set_parts(
struct netif *netif, s8_t addr_idx, u32_t i0, u32_t i1, u32_t i2, u32_t i3);
525 #define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i]) 526 void netif_ip6_addr_set_state(
struct netif* netif, s8_t addr_idx, u8_t
state);
527 s8_t netif_get_ip6_addr_match(
struct netif *netif,
const ip6_addr_t *ip6addr);
528 void netif_create_ip6_linklocal_address(
struct netif *netif, u8_t from_mac_48bit);
529 err_t netif_add_ip6_address(
struct netif *netif,
const ip6_addr_t *ip6addr, s8_t *chosen_idx);
530 #define netif_set_ip6_autoconfig_enabled(netif, action) do { if(netif) { (netif)->ip6_autoconfig_enabled = (action); }}while(0) 531 #if LWIP_IPV6_ADDRESS_LIFETIMES 532 #define netif_ip6_addr_valid_life(netif, i) \ 533 (((netif) != NULL) ? ((netif)->ip6_addr_valid_life[i]) : IP6_ADDR_LIFE_STATIC) 534 #define netif_ip6_addr_set_valid_life(netif, i, secs) \ 535 do { if (netif != NULL) { (netif)->ip6_addr_valid_life[i] = (secs); }} while (0) 536 #define netif_ip6_addr_pref_life(netif, i) \ 537 (((netif) != NULL) ? ((netif)->ip6_addr_pref_life[i]) : IP6_ADDR_LIFE_STATIC) 538 #define netif_ip6_addr_set_pref_life(netif, i, secs) \ 539 do { if (netif != NULL) { (netif)->ip6_addr_pref_life[i] = (secs); }} while (0) 540 #define netif_ip6_addr_isstatic(netif, i) \ 541 (netif_ip6_addr_valid_life((netif), (i)) == IP6_ADDR_LIFE_STATIC) 543 #define netif_ip6_addr_isstatic(netif, i) (1) 545 #if LWIP_ND6_ALLOW_RA_UPDATES 546 #define netif_mtu6(netif) ((netif)->mtu6) 548 #define netif_mtu6(netif) ((netif)->mtu) 552 #if LWIP_NETIF_USE_HINTS 553 #define NETIF_SET_HINTS(netif, netifhint) (netif)->hints = (netifhint) 554 #define NETIF_RESET_HINTS(netif) (netif)->hints = NULL 556 #define NETIF_SET_HINTS(netif, netifhint) 557 #define NETIF_RESET_HINTS(netif) 560 u8_t netif_name_to_index(
const char *
name);
561 char * netif_index_to_name(u8_t idx,
char *
name);
562 struct netif* netif_get_by_index(u8_t idx);
565 #define netif_get_index(netif) ((u8_t)((netif)->num + 1)) 566 #define NETIF_NO_INDEX (0) 576 #define LWIP_NSC_NONE 0x0000 578 #define LWIP_NSC_NETIF_ADDED 0x0001 580 #define LWIP_NSC_NETIF_REMOVED 0x0002 582 #define LWIP_NSC_LINK_CHANGED 0x0004 586 #define LWIP_NSC_STATUS_CHANGED 0x0008 588 #define LWIP_NSC_IPV4_ADDRESS_CHANGED 0x0010 590 #define LWIP_NSC_IPV4_GATEWAY_CHANGED 0x0020 592 #define LWIP_NSC_IPV4_NETMASK_CHANGED 0x0040 594 #define LWIP_NSC_IPV4_SETTINGS_CHANGED 0x0080 596 #define LWIP_NSC_IPV6_SET 0x0100 598 #define LWIP_NSC_IPV6_ADDR_STATE_CHANGED 0x0200 642 } ipv6_addr_state_changed;
655 #if LWIP_NETIF_EXT_STATUS_CALLBACK 656 struct netif_ext_callback;
657 typedef struct netif_ext_callback
660 struct netif_ext_callback* next;
661 } netif_ext_callback_t;
663 #define NETIF_DECLARE_EXT_CALLBACK(name) static netif_ext_callback_t name; 665 void netif_remove_ext_callback(netif_ext_callback_t*
callback);
668 #define NETIF_DECLARE_EXT_CALLBACK(name) 669 #define netif_add_ext_callback(callback, fn) 670 #define netif_remove_ext_callback(callback) 671 #define netif_invoke_ext_callback(netif, reason, args) err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
Function prototype for netif->input functions.
void * state
This field can be set by the PPP protocol and could point to state information for the protocol...
Args to LWIP_NSC_IPV4_ADDRESS_CHANGED|LWIP_NSC_IPV4_GATEWAY_CHANGED|LWIP_NSC_IPV4_NETMASK_CHANGED|LWI...
void(* netif_status_callback_fn)(struct netif *netif)
Function prototype for netif status- or link-callback functions.
struct netif * netif_list
The list of network interfaces.
netif_input_fn input
This function is called by the PPP service to pass a packet up the TCP/IP stack.
struct netif * next
pointer to next in linked list
u16_t mtu
maximum transfer unit (in bytes)
u16_t netif_nsc_reason_t
Extended netif status callback (NSC) reasons flags.
lwIP Options Configuration
void(* netif_ext_callback_fn)(struct netif *netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t *args)
Function used for extended netif status callbacks Note: When parsing reason argument, keep in mind that more reasons may be added in the future!
Args to LWIP_NSC_IPV6_SET callback.
const ip_addr_t * old_address
Old IPv6 address.
char name[2]
descriptive abbreviation
Args to LWIP_NSC_LINK_CHANGED callback.
Statistics API (to be used from TCPIP thread)
#define NETIF_MAX_HWADDR_LEN
Must be the maximum of all used hardware address lengths across all types of interfaces in use...
netif_linkoutput_fn linkoutput
This function is called by ethernet_output() when it wants to send a packet on the interface...
u8_t old_state
Old IPv6 address state.
u8_t num
number of this interface.
u8_t hwaddr[6U]
link level hardware address of this interface
s8_t addr_index
Index of affected IPv6 address.
Main packet buffer struct.
struct netif * netif_default
The default network interface.
const ip_addr_t * address
Affected IPv6 address.
Generic data structure used for all lwIP network interfaces.
u8_t hwaddr_len
number of bytes used in hwaddr
err_t(* netif_init_fn)(struct netif *netif)
Function prototype for netif init functions.
Argument supplied to netif_ext_callback_fn.
s8_t addr_index
Index of changed IPv6 address.
s8_t err_t
Define LWIP_ERR_T in cc.h if you want to use a different type for your platform (must be signed)...
#define LWIP_NUM_NETIF_CLIENT_DATA
LWIP_NUM_NETIF_CLIENT_DATA: Number of clients that may store data in client_data member array of stru...
Args to LWIP_NSC_STATUS_CHANGED callback.
const ip_addr_t * old_address
Old IPv4 address.
IP address structure for passing IP addresses by value.
netif_mac_filter_action
MAC Filter Actions, these are passed to a netif's igmp_mac_filter or mld_mac_filter callback function...
#define LWIP_IPV6_NUM_ADDRESSES
LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif.
Args to LWIP_NSC_IPV6_ADDR_STATE_CHANGED callback.
IP address API (common IPv4 and IPv6)
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
Function prototype for netif->linkoutput functions.