Skip to content

Commit 3b0c6e2

Browse files
committed
Updates and prepares to build for idf-release/v5.1
1 parent d91332f commit 3b0c6e2

File tree

11 files changed

+133
-21
lines changed

11 files changed

+133
-21
lines changed

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
env:
106106
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
107107
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}
108-
run: bash ./build.sh
108+
run: bash ./build.sh -I release/v5.1 -A idf-release/v5.1
109109
- name: Release
110110
uses: jason2866/[email protected]
111111
with:

components/lwip/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ set(srcs
100100
"port/debug/lwip_debug.c"
101101
"port/sockets_ext.c"
102102
"port/freertos/sys_arch.c")
103-
if (${CONFIG_LWIP_ALTCP_TLS})
104103

104+
if (${CONFIG_LWIP_ALTCP_TLS})
105105
list(APPEND srcs
106106
"lwip/src/core/altcp_alloc.c"
107107
"lwip/src/core/altcp_tcp.c"
@@ -115,6 +115,7 @@ if (${CONFIG_LWIP_ALTCP_TLS})
115115

116116
set(requires mbedtls)
117117
endif()
118+
118119
if(CONFIG_LWIP_PPP_SUPPORT)
119120
list(APPEND srcs
120121
"lwip/src/netif/ppp/auth.c"
@@ -147,6 +148,10 @@ if(CONFIG_LWIP_PPP_SUPPORT)
147148
"lwip/src/netif/ppp/polarssl/md4.c"
148149
"lwip/src/netif/ppp/polarssl/md5.c"
149150
"lwip/src/netif/ppp/polarssl/sha1.c")
151+
152+
if(CONFIG_LWIP_NETIF_API)
153+
list(APPEND srcs "port/if_index.c")
154+
endif()
150155
endif()
151156

152157
if(NOT ${target} STREQUAL "linux")

components/lwip/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,27 @@ menu "LWIP"
837837
default 0x1 if LWIP_TCPIP_TASK_AFFINITY_CPU1
838838

839839

840+
config LWIP_IPV6_ND6_NUM_PREFIXES
841+
int "Max number of entries in IPv6 on-link prefixes cache"
842+
depends on LWIP_IPV6
843+
default 5
844+
help
845+
Maximum number of entries in IPv6 on-link prefixes cache
846+
847+
config LWIP_IPV6_ND6_NUM_ROUTERS
848+
int "Max number of entries in IPv6 default routers cache"
849+
depends on LWIP_IPV6
850+
default 3
851+
help
852+
Maximum number of entries in IPv6 default routers cache
853+
854+
config LWIP_IPV6_ND6_NUM_DESTINATIONS
855+
int "Max number of entries in IPv6 destinations cache"
856+
depends on LWIP_IPV6
857+
default 10
858+
help
859+
Maximum number of entries in IPv6 destinations cache
860+
840861
menuconfig LWIP_PPP_SUPPORT
841862
bool "Enable PPP support"
842863
default n

components/lwip/apps/dhcpserver/dhcpserver.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -1331,7 +1331,7 @@ static void kill_oldest_dhcps_pool(dhcps_t *dhcps)
13311331
assert(pre != NULL && pre->pnext != NULL); // Expect the list to have at least 2 nodes
13321332
p = pre->pnext;
13331333
minpre = pre;
1334-
minp = p;
1334+
minp = pre;
13351335

13361336
while (p != NULL) {
13371337
pdhcps_pool = p->pnode;
@@ -1345,8 +1345,11 @@ static void kill_oldest_dhcps_pool(dhcps_t *dhcps)
13451345
pre = p;
13461346
p = p->pnext;
13471347
}
1348-
1349-
minpre->pnext = minp->pnext;
1348+
if (minp == dhcps->plist) {
1349+
dhcps->plist = minp->pnext;
1350+
} else {
1351+
minpre->pnext = minp->pnext;
1352+
}
13501353
free(minp->pnode);
13511354
minp->pnode = NULL;
13521355
free(minp);

components/lwip/apps/ping/ping_sock.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -35,6 +35,8 @@ const static char *TAG = "ping_sock";
3535
#define PING_FLAGS_INIT (1 << 0)
3636
#define PING_FLAGS_START (1 << 1)
3737

38+
#define IP_ICMP_HDR_SIZE (64) // 64 bytes are enough to cover IP header and ICMP header
39+
3840
typedef struct {
3941
int sock;
4042
struct sockaddr_storage target_addr;
@@ -85,50 +87,54 @@ static esp_err_t esp_ping_send(esp_ping_t *ep)
8587

8688
static int esp_ping_receive(esp_ping_t *ep)
8789
{
88-
char buf[64]; // 64 bytes are enough to cover IP header and ICMP header
90+
char buf[IP_ICMP_HDR_SIZE];
8991
int len = 0;
9092
struct sockaddr_storage from;
9193
int fromlen = sizeof(from);
9294
uint16_t data_head = 0;
95+
ip_addr_t recv_addr;
96+
ip_addr_copy(recv_addr, *IP_ADDR_ANY);
9397

9498
while ((len = recvfrom(ep->sock, buf, sizeof(buf), 0, (struct sockaddr *)&from, (socklen_t *)&fromlen)) > 0) {
9599
#if CONFIG_LWIP_IPV4
96100
if (from.ss_family == AF_INET) {
97101
// IPv4
98102
struct sockaddr_in *from4 = (struct sockaddr_in *)&from;
99-
inet_addr_to_ip4addr(ip_2_ip4(&ep->recv_addr), &from4->sin_addr);
100-
IP_SET_TYPE_VAL(ep->recv_addr, IPADDR_TYPE_V4);
103+
inet_addr_to_ip4addr(ip_2_ip4(&recv_addr), &from4->sin_addr);
104+
IP_SET_TYPE_VAL(recv_addr, IPADDR_TYPE_V4);
101105
data_head = (uint16_t)(sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr));
102106
}
103107
#endif
104108
#if CONFIG_LWIP_IPV6
105109
if (from.ss_family == AF_INET6) {
106110
// IPv6
107111
struct sockaddr_in6 *from6 = (struct sockaddr_in6 *)&from;
108-
inet6_addr_to_ip6addr(ip_2_ip6(&ep->recv_addr), &from6->sin6_addr);
109-
IP_SET_TYPE_VAL(ep->recv_addr, IPADDR_TYPE_V6);
112+
inet6_addr_to_ip6addr(ip_2_ip6(&recv_addr), &from6->sin6_addr);
113+
IP_SET_TYPE_VAL(recv_addr, IPADDR_TYPE_V6);
110114
data_head = (uint16_t)(sizeof(struct ip6_hdr) + sizeof(struct icmp6_echo_hdr));
111115
}
112116
#endif
113117
if (len >= data_head) {
114118
#if CONFIG_LWIP_IPV4
115-
if (IP_IS_V4_VAL(ep->recv_addr)) { // Currently we process IPv4
119+
if (IP_IS_V4_VAL(recv_addr)) { // Currently we process IPv4
116120
struct ip_hdr *iphdr = (struct ip_hdr *)buf;
117-
struct icmp_echo_hdr *iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL(iphdr) * 4));
121+
struct icmp_echo_hdr *iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL_BYTES(iphdr)));
118122
if ((iecho->id == ep->packet_hdr->id) && (iecho->seqno == ep->packet_hdr->seqno)) {
123+
ip_addr_copy(ep->recv_addr, recv_addr);
119124
ep->received++;
120-
ep->ttl = iphdr->_ttl;
121-
ep->tos = iphdr->_tos;
125+
ep->ttl = IPH_TTL(iphdr);
126+
ep->tos = IPH_TOS(iphdr);
122127
ep->recv_len = lwip_ntohs(IPH_LEN(iphdr)) - data_head; // The data portion of ICMP
123128
return len;
124129
}
125130
}
126131
#endif // CONFIG_LWIP_IPV4
127132
#if CONFIG_LWIP_IPV6
128-
if (IP_IS_V6_VAL(ep->recv_addr)) { // Currently we process IPv6
133+
if (IP_IS_V6_VAL(recv_addr)) { // Currently we process IPv6
129134
struct ip6_hdr *iphdr = (struct ip6_hdr *)buf;
130135
struct icmp6_echo_hdr *iecho6 = (struct icmp6_echo_hdr *)(buf + sizeof(struct ip6_hdr)); // IPv6 head length is 40
131136
if ((iecho6->id == ep->packet_hdr->id) && (iecho6->seqno == ep->packet_hdr->seqno)) {
137+
ip_addr_copy(ep->recv_addr, recv_addr);
132138
ep->received++;
133139
ep->recv_len = IP6H_PLEN(iphdr) - sizeof(struct icmp6_echo_hdr); //The data portion of ICMPv6
134140
return len;

components/lwip/apps/sntp/sntp.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -243,6 +243,20 @@ const ip_addr_t* esp_sntp_getserver(u8_t idx)
243243
return sntp_getserver(idx);
244244
}
245245

246+
uint8_t esp_sntp_getreachability(uint8_t idx)
247+
{
248+
#if SNTP_MONITOR_SERVER_REACHABILITY
249+
return sntp_getreachability(idx);
250+
#endif
251+
LWIP_ERROR("sntp_getreachability() in not enabled in lwipopts", false, );
252+
return 0;
253+
}
254+
255+
esp_sntp_operatingmode_t esp_sntp_getoperatingmode(void)
256+
{
257+
return (esp_sntp_operatingmode_t)sntp_getoperatingmode();
258+
}
259+
246260
#if LWIP_DHCP_GET_NTP_SRV
247261
static void do_servermode_dhcp(void* ctx)
248262
{

components/lwip/include/apps/esp_sntp.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -218,6 +218,20 @@ const ip_addr_t* esp_sntp_getserver(u8_t idx);
218218
*/
219219
bool esp_sntp_enabled(void);
220220

221+
/**
222+
* @brief Gets the server reachability shift register as described in RFC 5905.
223+
* @param idx Index of the SNTP server
224+
* @return reachability shift register
225+
*/
226+
uint8_t esp_sntp_getreachability(uint8_t idx);
227+
228+
/**
229+
* @brief Get the configured operating mode
230+
*
231+
* @return operating mode enum
232+
*/
233+
esp_sntp_operatingmode_t esp_sntp_getoperatingmode(void);
234+
221235
#if LWIP_DHCP_GET_NTP_SRV
222236
/**
223237
* @brief Enable acquiring SNTP server from DHCP
@@ -269,6 +283,16 @@ const ip_addr_t* sntp_getserver(u8_t idx)
269283
return esp_sntp_getserver(idx);
270284
}
271285

286+
static inline uint8_t sntp_getreachability(uint8_t idx)
287+
{
288+
return esp_sntp_getreachability(idx);
289+
}
290+
291+
static inline esp_sntp_operatingmode_t sntp_getoperatingmode(void)
292+
{
293+
return esp_sntp_getoperatingmode();
294+
}
295+
272296
#endif /* ESP_LWIP_COMPONENT_BUILD */
273297

274298

components/lwip/lwip

components/lwip/port/if_index.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "lwip/if_api.h"
8+
9+
unsigned int if_nametoindex(const char *ifname)
10+
{
11+
return lwip_if_nametoindex(ifname);
12+
}
13+
14+
char *if_indextoname(unsigned int ifindex, char *ifname)
15+
{
16+
return lwip_if_indextoname(ifindex, ifname);
17+
}

components/lwip/port/include/lwipopts.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,20 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
12501250
*/
12511251
#define LWIP_ND6_NUM_NEIGHBORS CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS
12521252

1253+
/**
1254+
* LWIP_ND6_NUM_PREFIXES: Maximum number of entries in IPv6 on-link prefixes cache
1255+
*/
1256+
#define LWIP_ND6_NUM_PREFIXES CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES
1257+
1258+
/**
1259+
* LWIP_ND6_NUM_ROUTERS: Maximum number of entries in IPv6 default routers cache
1260+
*/
1261+
#define LWIP_ND6_NUM_ROUTERS CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS
1262+
1263+
/**
1264+
* LWIP_ND6_NUM_DESTINATIONS: Maximum number of entries in IPv6 destinations cache
1265+
*/
1266+
#define LWIP_ND6_NUM_DESTINATIONS CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS
12531267
/*
12541268
---------------------------------------
12551269
---------- Hook options ---------------

components/lwip/test_apps/main/lwip_test.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -294,8 +294,16 @@ void test_sntp_timestamps(int year, bool msb_flag)
294294
localtime_r(&now, &timeinfo);
295295
TEST_ASSERT_EQUAL(year, 1900 + timeinfo.tm_year);
296296

297+
// Check that the server 0 was reachable
298+
TEST_ASSERT_EQUAL(1, esp_sntp_getreachability(0));
297299
// close the SNTP and the fake server
298300
esp_sntp_stop();
301+
302+
// Test some other SNTP APIs
303+
TEST_ASSERT_EQUAL(0, esp_sntp_getreachability(0));
304+
TEST_ASSERT_EQUAL(ESP_SNTP_OPMODE_POLL, esp_sntp_getoperatingmode());
305+
const ip_addr_t *server_ip = esp_sntp_getserver(0);
306+
TEST_ASSERT_EQUAL(PP_HTONL(IPADDR_LOOPBACK), server_ip->u_addr.ip4.addr);
299307
close(sock);
300308
}
301309

0 commit comments

Comments
 (0)