Commit graph

6,767 commits

Author SHA1 Message Date
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
Fabio Baltieri
6ebc196008 net: sockets: getaddrinfo: use k_ variants for memory allocation
The rest of the network (and generally Zephyr subsystem code) use the k_
prefixed variants for memory allocation, which results in data goin in
the _system_heap rather than the stdlib z_malloc_heap.

The code in getaddrinfo use the z_ ones as well apart from the actual
getaddrinfo implementation, which seems like an oversight, change it to
use k_calloc and k_free as well.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-08-06 12:15:49 +03:00
Maochen Wang
3ad0b53003 net: l2: wifi: fix the build error of hostapd enterprise
Fix the build error when hostapd enterprise is enabled, it should use
new wifi_set_enterprise_credentials API, instead of
wifi_set_enterprise_creds.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-08-05 13:24:02 -04:00
Tim Pambor
be37d72a40 net: tcp: Avoid casting unaligned address to struct in_addr
This change addresses an alignment problem reported by UBSAN by
using a copy of the address. This avoids the need for extensive
rework to support *_raw variants in the routing layer.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-08-05 13:23:21 -04:00
Seppo Takalo
05dfc7145f net: lwm2m: Fix string truncation on some content formatters
LwM2M engine does not allow strings to be truncated as it would
lead to invalind UTF-8 strings.

However, some content formatters were truncating, so I fixed at least
these
* plain text
* TLV
* SenML CBOR
* SenML JSON
* JSON
* CBOR

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-05 13:20:57 -04:00
Chaitanya Tata
59ff12656f net: l2: wifi: Fix the default keepalive value
30s is too aggressive for most APs, and hostapd also uses 5mins as the
default value.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-08-04 19:55:27 +01:00
Malte Werschy
6ceb672194 net: sockets: ensure socket obj core is only linked once
Repeated linking of socket object cores can corrupt the linked list.

Fixes: #93587

Signed-off-by: Malte Werschy <werschy.m@gmail.com>
2025-08-04 11:55:34 +01:00
WenBin Zhang
b54f4386bd net: shell: Move to a separate Kconfig file
Move it to a separate Kconfig file and move it under the net/lib/shell.
When using menuconfig, it helps to reduce the confusion of network
configuration options.

Signed-off-by: WenBin Zhang <freey7955@gmail.com>
2025-08-01 07:46:11 -04:00
Seppo Takalo
d0cba34c7f net: lwm2m: Prevent QUEUE_RX_OFF while waiting for CoAP Ack
The LwM2M RD client state machine have no knowledge of ongoing
observations or any other CoAP traffic and might trigger
QUEUE_RX_OFF state while engine is still waiting for Ack.

This can happen if CoAP Ack timeout is longer than
CONFIG_LWM2M_QUEUE_MODE_UPTIME and response is lost or taking
longer than QUEUE_MODE_UPTIME.

When observation is lost, CoAP Ack may be send, but socket is not
listening anymore if its closed or not polled while in RX_OFF and this
stops observation.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-01 07:39:16 -04:00
Jukka Rissanen
6797fa642d net: sockets: Allow test to override DNS timeout
The minimum 1 sec timeout for getaddrinfo() call is too long
when executing queries from network tests. So allow test to override
the minimum and set it to very low value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-31 17:10:45 -04:00
Jukka Rissanen
80e458ce7b net: dns: Resolve localhost name
Allow user to query localhost name and get a localhost address
127.0.0.1 or ::1 back. This is only enabled if loopback driver
is used as the use case does not make much sense otherwise.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-31 17:10:45 -04:00
Jukka Rissanen
cb163d1f28 net: dns: Resolve local hostname
Make sure that if user has enabled hostname support, we are
able to query it and get a local IP address back.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-31 17:10:45 -04:00
Hui Bai
1198d78898 hostap: Update 11k roaming mechanism
With this changes, device will check if AP support Neighbor Report or
not before trigger roaming. No need to issue 11k command to enable 11k,
if AP supports Neighbor Report, device will trigger 11k roaming with
priority.

Signed-off-by: Hui Bai <hui.bai@nxp.com>
2025-07-31 10:53:19 +01:00
Flavio Ceolin
39cf9bd0c0 net: ip: Use proper flexible array
0 length array is a GNU extension. Use proper C99 flexible
array.

Signed-off-by: Flavio Ceolin <flavio.ceolin@gmail.com>
2025-07-31 10:52:49 +01:00
Andrey Dodonov
286362087d net: http: service: extend HTTP service with config
Update the HTTP service API to allow setting per-service configuration,
currently it is only custom socket creation callback,
but in the future it can be extended with other parameter

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2025-07-30 17:32:43 -04:00
Yusuke Omae
bd432c2727 net: gptp: add missing stepsRemoved assignment
The stepsRemoved of masterPriorityVector was
left unassigned when the best_port is not itself.

Signed-off-by: Yusuke Omae <s1413091@gmail.com>
2025-07-29 11:20:32 +01:00
Robert Lubos
279de669b5 net: lwm2m: Stop the LwM2M engine in case of fatal network error
In case of fatal network error (i.e. when the LwM2M client runs out of
retries), call lwm2m_engine_stop() to cleanup any allocated resources
for the client. The engine is dead at that point anyway so the
application needs to recover.

