Skip to content

Commit d02ea23

Browse files
committed
Update the esp-lwip to 2.2.0-release/v5.4 with appropriate wrap edits matching esp-idf branch
1 parent 41d54eb commit d02ea23

File tree

17 files changed

+413
-129
lines changed

17 files changed

+413
-129
lines changed

components/lwip/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ if(CONFIG_LWIP_ENABLE)
102102
"port/debug/lwip_debug.c"
103103
"port/sockets_ext.c"
104104
"port/freertos/sys_arch.c")
105-
106-
if (${CONFIG_LWIP_ALTCP_TLS})
107105

106+
if (${CONFIG_LWIP_ALTCP_TLS})
108107
list(APPEND srcs
109108
"lwip/src/core/altcp_alloc.c"
110109
"lwip/src/core/altcp_tcp.c"
@@ -150,7 +149,13 @@ if(CONFIG_LWIP_ENABLE)
150149
"lwip/src/netif/ppp/vj.c")
151150
endif()
152151

153-
if(NOT ${target} STREQUAL "linux")
152+
if(CONFIG_LWIP_DHCP_DOES_ARP_CHECK)
153+
list(APPEND srcs "port/acd_dhcp_check.c")
154+
elseif(CONFIG_LWIP_DHCP_DOES_ACD_CHECK)
155+
list(APPEND srcs "lwip/src/core/ipv4/acd.c")
156+
endif()
157+
158+
if(NOT ${target} STREQUAL "linux")
154159
# Support for vfs and linker fragments only for target builds
155160
set(linker_fragments linker.lf)
156161
if(CONFIG_VFS_SUPPORT_IO)
@@ -237,10 +242,6 @@ if(CONFIG_LWIP_ENABLE)
237242
idf_component_optional_requires(PRIVATE openthread)
238243
endif()
239244

240-
if(CONFIG_ETH_ENABLED)
241-
idf_component_optional_requires(PRIVATE esp_eth)
242-
endif()
243-
244245
if(CONFIG_LWIP_DHCP_RESTORE_LAST_IP)
245246
idf_component_optional_requires(PRIVATE nvs_flash)
246247
endif()

components/lwip/Kconfig

Lines changed: 98 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,19 @@ menu "LWIP"
135135

136136
config LWIP_MAX_SOCKETS
137137
int "Max number of open sockets"
138-
range 1 16
138+
range 1 253
139139
default 10
140140
help
141+
The practical maximum limit is
142+
determined by available heap memory at runtime.
143+
141144
Sockets take up a certain amount of memory, and allowing fewer
142145
sockets to be open at the same time conserves memory. Specify
143146
the maximum amount of sockets here. The valid value is from 1
144-
to 16.
147+
to 253. If using value above 61, update CMakeLists defining
148+
FD_SETSIZE to the number of sockets used plus the
149+
expected open files (minimum of +3 for stdout, stderr and stdin).
150+
145151

146152
config LWIP_USE_ONLY_LWIP_SELECT
147153
bool "Support LWIP socket select() only (DEPRECATED)"
@@ -312,13 +318,29 @@ menu "LWIP"
312318
Set TCPIP task receive mail box size. Generally bigger value means higher throughput
313319
but more memory. The value should be bigger than UDP/TCP mail box size.
314320

315-
config LWIP_DHCP_DOES_ARP_CHECK
316-
bool "DHCP: Perform ARP check on any offered address"
317-
default y
321+
choice LWIP_DHCP_CHECKS_OFFERED_ADDRESS
322+
prompt "Choose how DHCP validates offered IP"
323+
default LWIP_DHCP_DOES_ARP_CHECK
318324
depends on LWIP_IPV4
319325
help
320-
Enabling this option performs a check (via ARP request) if the offered IP address
321-
is not already in use by another host on the network.
326+
Choose the preferred way of DHCP client to check if the offered address
327+
is available:
328+
* Using Address Conflict Detection (ACD) module assures that the offered IP address
329+
is properly probed and announced before binding in DHCP. This conforms to RFC5227,
330+
but takes several seconds.
331+
* Using ARP check, we only send two ARP requests to check for replies. This process
332+
lasts 1 - 2 seconds.
333+
* No conflict detection: We directly bind the offered address.
334+
335+
config LWIP_DHCP_DOES_ARP_CHECK
336+
bool "DHCP provides simple ARP check"
337+
depends on !LWIP_AUTOIP
338+
config LWIP_DHCP_DOES_ACD_CHECK
339+
bool "DHCP provides Address Conflict Detection (ACD)"
340+
config LWIP_DHCP_DOES_NOT_CHECK_OFFERED_IP
341+
bool "DHCP does not detect conflict on the offered IP"
342+
343+
endchoice
322344

