Skip to content

Commit a1e59e9

Browse files
d-a-vdevyte
authored andcommitted
update to lwIP-2.1.0: partial SACK support by default (de-selectable in menu) (#5126)
* update to lwIP-2.1.0rc1: partial SACK support fix #4176 * hash fix * get some flash back due to mistake in conf (fragmentation & reassembly was incorrectly enabled) (ahah I scared you) * add missing include files * update to lwip-2.1.0(release) + remove unused lwIP's include files * lwIP release 2.1.0, SACK is now default, bigger, no-SACK is selectable * fix ldscript * pio * rename 'sack' option to 'feat'ure option, + IP fragmentation/reassembly * merge, fix pio * change internal/hidden string * pio: more lwip2 configuration: + without sack for no change in flash footprint
1 parent 3c13751 commit a1e59e9

Some content is hidden

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

130 files changed

+4738
-9207
lines changed

Diff for: boards.txt

+448-224
Large diffs are not rendered by default.

Diff for: tools/boards.txt.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -931,14 +931,22 @@
931931
####################### lwip
932932

933933
'lwip2': collections.OrderedDict([
934-
( '.menu.ip.lm2', 'v2 Lower Memory' ),
935-
( '.menu.ip.lm2.build.lwip_include', 'lwip2/include' ),
936-
( '.menu.ip.lm2.build.lwip_lib', '-llwip2' ),
937-
( '.menu.ip.lm2.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=536' ),
938-
( '.menu.ip.hb2', 'v2 Higher Bandwidth' ),
939-
( '.menu.ip.hb2.build.lwip_include', 'lwip2/include' ),
940-
( '.menu.ip.hb2.build.lwip_lib', '-llwip2_1460' ),
941-
( '.menu.ip.hb2.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=1460' ),
934+
( '.menu.ip.lm2f', 'v2 Lower Memory' ),
935+
( '.menu.ip.lm2f.build.lwip_include', 'lwip2/include' ),
936+
( '.menu.ip.lm2f.build.lwip_lib', '-llwip2-536-feat' ),
937+
( '.menu.ip.lm2f.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1' ),
938+
( '.menu.ip.hb2f', 'v2 Higher Bandwidth' ),
939+
( '.menu.ip.hb2f.build.lwip_include', 'lwip2/include' ),
940+
( '.menu.ip.hb2f.build.lwip_lib', '-llwip2-1460-feat' ),
941+
( '.menu.ip.hb2f.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=1' ),
942+
( '.menu.ip.lm2n', 'v2 Lower Memory (no features)' ),
943+
( '.menu.ip.lm2n.build.lwip_include', 'lwip2/include' ),
944+
( '.menu.ip.lm2n.build.lwip_lib', '-llwip2-536' ),
945+
( '.menu.ip.lm2n.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=0' ),
946+
( '.menu.ip.hb2n', 'v2 Higher Bandwidth (no features)' ),
947+
( '.menu.ip.hb2n.build.lwip_include', 'lwip2/include' ),
948+
( '.menu.ip.hb2n.build.lwip_lib', '-llwip2-1460' ),
949+
( '.menu.ip.hb2n.build.lwip_flags', '-DLWIP_OPEN_SRC -DTCP_MSS=1460 -DLWIP_FEATURES=0' ),
942950
]),
943951

944952
'lwip': collections.OrderedDict([

Diff for: tools/platformio-build.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,27 @@ def scons_patched_match_splitext(path, suffixes=None):
137137
#
138138
if "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY" in flatten_cppdefines:
139139
env.Append(
140-
CPPDEFINES=[("TCP_MSS", 536)],
140+
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1)],
141141
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
142-
LIBS=["lwip2"]
142+
LIBS=["lwip2-536-feat"]
143143
)
144144
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH" in flatten_cppdefines:
145145
env.Append(
146-
CPPDEFINES=[("TCP_MSS", 1460)],
146+
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1)],
147147
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
148-
LIBS=["lwip2_1460"]
148+
LIBS=["lwip2-1460-feat"]
149+
)
150+
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH" in flatten_cppdefines:
151+
env.Append(
152+
CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 0)],
153+
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
154+
LIBS=["lwip2-536"]
155+
)
156+
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH" in flatten_cppdefines:
157+
env.Append(
158+
CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 0)],
159+
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
160+
LIBS=["lwip2-1460"]
149161
)
150162
else:
151163
env.Append(

Diff for: tools/sdk/ld/eagle.app.v6.common.ld.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ SECTIONS
110110
*libstdc++.a:(.literal .text .literal.* .text.*)
111111
*liblwip_gcc.a:(.literal .text .literal.* .text.*)
112112
*liblwip_src.a:(.literal .text .literal.* .text.*)
113-
*liblwip2.a:(.literal .text .literal.* .text.*)
114-
*liblwip2_1460.a:(.literal .text .literal.* .text.*)
113+
*liblwip2-536.a:(.literal .text .literal.* .text.*)
114+
*liblwip2-1460.a:(.literal .text .literal.* .text.*)
115+
*liblwip2-536-feat.a:(.literal .text .literal.* .text.*)
116+
*liblwip2-1460-feat.a:(.literal .text .literal.* .text.*)
115117
*libbearssl.a:(.literal .text .literal.* .text.*)
116118
*libaxtls.a:(.literal .text .literal.* .text.*)
117119
*libat.a:(.literal.* .text.*)

Diff for: tools/sdk/lib/liblwip2-1460-feat.a

1.4 MB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-1460.a

1.32 MB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-536-feat.a

1.4 MB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2-536.a

1.32 MB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2.a

-1.22 MB
Binary file not shown.

Diff for: tools/sdk/lib/liblwip2_1460.a

-1.22 MB
Binary file not shown.

Diff for: tools/sdk/lwip2/include/arch/cc.h

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef uint32_t sys_prot_t; // not really used
6262
#define SYS_ARCH_DECL_PROTECT(lev)
6363
#define SYS_ARCH_PROTECT(lev) os_intr_lock()
6464
#define SYS_ARCH_UNPROTECT(lev) os_intr_unlock()
65+
#define LWIP_NO_CTYPE_H 1
6566

6667
///////////////////////////////
6768
//// DEBUG

Diff for: tools/sdk/lwip2/include/lwip-git-hash.h

+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-13-g163bb82"
4+
#define LWIP_HASH_STR "STABLE-2_1_0_RELEASE/glue:arduino-2.4.2-13-g80224f0"
55
#endif // LWIP_HASH_H

Diff for: tools/sdk/lwip2/include/lwip/api.h

+58-27
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,25 @@ extern "C" {
5858
*/
5959

6060
/* Flags for netconn_write (u8_t) */
61-
#define NETCONN_NOFLAG 0x00
62-
#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
63-
#define NETCONN_COPY 0x01
64-
#define NETCONN_MORE 0x02
65-
#define NETCONN_DONTBLOCK 0x04
61+
#define NETCONN_NOFLAG 0x00
62+
#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
63+
#define NETCONN_COPY 0x01
64+
#define NETCONN_MORE 0x02
65+
#define NETCONN_DONTBLOCK 0x04
66+
#define NETCONN_NOAUTORCVD 0x08 /* prevent netconn_recv_data_tcp() from updating the tcp window - must be done manually via netconn_tcp_recvd() */
67+
#define NETCONN_NOFIN 0x10 /* upper layer already received data, leave FIN in queue until called again */
6668

6769
/* Flags for struct netconn.flags (u8_t) */
70+
/** This netconn had an error, don't block on recvmbox/acceptmbox any more */
71+
#define NETCONN_FLAG_MBOXCLOSED 0x01
6872
/** Should this netconn avoid blocking? */
6973
#define NETCONN_FLAG_NON_BLOCKING 0x02
7074
/** Was the last connect action a non-blocking one? */
7175
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
76+
#if LWIP_NETCONN_FULLDUPLEX
77+
/** The mbox of this netconn is being deallocated, don't use it anymore */
78+
#define NETCONN_FLAG_MBOXINVALID 0x08
79+
#endif /* LWIP_NETCONN_FULLDUPLEX */
7280
/** If a nonblocking write has been rejected before, poll_tcp needs to
7381
check if the netconn is writable again */
7482
#define NETCONN_FLAG_CHECK_WRITESPACE 0x10
@@ -78,7 +86,12 @@ extern "C" {
7886
dual-stack usage by default. */
7987
#define NETCONN_FLAG_IPV6_V6ONLY 0x20
8088
#endif /* LWIP_IPV6 */
81-
89+
#if LWIP_NETBUF_RECVINFO
90+
/** Received packet info will be recorded for this netconn */
91+
#define NETCONN_FLAG_PKTINFO 0x40
92+
#endif /* LWIP_NETBUF_RECVINFO */
93+
/** A FIN has been received but not passed to the application yet */
94+
#define NETCONN_FIN_RX_PENDING 0x80
8295

8396
/* Helpers to process several netconn_types by the same code */
8497
#define NETCONNTYPE_GROUP(t) ((t)&0xF0)
@@ -214,8 +227,8 @@ struct netconn {
214227
struct udp_pcb *udp;
215228
struct raw_pcb *raw;
216229
} pcb;
217-
/** the last error this netconn had */
218-
err_t last_err;
230+
/** the last asynchronous unreported error this netconn had */
231+
err_t pending_err;
219232
#if !LWIP_NETCONN_SEM_PER_THREAD
220233
/** sem that is used to synchronously execute functions in the core context */
221234
sys_sem_t op_completed;
@@ -228,6 +241,11 @@ struct netconn {
228241
by the application thread */
229242
sys_mbox_t acceptmbox;
230243
#endif /* LWIP_TCP */
244+
#if LWIP_NETCONN_FULLDUPLEX
245+
/** number of threads waiting on an mbox. This is required to unblock
246+
all threads when closing while threads are waiting. */
247+
int mbox_threads_waiting;
248+
#endif
231249
/** only used for socket layer */
232250
#if LWIP_SOCKET
233251
int socket;
@@ -240,7 +258,7 @@ struct netconn {
240258
#if LWIP_SO_RCVTIMEO
241259
/** timeout in milliseconds to wait for new data to be received
242260
(or connections to arrive for listening netconns) */
243-
int recv_timeout;
261+
u32_t recv_timeout;
244262
#endif /* LWIP_SO_RCVTIMEO */
245263
#if LWIP_SO_RCVBUF
246264
/** maximum amount of bytes queued in recvmbox
@@ -258,9 +276,6 @@ struct netconn {
258276
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
259277
u8_t flags;
260278
#if LWIP_TCP
261-
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
262-
this temporarily stores how much is already sent. */
263-
size_t write_offset;
264279
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
265280
this temporarily stores the message.
266281
Also used during connect and close. */
@@ -270,21 +285,23 @@ struct netconn {
270285
netconn_callback callback;
271286
};
272287

288+
/** This vector type is passed to @ref netconn_write_vectors_partly to send
289+
* multiple buffers at once.
290+
* ATTENTION: This type has to directly map struct iovec since one is casted
291+
* into the other!
292+
*/
293+
struct netvector {
294+
/** pointer to the application buffer that contains the data to send */
295+
const void *ptr;
296+
/** size of the application data to send */
297+
size_t len;
298+
};
299+
273300
/** Register an Network connection event */
274301
#define API_EVENT(c,e,l) if (c->callback) { \
275302
(*c->callback)(c, e, l); \
276303
}
277304

278-
/** Set conn->last_err to err but don't overwrite fatal errors */
279-
#define NETCONN_SET_SAFE_ERR(conn, err) do { if ((conn) != NULL) { \
280-
SYS_ARCH_DECL_PROTECT(netconn_set_safe_err_lev); \
281-
SYS_ARCH_PROTECT(netconn_set_safe_err_lev); \
282-
if (!ERR_IS_FATAL((conn)->last_err)) { \
283-
(conn)->last_err = err; \
284-
} \
285-
SYS_ARCH_UNPROTECT(netconn_set_safe_err_lev); \
286-
}} while(0);
287-
288305
/* Network connection functions: */
289306

290307
/** @ingroup netconn_common
@@ -294,6 +311,7 @@ struct netconn {
294311
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
295312
struct netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
296313
netconn_callback callback);
314+
err_t netconn_prepare_delete(struct netconn *conn);
297315
err_t netconn_delete(struct netconn *conn);
298316
/** Get the type of a netconn (as enum netconn_type). */
299317
#define netconn_type(conn) (conn->type)
@@ -306,19 +324,26 @@ err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr,
306324
#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
307325

308326
err_t netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port);
327+
err_t netconn_bind_if(struct netconn *conn, u8_t if_idx);
309328
err_t netconn_connect(struct netconn *conn, const ip_addr_t *addr, u16_t port);
310329
err_t netconn_disconnect (struct netconn *conn);
311330
err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
312331
/** @ingroup netconn_tcp */
313332
#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
314333
err_t netconn_accept(struct netconn *conn, struct netconn **new_conn);
315334
err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf);
335+
err_t netconn_recv_udp_raw_netbuf(struct netconn *conn, struct netbuf **new_buf);
336+
err_t netconn_recv_udp_raw_netbuf_flags(struct netconn *conn, struct netbuf **new_buf, u8_t apiflags);
316337
err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
338+
err_t netconn_recv_tcp_pbuf_flags(struct netconn *conn, struct pbuf **new_buf, u8_t apiflags);
339+
err_t netconn_tcp_recvd(struct netconn *conn, size_t len);
317340
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
318341
const ip_addr_t *addr, u16_t port);
319342
err_t netconn_send(struct netconn *conn, struct netbuf *buf);
320343
err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size,
321344
u8_t apiflags, size_t *bytes_written);
345+
err_t netconn_write_vectors_partly(struct netconn *conn, struct netvector *vectors, u16_t vectorcnt,
346+
u8_t apiflags, size_t *bytes_written);
322347
/** @ingroup netconn_tcp */
323348
#define netconn_write(conn, dataptr, size, apiflags) \
324349
netconn_write_partly(conn, dataptr, size, apiflags, NULL)
@@ -328,6 +353,8 @@ err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
328353
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
329354
err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr,
330355
const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);
356+
err_t netconn_join_leave_group_netif(struct netconn *conn, const ip_addr_t *multiaddr,
357+
u8_t if_idx, enum netconn_igmp join_or_leave);
331358
#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
332359
#if LWIP_DNS
333360
#if LWIP_IPV4 && LWIP_IPV6
@@ -339,14 +366,18 @@ err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
339366
#endif /* LWIP_IPV4 && LWIP_IPV6 */
340367
#endif /* LWIP_DNS */
341368

