Skip to content

Commit a645360

Browse files
authored
Merge pull request #2 from fprwi6labs/update_LwIP_stack
Update LwIP stack to version 2.0.3
2 parents a9f907c + 50cfc59 commit a645360

Some content is hidden

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

89 files changed

+2684
-1166
lines changed

CHANGELOG

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,171 @@ HISTORY
44

55
* [Enter new changes just after this line - do not remove this line]
66

7+
(STABLE-2.0.3)
8+
9+
++ Bugfixes:
10+
11+
2017-09-11: Simon Goldschmidt
12+
* tcp_in.c: fix bug #51937 (leaking tcp_pcbs on passive close with unacked data)
13+
14+
2017-08-02: Abroz Bizjak/Simon Goldschmidt
15+
* multiple fixes in IPv4 reassembly (leading to corrupted datagrams received)
16+
17+
2017-03-30: Simon Goldschmidt
18+
* dhcp.c: return ERR_VAL instead of asserting on offset-out-of-pbuf
19+
20+
2017-03-23: Dirk Ziegelmeier
21+
* dhcp.h: fix bug #50618 (dhcp_remove_struct() macro does not work)
22+
23+
(STABLE-2.0.2)
24+
25+
++ New features:
26+
27+
2017-02-10: Dirk Ziegelmeier
28+
* Implement task #14367: Hooks need a better place to be defined:
29+
We now have a #define for a header file name that is #included in every .c
30+
file that provides hooks.
31+
32+
2017-02-10: Simon Goldschmidt
33+
* tcp_close does not fail on memory error (instead, FIN is sent from tcp_tmr)
34+
35+
++ Bugfixes:
36+
37+
2017-03-08
38+
* tcp: do not keep sending SYNs when getting ACKs
39+
40+
2017-03-08: Joel Cunningham
41+
* tcp: Initialize ssthresh to TCP_SND_BUF (bug #50476)
42+
43+
2017-03-01: Simon Goldschmidt
44+
* httpd: LWIP_HTTPD_POST_MANUAL_WND: fixed double-free when httpd_post_data_recved
45+
is called nested from httpd_post_receive_data() (bug #50424)
46+
47+
2017-02-28: David van Moolenbroek/Simon Goldschmidt
48+
* tcp: fixed bug #50418: LWIP_EVENT_API: fix invalid calbacks for SYN_RCVD pcb
49+
50+
2017-02-17: Simon Goldschmidt
51+
* dns: Improved DNS_LOCAL_HOSTLIST interface (bug #50325)
52+
53+
2017-02-16: Simon Goldschmidt
54+
* LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)
55+
56+
2017-02-13: Simon Goldschmidt/Dirk Ziegelmeier
57+
* For tiny targtes, LWIP_RAND is optional (fix compile time checks)
58+
59+
2017-02-10: Simon Goldschmidt
60+
* tcp: Fixed bug #47485 (tcp_close() should not fail on memory error) by retrying
61+
to send FIN from tcp_fasttmr
62+
63+
2017-02-09: Simon Goldschmidt
64+
* sockets: Fixed bug #44032 (LWIP_NETCONN_FULLDUPLEX: select might work on
65+
invalid/reused socket) by not allowing to reallocate a socket that has
66+
"select_waiting != 0"
67+
68+
2017-02-09: Simon Goldschmidt
69+
* httpd: Fixed bug #50059 (httpd LWIP_HTTPD_SUPPORT_11_KEEPALIVE vs.
70+
LWIP_HTTPD_KILL_OLD_ON_CONNECTIONS_EXCEEDED)
71+
72+
2017-02-08: Dirk Ziegelmeier
73+
* Rename "IPv6 mapped IPv4 addresses" to their correct name from RFC4191:
74+
"IPv4-mapped IPv6 address"
75+
76+
2017-02-08: Luc Revardel
77+
* mld6.c: Fix bug #50220 (mld6_leavegroup does not send ICMP6_TYPE_MLD, even
78+
if last reporter)
79+
80+
2017-02-08: David van Moolenbroek
81+
* ip6.c: Patch #9250: fix source substitution in ip6_output_if()
82+
83+
2017-02-08: Simon Goldschmidt
84+
* tcp_out.c: Fixed bug #50090 (last_unsent->oversize_left can become wrong value
85+
in tcp_write error path)
86+
87+
2017-02-02: Dirk Ziegelmeier
88+
* Fix bug #50206: UDP Netconn bind to IP6_ADDR_ANY fails
89+
90+
2017-01-18: Dirk Ziegelmeier
91+
* Fix zero-copy RX, see bug bug #50064. PBUF_REFs were not supported as ARP requests.
92+
93+
2017-01-15: Axel Lin, Dirk Ziegelmeier
94+
* minor bug fixes in mqtt
95+
96+
2017-01-11: Knut Andre Tidemann
97+
* sockets/netconn: fix broken default ICMPv6 handling of checksums
98+
99+
(STABLE-2.0.1)
100+
101+
++ New features:
102+
103+
2016-12-31: Simon Goldschmidt
104+
* tcp.h/.c: added function tcp_listen_with_backlog_and_err() to get the error
105+
reason when listening fails (bug #49861)
106+
107+
2016-12-20: Erik Andersen
108+
* Add MQTT client
109+
110+
2016-12-14: Jan Breuer:
111+
* opt.h, ndc.h/.c: add support for RDNSS option (as per RFC 6106)
112+
113+
2016-12-14: David van Moolenbroek
114+
* opt.h, nd6.c: Added LWIP_HOOK_ND6_GET_GW()
115+
116+
2016-12-09: Dirk Ziegelmeier
117+
* ip6_frag.c: Implemented support for LWIP_NETIF_TX_SINGLE_PBUF
118+
119+
2016-12-09: Simon Goldschmidt
120+
* dns.c: added one-shot multicast DNS queries
121+
122+
2016-11-24: Ambroz Bizjak, David van Moolenbroek
123+
* tcp_out.c: Optimize passing contiguous nocopy buffers to tcp_write (bug #46290)
124+
125+
2016-11-16: Dirk Ziegelmeier
126+
* sockets.c: added support for IPv6 mapped IPv4 addresses
127+
128+
++ Bugfixes:
129+
130+
2016-12-16: Thomas Mueller
131+
* api_lib.c: fixed race condition in return value of netconn_gethostbyname()
132+
(and thus also lwip_gethostbyname/_r() and lwip_getaddrinfo())
133+
134+
2016-12-15: David van Moolenbroek
135+
* opt.h, tcp: added LWIP_HOOK_TCP_ISN() to implement less predictable initial
136+
sequence numbers (see contrib/addons/tcp_isn for an example implementation)
137+
138+
2016-12-05: Dirk Ziegelmeier
139+
* fixed compiling with IPv4 disabled (IPv6 only case)
140+
141+
2016-11-28: Simon Goldschmidt
142+
* api_lib.c: fixed bug #49725 (send-timeout: netconn_write() can return
143+
ERR_OK without all bytes being written)
144+
145+
2016-11-28: Ambroz Bizjak
146+
* tcpi_in.c: fixed bug #49717 (window size in received SYN and SYN-ACK
147+
assumed scaled)
148+
149+
2016-11-25: Simon Goldschmidt
150+
* dhcp.c: fixed bug #49676 (Possible endless loop when parsing dhcp options)
151+
152+
2016-11-23: Dirk Ziegelmeier
153+
* udp.c: fixed bug #49662: multicast traffic is now only received on a UDP PCB
154+
(and therefore on a UDP socket/netconn) when the PCB is bound to IP_ADDR_ANY
155+
156+
2016-11-16: Dirk Ziegelmeier
157+
* *: Fixed dual-stack behaviour, IPv6 mapped IPv4 support in socket API
158+
159+
2016-11-14: Joel Cunningham
160+
* tcp_out.c: fixed bug #49533 (start persist timer when unsent seg can't fit
161+
in window)
162+
163+
2016-11-16: Roberto Barbieri Carrera
164+
* autoip.c: fixed bug #49610 (sometimes AutoIP fails to reuse the same address)
165+
166+
2016-11-11: Dirk Ziegelmeier
167+
* sockets.c: fixed bug #49578 (dropping multicast membership does not work
168+
with LWIP_SOCKET_OFFSET)
169+
170+
(STABLE-2.0.0)
171+
7172
++ New features:
8173

