Commit Graph

6183 Commits

Author SHA1 Message Date
Harrold Spier
79c8a04152 SNMP netconn API should not check for core locked
See patch #9907
2021-03-04 21:29:20 +01:00
Jeremy HU
4a169109a7 makefsdata: Fix flags missing
Fix the Perl script from which the generated fsdata.c cause runtime assertion: "HTTP headers not included in file system".
2021-03-04 21:16:48 +01:00
Oliver Hitz
b5176936c7 tcp: make tcp_listen() inherit the netbuf_idx of the original pcb
This simple patch causes tcp_listen() to inherit the netbuf_idx setting
of the original pcb. Without this, it is not possible to restrict a
socket to a specific interface using SO_BINDTODEVICE before listening.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-03-04 21:15:25 +01:00
Simon Goldschmidt
3666dcc66c tcp: send RST to input netif when no pcb is available
If we know there's no matchin pcb (e.g. for routing), don't even
try to pass NULL but instead send the RST to the input netif.

See also patch #9988.
2021-03-04 21:10:28 +01:00
Simon Goldschmidt
1f4a029d10 mqtt: check data_cb != NULL 2021-03-04 20:18:04 +01:00
Simon Goldschmidt
d7a0757764 mqtt: allow calling mqtt_set_inpub_callback before mqtt_client_connect
See also patch #10037
2021-03-04 20:14:46 +01:00
Christoffer Lind
600e248f06 dhcp: generate new xid for DHCP release 2021-03-02 22:49:57 +01:00
Erik Ekman
e02d126b07 lowpan6: Use arch-independent printf formatters 2021-02-13 21:14:29 +01:00
Thomas Mueller
7a2923020f Fix typo in definition of netif_is_flag_set() macro 2021-02-08 19:17:20 +01:00
Simon Goldschmidt
9aae444f49 pbuf_free: remove outdated comment about packet queues
See bug #59875
2021-01-30 22:08:36 +01:00
Simon Goldschmidt
3e098f90df pbuf: fix allocating large PBUF_RAM
See bug #59974
2021-01-30 22:06:46 +01:00
Mike Kleshov
6fee08daab httpd: revert part of previous change
pextension needs to be zeroed in case fs_file structure
is reused in a persistent HTTP connection
2021-01-29 08:02:56 +03:00
yuanjm
b00a05d086 lwip_selscan: lwip_selscan return -1 without setting errno number
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 21:00:37 +01:00
Simon Goldschmidt
fc5b6f7b0e lwiperf: fix double-free of pcb on error
See bug #59841 (PCB double-free happened at lwiperf TCP error)

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2021-01-28 20:00:11 +01:00
Mike Kleshov
9b040624c0 httpd: follow-up to previous commit
see bug #59876
2021-01-28 19:53:57 +03:00
Mike Kleshov
69725292a0 httpd: wrap fs_file::pextension in a config macro
see bug #59876
2021-01-28 08:29:25 +03:00
Mike Kleshov
89dca4588f httpd: follow-up to previous commit, replace strstr() with memcmp() 2021-01-27 19:28:19 +03:00
Mike Kleshov
fdd702e61b httpd: fix bug #58223 2021-01-26 19:19:32 +03:00
Mike Kleshov
1678b21a94 httpd: remove fs_file::is_custom_file, use fs_file::flags instead 2021-01-25 21:49:17 +03:00
Erik Ekman
651d0af0b6 netdb: Accept '0' as service in lwip_getaddrinfo
Fixes bug #59925
2021-01-22 20:20:51 +01:00
Erik Ekman
b5618c51ca altcp: Fix memory leak in altcp_tls_free_config
Reported in bug #59032 by Ondrej Lufinka,
fix suggested by David GIRAULT.
2021-01-13 22:19:47 +01:00
Erik Ekman
35550eeab3 icmp: Fix copied length in response packets
Fixes bug #59364, reported by Yi Guai
2021-01-13 20:31:55 +01:00
Mike Kleshov
c6777547f6 Make sure tag insertion is complete when tag is followed by EOF.
See bug #59728.

