Commit graph

6647 commits

Author SHA1 Message Date
Georgios Vasilakis
53b2802fff net: websocket: Allow using PSA APIs to calculate SHA1
The websocket used mbedtls functions to calculate the
SHA1 needed. Update the code to use PSA crypto calls instead
when the configuration CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT
is enabled.

This can be useful for applications which use TF-M
since it only provides PSA crypto APIs.

Also check the error code from the mbedtls_sha1
call since it can fail and it was not checked before.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2025-09-12 18:31:04 +02:00
Yangbo Lu
5aaf69e145 net: ethernet: make inclusion relation clear for DSA and Ethernet headers
DSA is part of Ethernet and will utilize more Ethernet definitions for
more features support. So, it's proper to let DSA header include
Ethernet header with moving some DSA definiton from DSA header to
Ethernet header and adding DSA header including in c files using DSA
definition.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-12 13:19:41 +02:00
Yangbo Lu
0501be8090 net: ethernet: use void pointer for dsa switch context
In ethernet_context structure, it just needs a void pointer
for dsa switch context.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-12 13:19:41 +02:00
Philipp Finke
8a831150f0 net: sockets: socket_service: Fixed issue that prevented reconfiguration
Once running, a socket service could not be reconfigured (i.e. changing
file descriptors and/or events to be polled). This was due to an wrong
check at the end of the thread main loop of socket_service_thread that
evaluated to false as variable ret is zero if trigger_work(), which is
called previously for all returned events, returns successfully.

Signed-off-by: Philipp Finke <philipp_finke@gmx.de>
2025-09-12 08:20:18 +01:00
Cristian Bulacu
cbd599fecd net: sockets: Return mapped address from sock_get_pkt_src_addr() function
When an IPv4 packet is received on a dual-stack socket, return
the mapped v4 to v6 address as source address.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-09-11 18:09:09 +01:00
Cristian Bulacu
48897a9090 net: context: Fix issues in context_sendto() function
Fixed issue when `sendmsg()` was in use and `CONFIG_NET_IPV6`
and `CONFIG_NET_IPV4_MAPPING_TO_IPV6` were in use, as `dst_addr`
argument of `context_sendto()` was passed NULL,
but also used to determine `sa_family`.
Use msghdr, if available, to determine if v4 to v6 mapping is
present.
Also set `dst_addr` to unmapped value  when v4 to v6 mapping is
used.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-09-11 18:09:09 +01:00
Cristian Bulacu
3072c53a84 net: context: Add support to set hoplimit when v4 to v6 mapping is used
If v4 to v6 mapping is used, cmsg_level and cmsg_type should
be compared with IPv6 values even if pkt family if AF_INET.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-09-11 18:09:09 +01:00
Jukka Rissanen
80953bb8e0 net: tcp: Print TCP connection info consistently
Print TCP connection pointer value for debug prints
consistently so that it is easier to find debug prints that
are related to a certain TCP connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-09-11 09:54:27 +02:00
Jeppe Odgaard
3813b3cdda net: config: sntp: improve logging
Print return code on error and remove logging in `sntp_resync_handler`
since it calls `net_init_clock_via_sntp` which already does logging.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-09-10 16:39:34 +02:00
Cla Mattia Galliard
8e6521a14d net: socket: Specify the packet socket-type, when inputting
Specify the socket type, when inputting a packet into a packet-socket.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-09-10 13:01:56 +02:00
Cla Mattia Galliard
b9968e9d1f net: core: Decide about l2-processing based on l2_processed-flag
Use the l2_processed-flag to decide whether a network packet needs to be
processed by an L2-handler. This could be used in the future to requeue
packets for later processing by a different traffic class queue.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-09-10 13:01:56 +02:00
Cla Mattia Galliard
0327bb1ae0 net: pkt: Store is_loopback info in packet meta-data
Store the flag in the packet meta-data so that processing may be deferred
if necessary.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-09-10 13:01:56 +02:00
Muhammad Waleed Badar
df6c1831de net: wifi: Add default for max managed interfaces
This default value 2 of WIFI_NM_MAX_MANAGED_INTERFACES
ensures WiFi network manager can properly handle both
access point and station interfaces.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2025-09-09 22:00:08 +02:00
Jeppe Odgaard
c6f31346d2 net: config: sntp: add resync interval range
RFC4330 section 10 states:

A client MUST NOT under any conditions use a poll interval less then 15
seconds.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2025-09-08 14:41:25 +02:00
Yangbo Lu
263911d79e net: net_if: use simple vlanX for vlan interface name
Used simple vlanX for vlan interface name. What interface the
vlan interface was attached to could be checked by "net iface"
or "net vlan".

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-04 11:34:15 +02:00
Yangbo Lu
0948812f70 net: vlan: drop current vlan interface naming
There were two problems about vlan interface naming currently.

1. When there were more than 1 vlan interfaces. It's not able to
   initialze name for all of them to same name VLAN-<free>.
2. When enabled vlan with tag, the name VLAN-xxx was used.
   However we may need to support multiple physical interfaces
   in the future. So, it's not able to use same name VLAN-xxx
   either for same tag on different physical interfaces.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-04 11:34:15 +02:00
Yangbo Lu
3fc03623ad net: shell: vlan: fix tag/attached info showing
There was call trace to execute "net vlan" if vlan interface
hadn't been enabled. Fixed it.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-09-04 11:34:15 +02:00
Benjamin Cabé
0132ea07fb doc: fix spelling errors tree-wide
fix some spelling errors in code comments and Kconfig helps

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-03 17:04:13 +02:00
Benjamin Cabé
637f1cd411 net: shell: dns: use int type for %.*s format specifier
The `%.*s` format specifier expects an int so cast the size_t parameter
to int.

Fixes an issue spotted in CI for:

    west twister -p native_sim/native/64 -s sample.net.dns_resolve.mdns

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-03 14:53:17 +03:00
Charles Hardin
633246a3ea net: dns: add query support for additional types CNAME, SRV, and TXT
These types are useful for IoT deployments and should be available
thru the resolver interface to get the data. The SRV is especially
useful to find services on the local network when not using a dns-sd
deployment and just something like Avanhi or Bonjour.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-09-02 18:42:35 +02:00
Charles Hardin
b60ae6fb1a net: dns: only add periods between labels and not on the first label
When resolving SRV records - the label might not be compressed so
the first entry into the net buf is the start of the name and a
period could end up at the start - ie. ".example.local" so only add
a period when the buffer is not empty.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-09-02 18:42:35 +02:00
Charles Hardin
ece1ed567b net: dns: adjust the enum for response type to be positive on success
The enum will auto increment, so in debug the IP and DATA records are
negative numbers which initially made this look like an error, so just
push the expected good values to be positive numbers in case of a print
or something else would imply these are ok.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-09-02 18:42:35 +02:00
Jonas Spinner
da75828459 net: gptp: fix clock accuracy description
Previously, the Kconfig option `NET_GPTP_CLOCK_ACCURACY_2_5MS` had a
incorrect description "1.5ms".

Signed-off-by: Jonas Spinner <jonas.spinner@burkert.com>
2025-08-25 17:49:39 +02:00
Robert Lubos
faa507ef6c net: Fix misc Kconfig style issues in networking area
Fix misc Kconfig style issues in networking area.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-21 20:12:48 +02:00
Charles Hardin
0fe091bc46 net: dns: fix the bounds conditions on the failures and error returns
The loop condition is not the count of the actual tries since the
continue or breaks can occur on the loop and thus a failure count
can falsely match a loop count even when a query is outstanding.

This can be seen when a dual stack resolve is used for IPv4 and IPv6
that has two fds to be used and the interface has only gotten an
IPv6 address. The failures on the IPv4 will indicate a 1 and the break
on the tried attempt on the IPv6 will break the loop on a 1.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-08-21 01:43:59 +02:00
Seppo Takalo
6cdae490e3 net: lwm2m: Suppress many LOG_ERR() that are not fatal
Suppress many LOG_ERR() messages from LwM2M registry
that are not necessary runtime errors.

Libraries and applications should be able to do following
without causing LOG_ERR to be produced:

