Commit graph

6,767 commits

Author SHA1 Message Date
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
Robert Lubos
e8548e697a net: sockets: Reserve a default heap space for getaddrinfo
Add a default heap reservation for gettaddrinfo(), enough for a single
function call in a default configuration on 64-bit platform.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-01 17:11:58 -04:00
Charles Hardin
f06840221e net: dns: swallow packets that have no useful records in them
There are some poorly compliant mdns responders on the network
that will respond with zero counts on the answers and the additional
records (in addition to the qdcount). So, this removes the checks
in the unpack method since this is a "valid" DNS packet but the
logic is already partially handled in the dns_read code already.

An example packet can be seen in this decode

  0000   33 33 00 00 00 fb 9a f8 c3 0c 07 0b 86 dd 60 07   33............`.
  0010   c4 e4 00 14 11 ff fe 80 00 00 00 00 00 00 98 f8   ................
  0020   c3 ff fe 0c 07 0b ff 02 00 00 00 00 00 00 00 00   ................
  0030   00 00 00 00 00 fb 14 e9 14 e9 00 14 f1 64 00 00   .............d..
  0040   84 00 00 00 00 00 00 00 00 00                     ..........

  User Datagram Protocol, Src Port: 5353, Dst Port: 5353
    Source Port: 5353
    Destination Port: 5353
    Length: 20
    Checksum: 0xf164 [unverified]
    [Checksum Status: Unverified]
    [Stream index: 2]
    [Stream Packet Number: 1]
    [Timestamps]
    UDP payload (12 bytes)
  Multicast Domain Name System (response)
    Transaction ID: 0x0000
    Flags: 0x8400 Standard query response, No error
        1... .... .... .... = Response: Message is a response
        .000 0... .... .... = Opcode: Standard query (0)
        .... .1.. .... .... = Authoritative: Server is an authority
                              for domain
        .... ..0. .... .... = Truncated: Message is not truncated
        .... ...0 .... .... = Recursion desired: Don't do query recursively
        .... .... 0... .... = Recursion available: Server can't do
                              recursive queries
        .... .... .0.. .... = Z: reserved (0)
        .... .... ..0. .... = Answer authenticated: Answer/authority
                              portion was not authenticated by the server
        .... .... ...0 .... = Non-authenticated data: Unacceptable
        .... .... .... 0000 = Reply code: No error (0)
    Questions: 0
    Answer RRs: 0
    Authority RRs: 0
    Additional RRs: 0

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-10-01 08:20:34 +02:00
Michael Zimmermann
9735cb313e net: mqtt_sn: handle timestamp being 0
When running just the test mqtt_sn_client::test_mqtt_sn_wait_suback on
native_sim, the current timestamp is still 0. That caused the test to fail,
because 0 is used as an indicator, that the message has never been sent,
thus sending it every time process_work is executed.

Instead of adding additional variables and complexity, the code now simply
treats now==0 special and waits 1ms until doing anything.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Michael Zimmermann
9b3b5b4447 net: mqtt_sn: scope msg_id to client instance
- The paho client does that, too.
- This allows running single tests, because they don't rely on previous
  ones having incremented the msg_id a certain number of times.
- The variable already existed in the client struct, but wasn't used. I
  guess it was intended that way but never implemented.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Michael Zimmermann
0e2e3c2ece net: mqtt_sn: implement predefined topics
Making the assumption, that mqtt_sn_connect does not process any incoming
data allows for this to be a very simple, additional API function instead
of adding more complexity to the connect function. This also means that the
user has to re-add predefined topics upon reconnects which don't reuse the
old session though.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-29 12:45:15 -04:00
Robert Lubos
e27f8ccf91 net: context: Fix IPv4-to-IPv6 mapped sendto()
Commit 48897a9090 fixed the address
mapping for dual-stack sockets when sendmsg() was used, however the same
similar issue appears (cannot check for AF_INET family for mapped
addresses as those are AF_INET6) for regular sendto() calls.

Therefore, for the sendto() case, where dst_addr is specified, check if
the address is mapped with net_ipv6_addr_is_v4_mapped() function as
well.

This also fixes another bug in sendmsg() case, where msghdr->msg_name
could've been dereferenced even if it was NULL (for example in case
of a connected socket).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-09-29 09:58:06 +02:00
Jukka Rissanen
ed6b4a2abd net: websocket: Send CLOSE back to server when received one
When zephyr receives WS CLOSE, send it back to server and close
the TCP connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-26 09:35:24 -04:00
Jukka Rissanen
688bc4bf86 net: websocket: Fix the typo in function name
s/interal/internal/g

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-26 09:35:24 -04:00
Jukka Rissanen
c155dfa3a3 net: tcp: Print relative seq and ack numbers
It is easier to debug things when both the relative and absolute
TCP seq and ack numbers are printed in debug prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-26 09:09:38 +02:00
Jukka Rissanen
fe932ddbf0 net: context: Remember socket shutdown status
Use the socket eof flag to determine whether the receive
callback should be installed. If the receive cb is not installed,
then the socket cannot receive any data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-26 09:09:38 +02:00
Cristian Bulacu
18f1abdc30 net: l2: openthread: Fix nat64 API compile warning
This PR includes OpenThread's NAT64 header file when
NAT64_TRANSLATOR is enabled. This is done to avoid compile
warnings when OT NAT64 API is used.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-09-25 14:18:45 -04:00
Yangbo Lu
dddb4a5a9d net: ethernet: drop duplicated bridge forwarding in TX
Ethernet TX should not handle bridge forwarding. The bridge layer
had already handled forwarding.

Current code is causing duplicated TX if sending is via bridge
interface, or causing needless TX on other bridge ports if sending
is via one bridge port.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-25 12:01:31 +01:00
Yangbo Lu
401cbbb6c5 net: bridge: fix pkt management during forwarding
There were several problems of pkt management during forwarding.

1. No need to do net_pkt_ref/net_pkt_unref around net_if_queue_tx.
2. Finally when completed forwarding, there was a net_pkt_unref for
   pkt using cloning. However it also applied to pkt not using
   cloning. This was causing pkt was released before sending.
3. Whether pkt cloning used or not, should not be decided by bridge
   interfaces count. It's should be decided by interface count to
   forward.
   An example was sending pkt via bridge interface. If there were
   two interfaces attached to bridge, cloning was needed but current
   code won't.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-25 12:01:31 +01:00
Cristian Bulacu
4cec954e2b net: l2: openthread: Add DHCP6_PD, DNS upstream resolver and SRP server
- Initialize platform requirements and start OpenThread DHCP6_PD
  feature.
- Added initialization logic for DNS upstream resolver.
	OTBR message data structure has been updated to store a user data
	structure, if needed.
- Added SRP server initialization call.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-09-24 15:50:18 +01:00
Michael Zimmermann
7f55e702eb net: mqtt_sn: udp: fix joining v6 multicast group
GCC gave the following warning:

mqtt_sn_transport_udp.c: In function ‘tp_udp_init’:
mqtt_sn_transport_udp.c:117:9: warning: ‘memcpy’ forming offset [12, 105]
is out of the bounds [0, 12] of object ‘mreqn’ with type ‘struct ip_mreqn’
[-Warray-bounds=]
  117 |         memcpy(&mreqn.imr_multiaddr, &udp->bcaddr.data[2], si...
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mqtt_sn_transport_udp.c:48:25: note: ‘mreqn’ declared here
   48 |         struct ip_mreqn mreqn;
      |                         ^~~~~

And it turns out that it's right. The original code looks like it tries to
copy the IP address to imr_multiaddr in a way that works for both v4 and
v6. It ignores, that bcaddr.data may be way larger than even a v6 addr,
because it's a buffer that's big enough to hold many other structs as well.

Not only that, IP_ADD_MEMBERSHIP is for IPv4 only and imr_multiaddr can
only hold an IPv4 address anyway.

This modifies the code to have separate code paths for v4 and v6 and call
the correct APIs. This also gets rid of the memcpy, since it can be a
simple struct assignment now.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-23 17:49:56 -04:00
Michael Zimmermann
557d2aa0e0 net: mqtt_sn: allow using all of CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE
The check didn't allow the address to be exactly this size.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-23 17:49:56 -04:00
Michael Zimmermann
8ae28567d3 net: mqtt_sn: udp: fix warning: ‘port’ may be used uninitialized
This can't happen, but GCC doesn't see the relation between out and port.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-23 17:49:56 -04:00
Michael Zimmermann
38b890e5e4 net: mqtt_sn: udp: fix typo in log message
It's called Broadcast, not Brodcast.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-09-23 17:49:56 -04:00
Robert Lubos
fda82471db net: llmnr_responder: Align with dns_unpack_query() change
dns_unpack_query() no longer prepends the unpacked query with extra dot,
therefore LLMNR responder needs to be aligned with this change when
parsing result and preparing response.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-09-22 17:51:55 -04:00
Robert Lubos
9e5922952a net: mdns_responder: Align with dns_unpack_query() change
dns_unpack_query() no longer prepends the unpacked query with extra dot,
therefore mDNS responder needs to be aligned with this change when
parsing result and preparing response.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-09-22 17:51:55 -04:00