342-
#define netconn_err(conn) ((conn)->last_err)
369+
err_t netconn_err(struct netconn *conn);
343370
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
344371

372+
#define netconn_set_flags(conn, set_flags) do { (conn)->flags = (u8_t)((conn)->flags | (set_flags)); } while(0)
373+
#define netconn_clear_flags(conn, clr_flags) do { (conn)->flags = (u8_t)((conn)->flags & (u8_t)(~(clr_flags) & 0xff)); } while(0)
374+
#define netconn_is_flag_set(conn, flag) (((conn)->flags & (flag)) != 0)
375+
345376
/** Set the blocking status of netconn calls (@todo: write/send is missing) */
346377
#define netconn_set_nonblocking(conn, val) do { if(val) { \
347-
(conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \
378+
netconn_set_flags(conn, NETCONN_FLAG_NON_BLOCKING); \
348379
} else { \
349-
(conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0)
380+
netconn_clear_flags(conn, NETCONN_FLAG_NON_BLOCKING); }} while(0)
350381
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
351382
#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
352383

@@ -355,9 +386,9 @@ err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
355386
* TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
356387
*/
357388
#define netconn_set_ipv6only(conn, val) do { if(val) { \
358-
(conn)->flags |= NETCONN_FLAG_IPV6_V6ONLY; \
389+
netconn_set_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); \
359390
} else { \
360-
(conn)->flags &= ~ NETCONN_FLAG_IPV6_V6ONLY; }} while(0)
391+
netconn_clear_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); }} while(0)
361392
/** @ingroup netconn_common
362393
* TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)
363394
*/

Diff for: tools/sdk/lwip2/include/lwip/apps/FILES

-2
This file was deleted.

Diff for: tools/sdk/lwip2/include/lwip/apps/fs.h

-103
This file was deleted.

0 commit comments

Comments
 (0)