Commit graph

5628 commits

Author SHA1 Message Date
Pisit Sawangvonganan 0d4961b8d4 net: wifi_utils: reduce valid_5g_chans_20mhz memory footprint
This change reduces the memory footprint by changing the data type of
`valid_5g_chans_20mhz` from `uint16_t` to `uint8_t`.

Additionally, since the maximum channel number for 5GHz Wi-Fi is 177,
it can fit within the `uint8_t` range.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-02-26 12:10:36 +01:00
Fin Maaß 652c2ae1f5 net: dhcpv4: Add vendor class identifier option
Adds the funktion to set the DHCPv4 option 60
(Vendor class identifier) via Kconfig.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-02-26 12:05:03 +01:00
Mateusz Karlic bdd09558bb net: shell: ipv4: Add command to set gateway
Add a command `net ipv4 gateway` that allows
setting IPv4 gateway for an interface from net shell.

Signed-off-by: Mateusz Karlic <mkarlic@antmicro.com>
2024-02-26 11:53:56 +01:00
Markus Lassila f033cd5601 net: sockets: tls: Add config for DTLS max fragment length
Add CONFIG_NET_SOCKETS_DTLS_MAX_FRAGMENT_LENGTH for limiting
the Maximum Fragment Length (MFL) for DTLS with Mbed TLS.

This is needed when MBEDTLS_SSL_OUT_CONTENT_LEN and
MBEDTLS_SSL_IN_CONTENT_LEN are set to larger values than the MTU
of the network and IP fragmentation is not supported.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2024-02-26 11:51:25 +01:00
Fin Maaß 7206737450 net: dhcpv4: request options from server
If a option callback is enabled, this option
should also be requested from the DHCPv4 server.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-02-26 11:44:45 +01:00
Chaitanya Tata 6c3b0ee5ff wifi: shell: Fix the case for acronym
DFS is an acronym, so, should be capitalized.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-02-26 11:41:40 +01:00
Chaitanya Tata 92fe088629 wifi: shell: Fix the header for passive transmission only
This flag indicates that only passive transmissions are allowed in that
channel for that regulatory domain.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-02-26 11:41:40 +01:00
Jukka Rissanen c5b0f542f0 net: socket: Start socket service earlier
Make sure that socket service is started earlier than
config library. This is enforced in config libs init.c
but set the default value here too.
The reason for this is that the config library might need
to start dhcpv4 server which needs socket service to work,
so the ordering is important here.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:40:15 +01:00
Jukka Rissanen 3de1f1b5d0 net: if: Check IPv6 pointers properly in hop limit setters/getters
We must make sure that IPv6 configuration pointer is valid
so that the hop limit can be set for a given interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:39:50 +01:00
Jukka Rissanen e7b1d6d8aa net: if: Check IPv4 pointers properly in TTL setters/getters
We must make sure that IPv4 configuration pointer is valid
so that the TTL can be set for a given interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:39:50 +01:00
Jukka Rissanen dceff4a98f net: if: Init must be called before setting the name
As the interface init function might configure the system
such a way that would affect the naming of the network
interface, we need to call the init before setting the name.
This is mostly needed by Wifi where the Wifi driver needs
to mark its network interface as Wifi interface as by default
the Wifi interface will look like Ethernet one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-26 11:39:25 +01:00
Maochen Wang 11a5904760 net: arp: Fix dead lock caused by arp_mutex
Fix the dead lock between rx_q and tx_q thread.
When tx_q thread prepares to send ARP packet, it might get
the net_if_tx_lock in net_if_tx(), then in net_arp_prepare(),
it will try to get the arp_mutex.
At the same time, if the rx_q thread receives an ARP reply
packet, in arp_update(), it will get the arp_mutex first,
and flush the packets in arp pending_queue and try to get
the net_if_tx_lock. Then the dead lock occurs, two threads
stuck and all the packcets can't be freed.
In arp_update(), taking the net_if_tx_lock first then taking
the arp_mutex can fix this issue.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2024-02-26 11:38:47 +01:00
Jukka Rissanen ea189d5aee net: sockets: Do not start service thread if too little resources
If the CONFIG_NET_SOCKETS_POLL_MAX is smaller than what is needed
for the socket service API to work properly, then we should not
start the service thread as the service API cannot work and might
cause memory overwrite in ctx.events[] array.

Fixes #69233

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-25 20:52:18 -05:00
Robert Lubos bc2858ad2d net: lib: coap: Add error check when waking server thread
There's not much to be done in case waking up the server thread with
socketpair send() fails, but at least we can log an error on such event
(to please coverity).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-19 19:07:03 +01:00
Jukka Rissanen 7e6813dcf5 net: trickle: Print the abs value using %u
The Imax_abs value should be printed using %u instead of %d
as it can be large and should be printed as positive value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-13 19:36:30 +01:00
Mike Szczys e72ac4b091 net: coap: add TOO_MANY_REQUESTS to return codes
Add COAP_RESPONSE_CODE_TOO_MANY_REQUESTS to coap_header_get_code(). CoAP
4.29 response code for "Too many requests" is defined in coap.h but was
missing from the list of cases, resulting in a 0 being returned instead
of the proper code.

Signed-off-by: Mike Szczys <mike@golioth.io>
2024-02-13 11:14:01 +01:00
Wojciech Slenska 6b1b8157cd wifi: shell: added NULL check to net_mgmt callback
By default variable context.sh is set to NULL. If any net_mgmt
event will be called when the variable has default value, there
will be a system exception.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2024-02-09 16:36:03 -06:00
Robert Lubos 7b6e7d6088 net: ipv6: Improve Neighbor Discovery thread safety
Currently, the only thread-safe part of the IPv6 Neighbor processing
implementation are stale_counter related operation.

Fix this, by extending the mutex protection over all of the module, so
that message handlers, timers and API functions do not interfere with
each other.

As IPv6 Neighbor cache is tightly coupled with the Routing module, use
the same mutex to protect both, neighbor and routing tables, to prevent
deadlocks.

Also, replace the semaphore used with a mutex, as it seems more fit for
this particular job.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-09 16:34:34 -06:00
Łukasz Duda 838f33494e net: tcp: Rate-limiting of neighbor reachability hints
This commit implements simple rate-limiting for Neighbor Reachability
Hints in TCP module to prevent the potentially costly process of
frequent neighbor searches in the table, enhancing system performance.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-02-09 16:26:10 -06:00
Markus Lassila ca7e69523c net: sockets: tls: Timeout DTLS with poll
Changed poll to perform incoming data check with connected
DTLS connections. This allows the CONFIG_NET_SOCKETS_DTLS_TIMEOUT
to timeout the connections to server socket if there is no
incoming data.

Previously, if the remote client closed the DTLS connection without
close notify, the timeout of the ongoing connection only happened
when next connection was taken to the server socket. Depending on
the timeouts, this could prevent the next connection from succeeding.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2024-02-09 10:25:46 -06:00
Kapil Bhatt 2207fedbc8 net: l2: wifi: Fix Print of SSID in WIFI scan result
WIFI scan result shows junk character in SSID because of
the length of ssid is maximum(32 character) which leads
to buffer overflow. It required one character for null
terminator ‘\0’.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-02-08 09:49:10 +00:00
Konrad Derda b324e1e4d8 net: buf: add max allocation size to allocation info
Previously, there was no way to determine maximum number of bytes
that can be allocated using only net_buf structure. This commit
introduces such field.

Moreover, this commit fixes an issue where allocation of less than
maximum number of bytes from a fixed buffer pool would set buffer's
size to this number instead of the whole buffer size.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-02-06 12:56:37 +01:00
Manuel Schappacher b5bf5a3cef net: gptp: Use local port identity when forwarding sync messages
As defined in IEEE802.1AS-2020 ch. 10.2.12.2.1, the port identity
of an MDSyncSend structure sent from a port shall be set to the
port identity of the sending port according to and ch. 8.5.2.

This commit replaces the port identity before forwarding a sync.

Fixes #68385

Signed-off-by: Manuel Schappacher <manuel.schappacher@hs-offenburg.de>
2024-02-02 22:35:20 +01:00
Jukka Rissanen 692ebf404c net: sockets: Update msg_controllen in recvmsg properly
If recvmsg() does not update control data, then it must
set msg_controllen length to 0 so that the caller can
understand this.

Fixes #68352

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-02 11:51:53 -06:00
Robert Lubos 68bc981c52 net: zperf: Fix session leak
In case zperf session was aborted by the user (by for instance stopping
it from shell), or practically in case of any other
communication-related error, the zperf session could end up in a state
other than NULL or COMPLETED, with no way to recover. This made the
session no longer usable and eventually could lead to zperf being not
able to start a new session anymore.

Fix this by introducing zperf_session_reset() function, which resets the
session state back to defaults. The function is called when the zperf
receiver service is stopped.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 10:31:53 -06:00
Robert Lubos 4ce0352026 net: zperf: Fix TCP receiver start/stop operation
The issues found for UDP receiver were also identified for TCP receiver,
this commit applies practically the same set of changes as in case of
UDP.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 10:31:53 -06:00
Robert Lubos 139bc4e87e net: zperf: Fix UDP receiver start/stop operation
This commit fixes restarting of UDP receiver service, along with some
other minor cleanups:

* The core issue was udp_server_running flag not being cleared when
  service was stopped. Fix this by introducing udp_receiver_cleanup()
  which does all of the required cleanups when receiver service is
  stopped. The function is called either when the application stopped
  the service with zperf_udp_download_stop(), or when the service was
  stopped due to error.
* net_socket_service_unregister() was not called on
  zperf_udp_download_stop(), but only from the service callback - that
  would not work in case there's no active communication.
* at the same time, net_socket_service_unregister() would be called from
  the service callback in case of errors. Fix this, by making
  udp_recv_data() only return an error, and let the service callback to
  do the cleanup.
* Remove no longer used udp_server_run semaphore
* Remove udp_server_stop - with socket services it seems no longer
  needed.
* zperf_udp_receiver_init() now returns an error, so that we don't
  mark the service as running in case of socket/services error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 10:31:53 -06:00
John Johnson 125a2bccaa net: net_pkt: add peer sockaddr member in net_pkt struct
Add sockaddr member in struct net_pkt to store peer address if offloaded
network inteface is used. This enables recvfrom() to fill in src_addr if
socket type is UDP and offloaded interface driver supports it.

Signed-off-by: John Johnson <john.filip.johnson@gmail.com>
2024-02-02 09:42:18 -06:00
Robert Lubos 3c76ff9a8c net: dhcpv4_server: Implement ICMP probing of offered addresses
DHCPv4 server will send an ICMP probe (echo request) for the requested
address before replying with DHCP Offer, unless probing is disabled in
Kconfig.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-02-02 12:42:44 +01:00
Pieter De Gendt 0bc1a2b314 net: lib: coap: Reduce CoAP server stack usage
Declare the CoAP server receiving buffer as static to lower the
stack usage.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-02-02 10:51:32 +01:00
Pisit Sawangvonganan 055ac61542 wifi: shell: replace print(...) with PR(...)
Additionally, replace the local print(sh, level, fmt, ...) macros
with PR, PR_ERROR, and PR_WARNING macros.

Then remove the print(sh, level, fmt, ...) macros.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-31 15:15:19 -06:00
Pisit Sawangvonganan 81342132fb wifi: shell: refactor to use PR(...) from "net_shell_private.h"
Replaced direct shell_fprintf calls with PR, PR_ERROR, PR_INFO
and PR_WARNING macros.

This change simplifies the code by using predefined macros.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-31 15:15:19 -06:00
Pisit Sawangvonganan 10939c7a02 wifi: shell: move "scan_result" variable into context struct
Moved 'scan_result' from a standalone variable into the 'context' struct
to enhance code optimization.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-31 15:15:19 -06:00
Pisit Sawangvonganan a8a39231e7 wifi: shell: introduce local 'sh' variable
This commit introduces a local variable 'sh' to store 'context.sh' for
use with the 'shell_fprintf' function.

By doing so, we avoid the repeated dereferencing of 'context.sh',
thereby reducing the code footprint.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-31 15:15:19 -06:00
Manuel Schappacher 6fc6b30fb3 net: gptp: Fix double converted byte order of BMCA info steps_removed
Fixes #68320

Signed-off-by: Manuel Schappacher <manuel.schappacher@hs-offenburg.de>
2024-01-31 15:53:06 +00:00
Łukasz Duda 5273af6ba8 net: ipv6: nbr: Add IPv6 reachability confirmation API
This commit introduces a new IPv6 API for positive reachability
confirmation, as specified in RFC 4861, Section 7.3.1. This feature aims
to enhance the effectiveness of the Neighbor Discovery mechanism, by
enabling upper-layer protocols to signal that the connection makes a
"forward progress".

The implementation within TCP serves as a reference. Compliance with
RFC 4861, especially Appendix E.1, was ensured by focusing on reliable
handshake and acknowledgment of new data transmissions.