* Checking existence of object, resource or resource instance
  using lwm2m_engine_get_res(), lwm2m_engine_get_res_inst()
  or path_to_objs(). These are only exposed in internal header.
* Delete object instance or resource instance without checking
  if it exits.

As there is no public API to check existence of some path,
application is much easier to write in a way that it directly
calls just lwm2m_get...(), lwm2m_set...(), lwm2m_delete...()
and trust the return code of -ENOENT.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-19 19:13:59 +02:00
Kapil Bhatt
f48a66121a net: zperf: Improve UDP multicast upload
UDP multicast uploads did not produce zperf-compatible server stats,
so the client waited for and tried to decode a non-existent reply,
causing “Unexpected response flags” and misleading
“LAST PACKET NOT RECEIVED!!!” output.

This change treats multicast as client-only: after sending
the negative-id FIN it does not wait for or decode server stats,
Instead transmits the FIN a few times to help receivers detect test end.
The shell prints a clear “Statistics (client only)” summary for multicast
and suppresses the error when client stats are valid.

Unicast behavior is unchanged.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-08-19 14:16:05 +02:00
Sean Kyer
a28925af31 net: ocpp: Fix cast warning
Fix warnings generated from casting pointers
of different sizes and string literals in ocpp

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-08-16 10:20:26 +02:00
Cristian Bulacu
4f644d8441 net: socket: Fix recvmsg() pktinfo support.
Fix an issue where IPV6_RECVPKTINFO was used instead of IPV6_PKTINFO
when insert_pktinfo was called.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
6c826efd5a net: context: Add support for setting hop limit from ancillary data
Add support to parse over msghdr and set pkt hop limit, if needed, when
sendmsg() is used.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
05f8edfebc net: socket: Add support for setting hop limit options
Add IP_RECVTTL or IPV6_RECVHOPLIMIT BSD socket options
that can be used to extract ttl/hop limit from ancillary data
in recvmsg() call.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
4388cb1438 net: context: Add support for setting receive hop limit option
Add support for setting IPV6_RECVHOPLIMIT or IP_RECVTTL socket option.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Adam Wojasinski
8fb7f8a19d net: lib: ptp: Fix PTP_UDP_IPv6_PROTOCOL compilation error
When the `PTP_UDP_IPv6_PROTOCOL` configuration is enabled
the `mcast_addr` variable is defined as an IPv6 structure, which
doesn't have `s_addr` member.

To not introduce preprocessor guarded code blocks in functions
added union to represent both configurations: IPv4 and IPv6.

Fixes: #92975

Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
2025-08-14 10:40:16 +03:00
Yangbo Lu
0e1b918066 net: dsa: support tag protocol setup
Supported tag protocol setup.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-08-13 22:09:50 -04:00
Yangbo Lu
28d0198ef1 net: dsa: add NXP NETC tag protocol driver
Added NXP NETC tag protocol driver.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-08-13 22:09:50 -04:00
Yangbo Lu
560249bcbc net: dsa: move DSA core options to subsystem
Moved DSA core options to subsystem.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2025-08-13 22:09:50 -04:00
Jordan Yates
19134fc53f net: lib: tls_credentials: fix unregistered log module
A logging module named `tls_credentials` was being declared, but no
other source module was creating and registering it. Do the registration
in the file to fix the compiler error.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-08-13 22:08:46 -04:00
Muzaffar Ahmed
445e993491 net: l2: wifi: Fix get RTS threshold in Wi-Fi shell
Changed the number of mandatory options of `rts threshold` to 1, so as
to allow no arguments for querying.

Signed-off-by: Muzaffar Ahmed <muzaffar.ahmed@silabs.com>
2025-08-12 12:35:22 +02:00
Andrey Dodonov
98db4d975c net: lib: http_server: prevent busfault if socket family is AF_UNSPEC
If webserver uses custom socket creation,
and it's family is AF_UNSPEC, net_sprint_addr will return NULL,
which leads to LOG_DBG crashing with busfault.
Add NULL check for that.

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2025-08-11 15:57:35 -04:00
Robert Lubos
09cbd286c5 net: connection: Use NET_CONN_*_PORT_SPEC flag when comparing ports
The NET_CONN_LOCAL/REMOTE_PORT_SPEC flags were set on the connection but
not really used. At the same time, when remote address was being
cleared, only the flag was unset, but the actual port number left
intact. This could lead to false port comparisons when remote address
was cleared from the connection context.

