Commit Graph

2367 Commits

Author SHA1 Message Date
Simon Goldschmidt
fc85b055d7 sys: add the possibility to fuzz what sys_now() returns 2020-02-17 21:39:46 +01:00
Simon Goldschmidt
1ffcc5079c Fix-more-typos-using-codespell
Committing nearly all changes done by 'codespell_check.sh -w'

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:53 +01:00
jona
d6a6b661d9 Fix typos using codespell
Conservative strategy was used, maybe other typos remain.

Rebased: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 21:45:41 +01:00
Simon Goldschmidt
d843e47a1d icmp6: keep to the RFC and send as much as possible with icmp6 error messages
See bug 56013

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-05 20:43:25 +01:00
Simon Goldschmidt
84228d4f4b nd6: cache neighbour index for each next hop, not globally
See bug #47792

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:53:22 +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
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
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
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
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
Simon Goldschmidt
44a3f631b3 inet: added missing IN6_IS_ADDR_* macros 2019-12-11 21:11:55 +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
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
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
03998f5147 autoip: fix 'autoip_remove_struct()' after changing storage to 'netif_client_data'
Reported-by: Amena El Homsi <amena.elhomsi@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-11-21 22:19:35 +01:00
Joan Lledó
7fd158a109 Make socket functions depend on LWIP_SOCKETS
* Socket functions definitions moved out of the
  #define LWIP_SOCKET_EXTERNAL_HEADERS as all users who
  set LWIP_SOCKETS to 1 will need them regardless they use
  lwip's or external socket headers.
2019-08-16 10:59:31 +02:00
Joan Lledó
f92d6702bc Sockets: declare msghdr->msg_iovlen as msg_iovlen_t
* Lwip declares msghdr->msg_iovlen as int, but when
  using external socket headers, some systems declare
  msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
  expects users to typedef it to the type they need
  for their system.
2019-08-11 20:12:02 +02:00
Simon Goldschmidt
602a66fe58 sockets: convert _HAVE_SA_LEN to lwip style 2019-08-01 21:04:06 +02:00
Joan Lledó
f126750ccd Add support for struct sockaddr with no sa_len field.
Lwip's struct sockaddr includes sa_len, but some systems
like Linux doesn't have this filed, which produces many
compilation problems when using external headers.

A set of macros has benn added to detect the absence of
sa_len and adapt sockets.c
2019-08-01 20:49:54 +02:00
Joan Lledó
fa6f8054eb Move LWIP_MARK_TCPIP_THREAD to include/lwip/sys.h
* LWIP_MARK_TCPIP_THREAD moved to include/lwip/sys.h
* Unix port macro definitions moved to sys_arch.h
  * LWIP_MARK_TCPIP_THREAD
  * LOCK_TCPIP_CORE
  * UNLOCK_TCPIP_CORE

(goldsimon@gmx.de: fixed unix Makefile build and win32 build)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:09:40 +02:00
Freddie Chopin
8291ff3dc0 Fix definition of LWIP_NUM_SYS_TIMEOUT_INTERNAL
In timeouts.c commit 7d1c26cc0c replaced
timeout for AUTOIP with a timeout for ACD, however the value of
LWIP_NUM_SYS_TIMEOUT_INTERNAL was not updated and still counts
LWIP_AUTOIP instead of LWIP_ACD. If user has AUTOIP disabled (or not
explicitly enabled) and DHCP enabled, then ACD gets automatically
enabled too. In this case there will be one timeout too little for lwIP
and first TCP packet received causes an assertion.

Also add LWIP_IPV6_DHCP6 to the value of LWIP_NUM_SYS_TIMEOUT_INTERNAL,
as it was also not accounted for.
2019-07-26 19:44:35 +02:00
Joan Lledó
9dca4a0211 New function tcpip_callback_wait() * Call a function inside the tcpip thread and block the calling thread until the callback finishes.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-13 20:52:48 +02:00
Joan Lledó
3546a0a4a0 IF_NAMESIZE: define it only if it's not defined before by system headers 2019-07-13 20:49:48 +02:00
Simon Goldschmidt
5465fdfd69 netconn: add callback arg storage
This reuses the member 'int socket' by making it a union containing
both int and void pointer.

See bug #56593.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
Suggested-by: Wilfred <wilfrednilsen@hotmail.com>
2019-07-13 20:46:36 +02:00
Simon Goldschmidt
aa545fbbc6 LWIP_NETCONN_FULLDUPLEX is not alpha any more 2019-07-10 21:14:35 +02:00
Giuseppe Modugno
832490eec8 Added the configuration option ALTCP_MBEDTLS_AUTHMODE to set the certificate verification mode.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-06-11 21:15:45 +02:00
Our Air Quality
ff17530997 mdns mdns_search_service mdns_search_stop: define the request id as unsigned. 2019-04-30 14:53:58 +02:00
Dirk Ziegelmeier
3d7ff53070 Apply patch for bug #56098: Support for MQTT over TLS port 443 instead of 8883 2019-04-30 13:22:09 +02:00
Our Air Quality
46bbfe4ee2 mdns: defined the service slot id as unsigned rather than signed. 2019-04-30 12:33:22 +02:00
Freddie Chopin
ec11b289cb Fix and simplify newlines in doxygen documentation
Replace '\n' with '<br>', as this allows doxygen to understand reference
names followed by newline. For some cases just drop the newline if it's
not required.

Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.