323345
config LWIP_DHCP_DISABLE_CLIENT_ID
324346
bool "DHCP: Disable Use of HW address as client identification"
@@ -411,6 +433,20 @@ menu "LWIP"
411433
Enabling this option allows DHCP server to support temporary static ARP entries
412434
for DHCP Client. This will help the DHCP server to send the DHCP OFFER and DHCP ACK using IP unicast.
413435

436+
config LWIP_DHCPS_ADD_DNS
437+
bool "Always add DNS option in DHCP responses"
438+
default y
439+
depends on LWIP_DHCPS
440+
help
441+
This allows the DNS option to be optional in the DHCP offers,
442+
depending on the server's runtime configuration.
443+
When enabled, the DHCP server will always add the DNS option to DHCP responses.
444+
If a DNS server is not explicitly configured, the server's IP address will be used
445+
as the fallback for the DNS option.
446+
When disabled, the DHCP server will only include the DNS option in responses
447+
if a DNS server has been explicitly configured.
448+
This option will be removed in IDF v6.x
449+
414450
endmenu # DHCPS
415451

416452
menuconfig LWIP_AUTOIP
@@ -708,8 +744,8 @@ menu "LWIP"
708744
int "The maximum number of pbufs queued on OOSEQ per pcb"
709745
depends on LWIP_TCP_QUEUE_OOSEQ
710746
range 0 12
711-
default 4 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP
712-
default 0 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP
747+
default 4 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND)
748+
default 0 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND)
713749
help
714750
If LWIP_TCP_OOSEQ_MAX_PBUFS = 0, TCP will not control the number of OOSEQ pbufs.
715751

@@ -765,7 +801,7 @@ menu "LWIP"
765801

766802
config LWIP_WND_SCALE
767803
bool "Support TCP window scale"
768-
depends on SPIRAM_TRY_ALLOCATE_WIFI_LWIP
804+
depends on (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND)
769805
default n
770806
help
771807
Enable this feature to support TCP window scaling.
@@ -876,13 +912,58 @@ menu "LWIP"
876912
default 0x0 if LWIP_TCPIP_TASK_AFFINITY_CPU0
877913
default 0x1 if LWIP_TCPIP_TASK_AFFINITY_CPU1
878914

915+
config LWIP_IPV6_MEMP_NUM_ND6_QUEUE
916+
int "Max number of IPv6 packets to queue during MAC resolution"
917+
depends on LWIP_IPV6
918+
range 3 20
919+
default 3
920+
help
921+
Config max number of IPv6 packets to queue during MAC resolution.
922+
923+
config LWIP_IPV6_ND6_NUM_NEIGHBORS
924+
int "Max number of entries in IPv6 neighbor cache"
925+
depends on LWIP_IPV6
926+
range 3 10
927+
default 5
928+
help
929+
Config max number of entries in IPv6 neighbor cache
930+
931+
config LWIP_IPV6_ND6_NUM_PREFIXES
932+
int "Max number of entries in IPv6 on-link prefixes cache"
933+
depends on LWIP_IPV6
934+
default 5
935+
help
936+
Maximum number of entries in IPv6 on-link prefixes cache
937+
938+
config LWIP_IPV6_ND6_NUM_ROUTERS
939+
int "Max number of entries in IPv6 default routers cache"
940+
depends on LWIP_IPV6
941+
default 3
942+
help
943+
Maximum number of entries in IPv6 default routers cache
944+
945+
config LWIP_IPV6_ND6_NUM_DESTINATIONS
946+
int "Max number of entries in IPv6 destinations cache"
947+
depends on LWIP_IPV6
948+
default 10
949+
help
950+
Maximum number of entries in IPv6 destinations cache
879951