Signed-off-by: Mike Kleshov <m.kleshov@gmail.com>
2021-01-01 11:26:30 +03:00
Erik Ekman
c748395bda PPP: Change data argument in sio_write to const
To fix the build after ppp_output_cb started taking it as const in
commit b2d1fc119d.

Fixes this failure:
../contrib/examples/ppp/pppos_example.c: In function ‘ppp_output_cb’:
../contrib/examples/ppp/pppos_example.c:163:29: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
   return sio_write(ppp_sio, (u8_t*)data, len);
                             ^
2020-12-03 09:47:00 +01:00
Sylvain Rochet
d1fc5c2ec4 PPP: add one more timer to PPP_NUM_TIMEOUTS_PER_PCB for late authentication
Authentication timer might still be running when entering network phase
for any necessary rechallenge, mostly for PPP server support.

Update the detailed analysis of simultaneously running PPP timers
taking into account the authentication timer that might still be
running and chose to increase the base number to 2 instead of
adding more unnecessary complexity.
2020-11-17 01:19:21 +01:00
Sylvain Rochet
9a9d92a59e PPP, PAP: cancel PAP timeout when authentication succeed or fail
upap_timeout is not currently stopped on authentication success or
fail events. This may have strange results if session is restarted
in a high pace because even if the timeout callback have a sanity
check against the PAP state the session can be restarted and be
back in the valid state before the timeout callback is actually
called.
2020-11-17 00:50:50 +01:00
Sylvain Rochet
3013e1fc19 PPP: remove unused ppp_pcb CHAP fields if server mode is disabled
pcb->settings.chap_timeout_time and pcb->settings.chap_max_transmits
are only used if server mode is enabled.
2020-11-17 00:26:32 +01:00
Sylvain Rochet
a4514cf416 PPP: fix unused parameter warning on prot_flavor if CHAP support is disabled
prot_flavor parameter is only used if CHAP support is enabled.
2020-11-16 22:26:00 +01:00
Sylvain Rochet
332119d7e0 PPP, magic: dot not assume LWIP_RAND will return 32 bits of randomness
Do not assume LWIP_RAND will return 32 bits of randomness because it is
probably going to be defined to directly return the rand() value. For
example, LCP magic numbers are 32-bit random values.
2020-10-27 21:52:18 +01:00
Sylvain Rochet
e239222775 PPP, magic: cleanup code and documentation
Documentation and simple code cleanup, no behavior change.
2020-10-27 21:47:26 +01:00
Sylvain Rochet
72d9132ecf PPP, PPPoL2TP: skip address & flags for PPP control packets
This is already what we inherently have always done for IPv4/IPv6
packets, so it works. Receivers must handle both cases anyway because
both behaviors are seen in the wild.
2020-10-23 17:34:25 +02:00
Sylvain Rochet
a494b990da PPP, PPPoS: drop in flight packets from the tcpip mailbox if PPP session is down
A previous call to ppp_input might have disconnected the session while
there were still packets in flight in the tcpip mailbox. Drop incoming
packets because ppp_input must never be called if the upper layer is
down.
2020-10-22 23:03:56 +02:00
Sylvain Rochet
a9f19cd7f1 PPP, PPPoS: only check open flag after events that may have changed it
Speed-up a little bit the PPPoS input parser by only checking the open
flag after calling the ppp_input function, the only one that can induce
a state change here.
2020-10-22 20:56:23 +02:00
Sylvain Rochet
22f13c24aa PPP: assert if ppp_set_* functions are called when session is not dead
ppp_set_* functions that set the PPP session parameters must only be
called when the session is in a dead state (i.e. disconnected),
otherwise not fatal but surprising results may happen.
2020-10-21 02:11:59 +02:00
Sylvain Rochet
dbb7c00aa5 PPP: add LWIP_ASSERT_CORE_LOCKED to ppp_set_notify_phase_callback
This function call the notify phase callback that should be called from
the lwIP core thread. This is especially true if the user callback
is not designed to be reentrant.
2020-10-21 01:43:57 +02:00
Freddie Chopin
c18a8dc9cc PPP, PPPoS: Remove useless cast from pppos_output_append() and pppos_output_last()
pppos_output_cb_fn() now takes `const void*`, so there is no need to
cast the payload (`void*`) to anything else.
2020-10-20 05:38:05 +02:00
Freddie Chopin
b2d1fc119d PPP, PPPoS: Use const void* instead of u8_t* in pppos_output_cb_fn()
There is no good reason why this function should take a non-const
pointer, as the output callback should never modify what lwIP gives it.
While changing that also switch to a more generic `void*` instead of
"byte".
2020-10-20 05:38:03 +02:00
Freddie Chopin
34156e0594 PPP, PPPoS: Remove useless cast from pppos_input_sys()
pppos_input() now takes `const void*`, so there is no need to cast the
payload (`void*`) to anything else.
2020-10-20 05:30:21 +02:00
Freddie Chopin
5ad2f06333 PPP, PPPoS: Use const void* instead of u8_t* in pppos_input()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:17 +02:00
Freddie Chopin
c5021bdc4d PPP, PPPoS: Use const void* instead of u8_t* in pppos_input_tcpip()
There is no good reason why this function should take a non-const
pointer. While changing that also switch to a more generic `void*`
instead of "byte".
2020-10-20 05:30:12 +02:00
Sylvain Rochet
3b57750715 PPP: remove LWIP_ASSERT_CORE_LOCKED on ppp_set_auth function
We do not have equivalents in PPPAPI for ppp_set_* functions because
calling them only makes sense while session is disconnected, furthermore
they are only setting structure members of the session configuration.
2020-10-20 04:15:25 +02:00
Sylvain Rochet
9b7cba9643 PPP: don't define PPP_IP if PPP_IPV4_SUPPORT is disabled
Doing so helps a lot at finding places where we have leftovers of IPv4
support when the support is disabled.
2020-10-20 03:59:34 +02:00
Sylvain Rochet
6584002826 PPP, PPPoS: only reserve header space for IPv4 and IPv6 packets if IP forwarding is enabled
We only have to reserve header space for forwarding for IPv4 and IPv6
packets, all other packets are PPP control packets. Doing so reduce
the need of having to coalesce the PBUF chain before PPP processes
control packets.
2020-10-20 03:53:07 +02:00
Sylvain Rochet
e801307738 PPP: set mtu6 too when setting PPP netif MTU
PPP peer can negotiate its MRU, therefore we don't know the MTU we are
going to use before starting PPP. This is an issue because netif_add
function assume that the netif init callback function will set the MTU,
netif_add will then copy mtu to mtu6. We have then to update mtu6 each
time we update mtu to keep them in sync. Doing so is fine because PPP
netif MTU is only updated when the netif is in link down state.
2020-10-20 02:53:46 +02:00
Sylvain Rochet
a39ce0f53b PPP, PPPoS: drop input packets much bigger than our MRU
Our current HDLC decoder does not protect against starving the Rx
PBUF POOL for one packet, most likely due to received garbage on
the serial port.

