Allow engine to give hints about ongoing CoAP transmissions.
This information can be used to control various power saving
modes for network interfaces. For example cellular networks might
support release assist indicator.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In slow networks, like Nb-IOT, when using queue mode,
there might be significant delay between the time we
put the packet into a transmission queue and the time
we actually start transmitting.
This might cause QUEUE_RX_OFF state to be triggered earlier
than expected. Remedy the issue by updating the timestamp on the
moment where packet is accepted by zsock_send().
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In case a waiting TLS socket reports an error in the underlying poll
call, try to read the actual error from the socket, instead of blindly
returning -EIO in all cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There are several subsystems and boards which require a relatively large
system heap (used by k_malloc()) to function properly. This became even
more notable with the recent introduction of the ACPICA library, which
causes ACPI-using boards to require a system heap of up to several
megabytes in size.
Until now, subsystems and boards have tried to solve this by having
Kconfig overlays which modify the default value of HEAP_MEM_POOL_SIZE.
This works ok, except when applications start explicitly setting values
in their prj.conf files:
$ git grep CONFIG_HEAP_MEM_POOL_SIZE= tests samples|wc -l
157
The vast majority of values set by current sample or test applications
is much too small for subsystems like ACPI, which results in the
application not being able to run on such boards.
To solve this situation, we introduce support for subsystems to specify
their own custom system heap size requirement. Subsystems do
this by defining Kconfig options with the prefix HEAP_MEM_POOL_ADD_SIZE_.
The final value of the system heap is the sum of the custom
minimum requirements, or the value existing HEAP_MEM_POOL_SIZE option,
whichever is greater.
We also introduce a new HEAP_MEM_POOL_IGNORE_MIN Kconfig option which
applications can use to force a lower value than what subsystems have
specficied, however this behavior is disabled by default.
Whenever the minimum is greater than the requested value a CMake warning
will be issued in the build output.
This patch ends up modifying several places outside of kernel code,
since the presence of the system heap is no longer detected using a
non-zero CONFIG_HEAP_MEM_POOL_SIZE value, rather it's now detected using
a new K_HEAP_MEM_POOL_SIZE value that's evaluated at build.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Update coap_service_send and coap_resource_send to take an optional
pointer argument to the newly introduced coap_transmission_parameters.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Replace function parameter 'retries' with pointer to structure
holding coap transmission parameters. This allows setting the
retransmission parameters individually for each pending request.
Add coap transmission parameters to coap_pending structure.
Update migration guide and release notes.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Use correct format specifier for LOG_ERR in lwm2m_obj_device.c. The
previously used format specifier of %u was correct for 32 bit systems
but would produce a build warning for 64 bit systems.
Fixes#66441
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
As the common.h is only meant to be used by the network
shell files, rename it to be more descriptive in order to
avoid possible conflicts with any other common.h file.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add new functions to the public CoAP API to configure CoAP packet
retransmission settings. Application may need to re-configure the
settings for example when cellular modem changes connection from
LTE-M to NB-IoT or vice versa.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
When a TCP connection is established, if there is no data exchange
between the two parties within the set time, the side that enables
TCP Keep-alive will send a TCP probe packet with the same sequence
number as the previous TCP packet. This TCP probe packet is an empty
ACK packet (the specification recommends that it should not contain
any data, but can also contain 1 nonsense byte, such as 0x00.). If
there is no response from the other side after several consecutive
probe packets are sent, it is determined that the tcp connection has
failed, and the connection is closed.
The keep-alive default parameters are aligned with Linux defaults.
Signed-off-by: Horse Ma <mawei@coltsmart.com>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If observed resource was written during the pMin period, it did
not schedule any wake-up event into the future. Notify message would
then only be generated as a result of any other (like Update) event.
Refactor check_notifications() to follow same pattern as retransmit_req().
Return the next event timestamp, which could be now.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
SNTP response is not analyzed for uncertainty, and no uncertainty is given
to the `struct sntp_time` returned. Fix it with a Kconfig option that adds
optional SNTP uncertainty and timestamp fields in SNTP time struct, and
calculates these when parsing the response.
Adds two helper functions to convert Q16.16/Q32.32 in seconds to `int64_t`
in microseconds to facilitate this.
Also changes combined `lvm` field in `struct sntp_pkt` to bit-fields
`li`, `vn`, and `mode`.
Signed-off-by: Jasper Smit <git@jrhrsmit.nl>
This reverts commit 5227f24815.
The coap observer events will be replaced with net_mgmt events.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
A device can be reset before the error code list is communicated
to a LwM2M server so optionally store error list in settings so it
can restored after reset.
Signed-off-by: Nick Ward <nix.ward@gmail.com>
If server registration fails, allow fallback to secondary server,
or fallback to bootstrap.
Also allow fallback to different bootstrap server.
Add API to tell RD client when server have been disabled by
executable command.
Changes to RD state machine:
* All retry logic should be handled in NETWORK_ERROR state.
* New state SERVER_DISABLED.
* Internally disable servers that reject registration
* Temporary disable server on network error.
* Clean up all "disable timers" on start.
* Select server first, then find security object for it.
* State functions return void, error handling is done using states.
* DISCONNECT event will only come when client is requested to stop.
* NETWORK_ERROR will stop engine. This is generic error for all kinds
of registration or network failures.
* BOOTSTRAP_REG_FAILURE also stops engine. This is fatal, and we cannot
recover.
Refactoring:
* Server selection logic is inside server object.
* sm_handle_timeout_state() does not require msg parameter. Unused.
* When bootstrap fail, we should NOT back off to registration.
This is a fatal error, and it stops the engine and informs application.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
React to disable executable, as well as add callback that allows
disabling server for a period of time.
Also add API that would find a next server candidate based on the
priority and server being not-disabled.
Move all server related functions into its own header.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Zephyr has its own multicast join/leave API but for
interoperability, it is possible to use the multicast
socket API and IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP
socket options.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Zephyr has its own multicast join/leave API but for
interoperability, it is possible to use the multicast
socket API and IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP
socket options.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We are creating a multicast address in mDNS or LLMNR
responder so set the TTL or hoplimit using the multicast
variant API.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We specifically set TTL/hoplimit to 1 for LLMNR,
but only want to set it if in that specific case.
We must not pass TTL/hoplimit value 0 as that would
cause the packet to be dropped.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The IPv4 TTL could only manipulated via net_context interface.
It makes sense to allow the same from socket interface via
the setsockopt/getsockopt calls.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This was somehow missed, but since ICMP rework, message handlers should
not dereference the packet, as it's done by the ICMP lib.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Set the static initialiser socket file descriptor to -1 to make sure
it is invalid before using coap_service_send.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add extra checks that make sure that msg_iov is set
as we cannot receive anything if receive buffers are
not set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The CoAP request handler returns errno codes in the following cases:
* ENOENT if no handler found; respond with 4.04
* ENOTSUP if an unknown request code received; respond with 4.00
* EPERM no handler found for the method; respond with 4.05
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Protected credential storage makes use of the PSA API, therefore it must
be present in the library include path. This was missed during the
recent CMakeLists.txt rework of this library.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If we for some reason are supplied unsupported socket type in
recvfrom(), then return ENOTSUP error to the caller instead of
silently accept it by returning 0.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user has set either IP_PKTINFO (for IPv4) or
IPV6_RECVPKTINFO (for IPv6) socket options, then the system
will return relevant information in recvmsg() ancillary data.
Fixes#36415
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add IP_PKTINFO or IPV6_RECVPKTINFO BSD socket options that
can be used to get extra information of received data in
the ancillary data in recvmsg() call.
For IPV6_RECVPKTINFO see RFC 3542 for details.
For IP_PKTINFO see Linux ip(7) manual page for details.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When a client uses wildcard subscription and a new message is
published to the matching topic for the first time, the gateway
sends REGISTER message to the client, containing the exact
topic name and a new topic ID.
This change fixes adding these topic ID and name to the internal
topics list.
Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
Add a function to MQTT-SN library API to get topic name by ID
from the internal topics list.
Signed-off-by: Alexander Vasiliev <alexander.vasiliev@siemens.com>
Added igmpv3 support based on the already existing structure for igmpv2.
The already existing api is not modified to prevent breaking exisiting
applications.
Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
Fix the CMakeLists of the tls_credentials and sockets folders
to link/interface to the net library instead of the zephyr library.
This fixes issues where some files are not found in the link interface
when compiling the sources in this folder.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Make sure we send the entire packet buffer before bumping the packet
counter, send() does not guarantee that all of the requested data will
be sent at once with STREAM socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case underlying socket reported error while waiting for TX, the
errno value was not set accordingly. This commit fixes this.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
RSRQ is the ratio between send and received signal strength and usually
understood/expected to be represented as a ratio in dB and as such always
has a negative range. So to allow RSRQ to be represented correctly the
resource must allow negative values, but currently it's limited to unsigned
8bit integers.
Signed-off-by: Henning Fleddermann <henning.fleddermann@grandcentrix.net>
Network interface numbering starts from 1, therefore when accessing
help/index array, the interface index should not be used directly, but
rather decremented by 1, to avoid out-of-bound access on those arrays.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure that the error message does not overflow the transmit buffer
when copying the error message string.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There's not really much to do when the transmission of the error reply
fails, but we can at least log the failure.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The result of string to float conversion in LwM2M shell write command
was not verified, which could result in incorrect data being written to
the resource.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As reported by Coverity, cpkt was being used before checking it's not
NULL.
Fixes#65372 / CID: 323075
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Since lwm2m_load_tls_credentials(ctx) will assume that the ctx has a
valid security object assigned to it, it should not be called at all
when ctx.use_dtls == false.
This solves a major bug where LwM2M comms are DTLS encrypted but FOTA is
allowed to be plain-text.
Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
No issues with gcc but clang gives this error for
the *v4 variable few lines below.
.../lib/dns/mdns_responder.c:712:2: error: expected expression
struct net_context *v4;
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Instead of just listening first network interface in the system,
install a multicast listener to all available network interfaces.
Fixes#18748
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
DTLS Connection Identifier support requires DTLS stack
that supports it. MbedTLS support in Zephyr is already
ported in, also some offloaded sockets support it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Adds a shell interface for TLS Credentials, allowing management of
credentials via the Zephyr shell
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Add (internal) support for sectag iterating.
Also officially marks negative sectag values as reserved for internal
use.
This will allow a prospective TLS credentials shell to iterate over all
available credentials.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Adds an internal credential_digest for generating a string digest of
credentials.
Such digests would allow users of a prospective TLS credentials shell to
verify the contents of a given credential without directly accessing
those contents.
Offloading the digest process to the underlying backend allows backends
for which private portions are not directly accessible to be eventually
supported.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
A CoAP client can re-issue an observe request (same endpoint and token)
to refresh it's subscription. No new observer should be registered in
this case.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add a function to the public CoAP API to find and return the unique
observer based on the address and token.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Core objects version reporting was broken for LwM2M version 1.1, as the
default object version not necessarily matches the LwM2M version.
Therefore, implement a table with default object versions for particular
LwM2M version, which can be looked up when determining whether it's
needed to include object version or not during Registration/Discovery.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds the option to register an event handler to CoAP
resources when observers are added/removed.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
In CoAP blockwise the client is supposed to
respond with 2.31 Continue code on Ack. This was recently
broken when Block1 parsing was moved after the initialization
of reponse packet. We need separate CoAP API to modify the code
of existing CoAP packet.
Also Ack packet should contain the Block1 options, even the
last one.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Implement testcases for Information Reporting Interface [300-399]:
* LightweightM2M-1.1-int-301 - Observation and Notification of parameter
values
* LightweightM2M-1.1-int-302 - Cancel Observations using Reset
* LightweightM2M-1.1-int-304 - Observe-Composite Operation
* LightweightM2M-1.1-int-306 – Send Operation
* LightweightM2M-1.1-int-307 – Muting Send
* LightweightM2M-1.1-int-308 - Observe-Composite and Creating
Object Instance
* LightweightM2M-1.1-int-309 - Observe-Composite and Deleting
Object Instance
* LightweightM2M-1.1-int-310 - Observe-Composite and modification of
parameter values
* LightweightM2M-1.1-int-311 - Send command
303 and 305 cannot be implemented using Leshan as it only support
passive cancelling of observation.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If the interface is WiFi one, then print information about it.
Also the device information is useful to know so print device
name corresponding to the network interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Do not include the resource type (rt=) in the registration message when
using the OMA JSON format. This was a workaround specifically for the
Wakaama LwM2M server which is no longer needed since the latest master
branch.
Signed-off-by: Marc Lasch <marc.lasch@husqvarnagroup.com>
Portfolio object created string buffers for Identity resources
that was overlapping on some cases.
Don't calculate pointers by hand, allow compiler to calculate it.
Fixes#64634
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Extend the previous support of creating object instances by allowing
creation of resource instances as well.
Similarly, add support for deleting.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If user adds IPv6 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user adds IPv4 address to the network interface, check
if the address is a multicast one and add it to multicast
group if it is.
Fixes#64389
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Default behaviour should only bind to port independent of IP, this
allows even multicast/broadcast L4 traffic to be received.
User can always specify a specific address to bind using shell or
Kconfig or API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Using a generic IP for address set failures is confusing, esp. two same
prints (one for v4 and the other for v6), so, use explicit version.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Moving the Zephyr specific config options from
modules/hostap/Kconfig to corresponding Kconfig where the
option is specified.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.
Fixes#64290
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The new "net sockets" command will utilize the object core
support to track and show information about BSD sockets that
are created in the system. This command is able to show info
for all network sockets (native, offloaded etc) in the system.
Example of the output of the new command:
uart:~$ net sockets
Creator Name Flags FD Lifetime (ms) Sent Received
main af_inet46 6ST 0 3260 819 498
main af_inet46 4ST 1 2110 469 142
main af_inet46 6DU 2 2110 9941 9941
main af_inet46 4DU 3 2110 1375 621
4 active sockets found.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The writefds is typically set if there is an error while
waiting for example the connect() to finish. So check if
the user supplied the writefds and update it accordingly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
In case ping is sent to own address, the request is looped back to the
stack and served before ping work had a chance to reschedule. In result,
when the final ping reply has been server, and ping operation finalized
with `ping_done()`, the work was rescheduled one last time, causing the
ping timeout to be reported. Fix this by rescheduling the work before
sending the actual request, so that the reply handler can cancel the
work properly in such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The remote address of the connection is checked whether
it is v4-mapping-to-v6 address in which case we should
print it such.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This allows IPv4 and IPv6 share the same port space.
User can still control the behavior of the v4-mapping-to-v6
by using the IPV6_V6ONLY socket option at runtime.
Currently the IPv4 mapping to IPv6 is turned off by
default, and also the IPV6_V6ONLY is true by default which
means that IPv4 and IPv6 do not share the port space.
Only way to use v4-mapping-to-v6 is to enable the Kconfig
option and turn off the v6only socket option.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fix two issues with net tcp command:
* The `net tcp` commands are still based on net_context API. For TCP,
the API caller (net shell) should add one extra reference to the
allocated net context, to prevent premature context release in case of
connection teardown. Currently that was not the case, and the context
was released too early, resulting in missing final ACK from the Zephyr
side on connection close.
* The net context API should not be called from the registered connect
callback, as this creates a temporary deadlock situation. The
net_context_connect() function blocks until the connection is
established, or an error or timeout occurs. For that time the
net_context mutex is being locked. In case of connection error (for
example after receiving RST packet) the connect callback is called,
indicating an error. If we try to call net_context API from within, a
deadlock situation takes place, as the context mutex is still locked
by the net_context_connect() (called from the shell thread). This
blocks the further execution of the TCP stack and can result in an
unexpected behavior (like for example retransmitting the SYN packet,
which takes place from yet another thread, TCP work queue).
Fix this, by releasing the net context not from the callback directly,
but based on the return value from net_context_connect().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The interface number is generated automatically if one
presses <tab> when expecting the interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow multiple commands use the same dynamic shell command
completion when expecting network interface index.
For example "net iface" and "net stats" are such commands.
The network interface expansion cannot be used in "net ipv6 add",
"net ipv4 add" and "net route" commands as they require more
data after the network interface index argument.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The "net stacks" has been obsolete for a long time already
so remove it for good. It is replaced by "kernel stacks" cmd.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This is a preparation for the refactoring. The old "net" command
is renamed "net_old" so that the individual commands can be
placed into a separate .c files.
This is done like this because we need to use the
SHELL_SUBCMD_SET_CREATE() to create the sub-command and then
use the SHELL_SUBCMD_ADD() in the .c files to add the command
into the sub-command and not get conflict with the same name
sub-command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This is preparation commit that moves the net shell code to
subsys/net/lib/shell directory. The following commits will
then refactor the code in net_shell.c to smaller and more
manageable pieces.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
As composite operations don't have path in CoAP packet,
it wrongly triggered a check for security object and got
denied the access.
Fixes#64012
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When objects are initialized, empty strings should be set to length of
zero, instead of length of the full buffer.
So use INIT_OBJ_RES_DATA_LEN() to give both, the buffer size and data
length.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When resource instances are initialized, we must calculate
beginning of the data buffer using the index and maximum
data length. Otherwise buffers would overlap with previous.
Fixes#64011
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
As the lwm2m_registry.c and specificly lwm2m_set()
functions already ensure null-terminator on string and
count that into string lenght, the content type handlers
should do the same.
When string is written, strlen()+1 is the data length.
When string is read, use the data length, so we don't
leak uninitialized strings. If buffer overrun have
removed the null-terminator the strlen() migh be larger
than data_len.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Resend the request with Echo option and the received Echo
option value when receiving a 4.01 (Unauthorized) response
with the Echo option.
Add missing header file kernel.h to coap_client.h.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Add new configuration value CONFIG_LWM2M_UPDATE_PERIOD
that allows calculating update period from last update,
instead of calculating it from the lifetime.
In runtime, server is allowed to change the lifetime of the
registration which causes update perdiod to be effected.
When fixed update period is preferred, UPDATE_PERIOD
config is then used.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Only confirmable messages need pending tracking. Non-confirmable
messages are released after sending.
Match incoming packets with token, not message ID.
Ignore responses with non-matching tokens.
Remove unused function send_reset().
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
In case observation token changes (the LwM2M server re-sends
observation request to the client), the LwM2M engine should cancel any
ongoing notifications based on the old token. Otherwise, it will be
impossible to match the pending notification reply (ACK) with the
observer context anymore, causing new notifications for this
observation to stall.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The compiler emits a "null where non-null expected" warning unless the
argument of strlen is non-null at compile time.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The "encryption only" security level was deprecated in IEEE
802.15.4-2015. This deprecation has already been introduced in the code
but was overlooked in net config.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
The current zperf tcp/udp download command doesn't provide the option
to bind the server to a specific host address. If there is more than
one interface, it will not be possible to test each interface with zperf
tcp/udp download command without building the Zpehyr.
This patch will add support for zperf tcp/udp download command to bind
server to host interface address.
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Added a new event for LWM2M_RD_CLIENT_EVENT_DEREGISTER for
indicate LwM2M client dereistartion.
Updated unit test and sample for new event type
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
This adds a function k_object_is_valid() to check if a kernel
object exists, of certain type, and has been initialized.
This replaces the same (or very similar) code that has been
copied from kernel into the network subsystem.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Fix bug in timeout_expired() function. Coap client was resending
pending messages after 500 ms (COAP_PERIODIC_TIMEOUT) and didn't
wait for retransmission timeout.
Use 64-bit k_uptime_get()
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
If an IPv4 address is requested on an IPv6 interface or vice versa
use a sane default fallback address to send the response.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The zperf shell sends a IPv6 ping at the start when working
with IPv6. Convert the sending of the ping to use the new API.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add DHCPv6 support to the net config library. In case DHCPv6 is enabled,
net config will attempt to acquire IPv6 address and/or prefix when used.
The user can select with Kconfig whether to request address or prefix
(or both).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Code using sys_csrand_get should depend on CONFIG_CSPRNG_ENABLED symbol
and not in ENTROPY_HAS_DRIVER since they are not using the entropy
device directly.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Previously each piece of LwM2M SEND was
using token length of zero. I think this was unintentional.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
To protect the integrity of outgoing block-wise transfers, append
Etag option that allows client to see if the received block is
generated from same content as it is expecting.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow blockwise-send buffers to be used with GET and FETCH
queries as well.
When outgoing packet is split into multiple blocks, don't free
it when first block is send. Keep it in memory until some other requests
come.
Following queries to next block are matched using CoAP token.
However, this required Leshan to use COAP.BLOCKWISE_REUSE_TOKEN=true
option from Californium.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
lwm2m_udp_receive() is only called with same function
pointer, so there no need to carry that in the parameter.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In reality, single-write is the only operation that handles
BLOCK1 operations when receiving paylod.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Partial content format support is required to have a proper support
for content format OPAQUE instead of threading it as a part of
plain text format.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Move commands that require parameters first into the list.
Move syntax line first, command documentation second,
flags last. This is much like Unix commands do
❯ /bin/ls --help
Usage: /bin/ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Compared to:
uart:~$ lwm2m
lwm2m - LwM2M commands
Subcommands:
read :read PATH [OPTIONS]
Read value from LwM2M resource
-x Read value as hex stream (default)
-s Read value as string
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In spec:
The LwM2M Client MUST reject any LwM2M Server operation on
the Security Object (ID: 0) with an "4.01 Unauthorized" response
code.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
With bootstrap one function is unused. Fix by changing
ifdef to if (IS_ENABLED()) so linker can drop it.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commits adds support for the SO_REUSEPORT socket option.
The implementation follows the behavior of BSD and tries to also follow
the specific additional features of linux with the following
limitations:
* SO_REUSEADDR and SO_REUSEPORT are not "the same" for client sockets,
as we do not have a trivial way so identify a socket as "client"
during binding. To get the Linux behavior, one has to use SO_REUSEPORT
with Zephyr
* No prevention of "port hijacking"
* No support for the load balancing stuff for incoming
packets/connections
There is also a new Kconfig option to control this feature, which is
enabled by default if TCP or UDP is enabled.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
This commit adds support for the SO_REUSEADDR option to be enabled for
a socket using setsockopt(). With this option, it is possible to bind
multiple sockets to the same local IP address / port combination, when
one of the IP address is unspecified (ANY_ADDR).
The implementation strictly follows the BSD implementation and tries to
follow the Linux implementation as close as possible. However, there is
one limitation: for client sockets, the Linux implementation of
SO_REUSEADDR behaves exactly like the one for SO_REUSEPORT and enables
multiple sockets to have exactly the same specific IP address / port
combination. This behavior is not possible with this implementation, as
there is no trivial way to identify a socket to be a client socket
during the bind() call. For this behavior, one has to use the
SO_REUSEPORT option in Zephyr.
There is also a new Kconfig to control this feature similar to other
socket options: CONFIG_NET_CONTEXT_REUSEADDR. This option is enabled by
default if TCP or UDP are enabled. However, it can still be disabled
explicitly.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
Allow Bootstrap server to close the DTLS connection immediately
after receiving Ack to Bootstrap-Finish command.
This is not an error as either parties are allowed to tear down
the connection.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow certain RD-client states to timeout.
As stated in LwM2M specification:
The bootstrap procedure failed when the LwM2M Client did not
receive the "Bootstrap-Finish" operation after the
EXCHANGE_LIFETIME time period expired.
The EXCHANGE_LIFETIME parameter is defined in RFC 7252
We must handle the case where Bootstrap server is not sending
information towards us.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When publish buffer run out, no thread active process work.
Fix this, by reschedule process work.
Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
Current MQTT-SN topic and publish allocators are not thread safe.
Fix this, by using k_mem_slab instead of arrays.
Signed-off-by: Weiwei Guo <guoweiwei@syriusrobotics.com>
Releasing the lock before notifying condvar led to a race condition
between a thread calling k_condvar_wait to wait for a condition variable
and another thread signalling for this same condition variable. This
resulted in the waiting thread to stay pending and the handle to it
getting removed from the notifyq, meaning it couldn't get woken up
again.
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.
Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
The errors are printed in hex, but no prefix was used. This could be
confused with usual errno return values. The 0x prefix makes clear
that it's a hex value.
Also a missing minus sign is added to one log message.
Signed-off-by: Martin Jäger <martin@libre.solar>
This is handy in testing of setting priority directly rather than
deriving from DSCP. Please note ICMP doesn't use net context.
This is applicable for both shell and API.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Add a network configuration option to configure whether IEEE 802.15.4
packets are expected to be ACKed or not.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In the IEEE 802.15.4 area certain settings must be set before
net_if_up() may be called (e.g. the channel).
Also net_if_up() may not be called if
CONFIG_IEEE802154_NET_IF_NO_AUTO_START=y.
This fixes the set-up order and handling of
CONFIG_IEEE802154_NET_IF_NO_AUTO_START.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Modify the signature of the k_mem_slab_free() function with a new one,
replacing the old void **mem with void *mem as a parameter.
The following function:
void k_mem_slab_free(struct k_mem_slab *slab, void **mem);
has the wrong signature. mem is only used as a regular pointer, so there
is no need to use a double-pointer. The correct signature should be:
void k_mem_slab_free(struct k_mem_slab *slab, void *mem);
The issue with the current signature, although functional, is that it is
extremely confusing. I myself, a veteran Zephyr developer, was confused
by this parameter when looking at it recently.
All in-tree uses of the function have been adapted.
Fixes#61888.
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add TLS_DTLS_CID socket option, which enables to use the Connection ID
extension for the DTLS session.
The option provides control of the use of CID with the `setsockopt()`
function. The value provided can disable, enable, and control whether to
provide a CID to the peer. It uses a random self CID (if told to provide
one to the peer) unless TLS_DTLS_CID_VALUE set previously.
Add TLS_DTLS_CID_VALUE to get or set the CID sent to the peer, if any.
Add TLS_DTLS_PEER_CID_VALUE to get the CID value provided by the peer,
if any.
Add TLS_DTLS_CID_STATUS to determine if CID used, and whether
bidirectional or one way.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
getsockname() did not work properly on bound sockets, as it verified
whether the socket has an active connection before retuning result. This
is not correct, as socket after bound may not have a connection yet.
Fix this, by verifying that local_addr on an underlying net_context is
set, to determine whether socket has a local address assigned, before
returning result.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
* Renamed 'coap_client_init_path_options' to
'coap_packet_set_path'
* Moved into 'coap.c'
* The function is public now
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Fix options initialization for path and query
when a final segment is one character long.
For example, "a/b" inits path as ["a"] instead
of expected ["a", "b"]. The same applies to
query option. The "a/abc?a&b" options won't
contain "b".
Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>