Though initially integrated with TCP, the API is designed for broader
applicability. For example, it might be used by some UDP-based protocols
that can indicate two-way communication progress.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-01-31 14:50:53 +01:00
Jukka Rissanen b03c3c0c48 net: socket: Start service thread from initialization function
We cannot always start the service monitor thread statically
because the static threads are started after the application
level. This means that when config library wants to start
dhcpv4 server which uses socket services, there would be a
deadlock. Simplest solution is to start the service thread
directly from socket service init function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-31 12:06:49 +00:00
Robert Lubos a147ac9a47 net: dhcpv4_server: Improve address pool range validation
Not only check if the address pool belongs to the same subnet as the
server, but also that it does not overlap with the server address -
otherwise the server might end up assigning its own address.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-31 12:06:23 +00:00
Jordan Yates 9ff1fcf7e7 net: conn_mgr: generic wifi_mgmt connectivity backend
As connectivity backends need to be bound in the same file that the
`net_if` is created in, define a common backend type for WiFi modems.
All WiFi modems should be controllable through the `wifi_mgmt` API, so
there should be no need for dedicated context.

When enabled, the particular implementation to be used is chosen through
`CONNECTIVITY_WIFI_MGMT_IMPL`. For now, the only choice is an
application defined backend.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-01-30 18:51:46 -05:00
Chaitanya Tata bff1b7487e wifi: shell: Add band support for STA
For a Wi-Fi station the connect API supports both band and channel
configuration, but for a shell command either channel or band makes
sense, so, overload the channel field to support band.

Rejig the band and channel validation to support all modes.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-30 18:00:26 +01:00
Øyvind Rønningstad 3ad47d214a lwm2m: Regenerate zcbor files
with zcbor 0.8.1

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-30 13:38:51 +01:00
Jordan Yates 1e1d2725a7 net: dns: option to disable auto context init
Adds an option to disable the automatic initialization of the default
dns_context. This lets applications use the default context, while also
managing the `init` and `close` functions.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-01-29 20:20:19 -06:00
Jordan Yates e5f4fa0f4a net: dns: function to default initialize context
Adds a function that can be used to initialize a dns context to the
default Kconfig values.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2024-01-29 20:20:19 -06:00
Robert Lubos b8556d0d79 net: icmp: Don't report error on ICMP messages w/o handler
ICMPv4/6 modules print error when ICMP message handling fails, which
includes no message handler registered. This is a bit problematic, as
there are many ICMP messages that Zephyr does not process, and every
time such a message is received, an error log is printed (which wasn't
the case before ICMP rework).

Restore the old behavior (no log on unrecognized ICMP message) by
explicitly filtering out ENOENT error code from printing error. That
way, log will only be printed if an error occured within the actual
message handler.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 14:57:35 +00:00
Robert Lubos cefc391db3 net: dhcpv6: Move DHCPv6 files to lib directory
For consistency with DHCPv4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 13:47:05 +01:00
Robert Lubos 19722aa8e8 net: dhcpv4: Move DHCPv4 files to lib directory
As discussed during DHCPv4 server integration, group DHCPv4 client files
with DHCPv4 server in a single lib directory.

Renamed internal "dhcpv4.h" header to "dhcpv4_internal.h" so that it's
not confused with the public "dhcpv4.h" header.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-29 13:47:05 +01:00
Jukka Rissanen 7da14d3129 net: shell: Clarify the name of the virtual interface
The net-shell printed virtual interface name so that it got
the impression it was the network interface name which is not
correct. Now the name is printed as "Virtual name" which is
unambiguous.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-29 10:58:33 +00:00
Jukka Rissanen a45d66c478 net: if: Do not join multicast address if IPv6 is not enabled
If IPv6 is not enabled for the interface, then do not try to
join the IPv6 solicited multicast address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-29 10:58:24 +00:00
Fengming Ye f61a0cb1fa net: zperf: fix the calculation ratio between mbps, kbps and bps
The ratio between mbps and kbps, kbps and bps should be 1000, instead of
1024, as common sense.
The wrong ratio will decrease the Zperf throughput result.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-01-29 10:05:35 +01:00
Jukka Rissanen a1d0764922 net: wifi: Make sure scan band string is null terminated
Make sure that scan band string is properly terminated when
parsing user supplied string.

Fixes: #67944
Coverity-CID: 342930

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-26 19:40:16 +01:00
Seppo Takalo 992936300b net: lwm2m: Use CID_SUPPORTED instead of CID_ENABLED
When ENABLED flag is used, we generate 32 byte DTLS
Connection Identifier and include that in our
DTLS Client HELO. This has no benefit as client only
has one connection toward the server, it does not need
any identification.

When SUPPORTED flag is used, we just include
zero length Connection Identifier in the handshake,
which tell server that we support Connection Identifier
and server can generate one for it.
We then use the CID in the packets that we send towards
server, but response packets don't contain any CID.
This gives all the benefit of CID as server is able to
identify us even when NAT mapping have changed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-26 12:00:51 -06:00
Sandip Dalvi 4c7eb600c6 net: wifi: add wifi driver version API
Add command to query to WiFi driver/firmware revision. The API is expected
to return the firmware revision and driver version as a string, and can be
used by the user to determine what revision of the WiFi driver is in use.

Signed-off-by: Sandip Dalvi <sandip.dalvi@nxp.com>
2024-01-26 14:29:39 +01:00
Alberto Escolar Piedras 4ff79cb74a subsys/net/lib/lwm2m: Define required source standard macros
Instead of relaying on those macros having been defined
somewhere else let's define them for this file.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Chaitanya Tata c07d648304 wifi: shell: Remove duplicate argument count checks
Now that we are using the shell macro to enforce argument count check,
both mandatory and optional arguments, these additions checks are
unnecessary.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Chaitanya Tata c53a1df138 wifi: shell: ap: Add a command to disconnect a station
The shell commands can be used to disconnect a connected station in AP
mode.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Chaitanya Tata de667a7fae wifi: ap: Add support to disconnect a STA
In AP mode, this can be used to disconnect a connected station.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-25 11:50:59 -05:00
Øyvind Rønningstad 1bbb0a9ddb lwm2m: Adapt to zcbor 0.8.0
Regenerate from CDDL, update patch, fix references in code.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 15:09:16 +00:00
Seppo Takalo ec3ec8cd2a net: lwm2m: Add LWM2M_ON_INIT() macro
Add macro that allows registration of initialization functions that
are called when LwM2M engine starts.

On LwM2M engine starts up, it first executes all initialization
functions in following priority order:
1. LWM2M_PRIO_ENGINE
2. LWM2M_PRIO_CORE, this is where all LwM2M core objects are initialized
3. LWM2M_PRIO_OBJ, this is where all other objects are initialized
4. LwM2M_PRIO_APP, application initialization.

Now on the initialization phase, we could rely that certain objects have
already been registered.
For example custom objects can register callbacks to core objects.
On application phase, we can initialize sensor objects and register
their callbacks because objects have already been initialized.

This LWM2M_ON_INIT() should replace all use of SYS_INIT()
with the default CONFIG_KERNEL_INIT_PRIORITY_DEFAULT.

Priority order is actually just alphabetical order of names, so
the order is set on a linkin phase, and we don't need any
runtime checking for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-24 10:44:28 +01:00
Vivekananda Uppunda 7eb0aa0468 net: wifi_shell: Remove TX-Injection and Promiscuous mode from Wi-Fi mode
Remove TX-Injection and Promiscuous mode setting from Wi-Fi mode shell
command. These commands are being moved to ethernet l2 layer

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-01-24 00:08:38 -05:00
Vivekananda Uppunda db4bf8d409 net: l2: ethernet: bring in TX-Injection mode to l2 ethernet
This set of changes brings in raw packet tx injection mode
feature to ethernet and removes it from being a Wi-Fi only feature.

It was earlier envisaged as Wi-Fi net management feature only.

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-01-24 00:08:38 -05:00
Seppo Takalo bf872870ea net: lwm2m: Fix segfault on failed bootstrap
If bootstrap fails, RD client will call lwm2m_engine_stop()
which will close the context.
The socket loop, however still contains a call to
hint_socket_state(context, NULL) which has a null pointer now.

Fix the segfault by allowing nullpointer on hint_socket_state().

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-01-22 17:25:02 +00:00
Robert Lubos 2c70c5d74a net: shell: Implement DHCPv4 server shell commands
Implement DHCPv4 shell module, which allows to start/stop DHCPv4 server
operation, and print server status (address leases).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos 3bc50871bc net: socket_services: Increase default stack size for DHCPv4 server
Increase socket services thread default stack size when DHCPv4 server is
enabled, as it uses synchronous processing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos 1e08bbd543 net: dhcpv4: Implement DHCPv4 server
Add basic socket-based implementation of DHCPv4 sever.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos db80ed3e8d net: if: Add function to obtain IPv4 netmask
Add a helper function to obtain IPv4 netmask configured on an interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Robert Lubos 1d14f13d75 net: arp: Make arp_update() function externally visible
So that it's possible to register ARP entries manually. Needed for DHCP
server implementation, which in unicast mode needs to reply to an IP
address that is not registered on the peer interface yet (hence no ARP
reply will be sent). It's needed to add an ARP entry manually in that
case, as hardware address is already known at that point.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-19 10:15:23 +00:00
Juha Ylinen 9eee8d2be5 net: lwm2m: Allow send operations when sleeping
Add new kconfig CONFIG_LWM2M_QUEUE_MODE_NO_MSG_BUFFERING.

When enabled and device is sleeping, Reqistration Update
message is skipped and messages from send operation and
notifications are sent right away.

Reqistration update message is also skipped when
lwm2m_engine resumes from pause state.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-19 09:48:46 +01:00
Bjarki Arge Andreasen 52be26a8e3 net: l2: ppp: Patch carrier lost and L2 enable/disable
L2 PPP is not able to handle the carrier being lost gracefully,
nor is it able to gracefully close the PPP connection when
net_if_down() is called.

This patch refactors the L2 PPP module to use the carrier state
to either properly close or simply terminate the PPP connection.

Additionally, it ensures that the PPP session is closed properly
before calling ppp->stop().

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-19 09:47:33 +01:00
Kapil Bhatt c22ce801e7 net: wifi_shell: Add help for maximum channels in scan
Add a line for scan's -c parameter which specify
to take care of maximum channels.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-19 09:44:22 +01:00
Markus Lassila 681330aaf0 net: sockets: tls: Fix crashes in get DTLS CID socket options
Get TLS_DTLS_CID_STATUS and TLS_DTLS_PEER_CID_VALUE utilize
mbedtls_ssl_get_peer_cid, which expects that mbedtls_ssl_setup
has been done.

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2024-01-19 09:41:34 +01:00
Jukka Rissanen 5a933299bb net: socket: Change the printf modifier to print size_t correctly
The argument is size_t, so change the printf modifier to %zd
to avoid warning prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen 84ff0e8cdf net: socket: Allow user to tweak service dispatcher thread priority
User is able to tweak the socket service dispatcher thread
priority in order to get better performance from the system
if needed. By default the dispatcher thread runs in lowest
application thread priority (K_LOWEST_APPLICATION_THREAD_PRIO).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen 38cacc7f63 net: shell: Make the thread name longer for sockets command
The thread name output field was a bit too short in "net sockets"
command, so make it 25 char long.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen d3bfef8399 net: shell: Do not crash if no sockets are found
The "net sockets" command was not checking if there is any
sockets in the system before trying to access them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen 1e8cbd5d43 net: zperf: Convert UDP receiver to use socket services
Use socket services API for UDP receiver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Jukka Rissanen 07823f7710 net: zperf: Convert TCP receiver to use socket services
Use socket services API for TCP receiver.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-18 20:13:31 +01:00
Chaitanya Tata df6d4e7717 wifi: shell: Log errors for validation
Handy in giving feedback to the user rather than silent failure.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata c9363a9c71 wifi: shell: Fix the channel extraction
The channel extraction from string directly uses the end variable with
limited data type, this causes issue if an invalid channel that exceeds
the data is given as an input e.g., 300, which would end up as a valid
channel 44.

Use an intermediate variable with type that can hold all possible
combinations (valid and invalid) and only after validation assign that
to the end type.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata 2f88df9cef wifi: shell: Add channel validation
Validate the channel for both STA and AP modes.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata 2f99379dd5 wifi: utils: Move channel helpers to public API
These can be used for channel validation outside the utils.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata c6f2152348 wifi: shell: Add a sanity check for MFP
For none and WPA-PSK MFP isn't applicable, it was only introduced in
WPA2-PSK (RSN) and later.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Chaitanya Tata 4a1847eb22 wifi: shell: Make channel mandatory for AP
For starting an AP mode, channel is mandatory, so, fix the arguments and
the help text.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-18 10:55:45 +01:00
Ajay Parida 4d854a193e net: mgmt: Print correct TWT teardown status message
Print success message for TWT teardown successful case.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-17 16:11:37 +00:00
Jukka Rissanen 3a37c5d987 net: shell: Require float printf support from libc
Various network shell commands like ping need floating
point support from libc so select the CONFIG_REQUIRES_FLOAT_PRINTF
option for it.