In order to avoid that, use the NET_CONN_*_PORT_SPEC flags to determine
whether to compare local/remote ports instead of checking the port value
right away (which may not be valid anymore if the flag is unset).

Also align with MISRA rules when comparing flags in other cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-11 13:23:42 -05:00
Robert Lubos
841035a2d6 net: connection: Fix mixed up comments
Local/remote address port comments were mixed up in the flags
documentation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-11 13:23:42 -05:00
Robert Lubos
271e0c54ed net: context: Reset peer address on connect with AF_UNSPEC
As per POSIX, for non-connection-mode sockets the peer address should be
reset if AF_UNSPEC family type is provided to the connect() call:

  "If the sa_family member of address is AF_UNSPEC, the socket's peer
   address shall be reset.""

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-11 13:23:42 -05:00
Chris Friedt
ef7c4dc3aa net: lib: ocpp: use sys_clock_gettime() instead of gettimeofday()
Use the native zephyr sys_clock_gettime() call instead of the XSI
gettimeofday(), since XSI is not required here and would normally
require CONFIG_XSI_SINGLE_PROCESS to be selected.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-08-11 13:21:11 -05:00
Chris Friedt
e197c312cc net: lib: ocpp: select Kconfig for reentrant function gmtime_r()
Select CONFIG_POSIX_C_LANG_SUPPORT_R for the reentrant version of
gmtime(), gmtime_r().

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-08-11 13:21:11 -05:00
Chaitanya Tata
9dda88fcbd net: ip: Use rate limited version
As this is the hot data path, use a rate limited warning variant.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-08-08 11:52:54 +03:00
Alberto Escolar Piedras
dece77924f net: ocpp: Fix multiple issues detected by clang
Fix multiple warnings detected by clang:
* implicit conversions back and forth from enumeration type
  'enum ocpp_notify_reason' to 'enum ocpp_pdu_msg'
  in ocpp_internal_handler()
* label followed by a declarations
* variable declared after one switch case and used in another
* mapping a int to uint and later using it in < 0 comparisons
  and with negative values

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-08-07 16:20:41 +02:00
Yusuke Omae
ddd41480a7 net: gptp: add missing stepsRemoved assignment
The stepsRemoved of portPriorityVector was
left unassigned when receiving Announce message.

Signed-off-by: Yusuke Omae <s1413091@gmail.com>
2025-08-07 13:15:28 +02:00
Yusuke Omae
877a31ab78 net: gptp: fix comparsion of stepsRemoved
The original implementation select the port
as best_port when stepsRemoved is equal to
the one of best_vector.
When challenger is from announce message
set in GPTP_PA_INFO_SUPERIOR_MASTER_PORT,
its stepsRemoved is the same as in the message.
When challenger is from master_priority
copied in GPTP_PA_INFO_UPDATE,
its stepsRemoved is [stepsRemoved of bestVector]+1.
Thus, we should add one to the challenger's
stepsRemoved in comparsion to avoid useless
update of bestVector.

Signed-off-by: Yusuke Omae <s1413091@gmail.com>
2025-08-07 13:15:28 +02:00
Saravanan Sekar
1a4f092348 net: ocpp: Add a support for Open Charge Point Protocol(OCPP v1.6) stack
Basic support for open charge point protocol v1.6 as native stack with
below functionality

1. Framework for ocpp stack and central system communication using RPC over
   websocket according to occp-j.
2. Core profile with basic PDU

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
Co-authored-by: Sanjay Vallimanalan <sanjay@linumiz.com>
2025-08-06 11:57:13 -04:00
Robert Lubos
0f66e9c680 net: context: Don't assert on address family mismatch
Providing a wrong address to the connect() call by the application is no
reason to assert, connect() should just return an error in such case.
Therefore remove the faulty assert and replace it with error log
instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-08-06 12:16:42 +03:00