880952
menuconfig LWIP_PPP_SUPPORT
881953
bool "Enable PPP support"
882954
default n
883955
help
884956
Enable PPP stack. Now only PPP over serial is possible.
885957

958+
config LWIP_PPP_ENABLE_IPV4
959+
bool "Enable IPV4 support for PPP connections (IPCP)"
960+
depends on LWIP_PPP_SUPPORT && LWIP_IPV4
961+
default y
962+
help
963+
Enable IPCP protocol in PPP negotiations, which assigns IPv4 addresses to the PPP client,
964+
as well as IPv4 DNS servers.
965+
You can disable this if your modem supports IPv6 only.
966+
886967
config LWIP_PPP_ENABLE_IPV6
887968
bool "Enable IPV6 support for PPP connections (IPV6CP)"
888969
depends on LWIP_PPP_SUPPORT && LWIP_IPV6
@@ -894,22 +975,6 @@ menu "LWIP"
894975
This would in turn fail the configuration for the whole link.
895976
If your modem is not responding correctly to PPP Phase Network, try to disable IPV6 support.
896977

897-
config LWIP_IPV6_MEMP_NUM_ND6_QUEUE
898-
int "Max number of IPv6 packets to queue during MAC resolution"
899-
depends on LWIP_IPV6
900-
range 3 20
901-
default 3
902-
help
903-
Config max number of IPv6 packets to queue during MAC resolution.
904-
905-
config LWIP_IPV6_ND6_NUM_NEIGHBORS
906-
int "Max number of entries in IPv6 neighbor cache"
907-
depends on LWIP_IPV6
908-
range 3 10
909-
default 5
910-
help
911-
Config max number of entries in IPv6 neighbor cache
912-
913978
config LWIP_PPP_NOTIFY_PHASE_SUPPORT
914979
bool "Enable Notify Phase Callback"
915980
depends on LWIP_PPP_SUPPORT
@@ -1304,11 +1369,15 @@ menu "LWIP"
13041369
choice LWIP_HOOK_IP6_INPUT
13051370
prompt "IPv6 packet input"
13061371
depends on LWIP_IPV6
1307-
default LWIP_HOOK_IP6_INPUT_NONE
1372+
default LWIP_HOOK_IP6_INPUT_DEFAULT
13081373
help
13091374
Enables custom IPv6 packet input.
1310-
Setting this to "default" provides weak implementation
1311-
stub that could be overwritten in application code.
1375+
Setting this to "default" provides weak IDF implementation,
1376+
which drops all incoming IPv6 traffic if the interface has no link local address.
1377+
(this default implementation is "weak" and could be still overwritten
1378+
in the application if some additional IPv6 input packet filtering is needed)
1379+
Setting this to "none" removes this default filter and conforms to the lwIP
1380+
implementation (which accepts multicasts even if the interface has no link local address)
13121381
Setting this to "custom" provides hook's declaration
13131382
only and expects the application to implement it.
13141383

components/lwip/apps/dhcpserver/dhcpserver.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
6161
#define DHCP_OPTION_BROADCAST_ADDRESS 28
6262
#define DHCP_OPTION_REQ_LIST 55
63+
#define DHCP_OPTION_CAPTIVEPORTAL_URI 114
6364
#define DHCP_OPTION_END 255
6465

6566
//#define USE_CLASS_B_NET 1
@@ -135,6 +136,7 @@ struct dhcps_t {
135136
dhcps_time_t dhcps_lease_time;
136137
dhcps_offer_t dhcps_offer;
137138
dhcps_offer_t dhcps_dns;
139+
char *dhcps_captiveportal_uri;
138140
dhcps_cb_t dhcps_cb;
139141
void* dhcps_cb_arg;
140142
struct udp_pcb *dhcps_pcb;
@@ -164,6 +166,7 @@ dhcps_t *dhcps_new(void)
164166
dhcps->dhcps_lease_time = DHCPS_LEASE_TIME_DEF;
165167
dhcps->dhcps_offer = 0xFF;
166168
dhcps->dhcps_dns = 0x00;
169+
dhcps->dhcps_captiveportal_uri = NULL;
167170
dhcps->dhcps_pcb = NULL;
168171
dhcps->state = DHCPS_HANDLE_CREATED;
169172
return dhcps;
@@ -238,6 +241,10 @@ void *dhcps_option_info(dhcps_t *dhcps, u8_t op_id, u32_t opt_len)
238241
option_arg = &dhcps->dhcps_mask;
239242
}
240243