Fixes #67601

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 16:09:17 +00:00
Markus Swarowsky 11175c3ad3 tf-m: Change NS include path for TF-M 2.0.0
The place where TF-M places its non-secure api header files has changed
Therefore changing it for for all applications that use it.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2024-01-17 16:52:52 +01:00
Gerhard Jörges 2a0e5e93f3 logging: net: update hostname
This commit adds a function that updates the hostname displayed by the
net backend. It is called by the network stack when the hostname is
updated.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-17 14:42:58 +01:00
Gerhard Jörges 72a51c7ec4 net: add set hostname function
This commit adds a function to set the hostname on runtime.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-17 14:42:58 +01:00
Jukka Rissanen 16a54f251a net: sockets: Refactor accept() to support objcore better
If user has not supplied address pointer when calling accept(),
then we would not be able to figure out the used socket domain
properly. But as there is now SO_DOMAIN option supported, use
that to get the correct socket domain.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 09:55:40 +01:00
Jukka Rissanen 298ab2c95d net: socket: Add support for SO_DOMAIN option
The getsockopt() will return the address domain of the given
socket like AF_INET or AF_INET6.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-17 09:55:40 +01:00
Ibe Van de Veire ba5bcb14ba net: ip: igmp: removed compiler warning when igmpv3 is enabled
Made the definition of in_addr all_routers conditional to remove
compiler warning:
warning: 'all_routers' defined but not used [-Wunused-const-variable=]
The warning occurs when igmpv3 is enabled.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2024-01-17 09:55:28 +01:00
Chaitanya Tata dc9d5d9321 wifi: shell: Fix typo in comparison
The length should be 3 for WMM not 4.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-16 14:25:37 -05:00
Konrad Derda a5b868d94a net: buf: add function to match buffer's content with a given data
This commit adds a new function the net_buf's API that allow an user
to match the net_buf's content with a data without copying it to a
temporary buffer.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-01-16 09:40:04 -06:00
Jukka Rissanen 6033161216 net: shell: Avoid gcc warning print with string catenation
gcc prints this warning message

'strncat' specified bound 1 equals source length [-Wstringop-overflow=]
   58 |                 strncat(fd, "C", 1);

There was no error in the code but avoid the warning by not using
strncat().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen f5e95852ce net: shell: Add sockets services prints
The socket services users to "net sockets" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Jukka Rissanen eff5d02872 net: sockets: Create a socket service API
The socket service provides a similar functionality as what
initd provides in Linux. It listens user registered sockets
for any activity and then launches a k_work for it. This way
each application does not need to create a thread to listen
a blocking socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-16 10:00:45 +01:00
Mirko Covizzi 998e839d67 net: sockets: prevent null pointer dereference
According to the POSIX specification, null pointer
is a valid value for the `address` argument
of the `accept` function.
This commit adds a check to prevent a null pointer
dereference inside `z_impl_zsock_accept`.

Signed-off-by: Mirko Covizzi <mirko.covizzi@nordicsemi.no>
2024-01-15 15:11:57 +01:00
Manuel Schappacher bff6054cb8 net: gptp: Always use GM PRIO root system id for announce messages
A problem occurred while running PTP on a multi-port target
(RENESAS RZT2M) with two ports enabled. Announce messages on the
switched devices master port always contained local clock information
instead information from received on the slave port from the better
GM clock. Depending on the BMCA config this turned into having more
than one GM in the system.

Sending always the locally stored GM information helped to overcome
this issue.

Signed-off-by: Manuel Schappacher <manuel.schappacher@hs-offenburg.de>
2024-01-15 09:57:34 +01:00
Ajay Parida fc959fce47 net: shell: Early wake up for TWT power save
Provision of configurable parameter for generating unblock event
ahead of TWT slot. Host application depending upon latencies can
configure this to wakeup rpu ahead of the TWT slot.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-12 15:56:56 -05:00
Daniel DeGrasse 76f547e763 net: l2: wifi: wifi_utils: Resolve build warning with strncpy function
ARM GCC version 12.2.0 (Zephyr SDK 0.16.4) generates the following build
warning from the strncpy call in "wifi_utils_parse_scan_bands":

warning: '__builtin_strncpy' output truncated before terminating nul
copying as many bytes from a string as its length

To resolve this warning, pass the maximum length of the temporary
parse_str buffer to strncpy. This also has the benefit of correctly null
terminating parse_str, since we already verify the
scan_bands_str is properly null terminated with the strlen() check in
this function. We can therefore remove the line adding a null terminator
to parse_str as well.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-01-12 12:55:35 +01:00
Ajay Parida 56de0a347e net: mgmt: Provide Regulatory channel info
Updated to provide regulatory channel information along with country
code.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-12 09:59:19 +01:00
Ajay Parida 3053484dcb net: mgmt: Update app of TWT teardown status
Update user/app status of TWT teardown sessions.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-01-11 15:42:50 -06:00
Chaitanya Tata 2ce295b71e wifi: shell: Fix missing case sensitivity
This was missed in earlier that tried to fix all string comparisons to
use case insensitive comparison.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 15:38:42 -06:00
Kapil Bhatt d8c362253d net: wifi_shell: Add example of scan option
Add an example of the scan's -c parameter
to help with understanding.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-11 16:14:46 +00:00
Jukka Rissanen b8708ee781 net: tcp: Fix the CONFIG_NET_TCP_RETRY_COUNT help text
The help text was incorrect, we return -ETIMEDOUT instead
of -ECONNRESET when retransmission timeout occurs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-11 10:26:47 -05:00
Chaitanya Tata 918e08fda8 wifi: shell: Add a shell command to list stations
In AP mode maintain the database of connected stations based on the
Wi-Fi management events and dump the list.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata 725c13bafb wifi: ap: Add client side events
These are helpful to track clients being added and deleted.
Applications can actions based on these events.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata 2703955aee wifi: ap: Add status events
These events communicate the status of AP mode operations (enable or
disable) with few pre-defined enumerations.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Chaitanya Tata 09e1ed039a wifi: Fix duplication
Use a common set of events and then add specific ones as per the
configuration.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-11 10:03:02 +01:00
Kapil Bhatt 773ebe9c41 net: wifi_shell: Update scan argument shell
Update the example of scan -c argument.
Default value for max channels is set to 3,
So, update the example according to that.
Add closing bracket in -s.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-10 20:56:32 -05:00
Kapil Bhatt 3e8dbaf75f net: wifi_utils: Fix max channels allow for scan
Fix the maximum channels allow for scan command
input.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-01-10 20:56:32 -05:00
Simon Walz 38aa4d5169 net: lwm2m: add gateway callback to handle prefixed messages
Adding a callback for handling lwm2m messages with prefixed paths defined
by the gateway object. If CONFIG_LWM2M_GATEWAY_OBJ_SUPPORT is set,
each path is checked for the prefix stored in the object instances of the
gateway object 25. If prefixes match the msg is passed to the gw_msg_cb.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2024-01-10 18:22:21 +00:00
Jonathan Hamberg 9c1a45cc00 posix: Fix name collision with __bswap
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's
byteswap.h. byteswap.h from host compiler used in posix_native_64 boards
causes a compilation issue.

This commit renames __bswap_ to BSWAP_ to prevent collision.

Before this commit a compilation error can be created by adding #include
<byteswap.h> to samples/net/sockets/echo/src/socket_echo.c

This does not change external API to byteorder.h, but does change
internal implementation which some other source files depend on.

Replaced manual byteswap operations in devmem_service.c with APIs from
byteorder.h which automatically converts to CPU endianess when necessary.

Fixes #44324