Prevent starving the Rx pool by checking incoming packets length
against PPP_MRU with a 10% margin because we only want to avoid
filling all PBUFs with garbage, we don't have to be pedantic.

Fixes bug #58441: Invalid PPP data accumulates forever.
2020-10-20 02:18:48 +02:00
Sylvain Rochet
51c6548631 PPP: allow negotiating MRU with PPP_MRU config option
PPP_MRU is now free to be used for what it should have been. Now using
it at PPP init stage to set the wanted MRU value, triggering a MRU
negotiation at the LCP phase.

I doubt anyone needs it anyway, but, well, at least it is fixed and the
MRU/MTU config mess is cleaned.

And while we are at it, better document PPP MRU config values.
2020-10-19 00:53:11 +02:00
Sylvain Rochet
90874392e3 PPP: force default MRU to 1500
RFC1661 mandates that default MRU value, that must be used prior
negotiation of MRU value and if MRU value is not negotiated later, must
be 1500.

That is, any PPP host must accept control frames of at least 1500 when
the PPP session start (there are no way to split them in multiples
frames anyway) and must use a value of 1500 if MRU is no negotiated
during LCP exchanges.

Therefore, having it configurable in ppp_opts is a mistake. It was wrong
and never worked because changing the value never triggered a MRU value
negotiation because it changed both the wanted MRU value and the RFC
default value to which the wanted value is compared to trigger a MRU
negotiation if values are not equal.
2020-10-18 23:54:48 +02:00
Sylvain Rochet
b8640678d6 PPP, LCP: merge PPP_MRU into PPP_DEFMRU
This is actually the same thing, both values are used interchangeably in
various places but their value must be the same.
2020-10-18 22:36:53 +02:00
Sylvain Rochet
331fe2dea2 PPP: rename netif_set/get_mtu to ppp_netif_set/get_mtu
Those are private functions, using the netif_ prefix here is not really
nice, especially with functions named netif_set_mtu and netif_get_mtu
for obvious reasons.
2020-10-18 22:11:18 +02:00
Sylvain Rochet
7633c24213 PPP, PPPoE, PPPoL2TP: remove persistent retries if sending packets fails
We currently retry indefinitely if sending packets fails, for example
if the output interface is down. We are even doing it if we are in
a middle of a connection process. This is not a very nice behavior
because PPP low level will retry indefinitely to connect and the user
application will never be warned that something is wrong.

