diff --git a/cores/esp8266/LwipIntfDev.h b/cores/esp8266/LwipIntfDev.h index 3354a32563..f8290d7cd6 100644 --- a/cores/esp8266/LwipIntfDev.h +++ b/cores/esp8266/LwipIntfDev.h @@ -66,6 +66,7 @@ class LwipIntfDev: public LwipIntf, public RawDev void setDefault(); + // true if interface has a valid IPv4 address bool connected() { return !!ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr)); @@ -305,8 +306,10 @@ void LwipIntfDev::netif_status_callback() { if (connected()) { - if (_default) + if (_default || (netif_default == nullptr && !ip_addr_isany(&_netif.gw))) { + // on user request, + // or if there is no current default interface, but a gateway is valid netif_set_default(&_netif); } sntp_stop(); diff --git a/tools/sdk/lib/liblwip2-1460-feat.a b/tools/sdk/lib/liblwip2-1460-feat.a index 15667a43f1..3ed56d2c2d 100644 Binary files a/tools/sdk/lib/liblwip2-1460-feat.a and b/tools/sdk/lib/liblwip2-1460-feat.a differ diff --git a/tools/sdk/lib/liblwip2-1460.a b/tools/sdk/lib/liblwip2-1460.a index aaf44366c8..7de7fadeda 100644 Binary files a/tools/sdk/lib/liblwip2-1460.a and b/tools/sdk/lib/liblwip2-1460.a differ diff --git a/tools/sdk/lib/liblwip2-536-feat.a b/tools/sdk/lib/liblwip2-536-feat.a index 73ffe5eeed..556e864256 100644 Binary files a/tools/sdk/lib/liblwip2-536-feat.a and b/tools/sdk/lib/liblwip2-536-feat.a differ diff --git a/tools/sdk/lib/liblwip2-536.a b/tools/sdk/lib/liblwip2-536.a index 1b3080ff81..f9ece4cea5 100644 Binary files a/tools/sdk/lib/liblwip2-536.a and b/tools/sdk/lib/liblwip2-536.a differ diff --git a/tools/sdk/lib/liblwip6-1460-feat.a b/tools/sdk/lib/liblwip6-1460-feat.a index 7a1edf6d3f..f50d97d2ad 100644 Binary files a/tools/sdk/lib/liblwip6-1460-feat.a and b/tools/sdk/lib/liblwip6-1460-feat.a differ diff --git a/tools/sdk/lib/liblwip6-536-feat.a b/tools/sdk/lib/liblwip6-536-feat.a index c21c9fd233..fae8152112 100644 Binary files a/tools/sdk/lib/liblwip6-536-feat.a and b/tools/sdk/lib/liblwip6-536-feat.a differ diff --git a/tools/sdk/lwip2/builder b/tools/sdk/lwip2/builder index 7421258237..450bb63c1b 160000 --- a/tools/sdk/lwip2/builder +++ b/tools/sdk/lwip2/builder @@ -1 +1 @@ -Subproject commit 7421258237b7c8f61629226961af498a0a6e0096 +Subproject commit 450bb63c1bc8b35770ca7f246945cf383569f52f diff --git a/tools/sdk/lwip2/include/glue.h b/tools/sdk/lwip2/include/glue.h index ffe84d2625..453a3830e9 100644 --- a/tools/sdk/lwip2/include/glue.h +++ b/tools/sdk/lwip2/include/glue.h @@ -118,4 +118,20 @@ err_glue_t glue2esp_linkoutput (int netif_idx, void* ref2save, void* data, size #define lwip_xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;})) #define lwip_xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") +// quickfix: workaround for definition of __PRI32(x) in inttypes.h +// it has changed with recent version of xtensa-gcc +// __INT32 is missing +// gcc-4.x: __PRI32(x) is __STRINGIFY(l##x) +// gcc-10.2.0: __PRI32(x) is __INT32 __STRINGIFY(x) +#include +#if !defined(__INT8) +#define __INT8 +#endif +#if !defined(__INT16) +#define __INT16 +#endif +#if !defined(__INT32) +#define __INT32 "l" +#endif + #endif // GLUE_H diff --git a/tools/sdk/lwip2/include/lwip-git-hash.h b/tools/sdk/lwip2/include/lwip-git-hash.h index 146c0d3110..96c8999789 100644 --- a/tools/sdk/lwip2/include/lwip-git-hash.h +++ b/tools/sdk/lwip2/include/lwip-git-hash.h @@ -1,5 +1,5 @@ // generated by makefiles/make-lwip2-hash #ifndef LWIP_HASH_H #define LWIP_HASH_H -#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258" +#define LWIP_HASH_STR "STABLE-2_1_3_RELEASE/glue:1.2-58-g450bb63" #endif // LWIP_HASH_H diff --git a/tools/sdk/lwip2/include/lwip/debug.h b/tools/sdk/lwip2/include/lwip/debug.h index baa6a40901..579fd242b2 100644 --- a/tools/sdk/lwip2/include/lwip/debug.h +++ b/tools/sdk/lwip2/include/lwip/debug.h @@ -120,9 +120,7 @@ #endif /* LWIP_NOASSERT */ #ifndef LWIP_ERROR -#ifndef LWIP_NOASSERT -#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message) -#elif defined LWIP_DEBUG +#ifdef LWIP_DEBUG #define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message)) #else #define LWIP_PLATFORM_ERROR(message) diff --git a/tools/sdk/lwip2/include/lwip/if_api.h b/tools/sdk/lwip2/include/lwip/if_api.h index 39017abd32..b7269e2a62 100644 --- a/tools/sdk/lwip2/include/lwip/if_api.h +++ b/tools/sdk/lwip2/include/lwip/if_api.h @@ -49,7 +49,9 @@ extern "C" { #endif +#ifndef IF_NAMESIZE #define IF_NAMESIZE NETIF_NAMESIZE +#endif char * lwip_if_indextoname(unsigned int ifindex, char *ifname); unsigned int lwip_if_nametoindex(const char *ifname); diff --git a/tools/sdk/lwip2/include/lwip/init.h b/tools/sdk/lwip2/include/lwip/init.h index a149be1848..6cabfc8fd4 100644 --- a/tools/sdk/lwip2/include/lwip/init.h +++ b/tools/sdk/lwip2/include/lwip/init.h @@ -54,7 +54,7 @@ extern "C" { /** x.X.x: Minor version of the stack */ #define LWIP_VERSION_MINOR 1 /** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 2 +#define LWIP_VERSION_REVISION 3 /** For release candidates, this is set to 1..254 * For official releases, this is set to 255 (LWIP_RC_RELEASE) * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ diff --git a/tools/sdk/lwip2/include/lwip/netif.h b/tools/sdk/lwip2/include/lwip/netif.h index c29a987610..89ab85d256 100644 --- a/tools/sdk/lwip2/include/lwip/netif.h +++ b/tools/sdk/lwip2/include/lwip/netif.h @@ -386,6 +386,10 @@ struct netif { #if LWIP_LOOPBACK_MAX_PBUFS u16_t loop_cnt_current; #endif /* LWIP_LOOPBACK_MAX_PBUFS */ +#if LWIP_NETIF_LOOPBACK_MULTITHREADING + /* Used if the original scheduling failed. */ + u8_t reschedule_poll; +#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ #endif /* ENABLE_LOOPBACK */ #if LWIP_IPV4 && IP_NAPT u8_t napt; @@ -454,7 +458,7 @@ void netif_set_gw(struct netif *netif, const ip4_addr_t *gw); #define netif_set_flags(netif, set_flags) do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0) #define netif_clear_flags(netif, clr_flags) do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0) -#define netif_is_flag_set(nefif, flag) (((netif)->flags & (flag)) != 0) +#define netif_is_flag_set(netif, flag) (((netif)->flags & (flag)) != 0) void netif_set_up(struct netif *netif); void netif_set_down(struct netif *netif); diff --git a/tools/sdk/lwip2/include/lwip/opt.h b/tools/sdk/lwip2/include/lwip/opt.h index 371286b6ab..410e3fffdd 100644 --- a/tools/sdk/lwip2/include/lwip/opt.h +++ b/tools/sdk/lwip2/include/lwip/opt.h @@ -1549,7 +1549,7 @@ * TCP_MSS, IP header, and link header. */ #if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__ -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) #endif /** @@ -1559,6 +1559,14 @@ #if !defined LWIP_PBUF_REF_T || defined __DOXYGEN__ #define LWIP_PBUF_REF_T u8_t #endif + +/** + * LWIP_PBUF_CUSTOM_DATA: Store private data on pbufs (e.g. timestamps) + * This extends struct pbuf so user can store custom data on every pbuf. + */ +#if !defined LWIP_PBUF_CUSTOM_DATA || defined __DOXYGEN__ +#define LWIP_PBUF_CUSTOM_DATA +#endif /** * @} */ @@ -1916,11 +1924,8 @@ /** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread, * writing from a 2nd thread and closing from a 3rd thread at the same time. - * ATTENTION: This is currently really alpha! Some requirements: - * - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from - * multiple threads at once - * - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox - * and prevent a task pending on this during/after deletion + * LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from + * multiple threads at once! */ #if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__ #define LWIP_NETCONN_FULLDUPLEX 0 @@ -2450,7 +2455,7 @@ * network startup. */ #if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__ -#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 +#define LWIP_IPV6_SEND_ROUTER_SOLICIT LWIP_IPV6 #endif /** @@ -2495,10 +2500,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** diff --git a/tools/sdk/lwip2/include/lwip/pbuf.h b/tools/sdk/lwip2/include/lwip/pbuf.h index 82902a4e98..e5daf968e8 100644 --- a/tools/sdk/lwip2/include/lwip/pbuf.h +++ b/tools/sdk/lwip2/include/lwip/pbuf.h @@ -219,6 +219,9 @@ struct pbuf { /** For incoming packets, this contains the input netif's index */ u8_t if_idx; + + /** In case the user needs to store data custom data on a pbuf */ + LWIP_PBUF_CUSTOM_DATA }; @@ -293,6 +296,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset); u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); diff --git a/tools/sdk/lwip2/include/lwip/priv/altcp_priv.h b/tools/sdk/lwip2/include/lwip/priv/altcp_priv.h index 2d3b2fdbce..d1de9b111b 100644 --- a/tools/sdk/lwip2/include/lwip/priv/altcp_priv.h +++ b/tools/sdk/lwip2/include/lwip/priv/altcp_priv.h @@ -85,6 +85,11 @@ typedef err_t (*altcp_get_tcp_addrinfo_fn)(struct altcp_pcb *conn, int local, ip typedef ip_addr_t *(*altcp_get_ip_fn)(struct altcp_pcb *conn, int local); typedef u16_t (*altcp_get_port_fn)(struct altcp_pcb *conn, int local); +#if LWIP_TCP_KEEPALIVE +typedef void (*altcp_keepalive_disable_fn)(struct altcp_pcb *conn); +typedef void (*altcp_keepalive_enable_fn)(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count); +#endif + #ifdef LWIP_DEBUG typedef enum tcp_state (*altcp_dbg_get_tcp_state_fn)(struct altcp_pcb *conn); #endif @@ -111,6 +116,10 @@ struct altcp_functions { altcp_get_tcp_addrinfo_fn addrinfo; altcp_get_ip_fn getip; altcp_get_port_fn getport; +#if LWIP_TCP_KEEPALIVE + altcp_keepalive_disable_fn keepalive_disable; + altcp_keepalive_enable_fn keepalive_enable; +#endif #ifdef LWIP_DEBUG altcp_dbg_get_tcp_state_fn dbg_get_tcp_state; #endif @@ -133,6 +142,10 @@ void altcp_default_dealloc(struct altcp_pcb *conn); err_t altcp_default_get_tcp_addrinfo(struct altcp_pcb *conn, int local, ip_addr_t *addr, u16_t *port); ip_addr_t *altcp_default_get_ip(struct altcp_pcb *conn, int local); u16_t altcp_default_get_port(struct altcp_pcb *conn, int local); +#if LWIP_TCP_KEEPALIVE +void altcp_default_keepalive_disable(struct altcp_pcb *conn); +void altcp_default_keepalive_enable(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count); +#endif #ifdef LWIP_DEBUG enum tcp_state altcp_default_dbg_get_tcp_state(struct altcp_pcb *conn); #endif diff --git a/tools/sdk/lwip2/include/lwip/prot/icmp6.h b/tools/sdk/lwip2/include/lwip/prot/icmp6.h index 3461120421..36989f6b32 100644 --- a/tools/sdk/lwip2/include/lwip/prot/icmp6.h +++ b/tools/sdk/lwip2/include/lwip/prot/icmp6.h @@ -146,6 +146,8 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +#define ICMP6_HLEN 8 + /** This is the ICMP6 header adapted for echo req/resp. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/tools/sdk/lwip2/include/lwip/prot/ip6.h b/tools/sdk/lwip2/include/lwip/prot/ip6.h index 0f6de45593..7df81edd69 100644 --- a/tools/sdk/lwip2/include/lwip/prot/ip6.h +++ b/tools/sdk/lwip2/include/lwip/prot/ip6.h @@ -44,6 +44,8 @@ extern "C" { #endif +#define IP6_MIN_MTU_LENGTH 1280 + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/tools/sdk/lwip2/include/lwipopts.h b/tools/sdk/lwip2/include/lwipopts.h index d4dc179558..508245e6c0 100644 --- a/tools/sdk/lwip2/include/lwipopts.h +++ b/tools/sdk/lwip2/include/lwipopts.h @@ -1557,7 +1557,7 @@ * TCP_MSS, IP header, and link header. */ #if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__ -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) +#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN) #endif /** @@ -1567,6 +1567,14 @@ #ifndef LWIP_PBUF_REF_T #define LWIP_PBUF_REF_T u8_t #endif + +/** + * LWIP_PBUF_CUSTOM_DATA: Store private data on pbufs (e.g. timestamps) + * This extends struct pbuf so user can store custom data on every pbuf. + */ +#if !defined LWIP_PBUF_CUSTOM_DATA || defined __DOXYGEN__ +#define LWIP_PBUF_CUSTOM_DATA +#endif /** * @} */ @@ -1924,11 +1932,8 @@ /** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread, * writing from a 2nd thread and closing from a 3rd thread at the same time. - * ATTENTION: This is currently really alpha! Some requirements: - * - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from - * multiple threads at once - * - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox - * and prevent a task pending on this during/after deletion + * LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from + * multiple threads at once! */ #if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__ #define LWIP_NETCONN_FULLDUPLEX 0 @@ -2464,7 +2469,7 @@ * network startup. */ #if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__ -#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 +#define LWIP_IPV6_SEND_ROUTER_SOLICIT LWIP_IPV6 #endif /** @@ -2509,10 +2514,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** @@ -3547,6 +3554,11 @@ -------------------------------------------------- */ +#include "lwip/debug.h" +#include "arch/cc.h" +#include "lwip-git-hash.h" +#include // settimeofday() + struct timeval + #ifndef LWIP_FEATURES #error LWIP_FEATURES must be defined #endif @@ -3584,6 +3596,19 @@ extern void lwip_hook_dhcp_parse_option(struct netif *netif, struct dhcp *dhcp, int msg_type, int option, int option_len, struct pbuf *pbuf, int option_value_offset); +#if LWIP_FEATURES +#define LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, option_len_ptr) { \ + /* https://github.com/esp8266/Arduino/issues/8223 */ \ + lwip_hook_dhcp_amend_options(netif, dhcp, state, msg, msg_type, option_len_ptr); \ + /* https://github.com/esp8266/Arduino/issues/8247 */ \ + if ((msg_type) == DHCP_DISCOVER) \ + *(option_len_ptr) = dhcp_option_hostname(*(option_len_ptr), (msg)->options, netif); \ +} + +extern void lwip_hook_dhcp_amend_options(struct netif *netif, struct dhcp *dhcp, int state, struct dhcp_msg *msg, + int msg_type, u16 *option_len_ptr); +#endif + /* -------------------------------------------------- ------------------ SNTP options ------------------ @@ -3629,11 +3654,6 @@ uint32_t SNTP_STARTUP_DELAY_FUNC; -------------------------------------------------- */ -#include "lwip/debug.h" -#include "arch/cc.h" -#include "lwip-git-hash.h" -#include // settimeofday() + struct timeval - // allow to handle special packets (user redefinable) struct pbuf; struct netif; diff --git a/tools/sdk/lwip2/include/netif/ppp/ppp_opts.h b/tools/sdk/lwip2/include/netif/ppp/ppp_opts.h index 6702bec618..479a006d10 100644 --- a/tools/sdk/lwip2/include/netif/ppp/ppp_opts.h +++ b/tools/sdk/lwip2/include/netif/ppp/ppp_opts.h @@ -44,6 +44,13 @@ #define PPPOE_SUPPORT 0 #endif +/** + * PPPOE_SCNAME_SUPPORT==1: Enable PPP Over Ethernet Service Name and Concentrator Name support + */ +#ifndef PPPOE_SCNAME_SUPPORT +#define PPPOE_SCNAME_SUPPORT 0 +#endif + /** * PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP */