Skip to content

Commit 4c07113

Browse files
authored
lwIP: v2.1.3 + dhcp fixes (#8319)
* lwIP: v2.1.3 * interface set as default when gw is valid
1 parent a05a71f commit 4c07113

21 files changed

+109
-31
lines changed

Diff for: cores/esp8266/LwipIntfDev.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class LwipIntfDev: public LwipIntf, public RawDev
6666

6767
void setDefault();
6868

69+
// true if interface has a valid IPv4 address
6970
bool connected()
7071
{
7172
return !!ip4_addr_get_u32(ip_2_ip4(&_netif.ip_addr));
@@ -305,8 +306,10 @@ void LwipIntfDev<RawDev>::netif_status_callback()
305306
{
306307
if (connected())
307308
{
308-
if (_default)
309+
if (_default || (netif_default == nullptr && !ip_addr_isany(&_netif.gw)))
309310
{
311+
// on user request,
312+
// or if there is no current default interface, but a gateway is valid
310313
netif_set_default(&_netif);
311314
}
312315
sntp_stop();

Diff for: tools/sdk/lib/liblwip2-1460-feat.a

6.88 KB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-1460.a

6 KB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-536-feat.a

6.88 KB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-536.a

6.01 KB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip6-1460-feat.a

11.9 KB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip6-536-feat.a

11.9 KB
Binary file not shown.

Diff for: tools/sdk/lwip2/include/glue.h

+16
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,20 @@ err_glue_t glue2esp_linkoutput (int netif_idx, void* ref2save, void* data, size
118118
#define lwip_xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
119119
#define lwip_xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
120120

121+
// quickfix: workaround for definition of __PRI32(x) in inttypes.h
122+
// it has changed with recent version of xtensa-gcc
123+
// __INT32 is missing
124+
// gcc-4.x: __PRI32(x) is __STRINGIFY(l##x)
125+
// gcc-10.2.0: __PRI32(x) is __INT32 __STRINGIFY(x)
126+
#include <inttypes.h>
127+
#if !defined(__INT8)
128+
#define __INT8
129+
#endif
130+
#if !defined(__INT16)
131+
#define __INT16
132+
#endif
133+
#if !defined(__INT32)
134+
#define __INT32 "l"
135+
#endif
136+
121137
#endif // GLUE_H

Diff for: tools/sdk/lwip2/include/lwip-git-hash.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// generated by makefiles/make-lwip2-hash
22
#ifndef LWIP_HASH_H
33
#define LWIP_HASH_H
4-
#define LWIP_HASH_STR "STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258"
4+
#define LWIP_HASH_STR "STABLE-2_1_3_RELEASE/glue:1.2-58-g450bb63"
55
#endif // LWIP_HASH_H

Diff for: tools/sdk/lwip2/include/lwip/debug.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@
120120
#endif /* LWIP_NOASSERT */
121121

122122
#ifndef LWIP_ERROR
123-
#ifndef LWIP_NOASSERT
124-
#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message)
125-
#elif defined LWIP_DEBUG
123+
#ifdef LWIP_DEBUG
126124
#define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message))
127125
#else
128126
#define LWIP_PLATFORM_ERROR(message)

Diff for: tools/sdk/lwip2/include/lwip/if_api.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
extern "C" {
5050
#endif
5151

52+
#ifndef IF_NAMESIZE
5253
#define IF_NAMESIZE NETIF_NAMESIZE
54+
#endif
5355

5456
char * lwip_if_indextoname(unsigned int ifindex, char *ifname);
5557
unsigned int lwip_if_nametoindex(const char *ifname);

Diff for: tools/sdk/lwip2/include/lwip/init.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern "C" {
5454
/** x.X.x: Minor version of the stack */
5555
#define LWIP_VERSION_MINOR 1
5656
/** x.x.X: Revision of the stack */
57-
#define LWIP_VERSION_REVISION 2
57+
#define LWIP_VERSION_REVISION 3
5858
/** For release candidates, this is set to 1..254
5959
* For official releases, this is set to 255 (LWIP_RC_RELEASE)
6060
* For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */

Diff for: tools/sdk/lwip2/include/lwip/netif.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ struct netif {
386386
#if LWIP_LOOPBACK_MAX_PBUFS
387387
u16_t loop_cnt_current;
388388
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
389+
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
390+
/* Used if the original scheduling failed. */
391+
u8_t reschedule_poll;
392+
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
389393
#endif /* ENABLE_LOOPBACK */
390394
#if LWIP_IPV4 && IP_NAPT
391395
u8_t napt;
@@ -454,7 +458,7 @@ void netif_set_gw(struct netif *netif, const ip4_addr_t *gw);
454458

455459
#define netif_set_flags(netif, set_flags) do { (netif)->flags = (u8_t)((netif)->flags | (set_flags)); } while(0)
456460
#define netif_clear_flags(netif, clr_flags) do { (netif)->flags = (u8_t)((netif)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)
457-
#define netif_is_flag_set(nefif, flag) (((netif)->flags & (flag)) != 0)
461+
#define netif_is_flag_set(netif, flag) (((netif)->flags & (flag)) != 0)
458462

459463
void netif_set_up(struct netif *netif);
460464
void netif_set_down(struct netif *netif);

Diff for: tools/sdk/lwip2/include/lwip/opt.h

+16-9
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@
15491549
* TCP_MSS, IP header, and link header.
15501550
*/
15511551
#if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__
1552-
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
1552+
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
15531553
#endif
15541554

15551555
/**
@@ -1559,6 +1559,14 @@
15591559
#if !defined LWIP_PBUF_REF_T || defined __DOXYGEN__
15601560
#define LWIP_PBUF_REF_T u8_t
15611561
#endif
1562+
1563+
/**
1564+
* LWIP_PBUF_CUSTOM_DATA: Store private data on pbufs (e.g. timestamps)
1565+
* This extends struct pbuf so user can store custom data on every pbuf.
1566+
*/
1567+
#if !defined LWIP_PBUF_CUSTOM_DATA || defined __DOXYGEN__
1568+
#define LWIP_PBUF_CUSTOM_DATA
1569+
#endif
15621570
/**
15631571
* @}
15641572
*/
@@ -1916,11 +1924,8 @@
19161924

19171925
/** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread,
19181926
* writing from a 2nd thread and closing from a 3rd thread at the same time.
1919-
* ATTENTION: This is currently really alpha! Some requirements:
1920-
* - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from
1921-
* multiple threads at once
1922-
* - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox
1923-
* and prevent a task pending on this during/after deletion
1927+
* LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from
1928+
* multiple threads at once!
19241929
*/
19251930
#if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__
19261931
#define LWIP_NETCONN_FULLDUPLEX 0
@@ -2450,7 +2455,7 @@
24502455
* network startup.
24512456
*/
24522457
#if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__
2453-
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
2458+
#define LWIP_IPV6_SEND_ROUTER_SOLICIT LWIP_IPV6
24542459
#endif
24552460

24562461
/**
@@ -2495,10 +2500,12 @@
24952500

24962501
/**
24972502
* LWIP_ICMP6_DATASIZE: bytes from original packet to send back in
2498-
* ICMPv6 error messages.
2503+
* ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH)
2504+
* ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST,
2505+
* so override this only if you absolutely have to!
24992506
*/
25002507
#if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__
2501-
#define LWIP_ICMP6_DATASIZE 8
2508+
#define LWIP_ICMP6_DATASIZE 0
25022509
#endif
25032510

25042511
/**

Diff for: tools/sdk/lwip2/include/lwip/pbuf.h

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ struct pbuf {
219219

220220
/** For incoming packets, this contains the input netif's index */
221221
u8_t if_idx;
222+
223+
/** In case the user needs to store data custom data on a pbuf */
224+
LWIP_PBUF_CUSTOM_DATA
222225
};
223226

224227

@@ -293,6 +296,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail);
293296
void pbuf_chain(struct pbuf *head, struct pbuf *tail);
294297
struct pbuf *pbuf_dechain(struct pbuf *p);
295298
err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from);
299+
err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset);
296300
u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
297301
void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset);
298302
err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);

Diff for: tools/sdk/lwip2/include/lwip/priv/altcp_priv.h

+13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ typedef err_t (*altcp_get_tcp_addrinfo_fn)(struct altcp_pcb *conn, int local, ip
8585
typedef ip_addr_t *(*altcp_get_ip_fn)(struct altcp_pcb *conn, int local);
8686
typedef u16_t (*altcp_get_port_fn)(struct altcp_pcb *conn, int local);
8787

88+
#if LWIP_TCP_KEEPALIVE
89+
typedef void (*altcp_keepalive_disable_fn)(struct altcp_pcb *conn);
90+
typedef void (*altcp_keepalive_enable_fn)(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count);
91+
#endif
92+
8893
#ifdef LWIP_DEBUG
8994
typedef enum tcp_state (*altcp_dbg_get_tcp_state_fn)(struct altcp_pcb *conn);
9095
#endif
@@ -111,6 +116,10 @@ struct altcp_functions {
111116
altcp_get_tcp_addrinfo_fn addrinfo;
112117
altcp_get_ip_fn getip;
113118
altcp_get_port_fn getport;
119+
#if LWIP_TCP_KEEPALIVE
120+
altcp_keepalive_disable_fn keepalive_disable;
121+
altcp_keepalive_enable_fn keepalive_enable;
122+
#endif
114123
#ifdef LWIP_DEBUG
115124
altcp_dbg_get_tcp_state_fn dbg_get_tcp_state;
116125
#endif
@@ -133,6 +142,10 @@ void altcp_default_dealloc(struct altcp_pcb *conn);
133142
err_t altcp_default_get_tcp_addrinfo(struct altcp_pcb *conn, int local, ip_addr_t *addr, u16_t *port);
134143
ip_addr_t *altcp_default_get_ip(struct altcp_pcb *conn, int local);
135144
u16_t altcp_default_get_port(struct altcp_pcb *conn, int local);
145+
#if LWIP_TCP_KEEPALIVE
146+
void altcp_default_keepalive_disable(struct altcp_pcb *conn);
147+
void altcp_default_keepalive_enable(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count);
148+
#endif
136149
#ifdef LWIP_DEBUG
137150
enum tcp_state altcp_default_dbg_get_tcp_state(struct altcp_pcb *conn);
138151
#endif

Diff for: tools/sdk/lwip2/include/lwip/prot/icmp6.h

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ PACK_STRUCT_END
146146
# include "arch/epstruct.h"
147147
#endif
148148

149+
#define ICMP6_HLEN 8
150+
149151
/** This is the ICMP6 header adapted for echo req/resp. */
150152
#ifdef PACK_STRUCT_USE_INCLUDES
151153
# include "arch/bpstruct.h"

Diff for: tools/sdk/lwip2/include/lwip/prot/ip6.h

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
extern "C" {
4545
#endif
4646

47+
#define IP6_MIN_MTU_LENGTH 1280
48+
4749
/** This is the packed version of ip6_addr_t,
4850
used in network headers that are itself packed */
4951
#ifdef PACK_STRUCT_USE_INCLUDES

Diff for: tools/sdk/lwip2/include/lwipopts.h

+34-14
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@
15571557
* TCP_MSS, IP header, and link header.
15581558
*/
15591559
#if !defined PBUF_POOL_BUFSIZE || defined __DOXYGEN__
1560-
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
1560+
#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)
15611561
#endif
15621562

15631563
/**
@@ -1567,6 +1567,14 @@
15671567
#ifndef LWIP_PBUF_REF_T
15681568
#define LWIP_PBUF_REF_T u8_t
15691569
#endif
1570+
1571+
/**
1572+
* LWIP_PBUF_CUSTOM_DATA: Store private data on pbufs (e.g. timestamps)
1573+
* This extends struct pbuf so user can store custom data on every pbuf.
1574+
*/
1575+
#if !defined LWIP_PBUF_CUSTOM_DATA || defined __DOXYGEN__
1576+
#define LWIP_PBUF_CUSTOM_DATA
1577+
#endif
15701578
/**
15711579
* @}
15721580
*/
@@ -1924,11 +1932,8 @@
19241932

19251933
/** LWIP_NETCONN_FULLDUPLEX==1: Enable code that allows reading from one thread,
19261934
* writing from a 2nd thread and closing from a 3rd thread at the same time.
1927-
* ATTENTION: This is currently really alpha! Some requirements:
1928-
* - LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from
1929-
* multiple threads at once
1930-
* - sys_mbox_free() has to unblock receive tasks waiting on recvmbox/acceptmbox
1931-
* and prevent a task pending on this during/after deletion
1935+
* LWIP_NETCONN_SEM_PER_THREAD==1 is required to use one socket/netconn from
1936+
* multiple threads at once!
19321937
*/
19331938
#if !defined LWIP_NETCONN_FULLDUPLEX || defined __DOXYGEN__
19341939
#define LWIP_NETCONN_FULLDUPLEX 0
@@ -2464,7 +2469,7 @@
24642469
* network startup.
24652470
*/
24662471
#if !defined LWIP_IPV6_SEND_ROUTER_SOLICIT || defined __DOXYGEN__
2467-
#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1
2472+
#define LWIP_IPV6_SEND_ROUTER_SOLICIT LWIP_IPV6
24682473
#endif
24692474

24702475
/**
@@ -2509,10 +2514,12 @@
25092514

25102515
/**
25112516
* LWIP_ICMP6_DATASIZE: bytes from original packet to send back in
2512-
* ICMPv6 error messages.
2517+
* ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH)
2518+
* ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST,
2519+
* so override this only if you absolutely have to!
25132520
*/
25142521
#if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__
2515-
#define LWIP_ICMP6_DATASIZE 8
2522+
#define LWIP_ICMP6_DATASIZE 0
25162523
#endif
25172524

25182525
/**
@@ -3547,6 +3554,11 @@
35473554
--------------------------------------------------
35483555
*/
35493556

3557+
#include "lwip/debug.h"
3558+
#include "arch/cc.h"
3559+
#include "lwip-git-hash.h"
3560+
#include <sys/time.h> // settimeofday() + struct timeval
3561+
35503562
#ifndef LWIP_FEATURES
35513563
#error LWIP_FEATURES must be defined
35523564
#endif
@@ -3584,6 +3596,19 @@ extern void lwip_hook_dhcp_parse_option(struct netif *netif, struct dhcp *dhcp,
35843596
int msg_type, int option, int option_len, struct pbuf *pbuf,
35853597
int option_value_offset);
35863598

3599+
#if LWIP_FEATURES
3600+
#define LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, state, msg, msg_type, option_len_ptr) { \
3601+
/* https://github.com/esp8266/Arduino/issues/8223 */ \
3602+
lwip_hook_dhcp_amend_options(netif, dhcp, state, msg, msg_type, option_len_ptr); \
3603+
/* https://github.com/esp8266/Arduino/issues/8247 */ \
3604+
if ((msg_type) == DHCP_DISCOVER) \
3605+
*(option_len_ptr) = dhcp_option_hostname(*(option_len_ptr), (msg)->options, netif); \
3606+
}
3607+
3608+
extern void lwip_hook_dhcp_amend_options(struct netif *netif, struct dhcp *dhcp, int state, struct dhcp_msg *msg,
3609+
int msg_type, u16 *option_len_ptr);
3610+
#endif
3611+
35873612
/*
35883613
--------------------------------------------------
35893614
------------------ SNTP options ------------------
@@ -3629,11 +3654,6 @@ uint32_t SNTP_STARTUP_DELAY_FUNC;
36293654
--------------------------------------------------
36303655
*/
36313656

3632-
#include "lwip/debug.h"
3633-
#include "arch/cc.h"
3634-
#include "lwip-git-hash.h"
3635-
#include <sys/time.h> // settimeofday() + struct timeval
3636-
36373657
// allow to handle special packets (user redefinable)
36383658
struct pbuf;
36393659
struct netif;

Diff for: tools/sdk/lwip2/include/netif/ppp/ppp_opts.h

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
#define PPPOE_SUPPORT 0
4545
#endif
4646

47+
/**
48+
* PPPOE_SCNAME_SUPPORT==1: Enable PPP Over Ethernet Service Name and Concentrator Name support
49+
*/
50+
#ifndef PPPOE_SCNAME_SUPPORT
51+
#define PPPOE_SCNAME_SUPPORT 0
52+
#endif
53+
4754
/**
4855
* PPPOL2TP_SUPPORT==1: Enable PPP Over L2TP
4956
*/

0 commit comments

Comments
 (0)