Skip to content

Commit 1a9403d

Browse files
authored
lwip2 fix and update (#4729)
* interactive example: update with option for using DHCP again after using static IP * lwip2: avoid crash when IP address is set to 0(any) by dhcp not getting its lease renewal in due time * lwip2: automatically remove oldest PCBs in time-wait state, limit their number thanks to @me-no-dev 07f4d4c#diff-f8258e71e25fb9985ca3799e3d8b88ecR399 * faq: update about tcpCleanup() * lwip2: add a macro HAS_PHY_CAPTURE=1 indicating capture facility is available
1 parent 144152c commit 1a9403d

File tree

8 files changed

+45
-6
lines changed

8 files changed

+45
-6
lines changed

doc/faq/readme.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,15 @@ This error may pop up after switching between
9393
How to clear TCP PCBs in time-wait state ?
9494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9595

96-
This is needed with lwIP-v1.4, less needed with lwIP-v2 but timeout is still
97-
too high.
96+
This is not needed anymore:
97+
98+
PCBs in time-wait state are limited to 5 and removed when that number is
99+
exceeded.
100+
101+
Ref. `lwIP-v1.4 <https://github.com/esp8266/Arduino/commit/07f4d4c241df2c552899857f39a4295164f686f2#diff-f8258e71e25fb9985ca3799e3d8b88ecR399>`__,
102+
`lwIP-v2 <https://github.com/d-a-v/esp82xx-nonos-linklayer/commit/420960dfc0dbe07114f7364845836ac333bc84f7>`__
103+
104+
For reference:
98105

99106
Time-wait PCB state helps TCP not confusing two consecutive connections with the
100107
same (s-ip,s-port,d-ip,d-port) when the first is already closed but still

libraries/esp8266/examples/interactive/interactive.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void loop() {
8585
case 'n': DO(WiFi.setSleepMode(WIFI_NONE_SLEEP));
8686
case 'l': DO(WiFi.setSleepMode(WIFI_LIGHT_SLEEP));
8787
case 'm': DO(WiFi.setSleepMode(WIFI_MODEM_SLEEP));
88-
case 's': DO(WiFi.config(staticip, gateway, subnet));
89-
case 'D': DO(wifi_station_dhcpc_start());
88+
case 'S': DO(WiFi.config(staticip, gateway, subnet)); // use static address
89+
case 's': DO(WiFi.config(0u, 0u, 0u)); // back to dhcp client
9090
}
9191
}

tools/sdk/lib/liblwip2.a

5.33 KB
Binary file not shown.

tools/sdk/lib/liblwip2_1460.a

5.33 KB
Binary file not shown.

tools/sdk/lwip2/include/gluedebug.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#ifdef __cplusplus
3636
extern "C"
3737
#endif
38+
#define HAS_PHY_CAPTURE 1
3839
void (*phy_capture) (int netif_idx, const char* data, size_t len, int out, int success);
3940

4041
/////////////////////////////////////////////////////////////////////////////
+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_0_3_RELEASE/glue:arduino-2.4.1-7-g2b827f8"
4+
#define LWIP_HASH_STR "STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-10-g0c0d8c2"
55
#endif // LWIP_HASH_H

tools/sdk/lwip2/include/lwipopts.h

+31
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,7 @@
29972997

29982998
/*
29992999
--------------------------------------------------
3000+
------------- End of original lwipopts -----------
30003001
--------------------------------------------------
30013002
*/
30023003

@@ -3013,4 +3014,34 @@ struct netif;
30133014
#endif
30143015
LWIP_ERR_T lwip_unhandled_packet (struct pbuf* pbuf, struct netif* netif) __attribute__((weak));
30153016

3017+
/*
3018+
--------------------------------------------------
3019+
----------------- TIME-WAIT tweak ----------------
3020+
--------------------------------------------------
3021+
port @me-no-dev time-wait tweak
3022+
https://github.com/esp8266/Arduino/commit/07f4d4c241df2c552899857f39a4295164f686f2#diff-f8258e71e25fb9985ca3799e3d8b88ecR399
3023+
*/
3024+
3025+
void tcp_kill_timewait (void);
3026+
#define TCP_TW_LIMIT(l) \
3027+
if (l) do { \
3028+
u32_t count_plus_1 = 1; \
3029+
struct tcp_pcb* tmp = tcp_tw_pcbs; \
3030+
if (tmp) \
3031+
while ((tmp = tmp->next)) \
3032+
++count_plus_1; \
3033+
while (--count_plus_1 > (l)) \
3034+
/* kill the oldest */ \
3035+
/* pcb in TW state */ \
3036+
tcp_kill_timewait(); \
3037+
} while (0)
3038+
3039+
/**
3040+
* MEMP_NUM_TCP_PCB_TIME_WAIT: the number of TCP pcbs in TIME_WAIT state.
3041+
* (requires the LWIP_TCP option, 0 = disabled)
3042+
*/
3043+
#ifndef MEMP_NUM_TCP_PCB_TIME_WAIT
3044+
#define MEMP_NUM_TCP_PCB_TIME_WAIT 5
3045+
#endif
3046+
30163047
#endif // MYLWIPOPTS_H

0 commit comments

Comments
 (0)