244+
break;
245+
case CAPTIVEPORTAL_URI:
246+
option_arg = &dhcps->dhcps_captiveportal_uri;
247+
241248
break;
242249
default:
243250
break;
@@ -292,6 +299,11 @@ err_t dhcps_set_option_info(dhcps_t *dhcps, u8_t op_id, void *opt_info, u32_t op
292299
dhcps->dhcps_mask = *(ip4_addr_t *)opt_info;
293300
}
294301

302+
break;
303+
304+
case CAPTIVEPORTAL_URI:
305+
dhcps->dhcps_captiveportal_uri = (char *)opt_info;
306+
break;
295307

296308
default:
297309
break;
@@ -400,6 +412,7 @@ static u8_t *add_msg_type(u8_t *optptr, u8_t type)
400412
*******************************************************************************/
401413
static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
402414
{
415+
u32_t i;
403416
ip4_addr_t ipadd;
404417

405418
ipadd.addr = *((u32_t *) &dhcps->server_address);
@@ -441,18 +454,22 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
441454
}
442455
}
443456

444-
*optptr++ = DHCP_OPTION_DNS_SERVER;
445-
*optptr++ = 4;
446457
if (dhcps_dns_enabled(dhcps->dhcps_dns)) {
458+
*optptr++ = DHCP_OPTION_DNS_SERVER;
459+
*optptr++ = 4;
447460
*optptr++ = ip4_addr1(&dhcps->dns_server);
448461
*optptr++ = ip4_addr2(&dhcps->dns_server);
449462
*optptr++ = ip4_addr3(&dhcps->dns_server);
450463
*optptr++ = ip4_addr4(&dhcps->dns_server);
464+
#ifdef CONFIG_LWIP_DHCPS_ADD_DNS
451465
}else {
466+
*optptr++ = DHCP_OPTION_DNS_SERVER;
467+
*optptr++ = 4;
452468
*optptr++ = ip4_addr1(&ipadd);
453469
*optptr++ = ip4_addr2(&ipadd);
454470
*optptr++ = ip4_addr3(&ipadd);
455471
*optptr++ = ip4_addr4(&ipadd);
472+
#endif /* CONFIG_LWIP_DHCPS_ADD_DNS */
456473
}
457474

458475
ip4_addr_t broadcast_addr = { .addr = (ipadd.addr & dhcps->dhcps_mask.addr) | ~dhcps->dhcps_mask.addr };
@@ -468,6 +485,17 @@ static u8_t *add_offer_options(dhcps_t *dhcps, u8_t *optptr)
468485
*optptr++ = 0x05;
469486
*optptr++ = 0xdc;
470487

488+
if (dhcps->dhcps_captiveportal_uri) {
489+
size_t length = strlen(dhcps->dhcps_captiveportal_uri);
490+
491+
*optptr++ = DHCP_OPTION_CAPTIVEPORTAL_URI;
492+
*optptr++ = length;
493+
for (i = 0; i < length; i++)
494+
{
495+
*optptr++ = dhcps->dhcps_captiveportal_uri[i];
496+
}
497+
}
498+
471499
*optptr++ = DHCP_OPTION_PERFORM_ROUTER_DISCOVERY;
472500
*optptr++ = 1;
473501
*optptr++ = 0x00;
@@ -1335,6 +1363,7 @@ err_t dhcps_start(dhcps_t *dhcps, struct netif *netif, ip4_addr_t ip)
13351363

13361364
dhcps->client_address_plus.addr = dhcps->dhcps_poll.start_ip.addr;
13371365

1366+
udp_bind_netif(dhcps->dhcps_pcb, dhcps->dhcps_netif);
13381367
udp_bind(dhcps->dhcps_pcb, &netif->ip_addr, DHCPS_SERVER_PORT);
13391368
udp_recv(dhcps->dhcps_pcb, handle_dhcp, dhcps);
13401369
#if DHCPS_DEBUG

0 commit comments

Comments
 (0)