Add a test case verifying that if there's a static resource defined
which overlaps a FS resource pointing to a directory, it takes
preference on exact URI match.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
lwm2m_setup() never reports errors and always returns 0.
The error check at the call site is therefore dead code.
Make the function void and drop the unused error handling.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
When the response has been sent completely to the client, the server
reports the new `HTTP_SERVER_TRANSACTION_COMPLETE` status. Together with
the existing `HTTP_SERVER_TRANSACTION_ABORTED` status, the application
can now also for successful completions of requests clean up any
resources allocated for handling the request.
This especially allows to dynamically allocate the response buffer
passed to the server in the request callback and free it when the
request is done.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Rename enum http_data_status to enum http_transaction_status
to better reflect its purpose, which is to indicate the status of the
overall HTTP transaction, not just data transfer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Fix build failures when compiling for 64-bit native_sim,
and add native_sim/native/64 to the platform allow list for
the coap client tests.
Signed-off-by: Sam Friedman <sam@golioth.io>
Some PSA configs were missing for DTLS to work in LwM2M interop tests.
CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID was defined twice, so remove
redundant entry.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The test fails on 64bit targets running out of heap.
Let's just increase it.
Circumstantially it started failing after
d5982f0f89
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The MQTT-SN v1.2 [0] specification specified the GwAddr as follows:
The GwAdd field has a variable length and contains the address of a GW. Its
depends on the network over which MQTT-SN operates and is indicated in the
first octet of this field. For example, in a ZigBee network the network
address is 2-octet long.
It specifies neither the possible values for the first octet, nor the
format of the network-specific address that follows. Thus, the
specification is incomplete and this functionality unusable.
I also wasn't able to find any implementation which implements a gwinfo
message where the address length is not zero. This includes
https://github.com/eclipse-paho/paho.mqtt-sn.embedded-c .
The current implementation in Zephyr simply copies a `struct sockaddr`
into GwAddr. This is a bad idea for many reasons, the most important one
being that the format is not even specified by POSIX [1]. They only say,
which defines must exist, not what their values are. And in fact, these
even differ between Zephyr and Linux.
Thus, I think it's best to remove the implementation to prevent people from
using this, which may even lead to memory safety issues, depending on the
length of CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE. If we were to receive an
updated specification, all we'd have to do is to convert between `struct
sockaddr` and mqtt-sn addresses both ways.
[0] https://groups.oasis-open.org/higherlogic/ws/public/download/66091/MQTT-SN_spec_v1.2.pdf
[1] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
When the response comes from a gateway, the address length is 0. I renamed
the test which tests a gwinfo from another client to make this more clear.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
Replace legacy Mbed TLS crypto support with PSA API.
RSA key exchange dependency was removed because all certificates and
keys used in the test are EC.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Verify that dns_unpack_name() generates a valid DNS name when unpacking
records and that it returns an error in case of overflow.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
According to the compiler, the ret variable might be uninitialized
in the function (looks like a false positive but fix it anyway).
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The file descriptor table is used in every area that expects to work on
files through descriptor indices. It can only be operated on through
functions whose names indicate a relationship with ZVFS (`zvfs_*fd*`).
The integer file descriptor mechanism shouldn't be separate from ZVFS.
This will make cooperation between different file access APIs much
simpler. This commit also makes preparations for the fdtable becoming
optional.
Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com>
No need to use Posix eventfd API in core network code as zvfs_eventfd
is compatible with it and we can now avoid using Posix headers
unnecessarily.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This adds a test for the composite writer with time serialized resource and
resource instance values.
Signed-off-by: Simon Walz <simon.walz@autosen.com>
Either remove the option from conf file or adjust its value
by using CONFIG_ZVFS_OPEN_ADD_SIZE_NET option because the
max number of socket descriptors is now calculated dynamically
at built time.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Introduce `lwm2m_set_cache_filter()` so applications can drop cached
samples before they reach the LwM2M SEND path.
Fixes#91590
Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
Use buffers instead of pointers for path and extra options provided in
the struct coap_client_request, so that the library keeps a copy of the
path/options instead of pointers. That way, the library can still work
correctly in case of retransmissions or block transfer in case when the
original path or options were automatic variables that went out of
context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make it easier to modify the response callback data by passing it as a
struct pointer rather than a long list of arguments.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Since the protocol doesn't have message IDs in the responses to these
update messages, there's no reliable way to know, if an update succeeded or
not. I use that fact to simplify the implementation by:
- Not providing success/failure callbacks.
- Not handling updating the variables in the client struct while
an update is in progess.
In addition to adding some tests, I tested this with the emqx server.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
- The paho client does that, too.
- This allows running single tests, because they don't rely on previous
ones having incremented the msg_id a certain number of times.
- The variable already existed in the client struct, but wasn't used. I
guess it was intended that way but never implemented.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
Make sure that the DNS cache tests have enough stack size for
each ztest thread so increase the stack to 1280 bytes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The ztest stack size might be too small for the net.dns.resolve.hostname
tests that was added recently. Increase it to 1280 bytes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The rest of the network (and generally Zephyr subsystem code) use the k_
prefixed variants for memory allocation, which results in data goin in
the _system_heap rather than the stdlib z_malloc_heap.
The code in getaddrinfo use the z_ ones as well apart from the actual
getaddrinfo implementation, which seems like an oversight, change it to
use k_calloc and k_free as well.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
LwM2M engine does not allow strings to be truncated as it would
lead to invalind UTF-8 strings.
However, some content formatters were truncating, so I fixed at least
these
* plain text
* TLV
* SenML CBOR
* SenML JSON
* JSON
* CBOR
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
lwm2m_get_string() and lwm2m_set_string() API does not allow
strings to be truncated and ensures NUL termination
regardles of using string or opaque resources to store the string.
Add tests to verify that is also true on multi-byte UTF-8
strings.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Build this test also with clang to increase coverage. This test is
selected because it had some issues with clang, however, there is
nothing special about this tests when it comes to clang, it will be one
of many to come to increase coverage.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The LwM2M RD client state machine have no knowledge of ongoing
observations or any other CoAP traffic and might trigger
QUEUE_RX_OFF state while engine is still waiting for Ack.
This can happen if CoAP Ack timeout is longer than
CONFIG_LWM2M_QUEUE_MODE_UPTIME and response is lost or taking
longer than QUEUE_MODE_UPTIME.
When observation is lost, CoAP Ack may be send, but socket is not
listening anymore if its closed or not polled while in RX_OFF and this
stops observation.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Update the HTTP service API to allow setting per-service configuration,
currently it is only custom socket creation callback,
but in the future it can be extended with other parameter
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>