Commit graph

7,037 commits

Author SHA1 Message Date
Robert Lubos
139ebb3128 net: sockets: tls: Validate credentials when registering on a socket
So far the TLS/DTLS credentials would only be validated upon first use,
i. e. when TLS/DTLS handshake was initiated. This could lead to some
confusion, especially when trying to understand the reason of the
handshake failure, as it wasn't clear whether the handshake failed due
to peer sending bad certificate or due to local configuration issues.

This commit attempts to improve this, by pre-validating the credentials
as soon as they are configured on a socket with TLS_SEC_TAG_LIST socket
option. That way, in case bad credentials are configured on a socket, or
more commonly, mbed TLS is misconfigured to handle certain credential
type, it will be caught early during socket configuration, instead of
during the handshake.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-20 11:26:26 -04:00
Robert Lubos
98e0ddecc0 net: lib: sntp: Fix transmit timestamp
Fix the transmit timestamp value sent in SNTP queries:

 * Use sys clock as a time source instead of the uptime,
 * As NTP epoch is different from Unix epoch (starts in 1900), adjust
   the seconds value with appropriate offset,
 * Finally, adjust the fraction calculation to the nanoseconds value
   from struct timespec. Do the math in 64-bit to avoid overflows and do
   the division at the end for more accurate results.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-20 11:58:59 +02:00
Felix Kolbe
689a0277f0 net: coap: Correct parameter constness in func signature
fix(coap_link_format): Correct parameter constness in func signature

For function coap_link_format:coap_well_known_core_get_len()
the request parameter is declared to be a pointer-to-const,
but the const is missing for one of the two function definitions,
that are chosen via CONFIG_COAP_WELL_KNOWN_BLOCK_WISE.

With this fix the code also compiles when enabling
CONFIG_COAP_WELL_KNOWN_BLOCK_WISE.

Signed-off-by: Felix Kolbe <felix.kolbe@gmail.com>
2025-10-20 11:52:39 +02:00
Jeppe Odgaard
25d5c73b0a net: config: sntp: optionally set rtc
Set RTC when an SNTP response is received if enabled via Kconfig option.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-10-17 17:02:55 +03:00
Pieter De Gendt
1da7a115cc net: l2: wifi: shell: Add bgscan command
Add a shell command to configure the background scanning.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-17 11:15:37 +02:00
Pieter De Gendt
93c4dbd2e0 modules: hostap: Support bgscan
Add configuration options for background scanning (bgscan) in
wpa_supplicant.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-17 11:15:37 +02:00
Qiang Zhao
56098d60b4 drivers: dsa_nxp_imx_netc: add Qbv capability
add Qbv capability for dsa_nxp_imx_netc

Signed-off-by: Qiang Zhao <qiang.zhao@nxp.com>
2025-10-16 22:34:41 -04:00
Qiang Zhao
d4928e8419 net: shell: Add Qbv shell
Added Qbv shell subcommand to net command.
Supported enable, set_config, set_time and get_info functions.

Signed-off-by: Qiang Zhao <qiang.zhao@nxp.com>
2025-10-16 22:34:41 -04:00
Qiang Zhao
16d6c46a0f net: ethernet: add NET_QBV Kconfig
Add NET_QBV in Kconfig, Qbv is Enhancements for Scheduled Traffic (EST),
one feature of TSN. The PTP clock provides the time reference for Qbv

Signed-off-by: Qiang Zhao <qiang.zhao@nxp.com>
2025-10-16 22:34:41 -04:00
Qiang Zhao
a12c664b53 net: dsa: add set/get_config support
Supported set/get_config API.

Signed-off-by: Qiang Zhao <qiang.zhao@nxp.com>
2025-10-16 22:34:41 -04:00
Cristian Bulacu
a2b554c699 net: l2: openthread: Improve Border Router packet forwarding logic
There are some cases when OpenThread opens a sockets and doesn't choose
as default it's internal interface, this leading to usage of
platform UDP module which will then send back the packet to the
OpenThread interface. In this case, the packet should not be treated as
originated from backbone interface.

Backbone router multicast listener callback functionality is improved.
A route with a prefix length of 128 is set
and a multicast address is added for each listener registration.
OpenThread interface joins that multicast address group.

