61 #ifndef __LWIP_NETIF_H__ 62 #define __LWIP_NETIF_H__ 63 #include <tinyara/config.h> 64 #include <net/ethernet.h> 66 #include <net/lwip/opt.h> 67 #ifdef CONFIG_NET_ETH_MTU 68 #define MAX_NET_DEV_MTU CONFIG_NET_ETH_MTU 70 #define MAX_NET_DEV_MTU 1500 73 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 75 #include <net/lwip/err.h> 76 #include <net/lwip/ip_addr.h> 77 #include <net/lwip/def.h> 78 #include <net/lwip/pbuf.h> 79 #include <net/lwip/stats.h> 85 #define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 93 #ifndef NETIF_MAX_HWADDR_LEN 94 #define NETIF_MAX_HWADDR_LEN 6U 109 #define NETIF_FLAG_UP 0x01U 112 #define NETIF_FLAG_BROADCAST 0x02U 118 #define NETIF_FLAG_LINK_UP 0x04U 122 #define NETIF_FLAG_ETHARP 0x08U 126 #define NETIF_FLAG_ETHERNET 0x10U 129 #define NETIF_FLAG_IGMP 0x20U 132 #define NETIF_FLAG_MLD6 0x40U 143 LWIP_NETIF_CLIENT_DATA_INDEX_AUTOIP,
146 LWIP_NETIF_CLIENT_DATA_INDEX_IGMP,
149 LWIP_NETIF_CLIENT_DATA_INDEX_MLD6,
154 #if LWIP_CHECKSUM_CTRL_PER_NETIF 156 #define NETIF_CHECKSUM_GEN_IP 0x0001 157 #define NETIF_CHECKSUM_GEN_UDP 0x0002 158 #define NETIF_CHECKSUM_GEN_TCP 0x0004 159 #define NETIF_CHECKSUM_GEN_ICMP 0x0008 160 #define NETIF_CHECKSUM_GEN_ICMP6 0x0010 161 #define NETIF_CHECKSUM_CHECK_IP 0x0100 162 #define NETIF_CHECKSUM_CHECK_UDP 0x0200 163 #define NETIF_CHECKSUM_CHECK_TCP 0x0400 164 #define NETIF_CHECKSUM_CHECK_ICMP 0x0800 165 #define NETIF_CHECKSUM_CHECK_ICMP6 0x1000 166 #define NETIF_CHECKSUM_ENABLE_ALL 0xFFFF 167 #define NETIF_CHECKSUM_DISABLE_ALL 0x0000 205 typedef err_t (*netif_output_fn)(
struct netif *
netif,
struct pbuf * p,
const ip4_addr_t * ipaddr);
217 typedef err_t (*netif_output_ip6_fn)(
struct netif * netif,
struct pbuf * p,
const ip6_addr_t * ipaddr);
229 #if LWIP_IPV4 && LWIP_IGMP 231 typedef err_t (*netif_igmp_mac_filter_fn)(
struct netif * netif,
const ip4_addr_t * group,
enum netif_mac_filter_action action);
233 #if LWIP_IPV6 && LWIP_IPV6_MLD 235 typedef err_t (*netif_mld_mac_filter_fn)(
struct netif * netif,
const ip6_addr_t * group,
enum netif_mac_filter_action action);
238 #if LWIP_DHCP || LWIP_AUTOIP || LWIP_IGMP || LWIP_IPV6_MLD || (LWIP_NUM_NETIF_CLIENT_DATA > 0) 243 #define netif_set_client_data(netif, id, data) netif_get_client_data(netif, id) = (data) 247 #define netif_get_client_data(netif, id) (netif)->client_data[(id)] 264 ip_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES];
267 u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES];
277 netif_output_fn output;
288 netif_output_ip6_fn output_ip6;
290 #if LWIP_NETIF_STATUS_CALLBACK 295 #if LWIP_NETIF_LINK_CALLBACK 300 #if LWIP_NETIF_REMOVE_CALLBACK 307 #ifdef netif_get_client_data 310 #if LWIP_IPV6_AUTOCONFIG 312 u8_t ip6_autoconfig_enabled;
314 #if LWIP_IPV6_SEND_ROUTER_SOLICIT 319 #if LWIP_NETIF_HOSTNAME 321 const char *hostname;
323 #if LWIP_CHECKSUM_CTRL_PER_NETIF 346 struct stats_mib2_netif_ctrs mib2_counters;
348 #if LWIP_IPV4 && LWIP_IGMP 351 netif_igmp_mac_filter_fn igmp_mac_filter;
353 #if LWIP_IPV6 && LWIP_IPV6_MLD 356 netif_mld_mac_filter_fn mld_mac_filter;
358 #if LWIP_NETIF_HWADDRHINT 363 struct pbuf *loop_first;
364 struct pbuf *loop_last;
365 #if LWIP_LOOPBACK_MAX_PBUFS 366 u16_t loop_cnt_current;
371 #if CONFIG_NSOCKET_DESCRIPTORS > 0 389 #ifdef CONFIG_NET_MULTIBUFFER 397 struct udp_pcb *dhcps_pcb;
402 #if LWIP_CHECKSUM_CTRL_PER_NETIF 403 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) do { \ 404 (netif)->chksum_flags = chksumflags; } while (0) 405 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) if (((netif) == NULL) || (((netif)->chksum_flags & (chksumflag)) != 0)) 407 #define NETIF_SET_CHECKSUM_CTRL(netif, chksumflags) 408 #define IF__NETIF_CHECKSUM_ENABLED(netif, chksumflag) 411 #if CONFIG_NSOCKET_DESCRIPTORS > 0 413 extern struct netif *g_netdevices;
424 struct netif *
netif_add(
struct netif *netif,
426 const ip4_addr_t * ipaddr,
const ip4_addr_t * netmask,
const ip4_addr_t * gw,
430 void netif_set_addr(
struct netif *netif,
const ip4_addr_t * ipaddr,
const ip4_addr_t * netmask,
const ip4_addr_t * gw);
443 void netif_set_ipaddr(
struct netif *netif,
const ip4_addr_t * ipaddr);
444 void netif_set_netmask(
struct netif *netif,
const ip4_addr_t * netmask);
445 void netif_set_gw(
struct netif *netif,
const ip4_addr_t * gw);
447 #define netif_ip4_addr(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->ip_addr))) 449 #define netif_ip4_netmask(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->netmask))) 451 #define netif_ip4_gw(netif) ((const ip4_addr_t*)ip_2_ip4(&((netif)->gw))) 453 #define netif_ip_addr4(netif) ((const ip_addr_t*)&((netif)->ip_addr)) 455 #define netif_ip_netmask4(netif) ((const ip_addr_t*)&((netif)->netmask)) 457 #define netif_ip_gw4(netif) ((const ip_addr_t*)&((netif)->gw)) 465 #define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) 467 #if LWIP_NETIF_STATUS_CALLBACK 470 #if LWIP_NETIF_REMOVE_CALLBACK 477 #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) 479 #if LWIP_NETIF_LINK_CALLBACK 483 #if LWIP_NETIF_HOSTNAME 485 #define netif_set_hostname(netif, name) do { if ((netif) != NULL) { (netif)->hostname = name; } } while (0) 487 #define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) 492 #define netif_set_igmp_mac_filter(netif, function) do { if ((netif) != NULL) { (netif)->igmp_mac_filter = function; } } while (0) 493 #define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) 496 #if LWIP_IPV6 && LWIP_IPV6_MLD 498 #define netif_set_mld_mac_filter(netif, function) do { if ((netif) != NULL) { (netif)->mld_mac_filter = function; } } while (0) 499 #define netif_get_mld_mac_filter(netif) (((netif) != NULL) ? ((netif)->mld_mac_filter) : NULL) 500 #define netif_mld_mac_filter(netif, addr, action) do { if ((netif) && (netif)->mld_mac_filter) { (netif)->mld_mac_filter((netif), (addr), (action)); } } while (0) 504 err_t netif_loop_output(
struct netif *netif,
struct pbuf *p);
505 void netif_poll(
struct netif *netif);
506 #if !LWIP_NETIF_LOOPBACK_MULTITHREADING 507 void netif_poll_all(
void);
511 err_t
netif_input(
struct pbuf *p,
struct netif *inp);
515 #define netif_ip_addr6(netif, i) ((const ip_addr_t*)(&((netif)->ip6_addr[i]))) 517 #define netif_ip6_addr(netif, i) ((const ip6_addr_t*)ip_2_ip6(&((netif)->ip6_addr[i]))) 518 void netif_ip6_addr_set(
struct netif *netif, s8_t addr_idx,
const ip6_addr_t * addr6);
519 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);
520 #define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[i]) 521 void netif_ip6_addr_set_state(
struct netif *netif, s8_t addr_idx, u8_t
state);
522 s8_t netif_get_ip6_addr_match(
struct netif *netif,
const ip6_addr_t * ip6addr);
523 void netif_create_ip6_linklocal_address(
struct netif *netif, u8_t from_mac_48bit);
524 err_t netif_add_ip6_address(
struct netif *netif,
const ip6_addr_t * ip6addr, s8_t * chosen_idx);
525 #define netif_set_ip6_autoconfig_enabled(netif, action) do { if (netif) { (netif)->ip6_autoconfig_enabled = (action); } } while (0) 528 #if LWIP_NETIF_HWADDRHINT 529 #define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) 531 #define NETIF_SET_HWADDRHINT(netif, hint)
int(* d_ifstate)(FAR struct netif *dev)
void * client_data[LWIP_NETIF_CLIENT_DATA_INDEX_MAX+LWIP_NUM_NETIF_CLIENT_DATA]
struct netif * netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input)
u8_t netif_alloc_client_data_id(void)
void netif_set_default(struct netif *netif)
err_t(* netif_input_fn)(struct pbuf *p, struct netif *inp)
int(* d_ifup)(FAR struct netif *dev)
int(* d_ifdown)(FAR struct netif *dev)
void netif_remove(struct netif *netif)
int(* d_txavail)(FAR struct netif *dev)
void netif_set_down(struct netif *netif)
void netif_set_link_down(struct netif *netif)
void netif_set_up(struct netif *netif)
struct netif * netif_list
void(* netif_status_callback_fn)(struct netif *netif)
err_t netif_input(struct pbuf *p, struct netif *inp)
u8_t d_buf[MAX_NET_DEV_MTU+CONFIG_NET_GUARDSIZE]
void netif_set_link_up(struct netif *netif)
err_t(* netif_init_fn)(struct netif *netif)
int(* d_txpoll)(FAR struct netif *dev)
struct netif * netif_default
u8_t hwaddr[NETIF_MAX_HWADDR_LEN]
#define NETIF_MAX_HWADDR_LEN
err_t(* netif_linkoutput_fn)(struct netif *netif, struct pbuf *p)
netif_linkoutput_fn linkoutput
lwip_internal_netif_client_data_index
struct netif * netif_find(const char *name)