Commit graph

6,767 commits

Author SHA1 Message Date
Robert Lubos
a713d8ea60 net: connection: Register connection type
Register connection type along with family and protocol, so that it's
possible to differentiate between connection listening for raw IP
datagrams and TCP/UDP/other packets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Robert Lubos
3449e224b4 net: openthread: Add missing error checks
Some OpenThread functions were called without verifying the return
value, which not only is not the best practice, but also could lead to
build warnings with llvm. This commit fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-08 16:12:17 +02:00
Robert Lubos
cf0b6068d2 net: coap_client: Fix CoAP client thread priority
The default thread priority for the CoAP client thread is set to
NUM_PREEMPT_PRIORITIES which is not a valid thread priority, as the
lowest application thread priority is actually
NUM_PREEMPT_PRIORITIES - 1. Because of this, CoAP client library gave an
assert on boot if assertions were enabled.

Kconfig does not allow for arithmetics when setting integer defaults,
therefore handle this at the preprocessor stage by limiting the actual
priority assigned to the CoAP client thread to a valid range.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-04 18:17:30 +02:00
Markus Lassila
392fda02b3 net: Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT
Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT to allow for longer
timeouts. This can be used to prevent dropping packets when
transmitting large amounts of data (with PPP).

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2025-04-04 14:57:06 +02:00
Eric Holmberg
84d3cafbce net: websocket: fix masked data when server sends close
When sending the close command as a server, the data is incorrectly
masked which violates RFC6455 section 5.1.

Use the is_client flag to avoid masking if the close is for a websocket
server.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2025-04-04 14:56:58 +02:00
Yakun Xu
eddb1af9aa openthread: map Thread network interface state
The current mapping gets the network interface into dormant state when
Thread is not attached. While the node is not capable of doing multi-hop
communication when it's not attached, it should be able to do link-local
communication. This commit changes the mapping to look at OpenThread's
own network interface state instead without further checking Thread's
device role, so that link-local communication is supported when a node
in detached state.

Signed-off-by: Yakun Xu <xyk@google.com>
2025-04-04 12:06:59 +02:00
Jukka Rissanen
43acb93607 net: shell: iface: Do not print DHCPv6 detail info if disabled
No point printing detailed DHCPv6 information if client support
is disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-02 05:30:32 +02:00
Jukka Rissanen
5e17f40178 net: shell: iface: Do not print DHCPv4 detail info if disabled
No point printing detailed DHCPv4 information if client support
is disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-02 05:30:32 +02:00
Jack Chistyakov
dd6adc7cad net: virtual: Clear multicast bit when generating link address
The least significant bit of the first octet of a MAC address is a
unicast/multicast bit. The bit should be cleared when generating a
random link address for a virtual interface. Any frames from such
interface/address will be dropped by the network as invalid if
the multicast bit is set.