Enabled forwarding capabilities for Backbone interface.
A border router should be able to perform default packet forwarding for
destination addresses with a multicast scope greater than admin-local.
In order to achieve this, multicast routes have been added to those
addreses. [https://datatracker.ietf.org/doc/rfc7346/]

For Border Router application, `ip6_addr_cb` is not installed.
otIp6SubscribeMulticastAddress call would re-register an IPV6 multicast
address which might have been registered by an OpenThread node using
`ipmadd add` command and even if that node performed `ipmaddr del`,
the address was still present in multicast listener table. This also
led to a missing MLDv2 message with that specific multicast IPV6
address.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-16 17:10:51 +03:00
Julien Vermillard
9ee47f2856 net: lwm2m: add cache filtering
Introduce `lwm2m_set_cache_filter()` so applications can drop cached
samples before they reach the LwM2M SEND path.

Fixes #91590

Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
2025-10-16 17:10:24 +03:00
Jordan Yates
e655c0ed1a net: ip: conn_mgr_connectivity usage calls
Add interface usage notifications to the `NET_NATIVE` code paths.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-15 15:39:25 +03:00
Jordan Yates
b92a43d7c0 net: conn_mgr_connectivity: idle timeouts
Implement idle timeouts, primarily in the common connectivity library,
with individual interfaces notifying the library when the interface has
been used.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-15 15:39:25 +03:00
Jordan Yates
e3a7bb30bd net: conn_mgr_connectivity: idle timeout parameter
Add an interface idle timeout parameter to the connectivity
binding structure. This will be used to track idle timeouts for
interfaces.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-15 15:39:25 +03:00
Jordan Yates
65b616f6d8 net: conn_mgr: connectivity: replace !binding
Replace all `!binding` checks with `binding == NULL` for MISRA
compliance.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-15 15:39:25 +03:00
Michael Zimmermann
f2bed4d6af net: mqtt_sn: Add support for publishing with QOS=-1
This doesn't try to optimize memory usage for QOS=-1 publications, because
it's easier to use existing structs and allocators instead of adding new
ones with less fields.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-15 15:35:58 +03:00
Michael Zimmermann
be0adf76b5 net: mqtt_sn: add support for short topics
The publish and subscribe APIs allocate topics implicitly, but don't
support allocating predefined or short topics. Additionally, we don't want
to force using short topics in case the passed topic is 2 bytes long, in
case the user doesn't want that (e.g. because the server doesn't support
it).

So instead, we add a new API which works similar to
mqtt_sn_predefine_topic, which allows allocating a short topic before using
any of these APIs.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-15 15:35:58 +03:00
Michael Zimmermann
e82b8cb150 net: mqtt_sn: never clear predefined and short topics
- These are independent from connections since they are always valid.
- Implicitly created topics(e.g. from publish or subscribe) can't be
  deleted either, so that doesn't make things worse compared to those.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-15 15:35:58 +03:00
Charles Hardin
7158f33c2b net: dns: extend the service resolver command line for ptr, srv, addr
The address resoution from RFC6763 is generally a PTR, SRV, TXT, and
an A or AAAA. Records, so this change is mainly to start drawing a
clear functional change between the DNS query shell and the DNS
service shell that should be more of a "avahi-browse" or "dns-sd"
functional style.

So, this is not a very robust implementation since it is a chain of
queries when the goal should be to get additional records from the
message itself but those changes can be added iteratively.

Basic point of this change is to show the procedure for the "browse"

- PTR service resolution
- SRV query from the result of the PTR
- AAAA (or A) from the result of the SRV

TXT records are ignored for now but should be added into this as
additional record support is extended.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-10-15 12:05:14 +03:00
Chaitanya Tata
f6cd5c0e7e net: lib: shell: Add options t display vendor data
Along with key-value pairs, add an option to dump vendor values as a
blob, use can choose either one or both.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-10-14 07:44:51 -04:00
Robert Lubos
75ef63921d net: coap_client: Move send buffer into request context
Keep a separate buffer for each request context instead of having a
single common buffer for the entire client context. This allows to
simplify the retransmission logic, as parallel requests will no longer
overwrite the buffer for each other. That way, we can simply retransmit
the packet w/o a need to recreate it, and thus reach to the payload
pointer or callback.

