Improve coap_client_cancel_requests(). Ensure it can be
called from a callback. Report error to waiting callbacks.
Clear active flag.
This is useful when the network becomes unavailable
or prior to disconnecting in order to save power.
Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
Fixes remote address for ping before upload. This caused the ping in zperf
upload to timeout as shown in the following output:
```
uart:~$ zperf udp upload 2001:db8::2 5001 10 50 1M
Remote port is 5001
Connecting to 2001:db8::2
Duration: 10.00 s
Packet size: 50 bytes
Rate: 1000 kbps
Starting...
ping 2001:db8::2 timeout
Rate: 1.00 Mbps
Packet duration 390 us
```
Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/68674
Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.
Previously only resources with post-write callback were able to
assemble the content.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.
Fixes#71351
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When the network inteface goes operational DOWN (for example cable
unplugged), clear "joined" flag on all registered multicast addresses,
so that MLD report is sent for them when the interface goes back up.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When bringing interface down, all IPv6 multicast addresses are removed
from the interface. However, when the interface was brought back up,
rejoin_ipv6_mcast_groups() would look only for solicited node mcast
addresses already present on the interface. In result, after going back
up, the interface was missing solicited-node mcast addresses for those
unicast addresses, that were already present on the interface when
bringing up.
As net_ipv6_mld_join() does similar checks to skip MLD when not needed,
we can just skip the lookup when rejoining, and use already defined
join_mcast_nodes().
Additionally, check for IPV6 and NO_ND flags on the interface before
attempting to add the address back, those multicast addresses are not
needed if ND is disabled on the interface.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a network interface is brought down and back up, DAD was not
performed for link-local unicast address.
This happens because the logic in the network interface code assumed
that DAD for link-local address is triggered when the address is added,
and it's explicitly omited when looping over IPv6 address. This wasn't
the case however when interface was brought back up, as the address was
already present on the interface, hence DAD skipped.
In Linux, the link-local address is removed from the interface when the
interface is brought down. Such approach solves the issue described,
hence implement it in a similar way in Zephyr.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There is no need to check our own context when going through
the used ports in the system. This prevents error when binding
in some corner cases.
Fixes#72035
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The new command is "net http" which shows all services and
related resources defined in the system.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Doing a normal close for a websocket does not close the underlying
real socket. If we do not have fd for the real socket, then it is
not possible to fully close a websocket connection. As we are allocating
a websocket using websocket_register() in HTTP server use case,
create a websocket_unregister() that will close both the real
socket and the websocket socket.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It is meant specifically for configuration of the PSA crypto library.
The underlying PSA configuration items are guarded by the condition
that a PSA crypto provider must be present, which is the case when
either TF-M is in use or MbedTLS's PSA core is built as part of
the application image.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Add option for zperf tcp upload that will enable periodic result reporting.
This is useful for monitoring performance swings during a longer session.
Signed-off-by: Adam Matus <adam.matus@nxp.com>
TCP nodelay option is part of zperf upload params, but was not being
set in common zperf_prepare_upload_sock function. Move it there
to align with how other options are set.
Signed-off-by: Adam Matus <adam.matus@nxp.com>
TLS socket have now been in Zephyr for a few years already and are
widely adopted across the codebase. Given above, they should no longer
be considered an experimental feature.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
According to the RFC, MODE_IS_INCLUDE/MODE_IS_EXCLUDE codes should be
used while sendling Multicast Listener Reports in response to a query.
When performing a transition between states (e.g., when joining or
leaving a multicast group) CHANGE_TO_INCLUDE_MODE/CHANGE_TO_EXCLUDE_MODE
have to be used.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
From RFC:
* "source list" is an unordered list of zero or more unicast
addresses from which multicast reception is desired or not desired [...]
It means that there is no need to add any special address to specify
"block all" and "allow all" states explicitly. This commit removes the
unnecessary addition.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
When BUILD_WITH_TFM is enabled we can dispatch hash computation
to TFM. This allows to remove the built-in support of SHA256 from
the non-secure side (if it's not used for any other purpose, of course).
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Moving toward the adoption of PSA crypto APIs, TinyCrypt is going
to be deprecated so we can remove it in favor of newer APIs.
Moreover tls_credentials is mostly meant to store data in the
protected storage meaning that there is a TFM implementation
providing this service. The same TFM can of course be used to
compute sha256 hashing thus saving memory footprint on the NS
side by removing TC.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
When using the TLS_CREDENTIALS_BACKEND_PROTECTED_STORAGE there is
BUILD_WITH_TFM enabled which means that we can take advantage of
TFM (thorugh PSA interface) to compute the SHA256 hash.
This removes the need for the built-in implementation of
mbedtls_sha256() on the non-secure image (unless it's used somewhere
else, of course) and therefore it helps in reducing the memory
footprint.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Add support for gratuitous ARP transmission by Zephyr network stack.
This allows to prematurely fill the peer ARP table, so there's no need
to send an explicit request when peer needs to send an actual packet.
The gratuitous ARP is send when the network interface is brought up
(joins the network) or a new IP address is added. The gratuitous ARP
request is also sent periodically, with a configurable interval time.
The gratuitous ARP should also be sent whenever MAC address of the
interface is changed, but as Zephyr only allows to do this when
interface is down, this is already covered by the first case (interface
brought up).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixing the websocket command output to align the fields and
printing interface index instead of a pointer value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add socket obj_core support to websocket so that the socket
information can be viewed by "net sockets" command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
After upgrading the HTTP connection to websocket, call the
application registered callback to transfer the ownership of
the socket to the application.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If the other end closes the connection, it is not exactly an
error so downgrade the print to debug level.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The http_server needs a way to bind a websocket socket to the
upgraded http connection socket. So websocket_register() is used
for that.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Use normal "config" in order to avoid this error from compliance
check script:
Found pointless 'menuconfig' symbols without children.
Use regular 'config' symbols instead.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow connection to be upgraded from HTTP/1.1 to websocket.
This commit does nothing yet with the upgraded connection.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Check what kind of upgrading we are doing and return error
if we receive upgrade that we do not support.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
`OPENTHREAD_PLATFORM_KEY_REF` should not be selected for RCP
architecture, as keys are handled on host's side and passed to
device over Spinel, and therefore they cannot be exported
on platform from reference with PSA Crypto API.
Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Two issues fixed:
When pull-context is created, it does not have to wake up the RD
client context. Ignore the EPERM warning.
When new pull-context creates a new socket, sometimes socket-loop
gets to recvfrom() before we have set O_NONBLOCK on the socket.
So use ZSOCK_MSG_DONTWAIT on zsock_recvfrom() so it does not
block the socket loop.
Fixes#71450
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
It may happen that the interface is up but not yet running
when we issue the rejoin_ipv6_mcast_groups(). This can be
fixed by calling this function again right after the iface
is set to 'running' state in the notify_iface_up handler.
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
When calling net_if_get_default(), print a warning if no
network interfaces are found. This helps debugging mysterious
crashes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When trying to get IPv6 prefix, if there are no network interfaces
then the net_if_get_default() will return NULL but we should not
crash at that point but return gracefully.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Making default preferred time much closer to default valid time
so that the served addresses are much shorter time in deprecated
state where they cannot be utilized. This is important in Zephyr
as there are limited number of IPv6 addresses that can be allocated
to the network interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The local address used for established TCP socket needs to be
dig out from TCP internals and not from context->local.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We usually cannot use context->local for established TCP connections
because the local address is not updated for TCP if we are bound to
any address. So create helper that try to figure out the end point
addresses.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add support for IPv6 Source Address Selection defined in RFC 5014.
This commit does not add any address selection support to getaddrinfo()
as described in the RFC. The AI_EXTFLAGS symbol and also the ai_eflags
to hints is added but they are not used by the code.
The public/temporary address selection is only done internally by
the net_if_ipv6_select_src_addr_hint() according to flags set by
setsockopt().
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When printing IPv4 and IPv6 address information in "net ipv4" and
"net ipv6" commands, print also reference count of the IP address.
This is useful for debugging purposes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add reference counting to network interface address (for both
IPv4 and IPv6) so that the address is not removed if there are
sockets using it. If the interface address is removed while there
are sockets using it, the connectivity will fail for the said
socket.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add events to be generated when privacy extension is enabled
or disabled, or when allow/deny filter is added or deleted.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>