Commit Graph

6827 Commits

Author SHA1 Message Date
Simon Goldschmidt
b3046d938e nd6: use a pointer where appropriate to make the code more readable
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:33:21 +01:00
Simon Goldschmidt
177bb6ca06 nd6: update addr_hint only if the index has actually changed 2020-02-03 20:57:28 +01:00
Simon Goldschmidt
4c15191b1d snmp: update documentation 2020-02-03 20:35:22 +01:00
Simon Goldschmidt
5de4967f23 ip4: forward: try to fix the build...
... by adding a default case
2020-01-30 23:22:00 +01:00
Simon Goldschmidt
38894637e7 ip4: forward: remove invalid const modifiers
This should fix the build...
2020-01-30 23:13:07 +01:00
Simon Goldschmidt
61c67fc229 ip_forward: fix IPv4 forwarding with multiple netifs/offloading
When we have multiple netifs where at least one has checksum offloading
capabilities, IP forwarding needs to set various checksum fields to 0
to prevent HW algorithms on calculating an invalid checksum.

-> set checksum fields of IP/UDP/TCP/ICMP to 0 in ip4_forward().

See bug #56288

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 23:02:16 +01:00
Simon Goldschmidt
695c323164 icmp: add a dedicated struct for the standard ICMP header
This is just to keep the code clean and prevent using the "echo" header
where any ICMP header is meant.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 22:50:25 +01:00
Simon Goldschmidt
75b2db4438 makefsdata: error files must start with "<errnr>." to match HTTP status
This is to prevent files like "4001.jpg" getting HTTP status 400 instead
of 100.

See bug #56290.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:22:36 +01:00
Simon Goldschmidt
0f5bf0aa37 httpd: error files must start with "<errnr>." to match HTTP status
This is to prevent files like "4001.jpg" getting HTTP status 400 instead
of 100.

See bug #56290.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:22:03 +01:00
Patrick Schlangen
8d7e436a9d Fix select_waiting not being decremented for sockets closed while in lwip_select()
See bug #57445. Short version of the description there: lwip_select() failed
to decrement 'select_waiting' of a socket since that code part failed on
'free_pending' sockets. However, the code does not have to check that as it
has marked the socket to be in use itself earlier.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 21:04:37 +01:00
Simon Goldschmidt
32a72b1a20 sntp: ensure sntp_retry_timeout reaches the configured limit
See bug #57620

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:47:19 +01:00
Felix Werner
3b2d7e289a Additional Debug-Print in api_msg.c
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:43:56 +01:00
Simon Goldschmidt
a4b578b483 pbuf: avoid using multiple PBUF_POOL buffers for IPv6
Use 'PBUF_IP_HLEN+PBUF_TRANSPORT_HLEN' instead of '40' to calculate
PBUF_POOL_BUFSIZE (the size of each PBUF_POOL buffer) since the former
can be 60 when IPv6 is enabled.

See bug #56355

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-30 20:42:15 +01:00
Simon Goldschmidt
dae8eb8d6e adapt unit test to new netif ext callback reason 2020-01-13 19:37:59 +01:00
Simon Goldschmidt
d6b5b5222f opt: make LWIP_IPV6_SEND_ROUTER_SOLICIT default to LWIP_IPV6
This ensures struct netif doesn't contain 'rs_count' if LWIP_IPV6
is disabled but LWIP_IPV6_SEND_ROUTER_SOLICIT is at its default.

See bug #56509
2020-01-12 20:34:18 +01:00
Simon Goldschmidt
8a8058a436 netif: add IPV4_ADDR_VALID ext status callback reason
This ext-callback reason is always issued when an IPv4 config
has been set, even if it has not changed (e.g. DHCP reboot)

See bug #55121
2020-01-12 20:30:38 +01:00
Simon Goldschmidt
bb31fbd737 ip6: fix printing rx packet headers
The call to ip6_debug_print needs to be moved before the
next-header parsing code.

See bug #56708
2020-01-10 23:10:49 +01:00
Simon Goldschmidt
bf1285e3c9 ppp: don't link debug functions if disable
This converts all ppp_*() debug functions to ppp_*(()) macros that
ensure the code is left out by the linker if the corresponding debug
setting is disabled.

Downside is that many lines of code are touched, but since these
already differ to upstream PPP sources, I figured that's ok...