This removes the requirement to keep the payload pointer, provided to
asynchronous coap_client_req() call, valid throughout the exchange
lifetime for simple cases (i.e. no block transfer used). In case of
block transfer, this is unavoidable and needs to be documented.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-14 12:50:39 +03:00
Robert Lubos
f7e9d21936 net: coap_client: Use buffers instead of pointers for path and options
Use buffers instead of pointers for path and extra options provided in
the struct coap_client_request, so that the library keeps a copy of the
path/options instead of pointers. That way, the library can still work
correctly in case of retransmissions or block transfer in case when the
original path or options were automatic variables that went out of
context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-14 12:50:39 +03:00
Pieter De Gendt
6728e78576 Revert "shell: Add user data argument to shell_set_bypass"
Revert a change that broke the stable API function shell_set_bypass.
This reverts commit 6b876dba1ba61b659b1b2d4c3ccd0ac41bd56027.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-13 18:12:42 -04:00
chao an
e83d8d957d net: dhcpv4_server: correct DHCPv4 lock scope for lease()
DHCPv4 server lease should release mutex correctly

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-10-13 11:28:11 -04:00
Triveni Danda
57a35d9cb4 net: l2: wifi: Fix override certs directory for sysbuild
Fix overriding the test certificates directory for enterprise mode
when using sysbuild. The override already works as expected without
sysbuild.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-10-13 09:38:37 -04:00
Michael Zimmermann
58016ed6b6 net: socket: tls: Fix type of pointer
mbedtls_ssl_get_peer_cid takes size_t, not socklen_t.
c546c1cad1
changed the type of socklen_t to something that is incompatible with native
offloaded sockets, which caused a compiler error.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-13 09:38:26 -04:00
Jani Hirsimäki
0f214d3d9e net: ip: ipv6_nbr: p2p link: NA without link address option
Neighbor Advertisement (NA) messages without a link-layer address option
are now accepted on point-to-point links. See RFC 7066, ch. 2.2.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2025-10-13 09:38:09 -04:00
Kiril Tzvetanov Goguev
7ea8b4478d lwm2m: Add missing offset param to write_package_cb calls for SWMGMT
Offset introduced by https://github.com/zephyrproject-rtos/zephyr/pull/72590 is missing
for write_package_cb call in SWGMGT OBJ this fixes compile issues
by adding the offset parameter

Signed-off-by: Kiril Tzvetanov Goguev <kiril.goguev@voiapp.io>
2025-10-10 12:56:04 -04:00
Cristian Bulacu
7a41ed320b net: ipv6_nbr: Handle lifetime from RDNSS message
When an IPV6 message that contains an RDNSS ICMPV6 option with a lifetime
equal to 0 is received, proceed to delete the indicated recursive DNS
servers listed in that option.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-10 12:55:46 -04:00
Cristian Bulacu
975635fc17 net: dns_resolve: Remove DNS server by specified address
This commit implements removal of a DNS server by specifing an IP
address.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-10 12:55:46 -04:00
Pieter De Gendt
4fa4329a16 shell: Add user data argument to shell_set_bypass
Allow passing some context to the shell bypass callback function by
providing a void pointer user data argument.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-10 12:53:55 -04:00
Robert Lubos
fa22fa37cb net: coap_client: Add optional payload callback for uploads
Add an optional payload callback field to the coap_client_request
structure, allowing the application to provide blocks of payload
interactively during the resource upload, instead of having to provide
entire payload in a single contigunous memory space.

If registered, the CoAP client library will call the payload callback
whenever a new PUT/POST message is being generated (note this is also
true for retransmissions) instead of using the payload pointer/length.
If the payload callback is NULL, then the library operates as usual.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-09 12:37:47 -04:00
Robert Lubos
a6560c1a7b net: coap_client: Handle block size negotiation on upload
During block uploads, the server may respond with Block 1 option with
a smaller block size than currently used (so called block size
negotiation). The CoAP client however did not read the Block 1 option
from the response, therefore ignoring the server request to lower the
block size.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-09 12:37:47 -04:00
Titouan Christophe
3c50822e1d samples: net: midi2: new sample
Add a new sample to demonstrate usage of the newly introduced
Network MIDI 2.0 host stack.

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
2025-10-08 08:42:27 +02:00
Titouan Christophe
b0fa1be5b0 net: lib: midi2: new Network MIDI 2.0 host stack
Add a new network protocol for MIDI2.0 over the network, using UDP sockets.
This allows Zephyr to host a UMP endpoint on the network, which can be
invited by UMP clients to exchange MIDI2.0 data.

Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
2025-10-08 08:42:27 +02:00
Anas Nashif
bf82f7ffac copyrights: fix copyright line
Add space before (c) to allow correct parsing by linters.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-07 22:53:45 -04:00
Pieter De Gendt
6a4b5cd3d3 net: lib: coap: Add packet pointer to client response callback data
Pass a pointer to the CoAP packet in the response data. This allows
callback function to inspect for CoAP options.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-07 11:00:50 +02:00
Pieter De Gendt
cbef8679f4 net: lib: coap: Convert client response callback arguments to struct
Make it easier to modify the response callback data by passing it as a
struct pointer rather than a long list of arguments.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-07 11:00:50 +02:00
Charles Hardin
2bfd76425a net: ip: account for the size in the inet_ntop code path
The code was writing to the dst without a verification check on
size which is not appropriate. The guard on the arguements should
be enforced and so just ensure the size is larger then the
definition of the strings from POSIX and return an error in those
cases.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-10-07 10:59:08 +02:00
Charles Hardin
a8aa8af946 net: dns: fix the inet_ntop buffer size mismatch with a sizeof
From the manpage for inet_ntop

  This function converts the network address structure src in the af
  address family into a character string.  The resulting string is
  copied to the buffer pointed to by dst, which must be a non-null
  pointer.  The caller specifies the number of bytes available in
  this buffer in the argument size.