bug #56004
2019-03-28 08:18:20 +01:00
Dirk Ziegelmeier
53818ad3e4 Add #define for minimum IPv6 MTU length 2019-03-28 08:16:47 +01:00
Dirk Ziegelmeier
e479bd56df Fix LWIP_ERROR macro - it should never be fatal (LWIP_ASSERT)
The only difference should be:
- LWIP_DEBUG enabled  -> print a diag message
- LWIP_DEBUG disabled -> NO diag message is printed
2019-02-08 12:29:05 +01:00
Simon Goldschmidt
5666f305ce sntp: obey KoD when using multiple servers
See bug #55253 (SNTP retry next server instantly result as a flood of NTP request).
Added 'sntp_getkodreceived()' to check the status.
2019-01-30 20:42:56 +01:00
Simon Goldschmidt
8e86555f93 mdns: fix compiler errors and coding style 2019-01-30 20:15:26 +01:00
David Girault
b4be0d8808 mdns: added support for searching services
Two new API:
err_t mdns_search_service(const char *name, const char *service, enum mdns_sd_proto proto,
                          struct netif *netif, search_result_fn_t result_fn, void *arg,
                          s8_t *request_id);
void mdns_search_stop(s8_t request_id);

One compilation flags:
LWIP_MDNS_SEARCH

One options flags:
MDNS_MAX_REQUESTS

Some structure declarations moved to allow use by callback result function.

Result domain names are early uncompress before calling application callback
because it cannot be made by application itself.

Allow search services with multiples labels included, like '_services._dns-sd'.

Search for `_services._dns-sd._udp.local.` is handled in a special way.
Only `PTR` answers are send back to the application.

The `mdns_search_service()` function won't assert if no more space in `mdns_request`
table, just return an error if too many simultanous requests.
2019-01-30 20:05:51 +01:00
Ivan Warren
9263d44847 Small documentation fix for TFTP
Apparently the TFTP server now also invokes the error() function in the
tftp_context struct.

Some tftp clients (for example Windows 10 TFTP client) will open the
remote file before checking the local file can be opened - and will then
send an error indication to the server to indicate there was an error
opening the local file. When the happens, the LWIP tftp server will
invoke the error() member of the tftp_context.
2019-01-30 19:56:49 +01:00
David J. Fiddes
8f2f43f093 Implement RFC4075 Receive SNTP servers via DHCPv6
This adds support for RFC4075 SNTP server configuration via DHCPv6.
The DHCPv6 options transmitted are now conditional on how LwIP is
configured.

A new SNTP application option SNTP_GET_SERVERS_FROM_DHCPV6 is used
to enable. For simplicity this is configured to use the global
LWIP_DHCP6_GET_NTP_SRV configuration setting.

Tests:
 - Check the global options now control the DHCPv6 request sent
   in Wireshark
 - Check against 0, 1 and 3 SNTP servers configured on an odhcpd
   server configured to support RFC 4075 SNTP server lists.
   Verify that the SNTP server list is updated on connection
   establishment on an ESP8266 WeMOS D1.
 - Verify that SNTP packets are sent and recieved from a
   configured server and that system time is updated.

Signed-off-by: David J. Fiddes <D.J@fiddes.net>
2019-01-30 17:49:18 +01:00
David Girault
b04d8a6a6c altcp: support for setting keepalive parameters 2019-01-30 17:42:46 +01:00
David Girault
b298afabdc altcp_tls_mbedtls: remove entropy/ctr_drbg from altcp_tls_config struct
Use only one entropy/ctr_drbg context for all altcp_tls_config structure allocated.

(Small adjustments before committing: fix coding style, adapt to changes in master)
2019-01-30 17:42:39 +01:00
Dirk Ziegelmeier
ea14b774c8 Replace several occurences of stdint types by lwIPs portability typedefs
Fixes bug #55405: Usage of uint8_t instead of ui8_t in TCP code
2019-01-06 21:19:04 +01:00
Jacob Kroon
c02fea0961 PPP, PPPoE: use service name and concentrator name
Make pppoe_create() actually store the passed service name and
concentrator name, so that they are passed in the PADI/PADR/PADS
packets.

Assume that the user application won't be freeing the strings and just
copy the string pointers, therefore remove the mem_free() in
pppoe_destroy().

Since only the pointers are copied now, make them 'const' in
pppoe_softc.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-20 13:24:04 +01:00
Jacob Kroon
7eab5947af PPP, PPPoE: fix build when PPPOE_SCNAME_SUPPORT is defined
lwip/src/netif/ppp/pppoe.c:768:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l1 = (int)strlen(sc->sc_service_name);
lwip/src/netif/ppp/pppoe.c:772:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l2 = (int)strlen(sc->sc_concentrator_name);

sc->sc_service_name and sc->sc_concentrator_name are best defined as
char* because there are passed to libc strings functions which expect
a char*.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:13:46 +01:00
Sylvain Rochet
96548ede2b PPP, PPPoE: rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT, prepare service name and concentrator support
Rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT because this is the only
feature enclosed by them. Prepare for proper service name and
concentrator name support by moving PPPOE_SCNAME_SUPPORT define to
ppp_opts.h.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:09:48 +01:00