We have the persist boolean in PPP settings to achieve more or less
the same thing anyway. Except it does it better at only retrying
indefinitely the initiation packet.
2020-10-18 17:10:13 +02:00
Sylvain Rochet
39cb84466d PPP: remove PPP_USE_PBUF_RAM configuration option
Having it configurable does not really make sense anymore, we already
need PBUF_RAM in all transmit paths. There are no real reason to keep
allocating PPP response buffers from the PBUF_POOL which should be now
reserved for receive paths only.
2020-10-18 16:44:23 +02:00
Sylvain Rochet
012fadd77f PPP: enable PPP_USE_PBUF_RAM by default
We need PBUF_RAM for quite a while for PPP, e.g. through pbuf_coalesce
and for all PPP transmit paths. There are no real reason to keep
allocating packets from PBUF_POOL for PPP control packets transmit path
by default today.
2020-10-18 02:34:43 +02:00
Sylvain Rochet
6b30cf62cc PPP, PPPoL2TP: fix displayed length in debug message
Packet length is p->tot_len here, not len.
2020-10-18 02:29:42 +02:00
Sylvain Rochet
5bf9cebb54 PPP: check that pbuf_coalesce succeed
When pbuf_coalesce fails it does nothing and returns the previous buffer
chain. Adds checks that pbuf_coalesce succeeded, otherwise drop incoming
packet.
2020-10-18 02:18:50 +02:00
Sylvain Rochet
7c0c3879b2 PPP, PPPoS: use PBUF_RAM in transmit pathway
Allocate Tx chunk in PBUF_RAM, using PBUF_POOL_BUFSIZE as a great
chosen value for chunk size.
2020-10-18 01:44:09 +02:00
Sylvain Rochet
3779cf7856 PPP, PPPoS: wait for next packet when we drop a packet before it is complete
If we fail to receive a full packet, for exemple if a memory allocation
fail for some reason, we currently do not wait for next packet flag
character and we start filling a new packet at next received byte. Then
we expect the checksum check to discard the packet.

The behavior seem to have been broken one or two decades ago when adding
support for PFC (Protocol-Field-Compression) and ACFC
(Address-and-Control-Field-Compression).

Rework to drop any character until we receive a flag character at init
and when we drop a packet before it is complete.
2020-10-17 20:09:35 +02:00
Sylvain Rochet
88ac7460f0 PPP: cleanup
Code cleaning only (misleading indents or comments, etc.), no behavior
change.
2020-10-17 17:53:04 +02:00
Sylvain Rochet
bedb4e4745 PPP: disable VJ support by default
VJ support is known to be broken when built with some compiler
optimizations enabled, disabling it by default until someone needs it
and fixes it.