In an unintended misconfiguration the resolve max string ended up
being 20 and tracking thru some wierd code issues determined some
stack corruption which came back to the shell command. So, just
fix the size argument to be the sizeof which then leads to the next
problem that the size is being ignored by inet_ntop.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-10-07 10:59:08 +02:00
Alberto Escolar Piedras
1264a923f3 net: mqtt_sn: udp: Adapt to new zsock_recvfrom() api.
zsock_recvfrom() takes as last argument a socklen_t pointer
( c546c1cad1 )
whose definition has changed.
So let's ensure we pass the right type of pointer to it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-06 20:00:20 +03:00
Alberto Escolar Piedras
d4094d431c net: dns: dispatcher: Fix type of pointer
zsock_recvfrom() takes as last argument a socklen_t pointer
which type was changed in
c546c1cad1
as is not anymore equivalent to size_t.
So let's ensure we pass the right type of pointer to it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-06 20:00:20 +03:00
Jukka Rissanen
c546c1cad1 net: socket: Change socklen_t to be 4 bytes long
There is an issue when zephyr is compiled with native_sim_64 where
size_t is 8 bytes. The socklen_t in specified as 4 bytes in Linux
even for 64 bit builds so we have a conflict between Linux and Zephyr.
To make things work properly, define socklen_t as uint32_t in order to
align with Linux. Four bytes is enough for socket address length anyway.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-06 09:38:01 +02:00
Pieter De Gendt
6693923734 net: wifi: mgmt: Remove extraneous newlines from logs
Some log statements appended unnecessary newlines, remove those.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-05 20:02:08 -04:00
Pieter De Gendt
ce45f4ca53 net: lib: wifi: mgmt: Fix memory leaks
When connecting to WiFi from stored credentials, the key_passwd is never
freed.
Additionally if the connect fails, the allocated data was never freed.

Convert heap allocated memory to stack allocated buffers.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-05 20:02:08 -04:00
Fabio Baltieri
37717b229f sys: util: rename Z_MIN Z_MAX Z_CLAMP to min max and clamp
Rename these three macros to an unprefixed lower-case variant. This is
normally not done for Zephyr macros (see container_of) but in this case
it seems like a good idea to adopt the lowercase names to:

1. have the same convention as the equivalent Linux macros, helping devs
   working cross project recognizing (mis)use patterns.
2. make it somewhat intuitive that the lowercase ones are meant to be
   used in functions while the uppercase ones are to be used for static
   evaluation.

Add few c++ guards to avoid colliding with std::min and std::max.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-10-03 21:14:11 -04:00
Andreas Schweigstill
78b8950fd1 net: http_server: Fix crash when cb refuses new websocket connection
Zephyr crashes when a new websocket connection is refused by the
user supplied callback function. This is caused by multiple calls
of close_client_connection(). After the first call the file handle
and the client->service pointer are invalid.

This fix checks if the file handle is valid.

Signed-off-by: Andreas Schweigstill <andreas@schweigstill.de>
2025-10-02 21:58:28 +02:00
Yangbo Lu
9304035610 net: bridge: support DSA port
DSA switch performs L2 switching on hardware on DSA user ports.
The promisc mode requirement doesn't apply to DSA user ports.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-10-02 21:57:32 +02:00
Michael Zimmermann
f07f0d288e net: mqtt_sn: Implement updating will topic and message
Since the protocol doesn't have message IDs in the responses to these
update messages, there's no reliable way to know, if an update succeeded or
not. I use that fact to simplify the implementation by:
- Not providing success/failure callbacks.
- Not handling updating the variables in the client struct while
  an update is in progess.

In addition to adding some tests, I tested this with the emqx server.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-02 09:31:53 +02:00