Skip to content

Commit 4de72d4

Browse files
committed
chore: update to v2.1.3_230818 modified by ST
from: https://github.com/STMicroelectronics/stm32_mw_lwip Signed-off-by: Frederic Pillon <[email protected]>
1 parent e779210 commit 4de72d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+548
-291
lines changed

Diff for: FEATURES

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems.
2+
3+
The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM.
4+
5+
Main features include:
6+
- Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0)
7+
- DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler)
8+
- APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API
9+
- Extended features: IP forwarding over multiple network interfaces
10+
- Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0)
11+
- Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
## Version
99

10-
This library is based on the version 2.1.2 of the LwIP stack modified by ST: https://github.com/STMicroelectronics/stm32_mw_lwip
10+
This library is based on the LwIP stack modified by ST: [stm32_mw_lwip](https://github.com/STMicroelectronics/stm32_mw_lwip) version [v2.1.3_230818](https://github.com/STMicroelectronics/stm32_mw_lwip/releases/tag/v2.1.3_230818).

Diff for: SECURITY.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Report potential product security vulnerabilities
2+
3+
ST places a high priority on security, and our Product Security Incident
4+
Response Team (PSIRT) is committed to rapidly addressing potential security
5+
vulnerabilities affecting our products. PSIRT's long history and vast experience
6+
in security allows ST to perform clear analyses and provide appropriate guidance
7+
on mitigations and solutions when applicable.
8+
9+
If you wish to report potential security vulnerabilities regarding our products,
10+
**please do not report them through public GitHub issues.** Instead, we
11+
encourage you to report them to our ST PSIRT following the process described at:
12+
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
13+
14+
### IMPORTANT - READ CAREFULLY:
15+
16+
STMicroelectronics International N.V., on behalf of itself, its affiliates and
17+
subsidiaries, (collectively “ST”) takes all potential security vulnerability
18+
reports or other related communications (“Report(s)”) seriously. In order to
19+
review Your Report (the terms “You” and “Yours” include your employer, and all
20+
affiliates, subsidiaries and related persons or entities) and take actions as
21+
deemed appropriate, ST requires that we have the rights and Your permission to
22+
do so.
23+
24+
As such, by submitting Your Report to ST, You agree that You have the right to
25+
do so, and You grant to ST the rights to use the Report for purposes related to
26+
security vulnerability analysis, testing, correction, patching, reporting and
27+
any other related purpose or function.
28+
29+
By submitting Your Report, You agree that ST’s
30+
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
31+
applies to all related communications.

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duino LwIP
2-
version=2.1.2
2+
version=2.1.3
33
author=Adam Dunkels <[email protected]>
44
maintainer=See url
55
sentence=A Lightweight TCP/IP stack

Diff for: src/api/api_lib.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ netconn_prepare_delete(struct netconn *conn)
201201

202202
API_MSG_VAR_ALLOC(msg);
203203
API_MSG_VAR_REF(msg).conn = conn;
204+
#if LWIP_TCP
204205
#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
205206
/* get the time we started, which is later compared to
206207
sys_now() + conn->send_timeout */
207208
API_MSG_VAR_REF(msg).msg.sd.time_started = sys_now();
208209
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
209-
#if LWIP_TCP
210210
API_MSG_VAR_REF(msg).msg.sd.polls_left =
211211
((LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT + TCP_SLOW_INTERVAL - 1) / TCP_SLOW_INTERVAL) + 1;
212-
#endif /* LWIP_TCP */
213212
#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
213+
#endif /* LWIP_TCP */
214214
err = netconn_apimsg(lwip_netconn_do_delconn, &API_MSG_VAR_REF(msg));
215215
API_MSG_VAR_FREE(msg);
216216

@@ -500,7 +500,7 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
500500

501501
NETCONN_MBOX_WAITING_INC(conn);
502502
if (netconn_is_nonblocking(conn)) {
503-
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_ARCH_TIMEOUT) {
503+
if (sys_arch_mbox_tryfetch(&conn->acceptmbox, &accept_ptr) == SYS_MBOX_EMPTY) {
504504
API_MSG_VAR_FREE_ACCEPT(msg);
505505
NETCONN_MBOX_WAITING_DEC(conn);
506506
return ERR_WOULDBLOCK;
@@ -597,7 +597,7 @@ netconn_recv_data(struct netconn *conn, void **new_buf, u8_t apiflags)
597597
NETCONN_MBOX_WAITING_INC(conn);
598598
if (netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK) ||
599599
(conn->flags & NETCONN_FLAG_MBOXCLOSED) || (conn->pending_err != ERR_OK)) {
600-
if (sys_arch_mbox_tryfetch(&conn->recvmbox, &buf) == SYS_ARCH_TIMEOUT) {
600+
if (sys_arch_mbox_tryfetch(&conn->recvmbox, &buf) == SYS_MBOX_EMPTY) {
601601
err_t err;
602602
NETCONN_MBOX_WAITING_DEC(conn);
603603
err = netconn_err(conn);
@@ -1346,7 +1346,7 @@ void
13461346
netconn_thread_init(void)
13471347
{
13481348
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
1349-
if ((sem == NULL) || !sys_sem_valid(sem)) {
1349+
if (!sys_sem_valid(sem)) {
13501350
/* call alloc only once */
13511351
LWIP_NETCONN_THREAD_SEM_ALLOC();
13521352
LWIP_ASSERT("LWIP_NETCONN_THREAD_SEM_ALLOC() failed", sys_sem_valid(LWIP_NETCONN_THREAD_SEM_GET()));
@@ -1357,7 +1357,7 @@ void
13571357
netconn_thread_cleanup(void)
13581358
{
13591359
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
1360-
if ((sem != NULL) && sys_sem_valid(sem)) {
1360+
if (sys_sem_valid(sem)) {
13611361
/* call free only once */
13621362
LWIP_NETCONN_THREAD_SEM_FREE();
13631363
}

Diff for: src/api/api_msg.c

+3
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@ netconn_alloc(enum netconn_type t, netconn_callback callback)
716716
conn->pending_err = ERR_OK;
717717
conn->type = t;
718718
conn->pcb.tcp = NULL;
719+
#if LWIP_NETCONN_FULLDUPLEX
720+
conn->mbox_threads_waiting = 0;
721+
#endif
719722

720723
/* If all sizes are the same, every compiler should optimize this switch to nothing */
721724
switch (NETCONNTYPE_GROUP(t)) {

Diff for: src/api/netdb.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ lwip_gethostbyname(const char *name)
128128
if (s_hostent.h_addr_list != NULL) {
129129
u8_t idx;
130130
for (idx = 0; s_hostent.h_addr_list[idx]; idx++) {
131-
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i] == %p\n", idx, s_hostent.h_addr_list[idx]));
132-
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa((ip_addr_t *)s_hostent.h_addr_list[idx])));
131+
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa(s_phostent_addr[idx])));
133132
}
134133
}
135134
#endif /* DNS_DEBUG */
@@ -306,7 +305,11 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
306305
/* service name specified: convert to port number
307306
* @todo?: currently, only ASCII integers (port numbers) are supported (AI_NUMERICSERV)! */
308307
port_nr = atoi(servname);
309-
if ((port_nr <= 0) || (port_nr > 0xffff)) {
308+
if (port_nr == 0 && (servname[0] != '0')) {
309+
/* atoi failed - service was not numeric */
310+
return EAI_SERVICE;
311+
}
312+
if ((port_nr < 0) || (port_nr > 0xffff)) {
310313
return EAI_SERVICE;
311314
}
312315
}

Diff for: src/api/sockets.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
688688
err = netconn_peer(newconn, &naddr, &port);
689689
if (err != ERR_OK) {
690690
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err));
691-
netconn_delete(newconn);
692691
free_socket(nsock, 1);
693692
sock_set_errno(sock, err_to_errno(err));
694693
done_socket(sock);
@@ -2073,7 +2072,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
20732072
/* Call lwip_selscan again: there could have been events between
20742073
the last scan (without us on the list) and putting us on the list! */
20752074
nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset);
2076-
if (!nready) {
2075+
if (nready < 0) {
2076+
set_errno(EBADF);
2077+
} else if (!nready) {
20772078
/* Still none ready, just wait to be woken */
20782079
if (timeout == 0) {
20792080
/* Wait forever */
@@ -2102,15 +2103,15 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
21022103
(exceptset && FD_ISSET(i, exceptset))) {
21032104
struct lwip_sock *sock;
21042105
SYS_ARCH_PROTECT(lev);
2105-
sock = tryget_socket_unconn_locked(i);
2106+
sock = tryget_socket_unconn_nouse(i);
2107+
LWIP_ASSERT("socket gone at the end of select", sock != NULL);
21062108
if (sock != NULL) {
21072109
/* for now, handle select_waiting==0... */
21082110
LWIP_ASSERT("sock->select_waiting > 0", sock->select_waiting > 0);
21092111
if (sock->select_waiting > 0) {
21102112
sock->select_waiting--;
21112113
}
21122114
SYS_ARCH_UNPROTECT(lev);
2113-
done_socket(sock);
21142115
} else {
21152116
SYS_ARCH_UNPROTECT(lev);
21162117
/* Not a valid socket */
@@ -2147,6 +2148,11 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
21472148
/* See what's set now after waiting */
21482149
nready = lwip_selscan(maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset);
21492150
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
2151+
if (nready < 0) {
2152+
set_errno(EBADF);
2153+
lwip_select_dec_sockets_used(maxfdp1, &used_sockets);
2154+
return -1;
2155+
}
21502156
}
21512157
}
21522158
}

Diff for: src/api/tcpip.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ tcpip_thread_poll_one(void)
217217
int ret = 0;
218218
struct tcpip_msg *msg;
219219

220-
if (sys_arch_mbox_tryfetch(&tcpip_mbox, (void **)&msg) != SYS_ARCH_TIMEOUT) {
220+
if (sys_arch_mbox_tryfetch(&tcpip_mbox, (void **)&msg) != SYS_MBOX_EMPTY) {
221221
LOCK_TCPIP_CORE();
222222
if (msg != NULL) {
223223
tcpip_thread_handle_msg(msg);

Diff for: src/arch/cc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef int sys_prot_t;
4040

4141
#define LWIP_PROVIDE_ERRNO
4242

43-
#if defined (__GNUC__) & !defined (__CC_ARM)
43+
#if defined (__GNUC__) && !(defined (__CC_ARM) || defined (__ARMCC_VERSION))
4444

4545
#define LWIP_TIMEVAL_PRIVATE 0
4646
#include <sys/time.h>

Diff for: src/arch/sys_arch.h

+1-13
Original file line numberDiff line numberDiff line change
@@ -38,31 +38,19 @@
3838
#error "NO_SYS need to be set to 0 to use threaded API"
3939
#endif
4040

41-
#include "cmsis_os.h"
41+
#include "cmsis_os2.h"
4242

4343
#ifdef __cplusplus
4444
extern "C" {
4545
#endif
4646

47-
#if (osCMSIS < 0x20000U)
48-
49-
#define SYS_MBOX_NULL (osMessageQId)0
50-
#define SYS_SEM_NULL (osSemaphoreId)0
51-
52-
typedef osSemaphoreId sys_sem_t;
53-
typedef osSemaphoreId sys_mutex_t;
54-
typedef osMessageQId sys_mbox_t;
55-
typedef osThreadId sys_thread_t;
56-
#else
57-
5847
#define SYS_MBOX_NULL (osMessageQueueId_t)0
5948
#define SYS_SEM_NULL (osSemaphoreId_t)0
6049

6150
typedef osSemaphoreId_t sys_sem_t;
6251
typedef osSemaphoreId_t sys_mutex_t;
6352
typedef osMessageQueueId_t sys_mbox_t;
6453
typedef osThreadId_t sys_thread_t;
65-
#endif
6654

6755
#ifdef __cplusplus
6856
}

Diff for: src/core/altcp.c

+36
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,24 @@ altcp_get_port(struct altcp_pcb *conn, int local)
501501
return 0;
502502
}
503503

504+
#if LWIP_TCP_KEEPALIVE
505+
void
506+
altcp_keepalive_disable(struct altcp_pcb *conn)
507+
{
508+
if (conn && conn->fns && conn->fns->keepalive_disable) {
509+
conn->fns->keepalive_disable(conn);
510+
}
511+
}
512+
513+
void
514+
altcp_keepalive_enable(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count)
515+
{
516+
if (conn && conn->fns && conn->fns->keepalive_enable) {
517+
conn->fns->keepalive_enable(conn, idle, intvl, count);
518+
}
519+
}
520+
#endif
521+
504522
#ifdef LWIP_DEBUG
505523
enum tcp_state
506524
altcp_dbg_get_tcp_state(struct altcp_pcb *conn)
@@ -666,6 +684,24 @@ altcp_default_get_port(struct altcp_pcb *conn, int local)
666684
return 0;
667685
}
668686

687+
#if LWIP_TCP_KEEPALIVE
688+
void
689+
altcp_default_keepalive_disable(struct altcp_pcb *conn)
690+
{
691+
if (conn && conn->inner_conn) {
692+
altcp_keepalive_disable(conn->inner_conn);
693+
}
694+
}
695+
696+
void
697+
altcp_default_keepalive_enable(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t count)
698+
{
699+
if (conn && conn->inner_conn) {
700+
altcp_keepalive_enable(conn->inner_conn, idle, intvl, count);
701+
}
702+
}
703+
#endif
704+
669705
#ifdef LWIP_DEBUG
670706
enum tcp_state
671707
altcp_default_dbg_get_tcp_state(struct altcp_pcb *conn)

Diff for: src/core/altcp_tcp.c

+43-9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "lwip/altcp_tcp.h"
5050
#include "lwip/priv/altcp_priv.h"
5151
#include "lwip/tcp.h"
52+
#include "lwip/priv/tcp_priv.h"
5253
#include "lwip/mem.h"
5354

5455
#include <string.h>
@@ -160,21 +161,25 @@ static void
160161
altcp_tcp_remove_callbacks(struct tcp_pcb *tpcb)
161162
{
162163
tcp_arg(tpcb, NULL);
163-
tcp_recv(tpcb, NULL);
164-
tcp_sent(tpcb, NULL);
165-
tcp_err(tpcb, NULL);
166-
tcp_poll(tpcb, NULL, tpcb->pollinterval);
164+
if (tpcb->state != LISTEN) {
165+
tcp_recv(tpcb, NULL);
166+
tcp_sent(tpcb, NULL);
167+
tcp_err(tpcb, NULL);
168+
tcp_poll(tpcb, NULL, tpcb->pollinterval);
169+
}
167170
}
168171

169172
static void
170173
altcp_tcp_setup_callbacks(struct altcp_pcb *conn, struct tcp_pcb *tpcb)
171174
{
172175
tcp_arg(tpcb, conn);
173-
tcp_recv(tpcb, altcp_tcp_recv);
174-
tcp_sent(tpcb, altcp_tcp_sent);
175-
tcp_err(tpcb, altcp_tcp_err);
176-
/* tcp_poll is set when interval is set by application */
177-
/* listen is set totally different :-) */
176+
/* this might be called for LISTN when close fails... */
177+
if (tpcb->state != LISTEN) {
178+
tcp_recv(tpcb, altcp_tcp_recv);
179+
tcp_sent(tpcb, altcp_tcp_sent);
180+
tcp_err(tpcb, altcp_tcp_err);
181+
/* tcp_poll is set when interval is set by application */
182+
}
178183
}
179184

180185
static void
@@ -446,6 +451,31 @@ altcp_tcp_setprio(struct altcp_pcb *conn, u8_t prio)
446451
}
447452
}
448453

454+
#if LWIP_TCP_KEEPALIVE
455+
static void
456+
altcp_tcp_keepalive_disable(struct altcp_pcb *conn)
457+
{
458+
if (conn && conn->state) {
459+
struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state;
460+
ALTCP_TCP_ASSERT_CONN(conn);
461+
ip_reset_option(pcb, SOF_KEEPALIVE);
462+
}
463+
}
464+
465+
static void
466+
altcp_tcp_keepalive_enable(struct altcp_pcb *conn, u32_t idle, u32_t intvl, u32_t cnt)
467+
{
468+
if (conn && conn->state) {
469+
struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state;
470+
ALTCP_TCP_ASSERT_CONN(conn);
471+
ip_set_option(pcb, SOF_KEEPALIVE);
472+
pcb->keep_idle = idle ? idle : TCP_KEEPIDLE_DEFAULT;
473+
pcb->keep_intvl = intvl ? intvl : TCP_KEEPINTVL_DEFAULT;
474+
pcb->keep_cnt = cnt ? cnt : TCP_KEEPCNT_DEFAULT;
475+
}
476+
}
477+
#endif
478+
449479
static void
450480
altcp_tcp_dealloc(struct altcp_pcb *conn)
451481
{
@@ -535,6 +565,10 @@ const struct altcp_functions altcp_tcp_functions = {
535565
altcp_tcp_get_tcp_addrinfo,
536566
altcp_tcp_get_ip,
537567
altcp_tcp_get_port
568+
#if LWIP_TCP_KEEPALIVE
569+
, altcp_tcp_keepalive_disable
570+
, altcp_tcp_keepalive_enable
571+
#endif
538572
#ifdef LWIP_DEBUG
539573
, altcp_tcp_dbg_get_tcp_state
540574
#endif

Diff for: src/core/init.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ PACK_STRUCT_END
237237
#error "NETCONN_MORE != TCP_WRITE_FLAG_MORE"
238238
#endif
239239
#endif /* LWIP_NETCONN && LWIP_TCP */
240-
#if LWIP_SOCKET
241-
#endif /* LWIP_SOCKET */
240+
#if LWIP_NETCONN_FULLDUPLEX && !LWIP_NETCONN_SEM_PER_THREAD
241+
#error "For LWIP_NETCONN_FULLDUPLEX to work, LWIP_NETCONN_SEM_PER_THREAD is required"
242+
#endif
242243

243244

244245
/* Compile-time checks for deprecated options.

0 commit comments

Comments
 (0)