Signed-off-by: Jack Chistyakov <jack.chistyakov@outlook.com>
2025-04-01 11:53:02 +02:00
Jukka Rissanen
137eba4e40 net: dns: Check compression flag properly
Allow only 0xc (0b11) as two highest bit to mark the compression
when parsing the CNAME response. See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Jukka Rissanen
5746f61d4c net: dns: Check recursive pointers for CNAME handling
Make sure that the CNAME handling checks recursive name pointers
and fails the response if recursion is detected.
See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Kapil Bhatt
6f9dbbd54f wifi: utils: Fix crash for scan
The check for index out of bound is missing, It turns into a crash
for input channel more than WIFI_MGMT_SCAN_CHAN_MAX_MANUAL.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-03-31 14:33:22 +02:00
Jukka Rissanen
8e908176c7 net: shell: iface: Print VPN public key
If the interface is a VPN interface, then print
the public key of the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
4eac955305 net: if: Add special handling for IPv4/6 address check for VPN
This is a hack that is used until we have proper IP routing
in place. The code has now special check that makes sure that
we only route IP packets to VPN interface when the packet is
destined to that subnet. So if destination IP address does
not belong to VPN interface subnet, it is not routed there.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
663867dbb0 net: if: Add helper to get src interface and address from dst address
Instead of calling various network interface API functions to get
the network interface and related source IP address, have a single
function that can return both data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
525b8e58a2 net: l2: virtual: Add support for VPN public/private key set/get
Add support for getting public address and setting private
key for the virtual interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
c073a01b39 net: shell: events: Print VPN event information
Add VPN events information printouts to event monitor.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
d95d391968 net: stats: Add VPN statistics support
Enable collection of VPN statistics and allow user to fetch it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
b7dec6c195 net: Add option for VPN enablement
Add support for setting up VPN enablers in the network stack.
These are to be used by the VPN implementation like Wireguard.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
0a8bad7e28 net: dhcpv4: Add parsing of received domain name
Currently we ignore the received domain name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
22f15de7a6 net: dhcpv4: Add parsing of received host name
Currently we ignore the received host name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
8ec4fba67c net: dhcpv4: Add parsing of broadcast address
Currently we ignore the broadcast address but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Cla Mattia Galliard
eb029b9ee1 net: http: server: Avoid compiler warnings for zero-length-arrays
Avoid compiler warnings for zero-length-arrays in the http-server. By using
memcpy instead of strcpy.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-28 16:11:27 +01:00
Triveni Danda
589333e4d9 wifi: shell: Add support for EAP-TLS method
Add support to read identity and private key password if
configured in Enterprise mode.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00
Triveni Danda
7b6f2572e5 net: lib: wifi_credentials: Use getopt API for adding network options
Use getopt API to process arguments for `cred add` command.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00
Cla Mattia Galliard
72fcca0304 net: virtual: Fix compiler warnings related to interface name
Fix compiler warning by adjusting the number of chars copied to the
destination. Compiler does not like if the destination size of the
`strncpy`-operation is the same as the number of characters written. Even
though it is not a bug in this case. Only copying size-1 characters fixes
the warning and exhibits the same behavior.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-27 21:33:40 +01:00
Fin Maaß
651d6a3b58 net: dhcpv4: remove redundant dependencys
Remove ``depends on NET_DHCPV4`` on options,
that are inside a ``if NET_DHCPV4``.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-03-27 17:18:49 +01:00
Jukka Rissanen
17a4315998 net: mdns_responder: Print return value if error in socket call
If socket call fails when mdns_responder creates listeners, then
print the return value to make it easier to figure out what is
wrong. Typically one needs to increase the size of
CONFIG_ZVFS_OPEN_MAX if errno is ENFILE.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 21:57:18 +01:00
Maximilian Deubel
916897f59e lib: tls_credentials: return size even if too big
The simple backend returns the size of the credential,
even if it is too big.
The secure backend should do the same,
our libraries depend on this behaviour.

Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
2025-03-26 16:22:28 +01:00
Jukka Rissanen
2e3f564a95 wifi: shell: Allow setting band to 0 in connect
The help text for connect says

[-b, --band] 0: any band (2:2.4GHz, 5:5GHz, 6:6GHz]