Signed-off-by: Jonathan Hamberg <jonathanhamberg@gmail.com>
2024-01-10 18:13:44 +00:00
Jukka Rissanen 35e1df6bb4 tests: net: tcp: Add support for close callback
Add a function callback that is called when the TCP connection
is closed. This is only available if doing network tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Jukka Rissanen b214207d91 net: tcp: Reschedule FIN timer when entering FIN state
The FIN timer was not set when we entered the FIN_WAIT_1 state.
This could cause issues if we did not receive proper packets
from peer. With this fix, the connection is always terminated
even if peer does not respond.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Jukka Rissanen 40215e07a3 net: tcp: Install a last ack timer in passive close
If we are in a passive close state, then it is possible that
the ack we are waiting is lost or we do not accept the one peer
sent to us because of some earlier out of memory issue.
So install a timer (using by default the FIN timer value) to
close the connection if the last ack is not received on time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-09 10:03:08 +01:00
Chaitanya Tata 9e6542b0cc wifi: shell: Use case insensitive comparison
The help text uses the capital case as its an acronym, but passing
capital case fails. Also extend that to others as well.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 352ee50af7 wifi: shell: Fix the inconsistency in commands separation
For better readability, below rules will help:

 * Each command should be separated by a newline
 * Each command should end with a full stop (intermediate statements
   shouldn't have full stops)

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 7e7dc76296 wifi: shell: Remove the unnecessary text
The parameters heading is implied and doesn't have the newline, so, just
remove it.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 352f63c909 wifi: shell: Fix the help for reg domain
Separate the two optional parameters and add help.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 467a89e6a4 wifi: shell: Remove the unnecessary text in scan
We are using standard notation to differentiate optional and mandatory,
so, no need for a heading.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 30c492d5de wifi: shell: Fix help for PS command
Clearly mark the args as optional.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 9b55802d98 wifi: shell: Fix optional arg count for connect
Fix an extra optional arg.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Chaitanya Tata 0044640be6 wifi: shell: Fix the arg count for reg domain
Missed accounting for "-f" option.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-01-05 14:43:21 -05:00
Juha Ylinen 7c53fa86ff net: lwm2m: Fix deadlock when calling lwm2m_engine_pause()
lwm2m_engine_pause() caused deadlock if it was called within
engine thread.

Remove while loop from lwm2m_engine_resume().

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Juha Ylinen 85dfe3df14 net: lwm2m: Delay triggering registration update
Add short delay before triggering registration update. This allows
postponing the update from application side if needed.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2024-01-05 09:06:27 +01:00
Jukka Rissanen 8d3d48e057 net: ipv6: Check that received src address is not mine
Drop received packet if the source address is the same as
the device address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 19:00:33 +00:00
Robert Lubos 898aa9ed9a net: sockets: tls: Align DTLS connect() behavior with regular TLS
DTLS socket is not really connection-less as UDP, as it required the
DTLS handshake to take place before the socket is usable. Therefore,
align the DTLS connect() behavior with regular TLS.
The change is backward compatible. connect() call is still optional for
DTLS socket (the handshake can still take place from send()/recv()) and
a socket option was provided to disable DTLS handshake on connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos c0d5d2fbd5 net: sockets: tls: Allow handshake during poll()
When using DTLS socket, the application may choose to monitor socket
with poll() before handshake has been complete. This could lead to
potential crash (as the TLS context may have been left uninitialized)
and unexpected POLLIN reports (while handshake was still not complete).
This commit fixes the above - POLLIN will only be reported once
handshake is complete and data is available

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 0a1bee48bf net: sockets: tls: Improve POLLERR error reporting
In case a socket error was caused by TLS layer, it was not reported with
POLLERR. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 5b3b462eed net: sockets: tls: Add flag indicating that session is closed
In case TLS session is closed at the TLS level (and thus recv() reports
0 to the application) a certain race occurs between consecutive recv()
call, and TCP session teardown. As mbedtls_ssl_read() only reports
session close upon receiving CLOSE alert, consecutive non-blocking
recv() calls would report EAGAIN instead of connection closed, if called
before underlying TCP connection was closed.

Fix this, by storing the information that TLS session has ended at TLS
socket level. The new flag will be checked before attempting further
mbed TLS actions, so that connection status is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 1dc9028316 net: sockets: tls: Add function to obtain underlying ssl context
For test purposes only. Should not be used in regular applications.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Jukka Rissanen ec42d825ec net: context: Fix the v4 mapped address handling in sendto
If we receive a IPv4 packet to v4 mapped address, the relevant
net_context is bound to IPv6. This causes issues if we try
to get the family from the context struct in sendto.
Fix this by checking if the destination address is IPv4 but
the socket is bound to IPv6 and v4 mapping is enabled.
If all these criterias are set, then set the family of the
packet separately and do not get it from net_context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 12:55:14 +01:00
Jukka Rissanen 8f97c1c2ee net: lib: sockets: Initialize iovec to 0 at start of func
Make sure iovec is initialized to a value so that there
is no possibility that it is accessed uninitialized.

Fixes: #66838
Coverity-CID: 334911

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:50 +01:00
Jukka Rissanen 4e5ef76b15 net: lib: mdns_responder: Fix interface count check
The original idea was to check that we have enough network
interfaces in the system. The check needs to verify max IPv4
and IPv6 supported interfaces instead of always checking
IPv6 one.

Fixes: #66843
Coverity-CID: 334899

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:38 +01:00
Seppo Takalo dc6e7aa4b1 net: lwm2m: Add transmission state indicator to RX as well
Refactored the socket state indication into its own function
that checks the state of TX queues as well as number of
pending CoAP responses.
Check the state after receiving a packet, as it might
have been a last Ack packet we have been waiting.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-27 16:07:59 +00:00
Seppo Takalo 071cad2e76 net: lwm2m: Deprecate lwm2m_get/set_u64
Deprecate lwm2m_set_u64() and lwm2m_get_u64 as only
LWM2M_RES_TYPE_S64 exist. Unsigned variant is not defined.

Technically these might have worked OK, but it is undefined
what happens to large unsigned values when those are
converted to various payload formats (like CBOR) that might
decode numbers differently depending of their signedness.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-22 09:54:07 +01:00
Jukka Rissanen 1a0b6745bd net: shell: Print more Ethernet statistics
Various Ethernet error statistics values were not printed
by the shell.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-22 09:53:26 +01:00
Jordan Yates 1ef0ec55c9 net: ip: dhcpv4: remove address on interface down
Any received address is no longer valid once the interface goes down.
Leaving the address assigned results in the L4 interface transitioning
through the following on reconnection:
 UP: Interface is connected
 DOWN: Old address is removed by DHCP
 UP: New address is re-added by DHCP

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-21 09:18:32 +01:00
Jordan Yates 434c93ddfb net: conn_mgr: output events as hex
Networking events are masks of bits, which are almost impossible to read
as decimal, and trivial to read as hex. Also unifies the format string
across multiple outputs for some flash savings.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-21 09:18:32 +01:00
Jukka Rissanen 19392a6d2b net: ipv4: Drop packet if source address is my address
If we receive a packet where the source address is our own
address, then we should drop it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-21 09:18:24 +01:00
Jukka Rissanen 6d41e68352 net: ipv4: Check localhost for incoming packet
If we receive a packet from non localhost interface, then
drop it if either source or destination address is a localhost
address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-21 09:18:24 +01:00
Seppo Takalo 6161fbdf21 net: lwm2m: Transmission state indications
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>
2023-12-20 11:57:48 +00:00
Seppo Takalo 0d650ffd26 net: lwm2m: Update TX timestamp on zsock_send()
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>
2023-12-20 11:57:48 +00:00
Seppo Takalo 01568b573a net: coap: Add API to count number of pending requests
Add coap_pendings_count() that return number of waiting
requests on the pendings array.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-20 11:57:48 +00:00
Robert Lubos 9aba4e8f3d net: sockets: tls: Read the actual error on interrupted wait
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>
2023-12-20 11:10:57 +01:00
Johan Hedberg 3fbf12487c kernel: Introduce a way to specify minimum system heap size
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>
2023-12-20 11:01:42 +01:00
Mario Paja 98336b2811 Revert "net: gptp: Fix announce message len"
This reverts commit 6b644dff67.

Reason: breaks Peer-to-Peer gPTP connection. A better solution should be
found to handle the optional TLV on the announce message (chapter 10.5.1
IEEE 802.1AS-2011)

Signed-off-by: Mario Paja <mario.paja@zal.aero>
2023-12-19 22:51:52 +00:00
Chaitanya Tata 6152e64aa0 wifi: shell: Fix arg count for regulatory domain
Regulatory domain supports both get and set, so, fix the argument
counts.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 17:46:12 +01:00
Robert Lubos b7e3ae2521 net: ipv6_mld: Silently drop MLDv1 queries
Zephyr does not support MLDv1 (which has a shorter header than MLDv2),
and this resulted in log errors being printed on header access if MLDv1
queries were received. Since receiving such packet is not really an
error, just drop it silently.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-18 09:28:42 +01:00
Pieter De Gendt 4807ada01e net: lib: coap: Use coap_transmission_parameters in coap_server
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>
2023-12-18 09:28:25 +01:00
Chaitanya Tata eaba47445a wifi: shell: Display RSSI only for station mode
RSSI makes sense only for modes that have a single peer, so, add a
station mode check.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 09:28:16 +01:00
Chaitanya Tata 9736cc7f29 wifi: shell: Fix AP argument checks and help
AP enable takes the same parameters as connect, so, update the help and
also fix the optional parameter count when security is involved.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-18 09:28:16 +01:00
Robert Lubos 0c095898fb net: shell: Prevent deadlock with net arp command
In case one of the networking shell backends is enabled, net arp command
could potentially trigger a deadlock, as it locks the ARP mutex before
TCP connection mutex, while TCP stack could do this in reverse order
(for instance when sending ACK or retransmission).

Mitigate this, by forcing a separate TX thread in such case, so that ARP
mutex is no longer accessed with TCP mutex locked.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-15 11:42:40 +00:00
Juha Ylinen d09d3d82ef net: lib: coap: Change coap_pending_init()
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>
2023-12-15 11:41:27 +00:00
Jukka Rissanen b6aea97dc7 net: l2: dummy: Add start/stop API functions
The dummy L2 layer does not implement any L2 functionality
but it does not mean that it should not implement start/stop
functions that are called when the related network interface
is brought up or taken down.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Jukka Rissanen d8ec9118b4 net: if: Interface stays down if device is not ready
It is pointless to take net interface up if the underlaying
device is not ready. Set also the interface status properly
in this case.

Fixes #65423

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-14 14:21:31 +01:00
Daniel DeGrasse 3091ddc4fe net: lib: lwm2m: use correct format specifier for LOG_ERR
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>
2023-12-14 09:32:43 +01:00
Declan Snyder e913ccc753 net: Add Kconfig for net buf alignment
Add a NET_BUF_ALIGNMENT kconfig to make net buffer alignment configurable.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-12-14 09:29:47 +01:00
Jukka Rissanen 477a4a5d34 net: shell: Rename the common.h to be more unique
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>
2023-12-13 20:13:39 +01:00
Robert Lubos 8cb4f09a28 net: tcp: Remove pointless recv callback calls
Calling the registered receive callback when releasing TCP context
doesn't make sense, as at that point the application should've already
closed the associated socket (that's one of the conditions for the
context to be released). Therefore, remove the pointless receive
callback call, while keeping the loop to unref any leftover data packets
(although again, I don' think there should be any packets left at that
point, as they're all consumed in tcp_in()).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-13 10:39:03 +01:00
Robert Lubos 6b00b537aa net: tcp: Fix deadlock with tcp_conn_close()
While improving thread safety of the TCP stack I've introduced a
possible deadlock scenario, when calling tcp_conn_close() in tcp_in().
This function shall not be called with connection mutex locked, as it
calls registered recv callback internally, which could lead to deadlock
between TCP/socket mutexes.

This commit moves the tcp_conn_close() back where it was originally
called. I've verified that the thread safety is still solid with the
test apps used originally.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-13 10:39:03 +01:00
Declan Snyder e4cca5145b net: Add fallback macro for nef_if_mon functions
Add empty macro for net_if_mon functions if they are not otherwise
defined, like the other functions in the net_if.c file have.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-12-12 10:58:38 +00:00
Juha Ylinen 69e28939dd net: lib: coap: Add new API to configure retransmission settings
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>
2023-12-12 10:56:29 +01:00
Jukka Rissanen b6d9ed095d net: Move trickle files to lib
The trickle algorithm files are clearly a library so move
them under lib/ directory.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-11 10:50:35 +01:00
Robert Lubos 2cc0d31d9f net: tcp: Move TCP Kconfig options to separate file
The number of Kconfig options for the TCP stack grew considerably,
therefore it makes sense to move them to a separate file not to bloat
the Kconfig file with generic networking options.

Take this opportunity to reorder TCP options, so that protocol
parameters (timings/buffer sizes) are not mixed up with optional
protocol features (fast retransmit/congestion avoidance etc.).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-11 10:11:10 +01:00
Robert Lubos a150380d65 net: tcp: Implement Keep-alive support
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>
2023-12-11 10:11:10 +01:00
Seppo Takalo 005dc60d24 net: lwm2m: Fix pmin handling on tickless
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>
2023-12-11 09:57:09 +01:00
Jasper Smit 6003927ac2 net: sntp: Add option for SNTP uncertainty
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>
2023-12-08 10:25:46 +00:00
Lingao Meng 786b9a0ad4 Bluetooth: Host: Add const prefix for UUID
Add const prefix for service uuid and char uuid.

Since Service UUID and Char UUID should not change in the service
definition, they are most reasonably defined as rodata, also for
save some ram footprint.

The field `attr->user_data` type is `void *`, as this PR change
all Service UUID to rodata, so there must add (void *) to avoid warning.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-12-07 16:16:43 +00:00
Pieter De Gendt c1204affab net: ip: net_mgmt: Support system work queue and synchronous callbacks
Add Kconfig choice for the user to select how Network Events are
handled. It's own thread, the system work queue or synchronous when
events are emitted.

By default a separate thread is created to be backwards compatible.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 16:15:53 +00:00
Pieter De Gendt 35761f724d net: lib: shell: Add CoAP descriptions to event monitor
Add a description for each CoAP event on L4.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Pieter De Gendt 5182dd24c6 net: lib: coap: Introduce net mgmt events for CoAP
Allow users to register net mgmt events callbacks for CoAP events.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-07 10:34:39 +00:00
Pieter De Gendt f712441840 Revert "net: lib: coap: Add support for observer event callbacks"
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>
2023-12-07 10:34:39 +00:00
Nick Ward b1d24e425c net: lwm2m: device object: optionally store error list in settings
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>
2023-12-06 17:55:22 +00:00
Nick Ward b75a3f691d net: lwm2m: device object: use LWM2M_DEVICE_ERROR_NONE
Use LWM2M_DEVICE_ERROR_NONE macro.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-12-06 17:55:22 +00:00
Robert Lubos 5f6b4479ed net: conn: Improve thread safety in connection module
Iterating over connection list w/o mutex lock could lead to a crash on
constant incoming packet flow. Fix this by:

1. Adding mutex lock when iterating over an active connection list, to
   prevent list corruption.
2. Create a copy of the callback and user data pointers before releasing
   lock, to prevent NULL pointer dereference in case connection is
   released before callback is executed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-06 09:23:54 +00:00
Robert Lubos 4ab2dded8d net: tcp: Eliminate race between input thread and TCP work queue
Eliminate race between TCP input thread and TCP work queue, when
dereferencing connection. This normally would not manifest itself during
standard TCP operation, but could be a potential opening for abuse, when
the already closed TCP connection is kept being spammed with packets.
The test scenario involved sending multiple TCP RST packets as a
response to establishing the connection, which could result in system
crash. The following changes in the TCP stack made it stable in such
scenario:

1. Use `tcp_lock` when searching for active connections, to avoid
   potential data corruption when connection is being removed when
  iterating.
2. Avoid memset() during connection dereference, not to destroy mutex
   associated with the connection. The connection context is only
   cleared during allocation now.
3. Lock the connection mutex while releasing connection.
4. In tcp_in(), after locking the mutex, verify the connection state,
   and quit early if the connection has already been dereferenced.
5. When closing connection from the TCP stack as a result of RST or
   malformed packet, verify connection state to make sure it's only done
   once, even if multiple RST packets were received.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-06 09:23:54 +00:00
Jukka Rissanen d5c7761314 net: ipv6: Silently drop unwanted NA messages
Silently drop the IPv6 Neighbor Advertisement if we receive it
for an unknown neighbor or if there some some issue in the packet.
Returning error here would cause the ICMP module to print an
actual error which just pollutes the log without any apparent
benefit.

Fixes #66063

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-06 09:22:44 +00:00
Seppo Takalo dc8f6da53c net: lwm2m: Implement fallback mechanism and support for diable
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>
2023-12-05 16:40:06 -06:00
Seppo Takalo ec962246e9 net: lwm2m: Allow disabling server for a period of time
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>
2023-12-05 16:40:06 -06:00
Seppo Takalo 304d920ef1 net: lwm2m: Allow finding security instance by short ID.
Add API to find a security instance ID with given Short Server ID.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-12-05 16:40:06 -06:00
Pieter De Gendt 3157aaaddb net: ip: mgmt: Add support for compile time event handlers
Add an iterable section with network event handlers.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-05 09:17:42 -05:00
Jukka Rissanen bed63764d6 net: socket: Add IPv6 multicast join/leave via socket
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>
2023-12-04 16:38:49 +00:00
Jukka Rissanen b58bddb85c net: socket: Add IPv4 multicast join/leave via socket
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>
2023-12-04 16:38:49 +00:00
Jukka Rissanen 060295c63b net: dns: responders: Set the multicast TTL or hoplimit
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>
2023-12-04 15:07:43 +01:00
Jukka Rissanen fc006d7daa net: dns: Do not pass 0 as TTL or hop limit
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>
2023-12-04 15:07:43 +01:00
Jukka Rissanen d44b72355b net: Refactor IP checks just before sending packets
* Check IPv4 TTL or IPv6 hop limit and drop the packet if
  the value is 0
* Check the IP addresses so that we do the loopback check
  at runtime if the packet is destined to loopback interface.
* Update the statistics properly for dropped packets.
* Do not update sent packets if we drop packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen b4a8e3ffff net: socket: Add support for adjusting IPv4 TTL
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>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 96ac91d1c9 net: Add support for adjusting IPv6 unicast hop limit
Add option support for adjusting the IPv6 unicast
hop limit value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen e397d199b1 net: if: Fix typo in IPv6 hop limit API name
The net_if_ipv6_set_hop_limit() API was missing the "_if_"
part in it. Fix this so that the network interface API is
consistent. The old function is deprecated and should not
be used. The old function is left to the code and it calls
the new properly named function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen 1c684bc360 net: Add support for adjusting IPv6 multicast hop limit
Add option support for adjusting the IPv6 multicast
multicast hop limit value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Jukka Rissanen de0268def0 net: context: Add support for adjusting IPv4 multicast ttl
Add option support for adjusting the IPv4 multicast
time-to-live value.

Fixes #60299

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-12-04 15:07:43 +01:00
Robert Lubos 839553a7d9 net: shell: ping: Fix double packet unref in ping reply handler
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>
2023-12-04 14:30:26 +01:00
Robert Lubos 67082289e1 net: l2: ethernet: Fix error handling after ARP prepare
Commit 55802e5e86 fixed error handling of
TX errors, in case ARP request was generated. There are however also
other places where post-ARP cleanup should be done on the TX path (like
running out of buffers for Ethernet L2 header allocation).

This commit fixes those cases in ethernet_send(), where function would
exit early and report error after ARP prepare stage.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-12-04 14:30:26 +01:00
Chaitanya Tata 07e3869809 wifi: shell: Add long arguments to help
Long arguments are handy for new users. Also use hyphen's rather than
underscore to follow the convention.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata 95b8ae37e3 wifi: shell: Enforce argument count checks
Use the proper API to enforce argument count checks as per mandatory or
optional params.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata 1c46e52bf8 wifi: shell: Add missing security options
Newly added security types are missing from the help. Also, now that we
have two variants of PSK, use the prefix to disambiguate.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata 8ad78a4bb4 wifi: shell: Fix PS mode help
There is only a single parameter called "mode" that takes two possible
values.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata 95e52c9c63 wifi: shell: Fix brackets type for optional params
General notation for Optional params is to use square brackets.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Chaitanya Tata 8a4f7c02c0 wifi: shell: Fix unbalanced braces
Fix the typo in braces for help.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-04 14:27:59 +01:00
Noah Luskey 8e4c70750a net: don't overwrite net_if name after iface is initialized
When interface names are enabled, a default name is applied
after initialization. Unintuitively, this overwrites any name that is
set during the net_if init.

This change sets a default name first, and then allows net_if
init to overwrite that default name if it chooses to.

Signed-off-by: Noah Luskey <noah@silvertree.io>
Signed-off-by: Noah Luskey <LuskeyNoah@gmail.com>
2023-12-04 14:18:53 +01:00
Kapil Bhatt cb7b650b92 net: l2: wifi: Fix Print of SSID in WIFI status
While printing SSID in wifi status command, If the
length is maximum(32 character). It leads to buffer
overflow. It required one character for null
terminator ‘\0’. Changing the Format Specifiers to
print proper SSID.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-12-01 11:03:43 +00:00
Mario Paja 6b644dff67 net: gptp: Fix announce message len
This fix addresses wrong announce message length warning message.

TLV is a variable length (4+8N) based on the 802.1AS-2011 (table 10-8). In
Zephyr TLV is fixed to 12 bytes. TLV type and length are already taken
into account in the announcement message length.

Signed-off-by: Mario Paja <mario.paja@zal.aero>
2023-12-01 11:02:57 +00:00
Chaitanya Tata eb9587596b wifi: Check WPA-PSK passphrase length
When WPA-PSK was introduced the passphrase length check was missed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-12-01 10:57:06 +00:00
Pieter De Gendt 266181b082 net: lib: coap: Add coap_service_is_running
Add a CoAP service API function to query the running state of the
provided service.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-12-01 10:56:56 +00:00
Pieter De Gendt 4ff8080b65 net: lib: coap: Init CoAP service socket fd to -1
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>
2023-12-01 10:56:56 +00:00
Jukka Rissanen 5d915398a4 net: sockets: Add additional checks to recvmsg()
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>
2023-12-01 10:56:34 +00:00
Robert Lubos 222fa42609 net: icmp: Fix Echo Replies with unspecified address
Fix two issues with sending ICMP Echo Reply for requests sent for
multicast address:
* Use the originator IP address instead of multicast when selecting
  source address for the reply
* In case no address match is found, drop the packet, instead of
  replying with unspecified address.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:07:45 +01:00
Pieter De Gendt 8252ec7570 net: lib: coap: Translate handler errors to CoAP response codes
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>
2023-11-30 10:07:32 +01:00
Robert Lubos 37d39425ee net: tcp: Fix possible race between TCP work items and context unref
Fix the possible race between TCP work items already scheduled for
execution, and tcp_conn_unref(), by moving the actual TCP context
releasing to the workqueue itself. That way we can be certain, that when
the work items are cancelled, they won't execute. It could be the case,
that the work item was already being processed by the work queue, so
clearing the context could lead to a crash.

Remove the comments around the mutex lock in the work handlers regarding
the race, as it's not the case anymore. I've kept the locks however, as
they do make sense in those places.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-30 10:06:50 +01:00
Jukka Rissanen 1f1712a89f net: context: Add ARG_UNUSED to relevant places in opt handling
If some specific option is not enabled, then add missing
ARG_UNUSED() calls in relevant functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Jukka Rissanen 77e522a5a2 net: context: Refactor option setters
Set separate option setters for bool, uint8_t and uint16_t
values. Use those generic setters when storing the desired
option value.

The uint16_t option setter stores the value to uint16_t variable
and expects that user supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Jukka Rissanen 55958d851f net: context: Refactor option getters
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.

Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.

The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.

For uint8_t value, it is expected that uint8_t value is supplied
instead of int.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-30 10:05:06 +01:00
Konrad Derda 3c39f7efd9 net: hostname: trigger an event when the hostname changes
This commit introduces new network event that is triggered on every
change of the hostname.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-11-29 13:16:16 -06:00
Lukasz Majewski 25addd0984 net: ethernet: Add support for setting T1S PLCA parameters
The Zephyr's core ethernet code had to be adjusted to support setting T1S
PLCA parameters from user Zephyr programs.

Such approach allows more flexibility, as T1S network configuration;
especially PLCA node numbers, can be assigned not only via device tree
at compile time. For example user can read them from EEPROM and then
configure the network accordingly.

For now - the union in struct ethernet_t1s_param only consists of plca
structure. This can change in the future, when other T1S OA parameters -
like Receive/Transmit Cut-Through Enable (bits RXCTE/TXCTE in OA_CONFIG0
register) are made adjustable from user program.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2023-11-29 10:06:30 +01:00
Robert Lubos afd2e9561c net: tls_credentials: Add missing include dir for PSA API
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>
2023-11-28 15:35:00 +01:00
Pieter De Gendt 473cc03c38 net: ip: icmp: Cleanup packet on failed priority check
A network memory leak would occur if the priority check fails.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-27 19:59:26 +01:00
Maciej Baczmanski c2f1ff7f5f net: openthread: upmerge to 75694d2
Regular OpenThread upmerge to commit `75694d2`.

Move CONFIG_OPENTHREAD_PLATFORM_KEY_REFERENCES_ENABLE
from header file to Kconfig.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-11-27 19:59:04 +01:00
Jukka Rissanen 1961adfb96 net: socket: Return ENOTSUP for unknown socket type in recvfrom()
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>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 5488e76bb2 net: socket: Add support for filling receive pktinfo data
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>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 80704bb361 net: socket: Add support for setting pktinfo options
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>
2023-11-27 19:58:47 +01:00
Jukka Rissanen c3acd56e27 net: context: Add support for setting receive pktinfo option
Add low level support for setting IP_PKTINFO or IPV6_RECVPKTINFO
socket options. The support is disabled by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 760c2f2949 net: sockets: Remove extra check from sendmsg()
There was double "if (status < 0)" check in sendmsg(),
remove the extra check.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Jukka Rissanen 4b365fab45 net: sockets: Add recvmsg() implementation
Add support for recvmsg() function which can return data
in msghdr struct (iovec).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-27 19:58:47 +01:00
Alexander Vasiliev 76276e2bd3 net: mqtt-sn: Remember incoming registered topic name
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>
2023-11-22 09:53:33 +01:00
Alexander Vasiliev 6caf76346a net: mqtt-sn: Add a function to get topic name by topic ID
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>
2023-11-22 09:53:33 +01:00
Ibe Van de Veire 1d0f47b005 net: ip: igmp: add igmpv3 support
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>
2023-11-21 15:50:31 +01:00
Ibe Van de Veire ca7ce90dc7 net: ip: utils: changed input arguments of igmp_checksum to net_pkt
Added igmpv3 checksum function to make it possible to calculate the
checksum of a complete igmpv3 pkt at once.

Signed-off-by: Ibe Van de Veire <ibe.vandeveire@basalte.be>
2023-11-21 15:50:31 +01:00
Declan Snyder cf42b8b2fb net: sockets: fix shadowing warning
Fix compiler local variable shadowing warning

Rename ret to bytes_sent in offending funciton

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-11-21 08:48:04 +00:00
Declan Snyder 7c72d4a2d6 net: Fix CMakeLists
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>
2023-11-21 08:48:04 +00:00
Robert Lubos aa6f698d31 net: zperf: Fix TCP packet counting
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>
2023-11-21 08:46:45 +00:00
Robert Lubos e6d90b409b net: sockets: tls: Set errno on TX waiting error
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>
2023-11-21 08:46:45 +00:00
Robert Lubos 3a38ec1aaa net: tcp: Feed TX semaphore on connection close
Otherwise, if the application was for example blocked on poll() pending
POLLOUT, it won't be notified.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos 9976ebb24b net: tcp: Rework data queueing API
Rework how data is queued for the TCP connections:
  * net_context no longer allocates net_pkt for TCP connections. This
    was not only inefficient (net_context has no knowledge of the TX
    window size), but also error-prone in certain configuration (for
    example when IP fragmentation was enabled, net_context may attempt
    to allocate enormous packet, instead of let the data be fragmented
    for the TCP stream.
  * Instead, implement already defined `net_tcp_queue()` API, which
    takes raw buffer and length. This allows to take TX window into
    account and also better manage the allocated net_buf's (like for
    example avoid allocation if there's still room in the buffer). In
    result, the TCP stack will not only no longer exceed the TX window,
    but also prevent empty gaps in allocated net_buf's, which should
    lead to less out-of-mem issues with the stack.
  * As net_pkt-based `net_tcp_queue_data()` is no longer in use, it was
    removed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Robert Lubos 16fd744c13 net: pkt: Add function for allocating buffers w/o preconditions
Add new function to allocate additional buffers for net_pkt, w/o any
additional preconditions/checks. Just allocate what was requested.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-21 08:46:45 +00:00
Henning Fleddermann 8e4c588eab net: lib: lwm2m: Use int16_t for signal quality
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>
2023-11-20 13:01:23 +01:00
Robert Lubos 8a75a4b9db net: shell: Fix array indexing with dynamic iface command
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>
2023-11-20 09:24:47 +01:00
Robert Lubos f0247131bf net: tftp: Ensure the error message fits into transmit buffer
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>
2023-11-20 09:24:18 +01:00
Robert Lubos 59544d58ef net: tftp: Verify connect return value
Verify that connect() succeeded before reporting success.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:18 +01:00
Robert Lubos 69e6b3a563 net: tftp: Log transmit error
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>
2023-11-20 09:24:18 +01:00
Robert Lubos a3362d969d net: lwm2m: Explicitly initialize path_list_size variable
To get rid of compiler warning about potential use of uninitialized
variable.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:11 +01:00
Robert Lubos 7f7d019b25 net: lwm2m: Add error checks for option encoding in BS registration
Add missing error checks when encoding CoAP options for Bootstrap
Register message

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:24:11 +01:00
Robert Lubos ec50e5393c net: lwm2m: shell: Add error check for string to float conversion
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>
2023-11-20 09:24:11 +01:00
Robert Lubos e702ecc8fb net: dhcpv6: Verify net_pkt_skip() return value
Verify the return value of net_pkt_skip() function, in case the parser
ignores the unrecognized options, so that in case the option was
malformed and the actual provided option length exceeds the packet
length, it is recognize (net_pkt_skip() should fail then).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-20 09:23:22 +01:00
Benjamin Cabé 79c677c0ef net: lib: coap: Fix NULL pointer dereference
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>
2023-11-20 09:23:12 +01:00
Henrik Brix Andersen c0c8952739 shell: do not enable subsystem/driver shell modules by default
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.

The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.

This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-20 09:21:40 +01:00
Benjamin Lindqvist 1d6d24b6ef net: lwm2m: don't load credentials on plaintext context
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>
2023-11-20 09:20:43 +01:00
Jukka Rissanen 5209666539 net: mdns: Fix compile error when using clang
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>
2023-11-17 12:40:33 +01:00
Jukka Rissanen 5049a049db net: mdns: Create a listener to all available network interfaces
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>
2023-11-17 12:40:33 +01:00
Jukka Rissanen dd2a222086 net: if: Add helper to calculate number of interfaces
Add a helper macro that can be used at runtime to return
the number of network interfaces in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen 3f891ced3a net: conn: Check also network interface for duplicates
When verifying if there are duplicate connections, check
also network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen 8157b48734 net: context: Add function to bound to a network interface
Helper function that marks the net_context to bound to a
network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Jukka Rissanen 31ee2e678d net: context: Allow binding to different interfaces
Allow user to bind to different network interface. This is
useful if binding a multicast address to a certain network
interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-17 12:40:33 +01:00
Seppo Takalo 8cfede8f2e net: lwm2m: Support DTLS Connection Identifier
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>
2023-11-17 09:23:29 +01:00
Tomasz Moń b5f4d8374a net: buf: Preserve buffer pointer in destroy callback
The use case is to have a netbuf pool that is used exclusively with
net_buf_alloc_with_data() where the destroy callback takes care of
freeing the actual data buffer pointed to by __buf.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-11-15 10:02:55 +01:00
Georges Oates_Larsen 9f093ab731 net: tls_credetials: Add TLS Credentials shell
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>
2023-11-14 10:40:02 +00:00
Georges Oates_Larsen f5d12102a0 net: tls_credentials: sectag iterators
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>
2023-11-14 10:40:02 +00:00
Georges Oates_Larsen 16bd8a82a6 net: tls_credentials: credential_digest
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>
2023-11-14 10:40:02 +00:00
Pieter De Gendt 655c72c52e net: lib: coap: coap_server: Allow clients to refresh observe requests
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>
2023-11-13 09:50:19 +01:00
Pieter De Gendt cbf9680f96 net: lib: coap: Add coap_find_observer
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>
2023-11-13 09:50:19 +01:00
Robert Lubos 61c392c5b1 net: iface: Introduce TX mutex locking
A recent iface lock removal in ed17320c3d
exposed issues with concurrent access on TX to drivers that are not
re-entrant.

Reverting that commit does not really solve the problem, as it would
still exist if multiple Traffic Class queues are in use.

Therefore, introduce a separate mutex for TX data path, protecting the
L2/driver from concurrent transfers from several threads.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-13 09:49:57 +01:00
Robert Lubos 8aba7740b8 net: lwm2m: Fix core objects version reporting
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>
2023-11-13 09:46:06 +01:00
Pieter De Gendt e8e6d23270 net: lib: coap: Add CoAP server shell
Add shell commands that allow to start/stop CoAP services.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt ae6e0106e7 net: lib: coap: Add service support
Add CoAP services and server as a subsystem implementation.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt 5227f24815 net: lib: coap: Add support for observer event callbacks
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>
2023-11-09 11:21:42 +01:00
Pieter De Gendt 291743b686 net: lib: coap: coap_remove_observer result type
Change coap_remove_observer to return the result of removing the
observer if found.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt fac670e1e2 net: lib: coap: Add coap_find_observer_by_token
Add a CoAP helper function to find a matching observer by token.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt cc89338888 net: lib: coap: Add coap_packet_is_request
Add function to check if CoAP packet is a request to the public API.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt 0a4668a2f7 net: lib: coap: Add coap_uri_path_match
Add URI path matching function to public CoAP API.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Pieter De Gendt bea29cf631 net: lib: coap: Add resources length based variants
Add length variant for the well known core resource and parsing.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-11-09 11:21:42 +01:00
Chaitanya Tata ed17320c3d net: Remove unnecessary lock
The main action in this function it queueing the packet for
transmission which doesn't need a lock and interface flags use atomic
operations.

So, remove the unnecessary lock.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-09 10:21:13 +00:00
Seppo Takalo d69d4013d3 net: lwm2m: Fix blockwise response code
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>
2023-11-08 15:11:36 +00:00
Robert Lubos 83f9fc4ce2 net: ip: Add hidden Kconfig symbol for IP fragmentation
Instead of consistently checking for both, IPv4 and IPv6 fragmentation
in several places, add a hidden Kconfig symbol which indicates that some
IP fragmentation has been enabled (either IPv4 or IPv6 or both).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos c724cf99f4 net: pkt: Add explicit flag to indicate packet is IP reassembled
The current logic to determine whether a packet is IP reassembled is
flawed, as it only worked in certain conditions (which was ok, as the
conditions were satisfied for the current use case, but now it's a
public function). Therefore, add an explicit flag that indicates whether
a packet is IP reassembled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 24abc4307b net: Verify L4 checksum unconditionally for reassembled packets
In case of reassembled IP packets, we cannot rely on checksum
offloading as the drivers/HW has no means to verify L4 checksum before
the fragment is reassembled. Therefore, for such packets, verify L4
checksum in the software unconditionally.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 76a256ea57 net: pkt: Add function to check if packet was reassembled at IP level
Move the existing code verifying that the net_pkt was reassembled at IP
level to a helper function, as it will be needed in other places as
well. Additionally, add packet family check before accessing union
fields.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 2836d0701d net: ip: Set net_context on the final fragment
IPv4/6 fragmentation did not set the net_context pointer on the fragment
packet and in result the send callback registered on net_context was not
called. Therefore, copy the net_context pointer from the original packet
to the final fragment to ensure that the registered callback is called.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 64e615263a net: ipv6: Set IP header length on the fragmented packet
IPv6 fragmentation code did not set the IP header field on the
fragment net_pkt.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 0c1c939d9e net: ipv6: Remove invalid/unneeded code from fragmentation logic
Skipping both next_hdr_off and last_hdr_off and filling last_hdr
variable doesn't make much sense, as this effectively moves the packet
cursor inside/behind the last (L4) header with no particular meaning.
Plus the last_hdr variable isn't really used anywhere, which kind of
proves the point. Therefore, remove the unused variable and needless
net_pkt operations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 13a22e6814 net: ipv6: Calculate checksum before fragmentation
In case the stack has to fragment the IPv6 packet, calculate the
checksum before fragmentation (if haven't done so).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 887a3a321d net: ipv4: Calculate checksum before fragmentation
In case the stack has to fragment the IPv4 packet, calculate the
checksum before fragmentation (if haven't done so).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 08879ea7fb net: ip: Add option to force checksum calculation
Modify internal L4 protocols APIs, to allow to enforce checksum
calculation, regardless of the checksum HW offloading capability.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos eadd933607 net: Set a flag when checksum has been computed
Set checksum flag on the net_pkt, when checksum is calculated in
software.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Robert Lubos 98b46340f2 net: pkt: Add flag indicating checksum status
Add new net_pkt checksum, which indicate checksum status on the packet
(i. e. whether it has already been calculated or not).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-11-08 15:09:37 +00:00
Przemyslaw Bida 2a4350dfd2 net: openthread: Adding snoop entries kconfig.
Adding missing `CONFIG_OPENTHREAD_TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES`
to thread kconfig file.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2023-11-08 10:08:58 +01:00
Jukka Rissanen e89c9a6671 net: tcp: Fix compilation if congestion avoidance is disabled
Fix tcp.c compilation if user unsets
CONFIG_NET_TCP_CONGESTION_AVOIDANCE config option.

Fixes #64824

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-11-07 09:54:31 +01:00
Chaitanya Tata d12627e70f wifi: shell: Move defaults to beginning
This sets defaults first and then overrides if configured, easier to
read.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-07 09:53:39 +01:00
Chaitanya Tata 8c179870d4 wifi: shell: Fix default band value
The enum is mainly to print output of band, so, the default value is 0
which means 2.4GHz, which is not correct when using it to configure like
in connect.

Fix the default value to unknown i.e., no user preference. This way we
can use same enum for both set and get.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-07 09:53:39 +01:00
Seppo Takalo 8608b2dc45 tests: lwm2m: Information Reporting Interface [300-399]
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>
2023-11-07 09:47:00 +01:00
Jukka Rissanen b0d0f60389 net: shell: Print device and wifi information for iface cmd
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>
2023-11-06 15:51:36 -06:00
Emil Lindqvist 7f19764d9e kconfig: name choices to make changable in outside Kconfigs
This commit names a couple of choices to allow the default
value to be overridden by Kconfig files out of tree

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2023-11-06 15:33:35 -06:00
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif ee9f278323 syscall: rename Z_SYSCALL_VERIFY -> K_SYSCALL_VERIFY
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c4d881183 syscall: rename Z_SYSCALL_ to K_SYSCALL_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c1aeb5fd3 syscall: rename z_user_ to k_usermode_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 56fddd805a syscall: rename z_user_from_copy -> k_usermode_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 6ba8176e33 syscall: rename z_user_alloc_from_copy -> k_usermode_alloc_from_copy
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif df9428991a syscall: Z_SYSCALL_MEMORY_ARRAY -> K_SYSCALL_MEMORY_ARRAY
Rename macros and do not use Z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4d5d04169d syscall: rename z_is_in_user_syscall
Rename z_is_in_user_syscall -> k_is_in_user_syscall

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
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>
2023-11-03 11:46:52 +01:00
Anas Nashif a6b490073e kernel: object: rename z_object -> k_object
Do not use z_ for internal structures and rename to k_object instead.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif c91cad735a kernel: object: rename z_object_init to k_object_init
Do not use z_ for internal API and rename to k_object_init.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif d2c025dd78 kernel: objects: rename z_dynamic_object_create -> k_object_create_dynamic
Do not use z_ for internal APIs and rename z_dynamic_object_create.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Marc Lasch 73bab817a0 net: lwm2m: Remove the resource type in registration message
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>
2023-11-03 11:44:28 +01:00
Chaitanya Tata d4d96b3df2 net: zperf: Fix the check for IPv6
It was typo.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-03 11:21:16 +01:00
Seppo Takalo b6ab302fe8 net: lwm2m: Fix overlapping buffers from Portfolio object
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>
2023-11-02 09:28:04 +01:00
Seppo Takalo 2eb804a558 net: lwm2m: Add shell support for deleting object and resource instances
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>
2023-11-02 09:27:55 +01:00
Benedikt Schmidt d7f0da1c78 net: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Jukka Rissanen e44de3e381 net: shell: Join IPv6 mcast group if needed
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>
2023-10-27 10:52:48 +02:00
Jukka Rissanen 1467d7fa7b net: shell: Join IPv4 mcast group if needed
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>
2023-10-27 10:52:48 +02:00
Chaitanya Tata a1024f6aeb net: zperf: By default bind to any IP address
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>
2023-10-27 10:52:19 +02:00
Chaitanya Tata dee1f2deaa net: zperf: Set default IP addresses only if configured
If the user has not configured then we see the error prints for the
defaults always.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-10-27 10:52:19 +02:00
Chaitanya Tata 6bd47ffb10 net: zperf: Distinguish between IPv4 and IPv6 address set failures
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>
2023-10-27 10:52:19 +02:00
Jukka Rissanen 83c875adab hostap: Move the relevant config options away from hostap
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>
2023-10-26 09:48:47 +02:00
Seppo Takalo cf513451eb net: lwm2m: Keep user_data between blocks
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>
2023-10-25 17:36:30 +02:00
Jukka Rissanen 8a58104396 net: shell: Add net-sockets command
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>
2023-10-24 11:11:30 +02:00
Jukka Rissanen 7d9f2ad2ca net: sockets: Add object core support to sockets
Use the generic object core support to track network sockets
and their statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 11:11:30 +02:00
Jukka Rissanen 5bf18e39ad net: sockets: Set writefds in case of error in select()
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>
2023-10-24 00:48:03 -07:00
Jukka Rissanen ec4973dd15 net: tcp: Set errno properly if connecting to non listening port
If we try to connect to a port which no socket is listening to,
we will get a packet with "ACK | RST" flags set. In this case
the errno should be ECONNREFUSED instead of ETIMEDOUT like we
used to return earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen b864880000 net: sockets: Add SO_ERROR socket option to SOL_SOCKET level
Return the last socket error to user.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Jukka Rissanen fd1c226cd8 net: tcp: Increment ref count in initial SYN
Increase reference count already when initial SYN is sent.
This way the tcp pointer in net_context is fully valid for
the duration of the connection.

Fixes #63952

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 00:48:03 -07:00
Robert Lubos c6fd2b2d44 net: shell: Fix unexpected timeout on loopback ping
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>
2023-10-24 09:05:20 +02:00
Robert Lubos dcf7b1905b net: core: Set LL address on loopback packet
In case packet is looped back to the stack, set LL address information
on the packet, using the LL address set on the corresponding network
interface, so that the information can be interpreted by the SOCK_DGRAM
packet socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-24 09:05:20 +02:00
Jukka Rissanen 73896eef6c net: Set Dummy net_if as default one for tests
If we run network tests under tests/net, then set the
Dummy network interface as a default one so that it will
be picked up first.

This should solve the issue if the DUT is having a real
network interfaces like onboard Ethernet interface which
could cause the test to fail. The test might fail in this
case because the network tests assume that only simulated
network interfaces are used by the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-24 09:05:04 +02:00
Jukka Rissanen 63d9c8fa06 net: shell: Print v4-mapping-to-v6 address properly
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>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 2238baa831 net: tcp: Do not overwrite remote address in new conn
When a new incoming connection is accepted, do not overwrite
the listening remote address. The remote address for the
listening socket is the any address (like :: for IPv6)
and not the accepted socket remote address.
This only affects the "net conn" shell command which prints
the remote address incorrectly. There is no problem accepting
new connections in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen e3f664dfe2 net: conn: Fix the rank value print
We should use the NET_CONN_RANK() macro when printing the
current rank value as that macro masks the rank values properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 1b4a76cc36 net: tcp: Fix the accepted socket address
The socket address passed in accept() call should point
to the new connection address and not the old one.
Fortunately this only affects things after the v4-mapping-to-v6
support so older code than this works fine.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen dea896f6e7 net: tcp: Set address len properly when accepting a socket
The address length of the accepted socket must reflect the
size of the address struct, so it should either be
sizeof(struct sockaddr_in) for IPv4 or sizeof(struct sockaddr_in6) for
IPv6 socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 4f37d63ed1 net: Add support for v4-mapping-to-v6 sockets
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>
2023-10-23 09:57:22 -05:00
Jukka Rissanen 256d5fac4f net: utils: Print IPv4 mapped IPv6 addresses properly
Add support for IPv4 mapped IPv6 addresses when converting
IP address to a string in inet_ntop() function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 09:57:22 -05:00
Robert Lubos 05361edb1b net: shell: Fix TCP connect behavior
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>
2023-10-23 16:08:37 +02:00
Yong Cong Sin 1f60c1379e net: shell: fix compilation errors
`suspend.c` and `resume.c` are missing the `zephyr/pm/device.h`
add that to fix compilation warning

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-10-23 14:20:23 +01:00
Jukka Rissanen 4b41f9f246 net: wifi: Fix compile error when -Werror -Wextra are set
The warning which became error looks like this

error: type qualifiers ignored on function return type
                                [-Werror=ignored-qualifiers]
  219 | const char * const wifi_ps_txt(enum wifi_ps ps_name);

It is pointless to add a const qualifier to a return value.
So remove the const pointer to avoid this warning.

Fixes #64197

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 11:06:23 +02:00
Jukka Rissanen 046f00244c net: shell: vlan: Enforce arg count via shell macro
Use the SHELL_CMD_ARG() to enforce the minimum parameter
count in vlan command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 4265fe7a93 net: shell: stats: Use generic iface idx dynamic completion
The interface number is generated automatically if one
presses <tab> when expecting the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 10def6cac5 net: shell: Allow dynamic interface name expansion
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>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 5bad9680a5 net: shell: Remove the stacks command
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>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 34cd82e80b net: shell: Removing extra stuff that is not needed
The remaining stuff that is not used in net_shell.c can be removed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen aab371364c net: shell: Add websocket command
Move "websocket" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen d84c2572ec net: shell: Add vlan command
Move "vlan" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 82a57b9789 net: shell: Add virtual command
Move "virtual" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 7a167648eb net: shell: Add udp command
Move "udp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 5afeade2fc net: shell: Add tcp command
Move "tcp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 7cdc235ff5 net: shell: Add suspend command
Move "suspend" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen fdb86e89a6 net: shell: Add stats command
Move "stats" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 76eab4e440 net: shell: Add stacks command
Move "stacks" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 8b4b064a85 net: shell: Add route command
Move "route" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen cb46113df4 net: shell: Add resume command
Move "resume" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen e5534b5262 net: shell: Add ppp command
Move "ppp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 58ad0a5c13 net: shell: Add pkt command
Move "pkt" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen a669d4aba3 net: shell: Add ping command
Move "ping" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 0c9fd96604 net: shell: Add nbr command
Move "nbr" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 5b6423dd2f net: shell: Add mem command
Move "mem" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen e0c30bc2b6 net: shell: Add ipv4 command
Move "ipv4" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 36db200c15 net: shell: Add ipv6 command
Move "ipv6" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 49012a5c6b net: shell: Add iface command
Move "iface" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 55eb526d0a net: shell: Add gptp command
Move "gptp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 97e0609dd9 net: shell: Add events command
Move "events" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen fea7001678 net: shell: Add dns command
Move "dns" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 5a7fd25e97 net: shell: Add conn command
Move "conn" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen e03adee6e4 net: shell: Add capture command
Move "capture" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 0e3b197f84 net: shell: Add arp command
Move "arp" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen e850517a15 net: shell: Add allocs command
Move "allocs" command to a separate file.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 3f36f78654 net: shell: Common header for all shell commands
Some useful APIs and macros for all net shell commands
to use.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 394a40470d net: shell: Rename current command as net_old
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>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 56c1bb813f net: shell: Move the shell code to subsys/net/lib/shell
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>
2023-10-23 10:40:28 +02:00
Jukka Rissanen 31081d8411 net: tcp: Change FL() macro to avoid runtime overhead
Instead of strlen() use sizeof() in FL() macro. This way
all the checks are done at compile time instead of runtime.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-20 15:15:28 +02:00
Robert Lubos 4ea3d247d0 net: tcp: Add Kconfig option to enable TCP RST on unbound ports
Add Kconfig option to control TCP RST behavior on connection attempts on
unbound ports. If enabled, TCP stack will reply with RST packet (enabled
by default).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Robert Lubos 95d9543e2e net: tcp: Send RST reply for unexpected TCP packets
Send RST as a reply for unexpected TCP packets in the following
scenarios:
1) Unexpected ACK value received during handshake (connection still open
   on the peer side),
2) Unexpected data packet on a listening port (accepted connection
   closed),
3) SYN received on a closed port.

This allows the other end to detect that the connection is no longer
valid (for example due to reboot) and release the resources.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Robert Lubos a28215d028 net: tcp: Add helper function to send RST packet w/o active connection
Add a helper function which allows to send a RST packet in response to
an unexpected TCP packet, w/o associated connection or net context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-10-20 15:13:22 +02:00
Seppo Takalo a95bafec74 net: lwm2m: Check access rights on composite operations
Composite operations need to check read/write access
rights as well.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-10-20 15:12:39 +02:00
Seppo Takalo 77ea861f12 net: lwm2m: Fix composite operations
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>
2023-10-20 15:12:39 +02:00
Seppo Takalo bd0ad5bd66 net: lwm2m: Initialize empty string sizes correctly on objects
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>
2023-10-20 15:11:32 +02:00
Seppo Takalo 015b1103fb net: lwm2m: Properly initialize buffers for resource instance
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>
2023-10-20 15:11:32 +02:00
Seppo Takalo 36d6a7257b net: lwm2m: Count null-terminator in string size
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>
2023-10-20 15:11:32 +02:00
Juha Ylinen 1aef034126 net: coap: add support for Echo option (RFC 9175)
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>
2023-10-20 15:09:44 +02:00
Juha Ylinen 1d9098f3f0 net: coap: Add support for request-tag (RFC 9175)
Add support for Request-Tag (RFC 9175) when doing block-wise
send.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
2023-10-20 15:09:44 +02:00
Ambroise Vincent 68dfd819c1 net: gptp: Create a stack size Kconfig option
The stack size was previously hardcoded in the source code, making it
difficult to change when enabling options that require a larger stack.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent 357f88bb59 net: ethernet: Don't use VLAN tag on gPTP messages
According to IEEE Std 802.1AS-2011 11.3.3, gPTP messages are not
VLAN-tagged.

Remove the use of VLAN headers for gPTP messages on the TX path.
The RX path is handled by the drivers. The network drivers in Zephyr
might need to be updated as well in order to accept receiving
non-VLAN-tagged gPTP messages when the CONFIG_NET_VLAN option is
selected.

Continue sending gPTP packets with VLAN tags when CONFIG_NET_GPTP_VLAN
is enabled. Specify that this option is for testing purposes.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent d0ac02a18d net: gptp: Invert priority of outgoing packets
The previous implementation was setting priority 3 (Critical
applications) for Sync, Pdelay and Pdelay_Resp messages; and priority 6
(Internetwork control) for the other PTP messages. This might have been
done under the incorrect understanding that "Critical applications" was
the highest priority.
This resulted in the Pdelay_Resp_Follow_Up getting sent before the
Pdelay_Resp message when enough TC_TX queues were being used
(NET_TC_TX_COUNT >= 2), which is an inversion compared to the intended
order.

Invert the priority of the outgoing PTP packets so that the PTP event
messages are sent with higher priority, as was originally intended.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Ambroise Vincent b7df39f81f net: ip: Clarify highest priority traffic class
The priority 3 (Critical applications) was incorrectly marked as
"highest priority", which might have led to incorrect use of
NET_PRIORITY_CA in some cases.

Note that this is already correctly advertized in other places, as it
was partially fixed in af8a0b1a5d.

NET_TC_SKIP_FOR_HIGH_PRIO was previously only allowing to push priority
3 (Critical applications) packets directly to the driver, but not the
ones with a higher priority. Change it so that it is now in effect for
priority 3 and above.

Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
2023-10-20 15:08:25 +02:00
Seppo Takalo 8ffb64d46f net: lwm2m: Allow configuring update period
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>
2023-10-20 14:57:38 +02:00
Jukka Rissanen 0a16d5c7c3 net: socket: mgmt: Check buf size in recvfrom()
Return EMSGSIZE if trying to copy too much data into
user supplied buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-12 10:33:36 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
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>
2023-10-10 14:23:50 +03:00
Jeroen van Dooren fe8d30dd42 net: ip: tcp: Fix kernel crash on idle thread
Fixing kernel crash caused by memory release
while having a scheduled work item pending.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-10-09 10:16:05 +02:00
Wojciech Slenska dcf6327d6a net: context: set context->local for offloaded iface
Currently context->local is not set for offloaded interface.
This change move net_offload_bind call after set of context->local.

Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
2023-10-04 20:29:33 +02:00
Juha Ylinen 22f09e9fa0 net: coap: release non-confirmable messages
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>
2023-10-04 11:25:16 +02:00
Robert Lubos 1b21109c2c net: lwm2m: Reset ongoing notification in case token changes
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>
2023-10-04 11:23:53 +02:00
Florian Grandel 630bfff65f net: lib: zperf: fix compiler warning
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>
2023-10-03 15:21:34 +01:00
Kieran Tyrrell a714b42080 net: ip: fix promiscuous mode altering packets
Always clone net_pkt to pass to promiscuous queue.
Previously, net_pkt was passed to L2 before conditionally cloning.
But L2 would in some cases strip ethernet headers, so cloned
net_pkt received through promiscuous interface would be missing headers.

Signed-off-by: Kieran Tyrrell <kieran@sienda.com>
2023-10-03 15:10:57 +01:00
Andrei Emeltchenko d68db1ecfa net: dhcpv6: Fix params check
Fix params check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-10-03 15:10:41 +01:00
Vivekananda Uppunda b0c9658029 net: l2: wifi: Fix Wi-Fi mode get command bug
The mode command operation has to be set to WIFI_MGMT_GET when the
option -g is provided. It was mistakenly set to true. Correcting the
same

This PR fixes #63424 and sets the proper value for the get command

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2023-10-03 11:30:13 +02:00
Bjarki Arge Andreasen d6a96a4b24 net: l2: ppp: Don't attempt reestablish PPP if carrier is down
This commit adds a check to prevent attempting to reestablish
the PPP session if the carrier is down. Without this check,
the PPP FSM attempts and fails to establish a PPP session
twice before giving up. The behavior is not breaking anything,
but it is not desired.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-09-30 18:47:33 +02:00
Peter Mitsis 2f003e59e4 kernel: Re-factor k_mem_slab definition
Rearranges the k_mem_slab fields so that information that describes
how much of the memory slab is used is co-located. This will allow
easier of its statistics into the object core statistics reporting
framework.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-09-30 08:04:14 +03:00
Robert Lubos 51d3341066 net: icmp: Don't unref net_pkt from the registered handler
A minor overlook from the recent ICMP rework, the registered handlers
should no longer unref the processed packet as it's now the
responsibility of the ICMP module.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-29 18:49:43 +03:00
Florian Grandel 60ad26403b net: l2: ieee802154: only log fully assembled pkts
As we already log fragmented packets there's no need to log them again
unless they have been fully assembled and the result is to be logged.

We also want to log the final packet in all cases (after mangling LL
address) for the non-fragmented case.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:31 +02:00
Florian Grandel a5d46e7d66 net: l2: ieee802154: mgmt: NET_CONTINUE unless pkt is unrefed
It is the general rule in Zephyr's network stack that methods that
return NET_OK are expected to have "consumed" the packet, i.e. it should
not be referenced any more.

This change applies this rule to the methods in ieee802154_mgmt.* for
improved consistency with the remainder of the network stack.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:31 +02:00
Florian Grandel 203391a378 net: l2: ieee802154: security config
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>
2023-09-29 16:27:31 +02:00
Florian Grandel 36402b6d2a net: pkt: time: introduce ns timestamp helper
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:

Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-29 16:27:15 +02:00
Rahul Singh 6ef75a26ea net: zperf: Add support for bind to host option for tcp/udp download
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>
2023-09-29 16:25:26 +02:00
Juha Heiskanen 647fb4dc8f net: lwm2m: RD client Deregister event indicate
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>
2023-09-29 16:53:55 +03:00
Jukka Rissanen 6661f05daf net: ppp: Mark the PPP L2 as non-experimental
The experimental status of the PPP L2 is long overdue so
it can be removed as the component is working fine.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-29 10:33:50 +02:00
Daniel Leung d47b1c05f3 kernel: userspace: add k_object_is_valid()
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>
2023-09-28 17:28:43 -04:00
Jordan Yates 2b92598df1 net: wifi: re-add WIFI_MGMT_FORCED_PASSIVE_SCAN
Re-add the `WIFI_MGMT_FORCED_PASSIVE_SCAN` option removed in #62751.
Now that `struct wifi_scan_params` is a reasonable size, we can enforce
the passive scan request even when no parameter struct is supplied by
the user.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-28 15:44:01 +02:00
Jordan Yates 3b7237e6cd net: wifi: shell: update SSID argument format
Instead of providing a comma seperated list of SSIDs, provide the SSIDs
individually. This substantially simplifies the implementation.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-28 15:44:01 +02:00
Juha Ylinen 3ffa1d5550 net: coap: Fix coap client timeout
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>
2023-09-28 15:18:12 +02:00
Florian Grandel bd038fc743 doc: ieee802154: l2: improved docs
Hides types used in the IEEE 802.15.4 L2 sub-API and L2-internal APIs
that are of no public interest and improves documentation of the
remainder.

The changes are mostly minor as the API documentation had already been
improved and clarified in previous changes. Also includes non-visible
documentation to the subsystem-internal Frame API by adding references
to the specification.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-28 15:13:12 +02:00
Georges Oates_Larsen 98a506f341 net: conn_mgr: Write documentation
Write documentation for conn_mgr and its subsystems, especially
guidelines for writing connectivity implementations

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2023-09-28 15:11:14 +02:00
Kapil Bhatt 29bbcb1e38 net: wifi: Move function from shell to mgmt
The CONFIG_NET_L2_WIFI_SHELL isn't always enabled.
But these functions might still be used, so need to
move functions into mgmt.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-09-28 12:30:29 +02:00
Anas Nashif 6d23a960db lib: os: build fdtable conditionally
Stop building fdtable by default, make it conditional and build it only
when needed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-09-28 06:25:16 -04:00
Pieter De Gendt cf8f92d73e net: lib: mdns_responder: Fallback IPv4/IPv6 address
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>
2023-09-28 10:53:53 +03:00
Jukka Rissanen fa4e978fba net: zperf: Fix the IPv6 ping done in shell
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>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 3baaa72920 net: icmp: Add offloading support
Add suitable functions that offloaded network device driver
can receive ICMP Echo-Request (ping) requests and give
ICMP responses back when it receives them from the network.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen c473626267 net: if: Add function for network interface offloading status
Add new net_if_is_offloaded(iface) that returns true if
the network interface is offloaded (either IP or socket
offloading is enabled for that interface) and false if
the interface is not offloaded.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen e3fb634e7a net: shell: Use the ICMP API for ping command
Change the ping command to use the ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 19273087f2 net: Use the ICMP API for receiving ICMP messages
Modify the internal network stack code to use the ICMP API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Jukka Rissanen 31a25da8c2 net: icmp: Introduce new API to send ICMP messages
Allow user to send ICMP Echo Request message a.k.a pings.
The same ICMP API and framework is used for network stack
internal needs in later commits. One benefit for this new
API is that it allows sending Echo Requests to offlined
network devices.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-28 09:34:20 +02:00
Robert Lubos 6fb19bc7f0 net: shell: Add DHCPv6 support
Print DHCPv6 status in net shell (with "net iface" command).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Robert Lubos 72cf06ada4 net: config: Add DHCPv6 support
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>
2023-09-28 09:31:20 +02:00
Robert Lubos afa5887b70 net: dhcpv6: Introduce net events for DHCPv6
Add net events for DHCPv6, in similar fashion as it's done for
DHCPv4.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Robert Lubos e73e78a550 net: dhcpv6: Add Zephyr DHCPv6 client
Add a DHCPv6 client implementation for Zephyr (RFC 8415).

The implementation allows to request IPv6 address and/or prefix from the
DHCPv6 server, and for now supports only the mandatory set of DHCPv6
options needed to achieve this. Currently the implementation supports
the following scenarios:
 * Requesting new IPv6 address/prefix with Solicit/Request exchange
 * Refreshing existing leases with Confirm, Renew or Rebind (depending
   on the context).

For now, no Information Request (the case where neither IPv6 address or
prefix are requested) is supported. No support for Reconfigure was added
either, as this is optional (the client manifests clearly to the server
that it does not support Reconfigure). Support for these can be added
later if needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2023-09-28 09:31:20 +02:00
Flavio Ceolin 5d505c7b28 random: Fix feature dependency usage
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>
2023-09-27 11:55:10 -05:00
Florian Grandel a12a6ab5b9 drivers: ieee802154: introduce channel pages
Replaces the previous approach to define bands via hardware capabilities
by the standard conforming concept of channel pages.

In the short term this allows us to correctly calculate the PHY specific
symbol rate and several parameters that directly depend from the symbol
rate and were previously not being correctly calculated for some of the
drivers whose channel pages could not be represented previously:
* We now support sub-nanosecond precision symbol rates for UWB. Rounding
  errors are being minimized by switching from a divide-then-multiply
  approach to a multiply-then-divide approach.
* UWB HRP: symbol rate depends on channel page specific preamble symbol
  rate which again requires the pulse repetition value to be known
* Several MAC timings are being corrected based on the now correctly
  calculated symbol rates, namely aTurnaroundTime, aUnitBackoffPeriod,
  aBaseSuperframeDuration.

In the long term, this change unlocks such highly promising functional
areas as UWB ranging and SUN-PHY channel hopping in the SubG area (plus
of course any other PHY specific feature).

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-09-27 12:44:15 -04:00
Seppo Takalo a8f9777586 net: lwm2m: Generate new tokens for LwM2M SEND blocks
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo 1606d352e1 net: lwm2m: Append CoAP Etag to protect integrity of blockwise
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo ebb90c5184 net: lwm2m: Fix composite read on SenML-CBOR
Composite read was incorrectly trying to parse CoAP packet
instead of payload of the packet.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo 69cd597887 net: lwm2m: Refactor blockwise SEND to support GET and FETCH
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo b9028bb722 net: lwm2m: Remove unneeded function pointer parameter
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo 4e97607c27 net: lwm2m: Only parse block1 option for WRITE operation
In reality, single-write is the only operation that handles
BLOCK1 operations when receiving paylod.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo f227b56792 net: lwm2m: Separate opaque content format into its own
Opaque content format is not part of clear-text, so it
should be separated into its own file.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-27 15:44:30 +02:00
Seppo Takalo 42ce4bbfd7 net: lwm2m: Allow content formats to support only some data types
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>
2023-09-27 15:44:30 +02:00
Seppo Takalo ebfbf83153 net: lwm2m: Clean up shell documentation
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>
2023-09-26 16:55:16 +02:00
Jukka Rissanen 0e5016e502 net: arp: Directly send the queued pkt
We must send the packet without queueing it. The pkt has already
been queued for sending, once by net_if and second time in the ARP
queue. We must not queue it twice in net_if so that the statistics
of the pkt are not counted twice and the packet filter callbacks
are only called once.

Fixes #62483

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-26 15:07:20 +02:00
Pieter De Gendt cb4fb765f0 net: if: Add ASSERT in net_if_ipv4/6_select_src_addr
Add an assert for the destination address provided to find the best
source address.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-09-26 12:04:03 +02:00
Jukka Rissanen 37b8dc17bc net: socket: Allow same port if different address family
It is always possible to bind to same port if the sockets
are in different address family.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-09-25 10:53:49 +02:00
Jordan Yates b54951b86e net: wifi_mgmt: linearise scan_params->chan arrays
Turn the nested arrays of `scan_params->chan` into a single array.
This adds the requirement to specify the band for each channel, but
eliminates the large amount of dead memory for unused bands. Overall,
this saves 50% of the RAM space for this variable.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 09:48:16 +02:00
Jordan Yates 6a428f19b6 net: wifi_mgmt: make number of scan channels configurable
Make the maximum number of channels that can be manually scanned
configurable by the application. The previous value of 233 was vastly
overallocating memory as the largest band only contains 60 allocated
channels.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 09:48:16 +02:00
Marcin Gasiorek c668fbc4d2 net: ip: Add cloning of missing attributes
A few attributes isn't cloned togerder with pkt.
This commit add missing part.
Additionally, because the `eof` flag in net_pkt structure is
avilable unconditionally hence `#if defined(CONFIG_NET_SOCKETS)`
guard has been removed form setter and getter functions for
this flag.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-09-21 13:36:20 +02:00
Marcin Gasiorek 6a536f9f8c net: Deprecated and unused flags cleanup.
In net_pkt structure couple of flags are no longer used.
Flag pkt_queued can be removed permanently togeter with setter
and getter functions.
Second flag sent_or_eof has been renamed because it is still
used partially only for indicating EOF. Additionally unused setter
and getter for 'sent_' part of this flag are removed.

Signed-off-by: Marcin Gasiorek <marcin.gasiorek@nordicsemi.no>
2023-09-21 13:36:20 +02:00
Seppo Takalo 0a982c3617 net: lwm2m: Add shell command to create object instances
Some testcases might need to be able to create
object instances, so add shell command for it.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2023-09-21 10:15:34 +02:00
Seppo Takalo b0303f5bd3 net: lwm2m: Don't allow operations on security object
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>
2023-09-21 09:29:16 +02:00
Seppo Takalo d8d81a8075 net: lwm2m: Fix build warning on access-control object
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>
2023-09-21 09:29:05 +02:00
Kapil Bhatt 4b9f5cc455 net: l2: wifi: Change arrays to functions
The header file contains mixture of functions and static arrays.
Replacing static arrays to functions.
Initialize functions in C file.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2023-09-21 09:28:46 +02:00
Jordan Yates 5452665beb net: l2: wifi_mgmt: remove scan kconfig defaults
Remove the wifi_mgmt interface overriding default values with values
from kconfig. The defaults were only applied when a `params` struct was
provided by the application.

This is the case when the application is explicitly setting the options
it wants, why is the mgmt API changing these. When `params` is NULL and
thus modem defaults are requested, these defaults aren't applied. This
is the opposite behaviour from what seems reasonable.

In addition, these options are:
 * Undocumented
 * Using non-trivial string parsing functions (strtok)
 * Adding complexity to the API implementation by forcing support for
   ROM versions of command line arguments.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-20 20:21:49 +01:00
Tobias Frauenschläger dcc63120cf net: sockets: add support for SO_REUSEPORT
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>
2023-09-20 08:56:31 +02:00
Tobias Frauenschläger 3d3a221b1e net: sockets: add support for SO_REUSEADDR
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>
2023-09-20 08:56:31 +02:00
Konrad Derda b3a3a8b3a2 net: ip: use default interface while matching LL src address
While matching source address for a given Link-Local destination the
functions iterate over interfaces and return a first result with a
valid LL-address. However, they should first try to fetch address of
the default interface as it not always the first one on the list.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2023-09-19 15:24:04 +01:00
Seppo Takalo da1463756e net: lwm2m: Allow Bootstrap server to close DTLS connection
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>
2023-09-19 15:23:32 +01:00
Seppo Takalo f49309cf52 net: lwm2m: Add timeouts to state machine
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>
2023-09-19 15:23:14 +01:00