See bug #55199

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-01-10 21:42:45 +01:00
Simon Goldschmidt
827b60c155 debug: split debug enable checks from LWIP_DEBUGF to LWIP_DEBUG_ENABLED
In order to reuse the debug-enable checks for PPP debug macros,
move the flag and level checks from LWIP_DEBUGF to a new macro
that can be used elsewhere.
2020-01-10 20:50:25 +01:00
Simon Goldschmidt
b43f081b9a sockets: ioctl: fix _IO macros for 16 bit platforms
See bug #57565
2020-01-10 20:46:23 +01:00
David Girault
5c2887a241 sntp: remove existing timeout before creating new
This prevents sntp using more than 2 timeouts.
See bug #56431
2020-01-10 20:42:17 +01:00
Axel Lin
555812dcec netif_find: correctly check if atoi means '0' or error
Fixes: 4528215c99 ("netif_find: check if atoi means '0' or error")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2019-12-12 09:23:11 +08:00
Simon Goldschmidt
f857260e29 fix compiling fuzz test under Linux after merging contrib to main repo 2019-12-11 22:20:14 +01:00
David Girault
2be031e238 altcp_tls: ensure no memory leaks and entropy counter is protected 2019-12-11 21:22:42 +01:00
David Girault
dc7ba26e69 altcp_tls: use ERR_CLSD only for handshake error
This allow better handling of handshake error in application.
2019-12-11 21:22:42 +01:00
David Girault
316dbc792f altcp_tls: call the application sent() callback with usefull len
First calculate and sum TLS overhead when altcp_mbedtls_write() is called.
Then take care of it when calling application sent callback. Give reveived
len from inner_conn, minus calculated overhead.
2019-12-11 21:22:41 +01:00
David Girault
f97dacd014 altcp_tls: support for saving/restoring session information
According to mbedTLS source code and documentation, calls to
`mbedtls_ssl_conf_session_cache` and `mbedtls_ssl_conf_session_tickets_cb`
are only available if mbedTLS is configured for server mode (ie. MBEDTLS_SSL_SRV_C
is defined). This cannot be used on client mode to resume a previous session.

To allow session reuse in client mode, application must save session parameters
(including tickets provided by the server if any) after successfull connection
and restore them before attemting to reconnect. Since `alctp_close()` free the
structure, it cannot be used to store the required information.

So, two new API were added, directly wrapped to mbedTLS functions, allow application
to do that by itself.

Also added full declaration of `struct altcp_tls_session` in altcp_tls.h to allow
easier usage in application when using mbedTLS port.
2019-12-11 21:22:41 +01:00
David Girault
d84a84e5ca altcp_tls_mbedtls: ensure configuration is properly freed 2019-12-11 21:22:41 +01:00
Simon Goldschmidt
44a3f631b3 inet: added missing IN6_IS_ADDR_* macros 2019-12-11 21:11:55 +01:00
Simon Goldschmidt
a9e73bc412 ip6addr_aton: support scoped address strings (via '%')
See task #15393

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:43:28 +01:00
Simon Goldschmidt
4528215c99 netif_find: check if atoi means '0' or error
Since atoi() returns 0 on error, we need to check if name[2] is '0'.
If it's not, atoi() failed.
2019-12-11 20:42:36 +01:00
Simon Goldschmidt
fbe032d05d mdns: fix clang warning about documentation error 2019-12-11 20:23:14 +01:00
David Girault
4baf17d5b2 mdns: restart probing when IP addresses has changed
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
4ca115a08e mdns: move MDNS_PROBE_DELAY_MS to mdns_opts.h to allow customisation
In some noisy WiFi environment, it may be necessary to increase this value to
300ms to accomodate WiFi latencies which may result in less than the required
250ms between two probe frames received by the Apple BCT application.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
2441c6fa3f mdns: abort packet analysis if conflict detected
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
6302423d7f mdns: handle tiebreaking loose like conflict
- Count tiebreaking loss in num_conflicts to include them in rate limit detection
- Restart probing using mdns_resp_restart allowing rate limiting for those cases

This ensure rate limiting is well activated during Apple Bonjour Conformance Tests.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:10 +01:00
David Girault
9301225895 mdns: support for multi-packet known answer (questions with TC bit)
This allow Apple Bonjour Conformance Test to not fail with the following tests:
- DISTRIBUTED DUPLICATE SUPPRESSION
- MULTIPLE QUESTIONS - DISTRIBUTED DUPLICATE SUPPRESSION

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:13:01 +01:00
David Girault
e85e473838 mdns: remove service TXT record from probe packets
TXT records isn't required to be unique in network, so it shouldn't be
included in probe packets.