9174
2016-07-27: Simon Goldschmidt

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# LwIP
22
Lightweight TCP/IP stack (LwIP) is a small independent implementation of the TCP/IP protocol suite that has been initially developed by Adam Dunkels and is now continued [here](https://savannah.nongnu.org/projects/lwip/).
3-
3+
44
Modified to fit Arduino libraries specifications.
5-
5+
66
It is used by the [STM32Ethernet](https://github.com/stm32duino/STM32Ethernet) library.
7+
8+
## Version
9+
10+
This library is based on the version 2.0.3 of the LwIP stack.

UPGRADING

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@ with newer versions.
88

99
* [Enter new changes just after this line - do not remove this line]
1010

11-
* TODO
11+
(2.0.2)
12+
13+
++ Application changes:
14+
15+
* slipif: The way to pass serial port number has changed. netif->num is not
16+
supported any more, netif->state is interpreted as an u8_t port number now
17+
(it's not a POINTER to an u8_t any more!)
18+
19+
(2.0.1)
20+
21+
++ Application changes:
22+
23+
* UDP does NOT receive multicast traffic from ALL netifs on an UDP PCB bound to a specific
24+
netif any more. Users need to bind to IP_ADDR_ANY to receive multicast traffic and compare
25+
ip_current_netif() to the desired netif for every packet.
26+
See bug #49662 for an explanation.
1227

1328
(2.0.0)
1429

src/Filelists.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,15 @@ NETBIOSNSFILES=$(LWIPDIR)/apps/netbiosns/netbiosns.c
167167
# TFTPFILES: TFTP server files
168168
TFTPFILES=$(LWIPDIR)/apps/tftp/tftp_server.c
169169

170+
# MQTTFILES: MQTT client files
171+
MQTTFILES=$(LWIPDIR)/apps/mqtt/mqtt.c
172+
170173
# LWIPAPPFILES: All LWIP APPs
171174
LWIPAPPFILES=$(SNMPFILES) \
172175
$(HTTPDFILES) \
173176
$(LWIPERFFILES) \
174177
$(SNTPFILES) \
175178
$(MDNSFILES) \
176179
$(NETBIOSNSFILES) \
177-
$(TFTPFILES)
180+
$(TFTPFILES) \
181+
$(MQTTFILES)

src/api/api_lib.c

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,17 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port)
259259
if (addr == NULL) {
260260
addr = IP4_ADDR_ANY;
261261
}
262-
#endif
262+
#endif /* LWIP_IPV4 */
263+
264+
#if LWIP_IPV4 && LWIP_IPV6
265+
/* "Socket API like" dual-stack support: If IP to bind to is IP6_ADDR_ANY,
266+
* and NETCONN_FLAG_IPV6_V6ONLY is 0, use IP_ANY_TYPE to bind
267+
*/
268+
if ((netconn_get_ipv6only(conn) == 0) &&
269+
ip_addr_cmp(addr, IP6_ADDR_ANY)) {
270+
addr = IP_ANY_TYPE;
271+
}
272+
#endif /* LWIP_IPV4 && LWIP_IPV6 */
263273

264274
API_MSG_VAR_ALLOC(msg);
265275
API_MSG_VAR_REF(msg).conn = conn;
@@ -293,7 +303,7 @@ netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port)
293303
if (addr == NULL) {
294304
addr = IP4_ADDR_ANY;
295305
}
296-
#endif
306+
#endif /* LWIP_IPV4 */
297307

298308
API_MSG_VAR_ALLOC(msg);
299309
API_MSG_VAR_REF(msg).conn = conn;
@@ -380,7 +390,6 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
380390
#if LWIP_TCP
381391
void *accept_ptr;
382392
struct netconn *newconn;
383-
err_t err;
384393
#if TCP_LISTEN_BACKLOG
385394
API_MSG_VAR_DECLARE(msg);
386395
#endif /* TCP_LISTEN_BACKLOG */
@@ -389,11 +398,10 @@ netconn_accept(struct netconn *conn, struct netconn **new_conn)
389398
*new_conn = NULL;
390399
LWIP_ERROR("netconn_accept: invalid conn", (conn != NULL), return ERR_ARG;);
391400

392-
err = conn->last_err;
393-
if (ERR_IS_FATAL(err)) {
401+
if (ERR_IS_FATAL(conn->last_err)) {
394402
/* don't recv on fatal errors: this might block the application task
395403
waiting on acceptmbox forever! */
396-
return err;
404+
return conn->last_err;
397405
}
398406
if (!sys_mbox_valid(&conn->acceptmbox)) {
399407
return ERR_CLSD;
@@ -469,7 +477,6 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
469477
{
470478
void *buf = NULL;
471479
u16_t len;
472-
err_t err;
473480
#if LWIP_TCP
474481
API_MSG_VAR_DECLARE(msg);
475482
#if LWIP_MPU_COMPATIBLE
@@ -493,13 +500,12 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
493500
#endif /* LWIP_TCP */
494501
LWIP_ERROR("netconn_recv: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;);
495502

496-
err = conn->last_err;
497-
if (ERR_IS_FATAL(err)) {
503+
if (ERR_IS_FATAL(conn->last_err)) {
498504
/* don't recv on fatal errors: this might block the application task
499505
waiting on recvmbox forever! */
500506
/* @todo: this does not allow us to fetch data that has been put into recvmbox
501507
before the fatal error occurred - is that a problem? */
502-
return err;
508+
return conn->last_err;
503509
}
504510
#if LWIP_TCP
505511
#if (LWIP_UDP || LWIP_RAW)
@@ -566,7 +572,7 @@ netconn_recv_data(struct netconn *conn, void **new_buf)
566572
#if (LWIP_UDP || LWIP_RAW)
567573
{
568574
LWIP_ASSERT("buf != NULL", buf != NULL);
569-
len = netbuf_len((struct netbuf *)buf);
575+
len = netbuf_len((struct netbuf*)buf);
570576
}
571577
#endif /* (LWIP_UDP || LWIP_RAW) */
572578

@@ -701,6 +707,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
701707
LWIP_ERROR("netconn_send: invalid conn", (conn != NULL), return ERR_ARG;);
702708

703709
LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %"U16_F" bytes\n", buf->p->tot_len));
710+
704711
API_MSG_VAR_ALLOC(msg);
705712
API_MSG_VAR_REF(msg).conn = conn;
706713
API_MSG_VAR_REF(msg).msg.b = buf;
@@ -738,6 +745,11 @@ netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
738745
return ERR_OK;
739746
}
740747
dontblock = netconn_is_nonblocking(conn) || (apiflags & NETCONN_DONTBLOCK);
748+
#if LWIP_SO_SNDTIMEO
749+
if (conn->send_timeout != 0) {
750+
dontblock = 1;
751+
}
752+
#endif /* LWIP_SO_SNDTIMEO */
741753
if (dontblock && !bytes_written) {
742754
/* This implies netconn_write() cannot be used for non-blocking send, since
743755
it has no way to return the number of bytes written. */
@@ -765,11 +777,7 @@ netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
765777
non-blocking version here. */
766778
err = netconn_apimsg(lwip_netconn_do_write, &API_MSG_VAR_REF(msg));
767779
if ((err == ERR_OK) && (bytes_written != NULL)) {
768-
if (dontblock
769-
#if LWIP_SO_SNDTIMEO
770-
|| (conn->send_timeout != 0)
771-
#endif /* LWIP_SO_SNDTIMEO */
772-
) {
780+
if (dontblock) {
773781
/* nonblocking write: maybe the data has been sent partly */
774782
*bytes_written = API_MSG_VAR_REF(msg).msg.w.len;
775783
} else {
@@ -873,15 +881,15 @@ netconn_join_leave_group(struct netconn *conn,
873881

874882
API_MSG_VAR_ALLOC(msg);
875883

876-
#if LWIP_IPV4
884+
#if LWIP_IPV4
877885
/* Don't propagate NULL pointer (IP_ADDR_ANY alias) to subsequent functions */
878886
if (multiaddr == NULL) {
879887
multiaddr = IP4_ADDR_ANY;
880888
}
881889
if (netif_addr == NULL) {
882890
netif_addr = IP4_ADDR_ANY;
883891
}
884-
#endif
892+
#endif /* LWIP_IPV4 */
885893

886894
API_MSG_VAR_REF(msg).conn = conn;
887895
API_MSG_VAR_REF(msg).msg.jl.multiaddr = API_MSG_VAR_REF(multiaddr);
@@ -920,6 +928,7 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
920928
sys_sem_t sem;
921929
#endif /* LWIP_MPU_COMPATIBLE */
922930
err_t err;
931+
err_t cberr;
923932

924933
LWIP_ERROR("netconn_gethostbyname: invalid name", (name != NULL), return ERR_ARG;);
925934
LWIP_ERROR("netconn_gethostbyname: invalid addr", (addr != NULL), return ERR_ARG;);
@@ -952,13 +961,13 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
952961
}
953962
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
954963

955-
err = tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg));
956-
if (err != ERR_OK) {
964+
cberr = tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg));
965+
if (cberr != ERR_OK) {
957966
#if !LWIP_NETCONN_SEM_PER_THREAD
958967
sys_sem_free(API_EXPR_REF(API_VAR_REF(msg).sem));
959968
#endif /* !LWIP_NETCONN_SEM_PER_THREAD */
960969
API_VAR_FREE(MEMP_DNS_API_MSG, msg);
961-
return err;
970+
return cberr;
962971
}
963972
sys_sem_wait(API_EXPR_REF_SEM(API_VAR_REF(msg).sem));
964973
#if !LWIP_NETCONN_SEM_PER_THREAD

0 commit comments

Comments
 (0)