If this isn't done, it is theoretically possible to restart the LwM2M
client (with lwm2m_rd_client_start() which does not report an error in
such case), which in turn could lead to resource leaks (like for
example the observer list is reinitialized) if the application
didn't call lwm2m_rd_client_stop() first. Calling lwm2m_engine_stop()
ensures that all resources are freed even if the application doesn't
call stop before restarting.

Stopping the engine is also needed when the network error occurs when
de-registering - in such case the engine goes straight into the IDLE
state, where it's possible to restart the client and thus reinitialize
the observer lists.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-29 11:18:36 +01:00
Jukka Rissanen
ec4d6786fd tests: net: ipv6: Test packet queing when sending NS
Add tests to make sure that if neighbor cache does not contain
info for neighbor link layer address, we can queue packets
and re-send them when the neighbor cache contains the data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-28 08:53:19 -04:00
Jukka Rissanen
31329e6acb net: ipv6: Allow NS timeout to be configured
Allow user to configure how long to wait for neighbor
advertisement.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-28 08:53:19 -04:00
Jukka Rissanen
255253b108 net: ipv6: Add packet queueing while waiting NA
If we do not know the neighbor link address, we need to send
neighbor solicitation message to net. While waiting neighbor
advertisement, there might be other packets that we want to
send to that neighbor. Queue those packets so that all of them
can be sent when NA message is received.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-28 08:53:19 -04:00
Gang Li
84d4592373 net: l2: wifi: add wifi config command
- Added "wifi config" command.
- Add OKC parameter to "wifi config" command.
  Set okc to 1 to enable opportunistic key caching.

Signed-off-by: Gang Li <gang.li_1@nxp.com>
2025-07-28 08:46:37 -04:00
Robert Lubos
d93c5d6072 net: tcp: Fix handling of keep-alive probes
Keep-alive probes have seq number set to SND.NXT - 1 and may or may not
contain an octet of data. The latter case was not handled properly
therefore add a special case when validating seq number to response to
keep-alive probes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-28 08:44:41 -04:00
Fengming Ye
6e079f3ed6 net: wifi: fix 11k cannot be set before connection
Support the case that 11k parameter can be set before wifi connection.
This field should not be cleared by connection.
Neighbor report will be cleared before start_roaming.
So wifi_connect don't need to clear 11k params.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2025-07-28 08:39:39 -04:00
Ajay Parida
c70b3504bb net: l2: wifi: Configure BSS max idle period
Support to configure BSS max idle period at runtime.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2025-07-25 17:03:38 +01:00
Triveni Danda
3f037430b6 net: l2: wifi: Refactor certificates processing code into common file
Refactor certificate processing code to eliminate duplication and
enable reuse across modules that require enterprise support.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-07-25 17:03:38 +01:00
Kapil Bhatt
fbd34dac0f wifi: Fix fractional part of Tx rate by converting to float
The Tx rate was previously stored as an integer, which caused loss of
precision for rates like 8.6 Mbps or 34.4 Mbps due to integer division.
The change will update data type to float.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-07-25 17:03:38 +01:00
Lorenz Clijnen
be38568577 net: openthread: Fix build with CONFIG_OPENTHREAD_INTERFACE_EARLY_UP
When building with CONFIG_OPENTHREAD_INTERFACE_EARLY_UP enabled,
`is_up` is undefined (since 596844a).

Signed-off-by: Lorenz Clijnen <github@lorc.be>
Signed-off-by: Lorenz Clijnen <l.clijnen@edna.eu>
2025-07-24 17:01:59 +01:00
Robert Lubos
1e77663c87 net: lwm2m: Optimize value attributes verification
As lwm2m_notify_observer_path() now reads attributes for the updated
resource, value_conditions_satisfied() does not need to read the
attributes again, it can just reuse the already available data.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 17:01:07 +01:00
Robert Lubos
b633f3a9de net: lwm2m: Verify pmin for updated resource on notify check
When updating a resource, the LwM2M library verified pmin attribute on
all resources/objects in the observer path list and chose the smallest
value. While this make sense for determining the lower-boundary for the
next notification time, it could lead to unnecessary notifications being
generated too early if the updated resource had a higher pmin value
configured on it.

Therefore, when checking notification criteria for an updated resource,
check the pmin value for that resource path and if set and higher than
the lowest pmin value evaluated for the observer list, use it instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 17:01:07 +01:00
Robert Lubos
6bfeb4fe45 net: lwm2m: senml_cbor: Verify data len before calling memcpy
Check if there actually is data to copy before calling memcpy() to
prevent potentially calling memcpy() with NULL value pointer.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 16:58:05 +01:00
Robert Lubos
779d8521a8 net: lwm2m: oma_tlv: Fix UBSAN warnings about signed integers
* Simplify the logic of the get_number() function to address the corner
  cases reported by UBSAN regarding byte-swapping signed integer values.

  The existing logic was actually only valid for little-endian systems,
  as it expected that the bytes written from the packet buffer will be
  stored at the beginning of the int64_t memory, plus the actual
  byte-swapping with signed integer casts inside was hard to follow.
  Switch to a plain uint8_t buffer for integer readout, and use
  dedicated system function to convert the big-endian data in the buffer
  into unsigned integer in the system endianness, followed by the final
  cast to a signed value.

* Add explicit cast to uint32_t in put_objlnk() to prevent warning about
  not-fitting integer after byte shift, and update the result type to
  uint32_t as well.

* Switch to buffer with sys_put_be16/32/64 when writing integers due to
  similar warnings about byte-swapping signed values.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-24 16:58:05 +01:00