but it disallows setting band to 0. Change this and allow
band 0 option when doing normal connect. Disallow setting
the band 0 when enabling AP mode.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Jukka Rissanen
a8da7d652f wifi: shell: Map negative status code to valid status codes
The negative status code is actually the errno which we might
get returned from lower levels. For example if user sets -t
(timeout) option, the -ETIMEDOUT might be returned. In this case
map the errno value to connection timeout status value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Jukka Rissanen
92da8cb69f wifi: shell: Return text description of connection error
If "wifi connect" fails, tell user why in textual format.
This helps debugging connectivity issues.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 16:22:01 +01:00
Tom Hughes
918ae79522 net: mdns_responder: Replace pragma with TOOLCHAIN_DISABLE macro
These macros were recently introduced and replaced everywhere (#84065),
but this was missed.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-03-26 16:20:26 +01:00
Robert Lubos
8935579d0a net: mqtt: Improve disconnect error notification for MQTT 5.0
As MQTT 5.0 allows to specify the disconnect reason in the Disconnect
packet, use this new feature to improve error notification to the
broker, according to the error guidelines in the MQTT 5.0 spec.
For most cases, a generic arbitrary mapping between errno values and
reason codes is used, however the parser can specify the disconnect
reason code manually to better handle certain corner cases (like invalid
topic alias used).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
e9da3b3e0c net: mqtt: Add support for MQTT 5.0 topic aliases
Add support for handling topic aliases received from the broker.
The MQTT client implementation will store received topic for further use
in case consecutive PUBLISH received from the broker contains no topic
but alias only.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
1d743fa65a net: mqtt: Add support for MQTT 5.0 AUTH packet
Add support for a new AUTH message introduced in MQTT 5.0.
This is a new mechanism specified by MQTT 5.0, which allows clients and
brokers for enhanced authentication in between CONNECT and CONNACK
exchange. An additional MQTT event (MQTT_EVT_AUTH) was specified which
is triggered when the AUTH packet arrives from the broker.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
55e1c10894 net: mqtt: Add MQTT 5.0 support for DISCONNECT
Add support for DICONNECT message specified in MQTT 5.0.
As with MQTT 5.0, the disconnect can now also be initiated by the
broker, it was needed to add decoder support for the message.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
2459ffae41 net: mqtt: Add MQTT 5.0 support for SUBACK/UNSUBACK
Add support for SUBACK/UNSUBACK messaged specified in MQTT 5.0.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
efd795b066 net: mqtt: Add MQTT 5.0 support for SUBSCRIBE/UNSUBSCRIBE
Add support for SUBSCRIBE/UNSUBSCRIBE messages specified in MQTT 5.0.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
c21e64251b net: mqtt: Add MQTT 5.0 support for PUBLISH ACKs
Add support for PUBACK, PUBREC, PUBREL and PUBCOMP specified in MQTT
5.0. As all of these acknowledgment packets have similar format,
introduced a common encoder/decoder to handle ACK packets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
15ad90aceb net: mqtt: Add MQTT 5.0 support for PUBLISH
Add support for PUBLISH message specified in MQTT 5.0. The message
encoder and decoder were updated to support MQTT properties.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
6038676b83 net: mqtt: Add MQTT 5.0 support for CONNACK
Add support for CONNACK message specified in MQTT 5.0, along with
property decoders required to decode MQTT properties. Decoded properties
are provided to the application within mqtt_connack_param structure,
accompanying the CONNACK event.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
8fe2965500 net: mqtt: Add MQTT 5.0 support for CONNECT
Add support for CONNECT message specified in MQTT 5.0, along with
property encoders required to encode MQTT properties which is a new
concept in MQTT 5.0. Connect and will properties can be specified by the
application in the mqtt_client structure before connecting.

Introduce a helper function which allows to verify whether MQTT 5.0 is
used or not, so that it's still possible to use MQTT 3.1 even if MQTT
5.0 support is enabled in Kconfig.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
1eb9a5c241 net: mqtt: Fix helper macro for encoded binary data length
The macro did not take into account the 2-byte binary data length
encoded before the actual binary data.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Robert Lubos
f31a45f57c net: mqtt: Add Kconfig to select maximum supported MQTT version
It should be possible to select maximum supported MQTT version, so that
for example MQTT 5.0 features can be compiled-out in case they're not
needed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-26 16:19:42 +01:00
Seppo Takalo
05abdf5d0b net: lwm2m: Deprecate LWM2M_ENGINE_MESSAGE_HEADER_SIZE
Kconfig value LWM2M_ENGINE_MESSAGE_HEADER_SIZE added
an extra headroom for CoAP packet sizes so that
if CoAP Block-Wise transfer block-size is configured
to be same as LWM2M_COAP_MAX_MSG_SIZE, the full
payload block would usually fit to the datagram.

This causes too much confusion to be usable.
CoAP headers and options vary on sizes, and there is
no runtime limitations that we should check the
header size against.

Only real limitation is the CoAP packet size, which
must fit into the UDP datagram with typical DTLS headers.

Only limitation for CoAP block-size then is that
it must fit into the CoAP message with all the headers
and options. But as the option sizes, like path, vary,
it must be checked runtime.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-03-26 11:32:23 +01:00
Pieter De Gendt
044a94f06a net: lib: coap: coap_server: Use eventfd instead of socket pair
Convert the socket poll logic to use a more lightweight eventfd file
descriptor instead of a socket pair.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-03-26 08:55:45 +01:00
Jukka Rissanen
f7d37ea87c net: ipv4: Add DiffServ DSCP code point definitions
Add DSCP defines for cases where the IPv4 packets need
classification.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-25 11:00:33 +01:00
AbdElRahman Khalifa
b11703623c net: Add support for IPv4_MULTICAST_LOOP in net_context
Add support for the IP_MULTICAST_LOOP socket option to control
multicast packet loopback.

Signed-off-by: AbdElRahman Khalifa <abdelrahman.5alifa@gmail.com>
2025-03-24 09:54:05 +01:00
Jukka Rissanen
cc282e56e8 net: mdns_responder: Use memcpy instead of strncpy for iface name
Following warning is printed if using strncpy(), so use memcpy()
instead. Note that this is false positive as there is no error here but
in order to avoid the warning, change the copy function.

subsys/net/lib/dns/mdns_responder.c:1371:25: warning:
'strncpy' output may be truncated copying 7 bytes from a string
of length 8 [-Wstringop-truncation]
 1468 | strncpy(if_req.ifr_name, name, sizeof(if_req.ifr_name) - 1);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

subsys/net/lib/dns/mdns_responder.c:1468:25: warning:
'strncpy' output may be truncated copying 7 bytes from a string
of length 8 [-Wstringop-truncation]
 1468 | strncpy(if_req.ifr_name, name, sizeof(if_req.ifr_name) - 1);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 17:05:10 +01:00