Fix below build error:
In file included from
../../../../lwip/src/../test/unit/tcp/test_tcp.c:3:0:
../../../../lwip/src/../test/unit/tcp/test_tcp.c: In function
‘test_tcp_rto_timeout_syn_sent_impl’:
../../../../lwip/src/../test/unit/tcp/test_tcp.c:1246:113: error: suggest parentheses around arithmetic in operand of ‘|’ [-Werror=parentheses]
const u16_t tcp_syn_opts_len = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_MSS|TF_SEG_OPTS_WND_SCALE|TF_SEG_OPTS_SACK_PERM|TF_SEG_OPTS_TS);
^
../../../../lwip/src/include/lwip/priv/tcp_priv.h:305:4: note: in definition of macro ‘LWIP_TCP_OPT_LENGTH’
(flags & TF_SEG_OPTS_MSS ? LWIP_TCP_OPT_LEN_MSS : 0) + \
^~~~~
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Fail to build if PPP_SUPPORT is disabled because PPP_NUM_TIMEOUTS
references defines that are unknown if PPP_SUPPORT == 0. Move
PPP_NUM_TIMEOUTS to PPP_SUPPORT block and set a default value to 0
if PPP_NUM_TIMEOUTS is still not defined at the end of ppp_opts.h.
Fixes: e4e0fc4193 ("PPP: set PPP_NUM_TIMEOUTS_PER_PCB value to computed number of simultaneous timers")
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
A deep analysis of simultaneously running timers showed we can use a
slightly smaller value for PPP_NUM_TIMEOUTS_PER_PCB, value which was
arbitrarily chosen to a safe value based on the number of enabled PPP
features. Add the boring and long analysis to the end of our internal
header file and use the result in ppp_opts.h.
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
Only the transmission side works for now (todo: dual and tradeoff mode).
Also, only a 10 second timeout mode is implemented for now.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
We never use the current peer NS value but always the next expected peer
NS value (current value plus one).
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
... and add a unit test for it.
Moved resetting netif->rs_count from all reports to link-up and netif-up only.
While at it, clean up the interface a bit so that netif->rs_count is touched
from nd6.c only.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
arp table functions, nd6 destination cache and struct netif_hint
can now be u16_t or u8_t depending on table size, so up to 32K
entries can be used in these tables (s16_t)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This should hide the internal type used for access to the ARP table
which currently is s8_t or u8_t, depending on the use case.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This timeout is used to measure TFTP_TIMEOUT_MSECS fine enough.
Calling tftp_tmr at a 50ms interval to handle a 1 seconds timeout
produces way too much cpu load (and prevents sleep).
Signed-off-by: goldsimon <goldsimon@gmx.de>
Threads blocked on the rx mbox are counted and on close,
one "netconn closed" message per thread is posted to the mbox
to ensure all threads are woken.
The netconn can then be safely deleted. In socket API, "fd_used"
and "fd_free_pending" help with auto-deleting the netconn.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This is necessary to implement fullduplex sockets that are closed asynchronously:
the netconn in the socket must not be freed before all threads have given up
using it.
We now call the first part of 'netconn_delete()' (moved to 'netconn_prepare_delete()')
from lwip_close() and only actually end up calling 'netconn_free()' from
'free_socket()', which might be called later if LWIP_NETCONN_FULLDUPLEX is enabled.
Signed-off-by: goldsimon <goldsimon@gmx.de>
netifapi related lwIP internal definitions should be guarded
by #if LWIP_NETIF_API rather than #if LWIP_NETCONN || LWIP_SOCKET.
Fix below build errors:
cc -g -DLWIP_DEBUG -Wall -pedantic -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wunreachable-code -Wuninitialized -Wmissing-prototypes -Wredundant-decls -Waggregate-return -Wlogical-not-parentheses -Wlogical-op -Wc90-c99-compat -Wtrampolines -I. -I../../.. -I../../../../lwip/src/include -I../../../ports/unix/port/include -I../../../../mbedtls/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -c ../../../../lwip/src/api/netifapi.c In file included from ../../../../lwip/src/api/netifapi.c:46:0:
../../../../lwip/src/include/lwip/netifapi.h:76:50: error: unknown type name 'netifapi_void_fn'; did you mean 'netif_init_fn'?
err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
^~~~~~~~~~~~~~~~
netif_init_fn
../../../../lwip/src/include/lwip/netifapi.h:77:29: error: unknown type name 'netifapi_errt_fn'; did you mean 'netif_input_fn'?
netifapi_errt_fn errtfunc);
^~~~~~~~~~~~~~~~
netif_input_fn
../../../../lwip/src/api/netifapi.c: In function 'netifapi_do_netif_add':
../../../../lwip/src/api/netifapi.c:67:22: error: dereferencing pointer to incomplete type 'struct netifapi_msg'
if (!netif_add( msg->netif,
^~
Fixes: 30a2283993 ("Move netifapi private definitions to priv/api_msg.h")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This protocol is sent over a 2nd netif via UDP/IP and can used to analyze
6LoWPAN with a Wireshark dissector.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This simply wasn't the case until 6LoWPAN. However, since tcpip_input is like this, we
should stay with that pattern.
Adapted documentation in netif.h
Signed-off-by: goldsimon <goldsimon@gmx.de>
Avoid "LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS" redefined build
warning if it's set to 0 by lwipopts.h.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Works as expected, but some features are not implemented yet.
(See patch #9364: RFC7668 - 6lowpan over Bluetooth Low Energy -- a new netif)
(I've change the file names only; sg)
Signed-off-by: goldsimon <goldsimon@gmx.de>
In contrast to netif_get_client_data, netif_alloc_client_data_id() is only
available if LWIP_NUM_NETIF_CLIENT_DATA > 0, not for DHCP etc.
This is correct in netif.c but wrong in netif.h
enum tcpip_msg_type and struct tcpip_msg have members which are only
used when core locking and/or core locking input are disabled. Remove
these from the union to reduce the size. Remove from enum to prevent
usage when these are options are disabled
A quick sizeof test with MSVC 2013 showed a 4 byte size reduction for
struct tcpip_msg (16 bytes -> 12bytes) for the following configuration:
LWIP_TCPIP_CORE_LOCKING 1
LWIP_TCPIP_CORE_LOCKING_INPUT 1
LWIP_TCPIP_TIMEOUT 0
FIN should only be reported once (as '0' for sockets, as 'ERR_CLSD' for
netconns). Before this change, ERR_CLSD was returned forever...
This is the 2nd try. First try (commit ebcae98ae6)
was buggy in that it could drop the FIN if it was read together with data
(reverted in commit ebcae98ae6).
This version fixes this by adding an apiflag and a netconn flag to keep
track of this.
clang failed to build:
../../../../lwip/src/include/lwip/tcp.h:180:11: error: parameter 'ERR_OK' not found in the function declaration [-Werror,-Wdocumentation]
* @param ERR_OK if OK, any error if connection should be dropped
^~~~~~
This hook is called from tcp_input() for all kinds of input pcbs when
selected to receive a pbuf (LISTEN, TIME_WAIT, rest). I can parse or
drop an rx pbuf.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This introduces the concept of ext (external/extended) arguments per
tcp_pcb (also for listening pcbs) to store more data than just one
"void *arg" per pcb. The "arg" is for use to applications, whereas
the ext_args may be used by frameworks and leave "arg" untouched.
In addition to a void pointer, callbacks are added to help frameworks
migrate arguments from listen pcb to connection pcb and to free args
when the pcb is freed.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This should make it easier to add debugging messages or other hooks
to the point where tcp pcbs are deallocated.
Signed-off-by: goldsimon <goldsimon@gmx.de>
LWIP_HOOK_SOCKETS_SETSOCKOPT() and LWIP_HOOK_SOCKETS_GETSOCKOPT()
are introduced to implement additional socket options. The hooks
are always called first and report back if they handled the option
or not.
Signed-off-by: goldsimon <goldsimon@gmx.de>
The LWIP_PBUF_MEMPOOL define used MEMP_ALIGN_SIZE instead of
LWIP_MEM_ALIGN_SIZE to calculate the element size of PBUF_POOL pbufs.
This is wrong for MEMP_OVERFLOW_CHECK, since MEMP_ALIGN_SIZE adds
MEMP_SANITY_REGION_AFTER_ALIGNED. This should be only added during
pool_base buffer allocation but for PBUF_POOL, it changed the size
of the pool elements.
This cleans up the code: sys_timeouts_mbox_fetch() was only used from
tcpip.c anyway, so let's move it there.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This fixes build error when LWIP_IPV4=0 && LWIP_IPV6=1:
cc -g -Wall -DLWIP_DEBUG -pedantic -Werror -Wparentheses -Wsequence-point -Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wc++-compat -Wwrite-strings -Wold-style-definition -Wcast-align -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wunreachable-code -Wuninitialized -Wlogical-op -I. -I../../.. -I../../../../lwip/src/include -I../../../ports/unix/port/include -I../../../../mbedtls/include -Wno-redundant-decls -DLWIP_HAVE_MBEDTLS=1 -c ../../../../lwip/src/apps/mdns/mdns.c
../../../../lwip/src/apps/mdns/mdns.c: In function ‘mdns_recv’:
../../../../lwip/src/apps/mdns/mdns.c:1817:10: error: implicit declaration of function ‘ip_addr_cmp_zoneless’; did you mean ‘ip6_addr_cmp_zoneless’? [-Werror=implicit-function-declaration]
if (!ip_addr_cmp_zoneless(ip_current_dest_addr(), &v6group)) {
^~~~~~~~~~~~~~~~~~~~
ip6_addr_cmp_zoneless
../../../../lwip/src/apps/mdns/mdns.c:1817:10: error: nested extern declaration of ‘ip_addr_cmp_zoneless’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This can be used to post preallocated messages from an ISR to the tcpip thread
when using FreeRTOS, where where calls differ between task level and ISR level.
Signed-off-by: goldsimon <goldsimon@gmx.de>
This broke when IPv6 got scopes added. Scopes/zones are checked
even if none of the compared addresses are link local.
Result of the bug was that IPv6 replies were always sent unicast to
the source instead of to the multicast address.
Add ip-generic version that ignores IP zone info, since the v6 group
address is not tied to any netif.
Changes made by me:
- Move all error handling code into mdns_resp_announce() so it can be safely used by external code
- Remove mdns_resp_netif_settings_changed() because it is the same as mdns_resp_announce() after my changes
- Declare #define for a "thread-safe" version of mdns_resp_announce in mdns.h instead of netifapi.h - I don't want to intermix netif API with APPs
Current code only works if the argument happen to be named as fraghdr,
fix it.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
This adds const to the sntp servername get/set API and internal storage
SNTP's usage of this name is read only and SNTP only passes it to dns_gethostbyname()
This was found by compiling with GCC -Wwrite-strings which makes the literal
SNTP_SERVER_ADDRESS a const string. This then produced warnings with sntp_init()'s
call to sntp_setservername()
lwip_isdigit/isxdigit/islower/isspace takes int as argument, so
explicitly cast to int to silence below build warnings.
src/core/ipv4/ip4_addr.c: In function 'ip4addr_aton':
src/core/ipv4/ip4_addr.c:160:5: warning: array subscript has type 'char' [-Wchar-subscripts]
if (!lwip_isdigit(c)) {
^
src/core/ipv4/ip4_addr.c:175:7: warning: array subscript has type 'char' [-Wchar-subscripts]
if (lwip_isdigit(c)) {
^
src/core/ipv4/ip4_addr.c:178:7: warning: array subscript has type 'char' [-Wchar-subscripts]
} else if (base == 16 && lwip_isxdigit(c)) {
^
src/core/ipv4/ip4_addr.c:179:9: warning: array subscript has type 'char' [-Wchar-subscripts]
val = (val << 4) | (u32_t)(c + 10 - (lwip_islower(c) ? 'a' : 'A'));
^
src/core/ipv4/ip4_addr.c:204:3: warning: array subscript has type 'char' [-Wchar-subscripts]
if (c != '\0' && !lwip_isspace(c)) {
^
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This adds a new hook allowing an external DNS resolver to be hooked into
netconn_gethostbyname(). The hook can handle some or all of the queries
One use case for this hook is to run mDNSResponder in the same system as LwIP
(mDNSResponder also uses LwIP's socekt APIs) and have it handle .local queries
while LwIP stack handles unicast DNS queries
ARMCC when using __packed structures will not implicitly convert a
pointer to a member of a packed structure to something which does not
have __packed. This results in a compiler error and was found with calls
to icmp6_param_problem
While there is a #pragma pack mode in ARMCC that disables this error, it
does require existing ports to switch over their packing mode and
perform integration
Current newlib does not define O_NDELAY, but it needs to be the same
as O_NONBLOCK rather than using the lwip value of 1.
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
This makes two cleanups that follows the same organization as close/closesocket:
1) There is no lwip_ioctlsocket. Instead lwip_ioctl should redirect to ioctlsocket
2) With LWIP_POSIX_SOCKETS_IO_NAMES enabled, lwip_ioctl/ioctlsocket should redirect to ioctl
Some systems need to take into account an RX buffer pool size when
advising an appropriate number of RX pbufs to queue on the ooseq
list. For some systems there is a practical hard limit beyond which
the rx pool becomes exhausted blocking reception of further buffers
until some are freed.
It also helps to be able to consider the available dynamic memory when
advising an appropriate maximum number of bytes to buffer on the ooseq
list.
These decisions can also benefit from knowing the number already
allocated on a particular pcb, so the ooseq tcp segement is passed to
these functions. For example, if the system only wants to allow the
total number of rx pbufs queued on all the ooseq lists to grow by one
and a pcb already has two then it can return three for this call, but
might return one for another call - supporting a greedy allocation
strategy.
Signed-off-by: goldsimon <goldsimon@gmx.de>
For this, convert 'u8_t nexth' to a pointer and change 'icmp6_param_problem()' to take a pointer, not an offset number
Signed-off-by: goldsimon <goldsimon@gmx.de>
This re-works the persist timer to have the following behavior:
1) Only start persist timer when a buffered segment doesn't fit within
the current window and there is no in-fligh data. Previously, the
persist timer was always started when the window went to zero even
if there was no buffered data (since timer was managed in receive
pathway rather than transmit pathway)
2) Upon first fire of persist timer, fill the remaining window if
non-zero by splitting the unsent segment. If split segment is sent,
persist timer is stopped, RTO timer is now ensuring reliable window
updates
3) If window is already zero when persist timer fires, send 1 byte probe
4) Persist timer and zero window probe should only be active when the
following are true:
* no in-flight data (pcb->unacked == NULL)
* when there is buffered data (pcb->unsent != NULL)
* when pcb->unsent->len > pcb->snd_wnd
- add a better-documented static function tcp_output_segment_busy
- try to reduce the number of checks
- tcp_rexmit_rto: iterate pcb->unacked only once
- no need to check for ref==1 in tcp_rexmit_fast when tcp_rexmit does
- call tcp_rexmit_fast if dupacks >= 3 (not == 3) and use TF_INFR flag to guard the fast-rexmit case (that way, it's triggered again on the next dupack)
- added `altcp_tls_free_config()`.
- added `altcp_tls_context()` function to allow mbedtls parameter tweak.
Since state structure isn't exported, this allow application to get
internal context (port dependent) to tweak it.
- free altcp_pcb when lower error callback called.
- expose `altcp_tcp_setup()` so we can wrap altcp over existing tcp pcb.
- avoid calling tcp_close() with NULL pcb.
- free altcp_pcb struct when error callback called.
According to `mqtt_tcp_err_cb()` in src/apps/mqtt/mqtt.c, altcp socket should
work the same way than raw tcp socket. So freeing altcp_pcb ensure this.
The new functions both take size_t as increment/decrement argument instead of s16_t (which needed to be range-checked before conversion everywhere) - in most places, the direction (increment or decrement) is known anyway, so no need to encode it in a sign bit
These are now defined to return != SYS_ARCH_TIMEOUT on success rather than the time
waiting. The returned times were unused by lwip and this simplifies at
least some implementations.
Signed-off-by: goldsimon <goldsimon@gmx.de>