Additionnaly, when TXT record is present, the Bonjour Conformance Test
from Apple Inc. always fail because generated probe nevert have TXT record.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:12:26 +01:00
David Girault
710b7fc158 mdns: add mdns_resp_restart_delay to allow re-probe delay selection
Called with `MDNS_INITIAL_PROBE_DELAY_MS` or `MDNS_PROBE_DELAY_MS` according to
needs.

When `mdns_resp_restart_delay()` called by `mdns_resp_rename_(netif|service)()`
functions, it is assumed this is because a conflict. So we should not use
`MDNS_INITIAL_PROBE_DELAY_MS` because the Bonjour Conformance Test will
complain like this:

```
START (PROBING)
NOTICE  16:40:09.501911: conflicting probe:
        smarTrEMotE-f8d0a4.Local.
ERROR   16:40:09.607288: Device did not provide a sufficient time gap between receiving a conflicting probe and reprobing.
ERROR   16:40:09.607333: expected_time_gap=237,actual_time_gap=105
```

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:12:04 +01:00
David Girault
cd278c426d mdns: remove duplicate acd_state_enum_t declaration
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
David Girault
aa79b90d3c mdns: update probe conflict function to provide service in conflict
- Send service slot index to the mdns result function. In case of conflict, the user
  will have to remove the service or rename it.
- Break after hostname conflict in order to managed it first, and managed service name
  conflict after.
- Provide a function to get the TXT userdata for a service (allowing app to match with
  its own data).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
David Girault
a2498898b0 mdns: increase mDNS output packet size
When more than one service (just 2) need to be probed for conflict, generation
of the probe packet fail because pbuf is too small!

So OUTPACKET_SIZE renamed to MDNS_OUTPUT_PACKET_SIZE and moved to mdns_opts.h
to allow configuration. Default configuration raise it to 1450 to have enough
space when MDNS_MAX_SERVICES > 1 else it remain 512.

Extract from RFC 6762, chapter 17, Multicast DNS Message Size:

   The 1987 DNS specification [RFC1035] restricts DNS messages carried
   by UDP to no more than 512 bytes (not counting the IP or UDP
   headers).  For UDP packets carried over the wide-area Internet in
   1987, this was appropriate.  For link-local multicast packets on
   today's networks, there is no reason to retain this restriction.
   Given that the packets are by definition link-local, there are no
   Path MTU issues to consider.

   Multicast DNS messages carried by UDP may be up to the IP MTU of the
   physical interface, less the space required for the IP header (20
   bytes for IPv4; 40 bytes for IPv6) and the UDP header (8 bytes).

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-11 20:11:13 +01:00
Simon Goldschmidt
cb3f0a9b17 fuzz: adapt to changes in mdns
mdns_resp_add_netif() takes only 3 arguments
2019-12-11 19:50:50 +01:00
Simon Goldschmidt
0caacf82b4 netif_add: zero-init netif->acd_list 2019-12-11 19:49:50 +01:00
Simon Goldschmidt
e0be5a7f6d default_netif.c: add missing include
For sys_msleep(), we need to include sys.h
2019-12-11 19:49:26 +01:00
Joan Lledó
2b6d9a56f7 Contrib: Add kFreeBSD to the Unix port
* cc.h:
  * Identify kFreeBSD by macros
  * Use standard error codes for this OS

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:55:22 +01:00
Christoffer Lind
f47d2ed5fe sys_arch_mbox_tryfetch not validated correctly
sys_arch_mbox_tryfetch() shall return SYS_MBOX_EMPTY or 0 according
to the documentation. Wherever the function is used the return
value is incorrectly compared to SYS_ARCH_TIMEOUT. For now
SYS_MBOX_EMPTY is defined to SYS_ARCH_TIMEOUT so this is not an
issue as long as SYS_MBOX_EMPTY isn't re-defined.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:46:47 +01:00
Simon Goldschmidt
af0499131f autoip: fix typo
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:43:47 +01:00
David Girault
30d445bd39 acd: inform address is good only when going in ongoing state
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00
David Girault
05ffe144dd acd: reset conflict count to ensure fast re-probing after announcing
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00