8603 Commits

Author SHA1 Message Date
b25d1af5f5 [posix] enhance otPlatAlarm implementation (#11424)
This commit enhances the posix `otPlatAlarm` implementation by:

- Avoiding casting from unsigned int to signed int. While this usually
  works, it's technically undefined behavior.
- Adding new `IsExpired()` and `CalculateDuration()` methods to avoid
  unsigned to signed casting and simplify the code.
- Ensuring `static_cast<>` is used instead of C-style casts.
2025-04-18 11:44:31 -07:00
3efe1c2c41 [mesh-forwarder] update and simplify Counters tracking (#11419) 2025-04-17 11:39:03 -06:00
2918437bb8 [build] enable -Wundef for MTD, FTD, and Radio builds (#11418)
This commit adds the `-Wundef` compiler flag to the OpenThread core,
CLI, and NCP builds when configured for MTD, FTD, or Radio types.

This flag helps ensure that no undefined macros are used within the
source code, protecting against potential typos in conditional
compilation checks (`#if` checks).
2025-04-17 11:36:18 -06:00
e1407fbab6 [border-agent] fix meshcop service omr entry (#11415) 2025-04-17 09:11:37 -06:00
b4282a82f2 [mbedtls] call mbedtls_ssl_set_hostname on setup (#11416)
Due to CVE-2025-27809, on newer versions of mbedtls, handshake
will fail unless hostname is set earlier.

TLS clients are not affected if they operate in a closed ecosystem
where the trusted certificate authority only issues certificates
to trusted hosts.

In this case, `mbedtls_ssl_set_hostname` with nullptr should
be called to avoid failures.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-04-16 08:40:55 -06:00
ad2c33c16c [dns] add a common helper UpdateRecordLengthInMessage() (#11409)
This commit adds `ResourceRecord::UpdateRecordLengthInMessage()`
helper method in `dns_types.hpp`.

This common helper is then used in the SRP client, DNSSD server, and
mDNS modules, replacing similar methods previously implemented within
these modules.
2025-04-16 08:26:37 -06:00
247b353e16 [mdns] alternate platform API for signaling local address changes (#11394)
This commit introduces an alternate mechanism for the platform layer
to signal local host address changes to the OpenThread mDNS module.

The existing approach, where the platform invokes
`otPlatMdnsHandleHostAddressEvent()` for each added or removed
address, remains supported.

The new approach allows the platform to call the newly added
`otPlatMdnsHandleHostAddressRemoveAll()` callback once, immediately
followed by invoking `otPlatMdnsHandleHostAddressEvent` for every
currently assigned IPv4 and IPv6 address on the interface.

These two approaches offer flexibility for platforms with varying
capabilities accommodating different operating systems and network
stacks. Some network stacks may provide mechanisms to identify the
added or removed addresses, while others may only provide the new
list upon a change.

The `test_mdns` unit test is updated to validate this newly added
mechanism.
2025-04-16 08:17:45 -06:00
d9d5b2e2c6 [tcat] implement get diagnostic tlvs in command class commissioning (#11163)
Adds implementation of Tcat TLV 0x26 Get Diagnostic TLVs.
It also adds support for long BleSecure messages >1280 bytes in BleSecure::Flush(void).
2025-04-14 09:22:58 -06:00
b868374d78 github-actions: bump actions/setup-python from 5.4.0 to 5.5.0 (#11410)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](42375524e2...8d9ed9ac5c)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-14 09:19:02 -06:00
98b88dc8f7 [dns-client] add support for arbitrary DNS record type query (#11359)
This commit introduces a new feature in `Dns::Client` to support
sending DNS queries for arbitrary record types. Callers are notified
of received response via a callback. New methods are provided to
parse and read all records in the response. Public APIs and related
CLI commands for this new feature are also added.

The `OPENTHREAD_CONFIG_DNS_CLIENT_ARBITRARY_RECORD_QUERY_ENABLE` build
configuration is added to control this feature. This allows projects
that do not require arbitrary DNS query functionality to disable it,
avoiding its associated firmware code size overhead.

Importantly, if a retrieved record type is PTR, CNAME, DNAME, NS, or
SRV, the record data in the received response contains a DNS name
which may use DNS name compression. For these specific record types,
the record data is first decompressed such that it contains the
uncompressed DNS name. For all other record types, the record data is
read and provided as it appears in the received response message.
2025-04-11 16:53:32 -07:00
1382f5f33e [message-queue] simplify retrieval of message queue information (#11405)
This commit simplifies how information about the message queue, such
as the number of messages, data buffers, or total bytes in the queue,
is retrieved. The `MessageQueue::GetInfo()` method is changed to
clear the passed-in `Info` structure (instead of adding the counts to
the existing fields and expecting the caller to clear it).

A new helper method, `MessageQueue::AddQueueInfos()`, is added to
aggregate queue information when needed.

Various modules, such as `MeshForwarder`, `Ip6`, and `Mle`, are
updated to provide methods to retrieve their queue information
instead of exposing a reference to their internal queues.

In particular, `Coap` is updated to provide combined information for
all its queues, including request and cached response queues. This
simplifies the `Instance::GetBufferInfo()` method, which retrieves
information about all queues across all components.
2025-04-09 13:23:10 -07:00
9e8316dac0 github-actions: bump step-security/harden-runner from 2.11.0 to 2.11.1 (#11403)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.11.0 to 2.11.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](4d991eb9b9...c6295a65d1)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.11.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-08 07:04:14 -07:00
c9c19aa9fa [mesh-forwarder] improve reachability check method names (#11395)
This commit renames methods related to reachability checks and the
sending of ICMP unreachable errors for better clarity and
consistency. The primary method for determining reachability is
renamed to `IsReachable()`. Methods that perform a reachability check
and, upon failure, send an ICMP unreachable error are renamed as
`CheckReachabilityToSendIcmpError()`, clearly indicating their
additional action of sending an ICMP error.
2025-04-07 21:55:54 -07:00
202fd30046 [ip6] simplify DetermineAction() (#11392)
This commit simplifies the `Ip6::DetermineAction()` method, which
determines the appropriate actions (`forwardThread`, `forwardHost`,
`receive`) for an IPv6 message based on its destination address and
origin.

- The code now uses `ExitNow()` to exit the method as soon as a
  specific action is determined. This avoids deeply nested `if/else`
  blocks and makes the control flow easier to understand.
- Some negative conditional checks have been refactored into positive
  checks with early exits. For example, a condition like `if
  (!cond1 || !cond2)` that guarded further processing is now
  expressed as `if (cond1 && cond2) { ExitNow(); }`, making the logic
  more direct.
- New comments have been added to clarify more complex checks and
  conditions within the method.
- The `RouteLookup()` method has been removed and its logic inlined
  directly into `DetermineAction()`. This improves code readability
  and allows for clearer distinction between forwarding to a host due
  to Border Router functionality versus forwarding as a last resort
  when no specific route exists.
2025-04-03 15:47:13 -07:00
c5f77ae2d6 [ip6] refactor HandleDatagram() to use DetermineAction() (#11392)
This commit introduces the `DetermineAction()` method to refactor the
code within `HandleDatagram()`. This new method centralizes the logic
for determining the appropriate action (e.g., `forwardThread`,
`forwardHost`, `receive`) for an IPv6 message based on its
destination address and origin.

This commit only focuses on code refactoring and does not introduce
any changes to the existing message processing logic.
2025-04-03 15:47:13 -07:00
13168c3a91 [mesh-forwarder] rename UpdateEidRlocCacheAndStaleChild() (#11393)
This method inspects a received message to perform two key actions:
- Updating the EID-to-RLOC cache (for snoop optimization) and
- Detecting whether a former child device has moved to a new parent.

The renaming clarifies the specific responsibilities of this method.
2025-04-03 08:33:16 -07:00
e4339c5939 [mesh-forwarder] simplify destination MAC address determination (#11391)
This commit simplifies the process of determining the destination MAC
address. Specifically, when the destination is a link-local unicast
address, the MAC address is derived directly from its Interface
Identifier (IID). This commit replaces and removes the
`GetMacDestinationAddress()` method, with the calling code now
directly determining the destination MAC address.
2025-04-03 08:32:10 -07:00
37b417a3ee [test] update OTBR Dockerfile path (#11390) 2025-04-02 10:14:33 -07:00
d2fcf539da [net-diag] implement non-preferred channels mask TLV support (#11367)
This commit adds support for the "non-preferred channels" TLV in
Network Diagnostics. New APIs and their related CLI commands are
added to allow users to get/set this value, which is then used to
respond to Diagnostic Get/Query messages requesting this TLV. This
commit also introduces a mechanism to monitor and notify the caller
when a Network Diagnostic Reset command is received for this TLV.

The `test-020-net-diag` test is updated to validate the new TLV and
its API.
2025-04-01 22:06:48 -07:00
7cfae1e05e [coap] update Instance::Get<Type>() to support application CoAP components (#11387)
This commit updates the template method `Instance::Get<Type>()` to
support retrieving the `ApplicationCoap` and `ApplicationCoapSecure`
sub-components within the `Instance` hierarchy. This change replaces
the previous direct methods used to access these CoAP components,
providing a more consistent approach to accessing sub-components.
2025-04-01 15:08:33 -07:00
999e7d0ecb [uptime] add GetUptimeInSeconds() method for simplified uptime retrieval (#11382)
This commit introduces a new method, `Uptime::GetUptimeInSeconds
()`, which returns the device's uptime in seconds. This new method
simplifies existing code that performed manual conversion of the
uptime from milliseconds to seconds.
2025-04-01 13:37:35 -07:00
ab6e241d90 [core] check exclusive selection of FTD, MTD, or RADIO configs (#11376)
This commit adds a check in `instance.cpp` to ensure that exactly one
of the `OPENTHREAD_CONFIG_FTD`, `OPENTHREAD_CONFIG_MTD`, or
`OPENTHREAD_CONFIG_RADIO` configuration options is enabled. This
enforces a clear definition of the build type and prevents potential
conflicts or unexpected behavior arising from ambiguous or incorrect
configurations.
2025-04-01 13:11:20 -07:00
42fbcbde2c [routing-manager] add manual OMR prefix configuration on BR (#11365)
This commit introduces a new mechanism in `RoutingManager` to
configure OMR prefix handling on a Border Router. This provides
manual administration options to explicitly set a custom OMR prefix
or disable it, in addition to the existing default behavior where the
BR automatically selects and manages the OMR prefix. These new
administrative configurations can also be used during testing,
particularly for certification tests.

This commit adds new public OpenThread APIs and a CLI command,
`br omrconfig`, for this functionality. Notably, the new APIs allow
updating the OMR configuration while the BR is enabled and running,
and the implementation correctly adjusts to the new requested
behavior.

A new detailed test case is added to the `test_routing_manager` unit
test, covering the new behavior.
2025-04-01 13:10:29 -07:00
f8c8f8fb1c [mac] add helpers to set MAC extended address from an IPv6 IID (#11385)
This commit add new helper methods `Mac::ExtAddress::SetFromIid()`
and `Mac::Address::SetExtendedFromIid()` which set the Extended
MAC Address from a given IPv6 Interface Identifier (IID). These
methods replace similar ones on `Ip6::InterfaceIdentifier` class
(`ConvertToExtAddress()` and `ConvertToMacAddress()`) to improve code
readability. It is more intuitive to call a `Set` method on the
object being modified rather than passing it as input to a `Convert`
method.
2025-04-01 13:10:04 -07:00
caa1222e2a [github-actions] add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to mbedtls-2 build (#11383) 2025-04-01 09:37:32 -07:00
ea55db3db8 [github-actions] add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to ot-commissioner build (#11384)
Resolves:

  CMake Error at third_party/googletest/repo/CMakeLists.txt:4 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
2025-04-01 09:37:15 -07:00
8c30b93fee [cli] add srp server port command to retrieve SRP server port (#11373)
This commit adds the `srp server port` CLI command, which maps to the
`otSrpServerGetPort()` API. This new command is now used in
`thread-cert/node.py` to implement `get_srp_server_port()`, allowing
direct retrieval of the SRP server port instead of indirectly parsing
the network data entry.
2025-03-31 14:07:37 -07:00
793dd9896d [mdns] support registering local host and its IPv6/IPv4 addresses (#11353)
This commit enhances the native OpenThread mDNS implementation to
streamline the registration of the local host and its IPv6/IPv4
addresses.

Previously, registering the local host required tracking host
addresses and using `otMdnsRegisterHost()`, similar to registering
any other host. This commit introduces a simpler alternative that
handles both IPv6 and IPv4 addresses.

The changes in this PR include:

- The local host name can be explicitly set by the caller using new
  API `otMdnsSetLocalHostName`. However, if not provided, the mDNS
  module automatically generates a name derived from the device's
  Extended MAC address.
- A new platform API callback, `otPlatMdnsHandleHostAddressEvent`, is
  introduced to notify the OpenThread mDNS module of host address
  changes.
- The OpenThread mDNS maintains an internal list of host addresses,
  automatically updating it based on platform callbacks. A short
  guard time is used to group multiple changes before announcing
  them. Transient changes (e.g., address removal and re-addition) are
  handled to prevent unnecessary announcements.
- Host IPv4 addresses (A records) are now supported. The `HostEntry`
  class is updated to optionally include IPv4 addresses, in addition
  to the required IPv6 addresses.
- A detailed test case in `test_mdns` covers all new local
  host-related behaviors.
2025-03-31 14:05:48 -07:00
921a7c542b github-actions: bump docker/login-action from 3.3.0 to 3.4.0 (#11379)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](9780b0c442...74a5d14239)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-31 09:08:17 -07:00
6c661ee55a [srp-config] update SRP_CLIENT_BUFFERS_MAX_SERVICES for ref device (#11372)
This commit increases the default `SRP_CLIENT_BUFFERS_MAX_SERVICES`
to 8 under `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`
2025-03-28 13:52:09 -07:00
f600294c43 [mac] replace more !OPENTHREAD_RADIO with direct FTD/MTD check (#11375)
This is a follow up to #11190 where more indirect `!OPENTHREAD_RADIO`
checks are replaced with direct MTD and FTD checks.
2025-03-28 10:31:21 -07:00
4f11483aa6 [cli] simplify simple commands using Process{Get/Set}() helpers (#11374) 2025-03-27 22:45:30 -07:00
8a14243dc8 [netdiag] add support for Enhanced Route TLV (#11211)
This commit adds support for the Network Diagnostics Enhanced Route
TLV (TLV number 37). This TLV provides information about established
links between routers, including the next hop and associated cost for
routes to all routers. This commit also adds CLI support and test
coverage for the new TLV.
2025-03-27 22:44:35 -07:00
36c9d14a34 [radio] clarify otExtAddress byte order and otPlatGetRssi behavior (#11366)
This commit enhances the documentation of certain `otPlatRadio` APIs
for improved clarity.

Most importantly, regarding the `otExtAddress` input parameters,
earlier APIs such as `otPlatRadioSetExtendedAddress()`, `otPlatRadio
{Add/Clear}SrcMatchExtEntry()` assume little-endian byte order. This
is already noted in their documentation. However, some more recent
APIs, namely `otPlatRadioConfigureEnhAckProbing()` and
`otPlatRadioEnableCsl()` do not explicitly specify the byte order.
Common radio platform implementations (and how the APIs are used)
assume big-endian byte order. While this discrepancy is unfortunate,
changing it would create backward compatibility with existing
platform implementations. This commit updates the documentation of
these APIs to mention the byte order and highlight their difference
from other APIs.

This commit also clarifies `otPlatGetRssi()` expected behavior.
2025-03-27 15:49:46 -07:00
ce7fad1c01 [test] fix get_srp_server_port() to handle the version field (#11368)
This commit fixes `get_srp_server_port()` in `thread-cert/node.py`.
This function parses Network Data service entries, searching for an
SRP/DNS unicast (non-preferred) entry, and then attempts to parse the
published port number of the SRP server by examining the last  bytes
of the "server data".

The SRP/DNS unicast entry was previously updated to optionally include
a "version" field at the end of the "server data". This update caused
the port number parsing to fail, as the code did not account for the
extra byte corresponding to the version field.

This commit resolves this issue by ensuring that the two bytes are
correctly read and interpreted as the port number, regardless of the
presence of the version field.
2025-03-27 13:32:14 -07:00
8d41a1d124 [sub-mac] WED performs periodic sampling by calling Sleep() and Receive() (#11318)
The WED listener only supports calling the `Radio::ReceiveAt()` for
periodic sampling.

This commit adds support for the WED to perform periodic sampling by calling
`Radio::Sleep()` and `Radio::Receive()`.
2025-03-27 09:10:37 -07:00
9398342b49 [netdata] add stable flag to otLowpanContextInfo and CLI output (#11334)
This commit updates `otLowpanContextInfo` to include the `mStable`
flag, indicating whether the 6LoWPAN Context TLV is marked as stable
or not. The `netdata show` CLI command is also updated to display the
stable flag when outputting the list of contexts. Additionally, this
commit updates the `test-019-netdata-context-id` test to adjust how
it checks and validates the "compress" flag.
2025-03-26 10:13:23 -07:00
079852b67e [uptime] enforce UPTIME feature for MTD and FTD builds (#11354)
This commit makes `OPENTHREAD_CONFIG_UPTIME_ENABLE` mandatory for FTD
and MTD builds. This requirement is now explicitly enforced in the
`uptime.hpp` header file. Consequently, this configuration is only
applicable for RADIO/RCP builds.

This commit also removes unnecessary `#if` checks for this
configuration within core modules used in MTD or FTD builds. The
OpenThread API and CLI command documentation are updated
accordingly.
2025-03-25 13:03:43 -07:00
ebccac6fbd [mdns] enhance RecordQuerier to support ANY record type queries (#11364)
This commit enhances `RecordQuerier` to support queries for the ANY
record type. When querying for ANY, the response may contain various
record types. The implementation ensures that these different types
are cached separately and correctly handles responses containing
multiple record types (with or without "cache-flush" flag).

The `test_mdns` unit test is updated to validate this new behavior in
detail.
2025-03-25 11:12:45 -07:00
e06a3ecdda [ncp] add spinel properties for CLI (#11344)
This commit introduces new Spinel properties to support CLI service in
NCP.

* Added `SPINEL_PROP_STREAM_CLI` property: This streaming property
  provides a bidirectional channel for interacting with the NCP's
  command-line interface (CLI). The host can send CLI commands to the
  NCP by setting this property. The NCP will then execute the
  commands. The NCP will send the output of the executed command (if
  any) back to the host via unsolicited notifications of this same
  property.
2025-03-25 10:33:43 -07:00
ff68d50469 [mesh-forwarder] do not CSL IE for non-neighbors (#11361)
This commit changes the mesh forwarder to avoid adding CSL IE when the
message is not destined to a known neighbor. This change also eliminates
the check to exclude the MLE Discovery Request for adding CSL IE.
2025-03-25 10:30:14 -07:00
7a258287f1 [instance] add otInstanceGetIndex() (#11197) 2025-03-24 10:04:38 -07:00
036256729c [spinel] add coprocessor reset failure callback (#11284)
Add a coprocessor reset failure callback to handle the coprocessor
reset failure instead of letting the program crash directly.
2025-03-24 08:49:27 -07:00
52ebf6f821 [cp-caps] replace nrfjprog with nrfutil in docs (#11356)
Nrfjprog is not longer recommended and was replaced
by the nrfutil. Replaced documentation occurrences mentioning
nrfjprog with nrfutil.
2025-03-24 08:47:21 -07:00
2271a2e41e github-actions: bump docker/setup-buildx-action from 3.9.0 to 3.10.0 (#11363)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](f7ce87c1d6...b5ca514318)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-24 08:31:05 -07:00
8c23a588ca [script] install gtest and gmock (#11358) 2025-03-24 08:29:53 -07:00
a41490ea40 [posix] update Posix::Resolver to support RDNSS-discovered recursive DNS servers (#11342)
Key Changes:
* Server Prioritization: RDNSS-discovered servers are prioritized
  based on their advertised lifetime. Servers with longer lifetimes
  are preferred.
* Recursive DNS Server List: The resolver maintains a list of
  recursive DNS servers, which now includes servers learned via RDNSS.
* DNS Query Integration: The resolver uses the RDNSS-learned servers
  when forwarding DNS queries upstream.
* Border Routing Integration: The RDNSS callback is registered to the
  border routing module.

Minor Changes:
* The unused function `Transaction *GetTransaction(int aFd)` is
  removed.
2025-03-24 08:29:15 -07:00
a8fef54bf6 [tests] improves the accuracy of service status check (#11352)
Previously, the code relied on the return code of the `service radvd
status` command to determine if `radvd` was running. This was
unreliable because the command could succeed even if the service was
not actually active.

The `is_radvd_running` function now parses the output of `service
radvd status` and specifically checks for the line "running" to
confirm that the service is truly running.
2025-03-20 08:30:49 -05:00
56b8fc0862 [ncp] implement backbone router multicast forwarding (#11350)
This commit adds a few NCP properties for Backbone Router multicast
forwarding to work in NCP design.
2025-03-20 08:28:05 -05:00
ba6a803ed5 [otci] update to support more commands (#11015)
* otci now supports all commands the Thread Test Harness requires
* improve typehinting across the board
* fixes some typos
2025-03-18 22:53:22 -05:00