It was mostly used with dial-up modems, it is useless with PPPoE and
PPPoL2TP and is probably useless as well with cellular modems, so
disabling it by default makes sense anyway.
2020-10-17 01:19:35 +02:00
Sylvain Rochet
729b3da96d PPP: remove casts from unsigned (strlen return value) to signed when checking auth
In theory, if provided username or password is over 0x80000000 byte long
(err...), casts to signed integer of strlen() return values is going to
return negative values breaking lengths checks.

Fix it by only using unsigned integer or size_t (guaranteed to be
unsigned) comparisons.
2020-10-16 21:16:05 +02:00
Sylvain Rochet
49bbc2d4bf PPP, PPPoE: prevent integer overflows when computing packets length
Check that service_name and concentrator_name strings length will not
trigger integer overflows when computing packets length.
2020-10-16 19:27:46 +02:00
Sylvain Rochet
678a7a4044 PPP, PPPoE: remove casts from unsigned (strlen return value) to signed
Those casts do not serve any purpose and can be safely removed.
2020-10-16 17:17:40 +02:00
Erik Ekman
c385f31076 Remove @ref to fix doxygen build
Generating docs for file src/incl/home/travis/build/lwip-tcpip/lwip/src/include/lwip/ip4_addr.h:151:s
error: unable to resolve reference to `ip4_addr_eq' for \ref command (warning treated as error, aborting now)
2020-07-07 18:59:50 +02:00
Erik Ekman
264a5a3e97 Rename IP and Ethernet equality checkers from _cmp to _eq
Functions ending in cmp are expected to return 0 on equality but these
return non-zero.

eth_addr_cmp -> eth_addr_eq

ip_addr_cmp -> ip_addr_eq
ip4_addr_cmp -> ip4_addr_eq
ip6_addr_cmp -> ip6_addr_eq

ip_addr_netcmp -> ip_addr_net_eq
ip4_addr_netcmp -> ip4_addr_net_eq
ip6_addr_netcmp -> ip6_addr_net_eq

ip_addr_cmp_zoneless -> ip_addr_zoneless_eq
ip6_addr_cmp_zoneless -> ip6_addr_zoneless_eq

ip6_addr_cmp_zone -> ip6_addr_zone_eq
ip6_addr_netcmp_zoneless -> ip6_addr_net_zoneless_eq
ip6_addr_nethostcmp -> ip6_addr_nethost_eq
ip6_addr_cmp_packed -> ip6_addr_packed_eq
ip6_addr_cmp_solicitednode -> ip6_addr_solicitednode_eq

All call sites have been changed, and fallback macros have been added to not
break external users.
2020-07-07 18:51:45 +02:00
Erik Ekman
8363c24e45 zepif: Copy possibly chained output pbuf properly
Fixes bug #58554
2020-07-03 18:55:08 +02:00
Erik Ekman
2bf8fcd7c2 pbuf: Add pbuf_copy_partial_pbuf library function
Like pbuf_copy, but can copy part of a pbuf to an offset in another.
pbuf_copy now uses this function internally.

Replace pbuf_take_at loop in icmp6 with pbuf_copy_partial_pbuf().
2020-07-03 18:55:02 +02:00
Erik Ekman
776e612872 Remove extra newlines in LWIP_ASSERT messages 2020-07-01 20:52:12 +02:00
Erik Ekman
8fe567b86f ip6: Fix incorrect assert in ip6_frag()
New test case now passes.

Fixes bug #57374 (Found by Hiromasa Ito).
2020-06-30 01:27:37 +02:00
Erik Ekman
a49c347b7e pbuf: Update documentation for pbuf_copy
Remove detail from when the method was called pbuf_take
which worked on packet queues.
2020-06-25 10:04:43 +02:00
Erik Ekman
488d4ad246 icmp6: Don't copy too much data
Fix of the fix for bug #58553
2020-06-24 01:09:37 +02:00
Erik Ekman
489405839a icmp6: Fix copying of chained pbuf in reply
Fixes bug #58553, and the newly added unit test.

The pbuf_take_at loop should probably be made into a pbuf library
function, which would avoid this mistake in the future and provide
a simpler implementation of pbuf_copy.
2020-06-24 01:00:12 +02:00
Daniel Pauli
0b370fbade add API function mdns_resp_netif_active() that can be used to test if an MDNS responder is active for a given network interface.
Signed-off-by: Erik Ekman <erik@kryo.se>
2020-06-19 16:23:34 +02:00
Erik Ekman
e80d4ff2cc tcp: Fix double free in tcp_split_unsent_seg()
Fixes bug #57377 (found by Hiromasa Ito).
2020-06-19 15:39:15 +02:00
Sylvain Rochet
3f47b04f16 PPP: add FIXME about removing netif_set_up() call later
User application code should be responsible to call netif_set_up() but
let's not break compatibility for now.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:52:47 +02:00
Sylvain Rochet
c8fda8d46c PPP: use netif_set_up() instead of setting NETIF_FLAG_UP flag
NETIF_FLAG_UP flag is not supposed to be set by netif init callback
anymore, call netif_set_up() instead.

Sure it would be better to let user application code call netif_set_up()
by itself as it is now meant to be but let's not break compatibility for
now and add a FIXME for next release with allowed behavior break.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:45:44 +02:00
Sylvain Rochet
cfe5ce9d49 init: raise an error if PPP CCP_SUPPORT==1 but MPPE_SUPPORT==0
Building PPP CCP support without adding any compressor support serve
no real use case. Forbid doing so instead of bloating the code with
more ifdef.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2020-04-09 03:17:30 +02:00
Sylvain Rochet
cd140b1105 Revert "ppp: fix compiling with CCP_SUPPORT=1 but MPPE_SUPPORT=0"
This reverts commit 6e7ea92d56.

We better forbid building configurations that does not make sense instead
of bloating the code with more ifdef. Here building CCP support without
adding any compressor support serve no real use case.
2020-04-09 03:05:30 +02:00
Hannes Gredler
f36e51e9c9 tcp_out: fix tcp_output_fill_options() arguments
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-04-02 20:15:58 +02:00
Simon Goldschmidt
003d34eebd tcp: fix sequence number comparison
This fixes both undefined behavior (see bug #51447) as well as a possible bug
where sequence numbers in 31 bit distance may come through.
2020-03-27 22:59:05 +01:00
Simon Goldschmidt
e30d50710d fuzz: allow overriding LWIP_RAND for fuzz tests
Fuzz tests need reproducible code, so we need an "unsafe" version of
LWIP_RAND() in this case...

Also, to reproduce fuzz tests cases from Linux on Windows,
LWIP_RAND_FOR_FUZZ_SIMULATE_GLIBC provides the first 20 random numbers that
glibc would have...
2020-03-27 22:42:06 +01:00
Simon Goldschmidt
34352e9649 altcp: mbedtls: no need for SYS_ARCH locking 2020-03-05 21:48:08 +01:00
Simon Goldschmidt
33f2b313c7 altcp: mbedtls: coding style fixes 2020-03-05 21:45:20 +01:00
Simon Goldschmidt
87618e2f2a Revert "altcp_tls_mbedtls: ensure configuration is properly freed"
This reverts commit d84a84e5ca.

This commit seemed to be merged in an invalid order
2020-03-05 21:40:23 +01:00
Simon Goldschmidt
21cde5dc9e altcp: mbedtls: fix compiling altcp_mbedtls_lower_sent() 2020-03-05 21:36:59 +01:00
Karol Domagalski
2e175a23cb ip4: ip4addr_aton: fix parsing of the octal IP representation 2020-03-05 21:27:59 +01:00
Simon Goldschmidt
adbc5b5f71 tcp: tighten up checks for received SYN
Any malicous segment could contain a SYN up to now (no check).
A SYN in the wrong segment could break OOSEQ queueing.
Fix this by allowing SYN only in states where it is required.

See bug #56397: Assert "tcp_receive: ooseq tcplen > rcv_wnd"

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-03-05 21:20:35 +01:00
Harrold Spier
0192fe773e Fix allowing negative offset for snmp_pbuf_stream_seek()
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-21 17:28:33 +01:00
Simon Goldschmidt
349c077feb Fix last commit for all netif loopback traffic 2020-02-21 17:25:51 +01:00
Nick Ballhorn-Wagner
349ec76ee5 fix memory leak in netif_loop_output if tcpip_try_callback fails
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-21 17:17:08 +01:00
Simon Goldschmidt
fc85b055d7 sys: add the possibility to fuzz what sys_now() returns 2020-02-17 21:39:46 +01:00
Simon Goldschmidt
ea9726056c and another codespell fix 2020-02-15 21:54:24 +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
6e7ea92d56 ppp: fix compiling with CCP_SUPPORT=1 but MPPE_SUPPORT=0
Even if that might not make much sense, it still shouldn't
result in compiler warnings.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-15 20:53:47 +01:00
Paul Mackerras
d281d3e959 PPP, EAP: ignore received EAP messages when not doing EAP
This adds some basic checks to the subroutines of eap_input to check
that we have requested or agreed to doing EAP authentication before
doing any processing on the received packet.  The motivation is to
make it harder for a malicious peer to disrupt the operation of pppd
by sending unsolicited EAP packets.  Note that eap_success() already
has a check that the EAP client state is reasonable, and does nothing
(apart from possibly printing a debug message) if not.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sylvain Rochet <gradator@gradator.net> (ported to lwIP PPP pcb struct)
2020-02-10 23:37:33 +01:00
Paul Mackerras
2ee3cbe69c PPP, EAP: fix bounds check in EAP code
Given that we have just checked vallen < len, it can never be the case
that vallen >= len + sizeof(rhostname).  This fixes the check so we
actually avoid overflowing the rhostname array.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sylvain Rochet <gradator@gradator.net> (compiler warning fix about int vs uint comparisons)
2020-02-10 23:37:25 +01:00
Simon Goldschmidt
cc6d5b7a29 ppp: fix compiling eap after changing debug functions 2020-02-06 20:51:02 +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
Gao Qingshui
a9ac18aebb ip6: enable ip6_autoconfig_enabled by default
See bug #56135

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-04 22:23:58 +01:00
Simon Goldschmidt
064d816ea1 altcp: fix altcp_tcp_close for LISTEN pcb
See bug #55219

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 22:13:07 +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
dc41eabf5f nd6: check defines for global tables for validity
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2020-02-03 21:49:57 +01:00
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
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
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
0caacf82b4 netif_add: zero-init netif->acd_list 2019-12-11 19:49:50 +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
David Girault
e09add37c1 acd: fix MAX_CONFLICTS check accorting RFC.
As written in RFC5227 in 2.1.1 Probe Details:

   A host implementing this specification MUST take precautions to limit
   the rate at which it probes for new candidate addresses: if the host
   experiences MAX_CONFLICTS or more address conflicts on a given
   interface, then the host MUST limit the rate at which it probes for
   new addresses on this interface to no more than one attempted new
   address per RATE_LIMIT_INTERVAL.

But `acd_restart` restart function check for `acd->num_conflicts > MAX_CONFLICTS`
which allow one more probe than expected.

So this commit change the test to `acd->num_conflicts >= MAX_CONFLICTS`.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-10 21:37:03 +01:00
Georgy Komarov
eaa8f34f6a lowpan6.c: fix unuinitialized variable if LWIP_6LOWPAN_IPHC==0 2019-12-10 21:19:53 +01:00
Simon Goldschmidt
fe25ca66af httpd: makefsdata: fix passing deflate level via commandline
See bug #57187

Reported-by: Anton Chasnyk <anton.chasnyk@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-02 21:13:45 +01:00
Simon Goldschmidt
bef201e162 sockets: fix IS_SOCK_ADDR_ALIGNED() for 16 bit platforms
See bug 57344

Reported-by: Victor Brzeski <VBrzeski@gmail.com>
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-12-02 20:53:13 +01:00