Commit Graph

9653 Commits

Author SHA1 Message Date
Jonathan Hui e01eea5c7e [nexus] migrate dataset_updater test to nexus (#12920)
This commit migrates the dataset_updater functional test from the
Python-based thread-cert framework to the Nexus simulation framework.

Nexus provides faster and more scalable network simulations within a
single process using virtual time.

The new test_dataset_updater.cpp covers:
- Network formation and child joining (MED and SED).
- Channel updates initiated by Leader and Router using DatasetUpdater.
- Dataset update overrides between nodes.

The legacy tests/scripts/thread-cert/test_dataset_updater.py is removed
as it is now redundant.
2026-04-18 21:54:17 -05:00
Jonathan Hui f76b876f22 [nexus] add test for informing previous parent on reattach (#12919)
This commit adds a new Nexus test to verify that a Sleepy End Device
(SED) correctly informs its previous parent after reattaching to a new
parent. This replicates the functionality of the now-deleted
test_inform_previous_parent_on_reattach.py script.

The test scenario involves:
- Forming a network with a Leader and a Router.
- Attaching a SED to the Leader.
- Simulating a link failure between the SED and Leader while allowing
  communication between the SED and Router.
- Verifying that the SED reattaches to the Router.
- Confirming that the SED sends an empty IPv6 message (Next Header 59)
  to the Leader's RLOC to inform it of the change.
- Ensuring the SED is successfully removed from the Leader's child
  table.

Migrating this test to Nexus allows for faster execution using virtual
time and single-process simulation.
2026-04-18 10:52:25 -05:00
Jonathan Hui 88f364af1b [tests] remove redundant SRP certification tests (#12910)
The following SRP test scripts in tests/scripts/thread-cert are
redundant as their functionality is now covered by the Nexus test
framework certification suite (test_1_3_SRP_TC_*):

- test_srp_register_single_service.py: Covered by Nexus
  test_1_3_SRP_TC_1.
- test_srp_lease.py: Covered by Nexus test_1_3_SRP_TC_3 (service
  lease) and test_1_3_SRP_TC_4 (key lease).
- test_srp_name_conflicts.py: Covered by Nexus test_1_3_SRP_TC_2.
- test_srp_auto_host_address.py: Covered by Nexus test_1_3_SRP_TC_13.
- test_srp_sub_type.py: Covered by Nexus test_1_3_SRP_TC_15.

Nexus tests are preferred as they run in a single process using
virtual time, making them faster and more reliable than the
multi-process simulation scripts.
2026-04-18 10:52:12 -05:00
Jonathan Hui 27321a2110 [nexus] add WebAssembly support using Emscripten (#12904)
This commit adds support for building the Nexus simulator for
WebAssembly (WASM) using the Emscripten toolchain. This enables the
simulator to run in a web browser environment with a JavaScript-based
control interface and visualization.

Key implementation details:
- Introduced `nexus_wasm.cpp` which defines Emscripten bindings (using
  Embind) for core simulation controls, including stepping time,
  node creation, topology orchestration, and state manipulation.
- Implemented a `WasmObserver` and a global event queue to capture
  simulation events (node state changes, link updates, packet events)
  and expose them to JavaScript via a polling mechanism (`pollEvent`).
- Updated the CMake build system to support the `EMSCRIPTEN` platform,
  configuring specific linker options for ES6 module export,
  modularization, and memory growth.
- Enhanced `build.sh` to allow targeting WASM via `emcmake`.
- Guarded file-system-dependent operations in `nexus_pcap.cpp` and
  adjusted `nexus_core.cpp` to handle WASM-specific constraints where
  standard I/O or multiple observers might not be applicable.
- Added `test_wasm_bindings.mjs`, a Node.js-based smoke test that
  verifies the integrity of the WASM bindings and event pipeline.
- Integrated `nexus-wasm-tests` into the GitHub Actions workflow to
  ensure continuous verification of the WASM build and functionality.
2026-04-17 15:25:28 -05:00
Abtin Keshavarzian c10b4e1da4 [logging] introduce log level override feature (#12903)
This commit introduces a mechanism to temporarily override the log
level. The `Instance` class now provides `OverrideLogLevel()` and
`RestoreLogLevel()` methods. When an override is active, the
effective log level is the maximum of the original user-set level and
the override level. If `SetLogLevel()` is called while an override is
active, it updates the original level and the effective level is
recomputed.

This ensures that log messages are generated only when needed,
without permanently losing the user's original log level
configuration.

The feature is controlled by the new configuration macro
`OPENTHREAD_CONFIG_LOG_LEVEL_OVERRIDE_ENABLE`.

A new Nexus unit test `test_log_override.cpp` is added to validate
the behavior of these new feature.
2026-04-17 13:23:14 -05:00
Jonathan Hui 5fad120d9b [tests] remove redundant MLE and connectivity tests (#12909)
The following test scripts in tests/scripts/thread-cert are now
redundant as their functionality is sufficiently covered by the Nexus
test framework:

- test_detach.py: Covered by Nexus MLE synchronization and parent
  selection tests.
- test_router_upgrade.py: Covered by 5.1.x Nexus router attachment
  tests.

Nexus tests are preferred for these scenarios as they execute in a
single process using virtual time, providing faster and more reliable
verification than the traditional multi-process simulation scripts.
2026-04-17 13:22:46 -05:00
Abtin Keshavarzian 064529cbfc [nexus] add helper to allow link between nodes in nexus (#12906)
Added `Core::AllowLinkBetween()` and `Core::UnallowLinkBetween()`
helper methods to the Nexus test platform. These methods simplify
establishing bidirectional links between nodes in simulation tests by
handling the reciprocal `AllowList()` calls in a single step.

Updated various Nexus test cases to utilize these new helpers,
replacing manual bidirectional `AllowList()` calls. This change
reduces verbosity and ensures consistency in how links are established
in the test topology.
2026-04-17 13:22:27 -05:00
Abtin Keshavarzian 7eb59f71da [network-diag] introduce AnswerBuilder to manage answer messages (#12887)
This commit introduces `AnswerBuilder` class to track and manage
Network Diagnostic answer messages. This class is used when the
response to a query requires multiple CoAP answer messages. It
automatically manages the inclusion of the Query ID and the Answer
TLVs(providing message indexing and "more-to-follow" flags) in each
allocated answer message, while maintaining all answer messages in a
queue. The `NetworkDiagnostic::Server` is updated to use the
`AnswerBuilder`, simplifying the logic for preparing and sending
answers.

The `AnswerBuilder` class is added in a new header file
`network_diagnostic_types.hpp` to allow for its reuse by other
modules in the future.
2026-04-17 13:21:59 -05:00
Jonathan Hui 254043deec [nexus] add gRPC support and live demo (#12898)
This commit introduces gRPC support to the Nexus simulator, enabling
remote control and monitoring of simulations. This infrastructure allows
external tools and visualizers to interact with the simulated network
in real-time.

Key changes:
- Defined `simulation.proto` providing the `NexusService` definition for
  simulation control and event streaming.
- Implemented `GrpcServer` in `nexus_grpc.cpp` which functions as a
  Nexus simulation observer, pushing events to connected clients.
- Added RPCs for dynamic node creation, position updates, node state
  control, and network orchestration (forming and joining).
- Implemented a real-time event stream that includes node state changes,
  link updates, and packet captures (with basic protocol decoding).
- Introduced `nexus_native.cpp` as an entry point for a persistent
  simulation server that can be controlled via gRPC.
- Updated `Core` and `Observer` interfaces to support a list of
  concurrent observers instead of a single instance.
- Enhanced the CMake build system to optionally find and link against
  gRPC and Protobuf, including automatic source generation.
- Updated CI (GitHub Actions) to include build and test steps for the
  new gRPC functionality.
- Added comprehensive unit tests in `test_grpc.cpp` to verify all
  exposed gRPC service methods.
2026-04-16 22:05:19 -05:00
Abtin Keshavarzian e536562296 [mle] simplify CslClockAccuracyTlv (#12905)
This commit updates `CslClockAccuracyTlv` to use the `SimpleTlvInfo`
and a separate `CslClockAccuracyTlvValue` class. This change
simplifies how the TLV is appended to and read from messages
by leveraging the `Tlv::Append<TlvType>` and `Tlv::Find<TlvType>`
helper methods (avoiding the use of `FindTlv()`).
2026-04-16 10:27:08 -05:00
Jonathan Hui e43df01933 [github-actions] remove multiple-instance job from simulation-1.1.yml (#12897)
This commit removes the redundant `multiple-instance` job from the
`simulation-1.1.yml` workflow. This job was used to run Thread 1.1
certification tests with `OT_MULTIPLE_INSTANCE=ON`.

The job is being removed to streamline the CI process and reduce
redundant test coverage, as multiple-instance configurations are
sufficiently covered in other workflow files. The dependency list
for the coverage collection job is also updated to reflect this
removal.
2026-04-15 16:20:45 -05:00
Jonathan Hui e8a52ab654 [nexus] fix false suppression of CHILD_REMOVED events (#12902)
The previous logic for suppressing CHILD_REMOVED events was flawed. It
checked if the neighbor was not in the child table. However, since the
callback is triggered after the child is removed, it was always false,
leading to false suppression for all removed children.

This caused the parent node to never emit "link removed" events to the
UI when children detached, leading to inconsistent link states (dashed
lines) when only one direction was active.

This fix updates the logic to check if a neighbor entry exists in the
neighbor table with an established link (kStateValid). This ensures we
only suppress the event when the child has successfully transitioned to
a router role and established a valid link.
2026-04-15 15:56:01 -05:00
Abtin Keshavarzian 8a032575da [mle] check router role allowed before sending multicast adv (#12876)
This commit updates `Mle::SendMulticastAdvertisement()` to verify
that the router role is allowed by calling `IsRouterRoleAllowed()`
before proceeding to send the multicast MLE advertisement.
2026-04-14 23:38:56 -05:00
Jonathan Hui e2d07be235 [nexus] introduce simulation observer interface and hooks (#12894)
This commit introduces the `SimulationObserver` interface and integrates
it into the Nexus core simulation logic. This allows external systems to
observe node state changes, link updates, and packet events in real-time.

Key changes:
- Defined `SimulationObserver` interface to handle node state changes,
  link updates, packet events, and event clearing.
- Added `SetObserver` and `GetObserver` methods to the `Core` class.
- Implemented `Core::HandleNeighborTableChanged` to notify the observer
  of neighbor additions and removals.
- Implemented `Core::HandleStateChanged` to track node role transitions
  and parent changes, updating links accordingly.
- Integrated packet event notification in `Core::ProcessRadio`,
  including basic destination node ID resolution for unicast frames.
- Added `Core::SetNodeEnabled` to allow enabling or disabling Thread and
  MLE on specific nodes at runtime.
- Updated `Core::Reset` to clear events via the observer.
- Increased `OPENTHREAD_CONFIG_MAX_STATECHANGE_HANDLERS` to accommodate
  the new nexus state change handler.
- Added `mLastParentId` to `Node` class to correctly manage link updates
  during parent switches or detachment.
2026-04-14 23:26:09 -05:00
Jonathan Hui 7829782b06 [ip6] enforce single Hop-by-Hop Options header rule (#12896)
RFC 8200 states that the Hop-by-Hop Options header MUST be the first
extension header and can only occur once in a packet. This commit
updates HandleExtensionHeaders to enforce this rule.

This fix prevents a potential infinite loop or exponential growth of
messages when multiple Hop-by-Hop headers (each containing an MPL
option) are processed. Previously, each MPL option could trigger its
own retransmission, and if these options were evicted from the MPL
SeedSet, they would be re-processed as new messages upon loopback,
leading to exponential growth and eventually a timeout.
2026-04-14 23:25:42 -05:00
Jonathan Hui 0a38d5f97b [nexus] introduce radio model for RSSI calculation (#12892)
This commit adds a new RadioModel class to simulate wireless propagation
characteristics between Nexus nodes. It implements a simple path-loss
model based on node distance to calculate RSSI.

Key changes include:
- Added RadioModel with CalculateRssi and ShouldDropPacket methods.
- Integrated RSSI calculation into the Core radio processing logic.
- Implemented packet dropping for signals below -100 dBm sensitivity.
- Added nexus_radio_model.cpp to the build system.
2026-04-14 16:35:28 -05:00
Abtin Keshavarzian 221a9cbbb0 [mle] track "router role allowed" state in a new variable (#12854)
This commit introduces a new member variable `mRouterRoleAllowed` in
the `Mle` class to cache the evaluation of whether the device is
currently permitted to operate as a router.

Previously, the `IsRouterEligible()` method evaluated several
conditions (e.g., `IsFullThreadDevice()`, `mRouterEligible` config,
and various fields in `SecurityPolicy`) every time it was called.
Since this method is invoked frequently across different `Mle`
operations, re-evaluating these conditions repeatedly was
inefficient.

The new `mRouterRoleAllowed` variable caches the final computed
result. It is updated via the `UpdateRouterRoleAllowed()` method
whenever any underlying input changes, such as:
- `Mle` starting.
- Configuration parameter updates (e.g., `SetRouterEligible()`).
- Security policy changes from the `KeyManager`.

This change centralizes the logic for handling role permission updates
into a single location (`UpdateRouterRoleAllowed()`). By
consolidating the actions taken when the allowed state changes, the
codebase is cleaner and easier to maintain and update.

It also provides a clearer conceptual distinction between the user's
router configuration (`mRouterEligible`) and the effective state
used by the device.
2026-04-14 14:15:22 -05:00
Jonathan Hui 582dc1cd67 [nexus] move TREL configuration to nexus-config header (#12891)
This commit moves the TREL configuration from the build script to the
nexus-config header file. This ensures that TREL is consistently enabled
for all nexus builds and simplifies the build script.

Specifically:
- Added OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE to
  tests/nexus/openthread-core-nexus-config.h.
- Removed OT_TREL from tests/nexus/build.sh and simplified the build
  options.
2026-04-14 13:13:39 -05:00
Jonathan Hui 47860a4eb4 [nexus] move multiple instance config to nexus config header (#12890)
This commit moves the `OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE`
configuration from the build scripts to the nexus-specific core
configuration header file.

Specifically:
- Added `#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 1` to
  `tests/nexus/openthread-core-nexus-config.h`.
- Removed `-DOT_MULTIPLE_INSTANCE=ON` from `tests/nexus/build.sh`.
- Removed `-DOT_MULTIPLE_INSTANCE=ON` from `tests/fuzz/oss-fuzz-build`.

This change centralizes nexus-specific configurations in the header
file, making the build scripts cleaner and ensuring consistent
configuration across different build environments that use the
nexus core config."
2026-04-14 13:12:29 -05:00
Esko Dijk 5c90231e48 [tcat] fix unit tests (#12875)
Due to a state retention issue in the unit test platform, TCAT tests were passing in ways they should not.
Now with the new settings/flash clearing per #12875 applied, these tests were failing.

This fixes TCAT unit tests to pass again and better express the expected behavior also.
2026-04-14 08:44:27 -07:00
Esko Dijk 68ab3a55a1 [tests] prevent settings/flash retaining between unit tests (#12875)
Issue: state was retained between OT instances in the unit test platform, across tests.
This commit adds settings and flash clearing as part of testInitInstance().
2026-04-14 08:44:27 -07:00
Jonathan Hui e336e7a86c [github-actions] simplify simulation-1.4 workflow (#12886)
This commit simplifies the Simulation 1.4 workflow by removing the
compiler and architecture matrix. Run-time issues due to compiler
differences or architecture have not been an issue, so testing a single
configuration is sufficient to reduce CI resource usage.

The workflow now uses the default environment instead of explicitly
testing both gcc/clang and m32/m64 architectures.
2026-04-13 23:39:16 -05:00
dependabot[bot] 20a83e1116 github-actions: bump docker/build-push-action from 7.0.0 to 7.1.0 (#12882)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 7.0.0 to 7.1.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/d08e5c354a6adb9ed34480a06d141179aa583294...bcafcacb16a39f128d818304e6c9c0c18556b85f)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 7.1.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>
2026-04-13 23:38:46 -05:00
Abtin Keshavarzian 40976e772d [time-sync] add compile-time check for TREL incompatibility (#12880)
This commit adds a compile-time check in `time_sync_service.hpp` to
ensure that `OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE` is not
enabled alongside `OPENTHREAD_CONFIG_TIME_SYNC_ENABLE`. The time
synchronization feature is experimental and currently only supports
IEEE 802.15.4 radio links. Attempting to use it over TREL is
unsupported and will now result in a build failure.
2026-04-13 22:49:34 -05:00
Abtin Keshavarzian 06ed4dce4e [crypto] add ContextWith template to simplify context allocation (#12885)
This commit introduces the `Context` and `ContextWith<kContextSize>`
helper classes in the `Crypto` namespace to wrap `otCryptoContext`
and manage its storage allocation. `ContextWith<kContextSize>`
handles the buffer allocation based on the configuration
`OPENTHREAD_CONFIG_CRYPTO_PLATFORM_ALLOCS_CONTEXT`, automatically
clearing and setting the buffer.

The `AesEcb`, `HkdfSha256`, `HmacSha256`, and `Sha256` classes are
updated to use the new `ContextWith` template for their `mContext`
members. This simplifies their initialization sequences and
constructors.
2026-04-13 22:48:35 -05:00
Abtin Keshavarzian 028f137367 [cli] add support to configure prompt output (#12884)
This commit introduces the ability to configure whether the CLI
interpreter outputs the prompt string (`> `) at runtime.

- Adds `mPromptEnabled` boolean flag (enabled by default) under the
  `OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE` configuration.
- Adds the `Interpreter::SetPromptConfig()` method to toggle this
  behavior.
- Updates `Interpreter::OutputPrompt()` to check `mPromptEnabled`
  before emitting the prompt string.
2026-04-13 22:47:17 -05:00
Jonathan Hui 23e9cc98b8 [tests] remove redundant 1.2 certification tests and CI job (#12883)
This commit removes the following legacy 1.2 certification test scripts:
- tests/scripts/thread-cert/v1_2_router_5_1_1.py
- tests/scripts/thread-cert/v1_2_test_parent_selection.py

It also removes the 'packet-verification-1-1-on-1-4' job from the
Simulation 1.4 workflow as it is no longer required.
2026-04-13 17:16:36 -05:00
Esko Dijk ea56e75ffe [tcat] fix CommCert4 to be signed by the correct CA (#12874)
Now signed by the correct 'Thread Certification DeviceCA'. A 'test'
target is added in the Makefile to test chaining.  The Thread
certification CA certificate is also added in the 'CA' directory,
which was missing.  Documentation is updated to clarify that the
'TcatCertCa' private key is not included in this repo; and other
clarifications.
2026-04-12 21:51:10 -05:00
Abtin Keshavarzian b5d0ea36be [test] add testResetInstance() to simulate device reset (#12878)
This commit introduces `testResetInstance()` in the unit test platform
layer to finalize an existing `ot::Instance` and re-initialize it
using the same underlying memory buffer, simulating a device reset.

This commit also updates `test_routing_manager.cpp` to use this new
function to streamline the test implementation.
2026-04-12 21:49:28 -05:00
Abtin Keshavarzian dea5c4559d [meshcop] add FindIn() and AppendTo() for SteeringDataTlv (#12871)
This commit introduces static helper methods `SteeringDataTlv::FindIn()`
and `SteeringDataTlv::AppendTo()` to simplify the handling of steering
data in `Message` objects.

`SteeringDataTlv::FindIn()` encapsulates the pattern of searching for a
`SteeringDataTlv` in a `Message` and reading its value into a
`SteeringData` object. `SteeringDataTlv::AppendTo()` provides a unified
way to append steering data to a `Message`, including a validity check.

These helpers are adopted across core modules (MeshCoP, MLE, Discovery)
and various Nexus tests, replacing manual TLV manipulation with a
cleaner and safer helper methods.
2026-04-12 21:40:47 -05:00
Abtin Keshavarzian 1ddfe45402 [cli] update SNTP and Diagnostic CLI commands (#12870)
This commit fixes the CLI implementation of `sntp` and `diagnostic`
commands by ensuring they use the public `otMessageInfo` type instead
of the internal `ot::Ip6::MessageInfo` class.
2026-04-12 21:39:55 -05:00
Jonathan Hui 32ade1684b [nexus] add test 1_4_PIC_TC_4 for NAT64 connectivity (#12862)
This commit implements the Nexus test specification 1_4_PIC_TC_4
to verify the Border Router (BR) built-in NAT64 translator.

The test verifies that the BR DUT:
- Automatically configures an IPv4 address and NAT64 prefix.
- Offers IPv4 internet connectivity to Thread devices using NAT64.
- Offers IPv4 local network connectivity to Thread devices.
- Operates a DNS recursive resolver to look up IPv4 server addresses.

New files added:
- tests/nexus/test_1_4_PIC_TC_4.cpp: C++ test execution script
- tests/nexus/verify_1_4_PIC_TC_4.py: Python pcap verification script

Integration:
- Updated tests/nexus/CMakeLists.txt to compile the test.
- Added test to default array in tests/nexus/run_nexus_tests.sh.
2026-04-10 21:40:06 -05:00
Abtin Keshavarzian 0d740686f3 [config] default enable "key references" with PSA crypto (#12877)
This commit updates the default value of the
`OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` configuration
to be enabled automatically when `OPENTHREAD_CONFIG_CRYPTO_LIB` is
set to `OPENTHREAD_CONFIG_CRYPTO_LIB_PSA`. Additionally, it adds a
compile-time check in `crypto_platform_psa.cpp` to enforce this
requirement. This ensures that the platform key references support is
always enabled when the PSA crypto library is selected.
2026-04-10 21:39:12 -05:00
Abtin Keshavarzian 581221eedb [instance] introduce ActiveInstanceTracker for context-aware logging (#12869)
This commit introduces `ActiveInstanceTracker` as the first member
variable of the `Instance` class to manage the global `gActiveInstance`
pointer (when `OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE` is
enabled).

By placing it as the very first member, we ensure its constructor
is called before any other member and its destructor is called after
all others. The `Instance` destructor body also explicitly sets
`gActiveInstance = this` at its start to "claim" the context during its
own destruction. This guarantees that logs emitted during both the
initialization and destruction of an `Instance` are always correctly
associated with that instance. Finally, the `ActiveInstanceTracker`
destructor sets `gActiveInstance` to `nullptr` at the very end to
prevent any potential use of a dangling pointer.
2026-04-10 21:38:35 -05:00
Abtin Keshavarzian 21181644aa [mle] add parameter-less AppendModeTlv() helper (#12868)
This commit introduces an overloaded version of `AppendModeTlv()`
that automatically uses the device's own `GetDeviceMode()`.
The new parameter-less version simplifies the common case where a
node reports its own mode. The parameterized version is
preserved for cases where a specific mode must be provided (e.g.,
parent reporting one of its children's mode).
2026-04-10 21:37:55 -05:00
Abtin Keshavarzian 9feec93a20 [mle] add AppendSourceAddressAndLeaderDataTlvs() helper (#12867)
This commit introduces `TxMessage::AppendSourceAddressAndLeaderDataTlvs()`
to consolidate the appending of `Source Address` and `Leader Data` TLVs.

This combination is frequently used together across various MLE messages
to provide the sender's identity and leader data. Centralizing this
into a single helper method improves code consistency.

Additionally, the `TxMessage` methods in `mle.hpp` and `mle.cpp` are
organized into "Appending single TLV" and "Appending multiple TLVs"
sections for better clarity and maintainability. Existing multi-TLV
methods like `AppendLinkAndMleFrameCounterTlvs()` and
`AppendActiveAndPendingTimestampTlvs()` are moved to the new section.
2026-04-10 21:37:24 -05:00
Abtin Keshavarzian a98813b30a [nexus] use Ip6::SetReceiveCallback() directly (#12865)
This commit updates the Nexus platform to use the internal core C++
API `Ip6::SetReceiveCallback()` instead of the public C API
`otIp6SetReceiveCallback()`.
2026-04-09 17:55:04 -05:00
Abtin Keshavarzian 7210dd212b [mle] centralize and unify address registration logic (#12864)
This commit introduces `Mle::ShouldRegisterUnicastAddrWithParent()` to
centralize the logic for determining which unicast addresses should be
registered with the parent.

Previously, the filtering logic for unicast addresses was duplicated
in `HasUnregisteredAddress()` and `AppendAddressRegistrationTlv()`. By
unifying this in a single helper method, the code ensures consistent
behavior between checking for unregistered addresses and actually
appending them to the MLE messages.

Additionally, this change:
- Marks `Mle::HasUnregisteredAddress()` as `const`.
- Updates `Mle::ShouldRegisterMulticastAddrsWithParent()` to improve
  readability and follow common coding patterns in the codebase.
2026-04-09 17:54:54 -05:00
Abtin Keshavarzian f2c081b5ae [mle] improve address registration in SendChildUpdateResponse() (#12863)
This commit improves the address registration behavior in
`Mle::SendChildUpdateResponse()` for non-FTD devices.

Previously, the device would always append only the mesh-local address
and then unconditionally attempt to send a follow-up Child Update
Request. The updated logic now checks if the parent's request
included a Challenge TLV. If not, all addresses are appended directly
to the response, eliminating the extra message exchange. If a
Challenge is present (indicating the parent is restoring its link),
only the mesh-local address is included to prevent message
fragmentation. In this case, if the device is attached and has
unregistered addresses, a follow-up Child Update Request is scheduled
via `mDelayedSender`.

The previous implementation indirectly assumed the parent would only
request the `Address Registration` TLV when restoring its link (the
current behavior of OpenThread parents). However, such behavior on the
parent is not strictly required and could change. This update on the
child side ensures robust address registration regardless of the
parent's specific behavior.
2026-04-09 17:54:31 -05:00
Jonathan Hui fc3ffa7a69 [nexus] fix segmentation fault during Core destruction (#12866)
When the Nexus test finishes, it automatically destructs all its allocated
Nodes sequentially. During this destruction phase, the OpenThread instance
attempts to destruct objects like `Nat64::Translator`, which might in turn
call logging mechanisms like `Mapping::Free()` that rely on the static
`Instance::GetActiveInstance()` pointer.

Because `Core::~Core()` did not maintain or update `gActiveInstance` while
iterating through node destructors, this pointer was left dangling, causing
segmentation faults when dereferenced by `ot::Instance::GetLogLevel()`.

This commit fixes `Core::~Core()` to manually loop through and destruct the
`mNodes` list, calling `UpdateActiveInstance(&node->GetInstance())` right
before destroying each node. This ensures that `gActiveInstance` points to
the correct context while node destruction logic runs.
2026-04-09 17:52:29 -05:00
Jonathan Hui dbbadb4021 [nexus] add test for IPv6 default route advertisement (PIC-TC-3) (#12860)
This commit adds a Nexus test case 1_4_PIC_TC_3 to verify the IPv6
default route advertisement behavior of a Border Router (BR) in a
Thread 1.4 network.

The test verifies that:
- The BR correctly advertises a default route (::/0) in Thread Network
  Data when it discovers a default route on the infrastructure link.
- The BR maintains the default route advertisement even if the
  infrastructure default route is withdrawn, provided a non-ULA prefix
  remains active on the infrastructure link.
- The default route advertisement is correctly restored or updated when
  the infrastructure default route is re-enabled.

The test implementation includes:
- test_1_4_PIC_TC_3.cpp: C++ test logic using the Nexus simulation
  framework, simulating BR, Router, End Device, and Infrastructure
  nodes (Eth_1, Eth_2). It uses a custom ICMPv6 receive callback to
  simulate "no route to host" conditions.
- verify_1_4_PIC_TC_3.py: Python verification script that analyzes
  the captured packets to ensure MLE Data Responses and ICMPv6 traffic
  match the expected behavior for each test step.

Integration:
- Updated tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh
  to include the new test in the automated test suite.
2026-04-09 17:18:28 -05:00
Jonathan Hui 05ad9803d8 [nexus] add 1.4 PIC-TC-1 test for DHCPv6-PD and DNS (#12859)
This commit adds a new Nexus test that implements the test
specification in test-1-4-PIC-TC-1.md. The test verifies Border
Router functionality including:
- DHCPv6-PD client to obtain OMR prefix
- Advertising route to OMR prefix on AIL (Stub Router)
- DNS recursive resolver for public internet addresses
- Connectivity (ICMPv6, UDP, TCP/HTTP) to internet and local servers

New files:
- tests/nexus/test_1_4_PIC_TC_1.cpp: C++ test execution
- tests/nexus/verify_1_4_PIC_TC_1.py: Python pcap verification

Nexus platform enhancements:
- Enabled DHCPv6-PD client in openthread-core-nexus-config.h
- Implemented DHCPv6-PD platform APIs in nexus_infra_if.cpp
- Added RDNSS option to RA in nexus_infra_if.cpp
- Improved packet delivery on infrastructure interface in nexus_core.cpp
- Fixed upstream DNS query matching in nexus_dns.cpp
2026-04-09 15:29:35 -05:00
Zhangwx b3ab4df0e8 [mbedtls] fix version check to correctly handle mbedtls v3.x and v4.0 (#12861)
Previously, version checks used `<= 0x03060500` to guard mbedtls v3.x
APIs, incorrectly treating any version above 3.6.5 (e.g. 3.6.6+) as
v4.0. Replace these checks with `< 0x04000000` to properly cover all
v3.x releases.
2026-04-09 15:18:26 -05:00
Abtin Keshavarzian 51353c41d5 [border-agent] add support for vo key in TXT data parser (#12858)
This commit adds support for the Vendor OUI (`vo`) key in the Border
Agent MeshCoP service TXT data parser.

The `otBorderAgentTxtDataInfo` structure and its internal counterpart
`TxtData::Info` are updated to include a boolean flag `mHasVendorOui`
and a 3-byte array `mVendorOui` to store the 24-bit vendor OUI.

The parsing logic in `TxtData::Info::ProcessTxtEntry()` is updated to
recognize the `vo` key and extract its value. Additionally, the CLI
`Interpreter` is updated to output the vendor OUI in hexadecimal
format when it is present in the parsed information.
2026-04-09 01:40:23 -05:00
Abtin Keshavarzian 0e8bb15545 [nexus] use InstanceLocator in InfraIf (#12856)
This commit updates the Nexus platform `InfraIf` class to inherit from
`InstanceLocator`, aligning it with the standard OpenThread architectural
patterns.

The `mNode` and `mNodeId` member variables are removed as they are now
redundant. Access to the associated `Instance` and other platform-level
components is now managed through `GetInstance()` and the newly added
`Instance::Get<T>` template specializations for `Node`, `InfraIf`,
`Udp`, `Trel`, and `Mdns`.

The `InfraIf::Init()` method is renamed to `AfterInit()` to better
reflect its role in the node initialization lifecycle. All call sites in
`nexus_infra_if.cpp` are updated to use the locator-based accessors.
2026-04-09 01:39:54 -05:00
Jonathan Hui 635d2ffaca [nexus] implement test 1_4_DNS_TC_5 for DNS record types (#12836)
This commit implements the Nexus test specification 1_4_DNS_TC_5 for
DNS record types and special cases in OpenThread 1.4.

The test verifies that the Border Router:
- Can resolve A and AAAA records from upstream DNS servers.
- Does not perform IPv6 AAAA synthesis from A records when not
  specifically requested or configured.
- Can resolve mDNS records on the Adjacent Infrastructure Link (AIL).
- Supports non-typical record types (RRTypes) and "Private Use"
  ranges (0xFF00-0xFFFE).
- Correctly blocks and responds with NXDomain for "ipv4only.arpa"
  queries, ensuring they are not forwarded upstream.

Test Implementation:
- Created test_1_4_DNS_TC_5.cpp to simulate the network topology and
  DNS query/response sequences.
- Created verify_1_4_DNS_TC_5.py to perform packet-level verification
  of the DNS interactions and BR behavior.
- Integrated the new test into the Nexus build and test execution
  scripts.
2026-04-08 20:01:15 -05:00
Jonathan Hui 3b84b4c5cb [nexus] implement test 1_4_DNS_TC_3 for upstream DNS resolver selection (#12835)
This commit implements the Nexus test specification 1_4_DNS_TC_3 for
upstream DNS resolver selection in OpenThread.

Nexus Platform Enhancements:
- Added OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE and
  OPENTHREAD_CONFIG_PLATFORM_DNS_ENABLE to nexus config.
- Implemented platform DNS APIs in nexus_dns.cpp, supporting
  upstream server selection based on prefix lifetimes and reachability.
- Added UdpHook to Core to allow tests to intercept and simulate
  responses for backbone UDP traffic on port 53.
- Updated InfraIf::Receive to call Core::HandleUdp for generic UDP
  interception.
- Added raw buffer delivery overloads for InfraIf::SendUdp.

Test Implementation:
- Created test_1_4_DNS_TC_3.cpp which performs network formation,
  RA signaling (PIO/RIO/RDNSS), and DNS resolution triggers.
- Created verify_1_4_DNS_TC_3.py to validate network behavior,
  RA contents, and correct upstream query routing using pktverify.
- Integrated the new test into CMakeLists.txt and the default
  run_nexus_tests.sh suite.
2026-04-08 17:01:03 -05:00
Abtin Keshavarzian 2b3b56def7 [mle] separate role transition and leader age checks (#12853)
This commit updates `Mle::HandleTimeTick()` to separate the processing
of role transitions and the checking of the leader's age into two
distinct `switch` statements.

Previously, these two checks were combined in a single `switch`
statement with complex fall-through logic. This structure contained
two issues:

1. For a device in the `kRoleChild` state, if the role transition
   timeout expired, the code would execute `ExitNow()`. This
   unintentionally skipped the leader age check and the rest of the
   operations in `Mle::HandleTimeTick()`, such as updating the
   `ChildTable` and `RouterTable`.
2. A non-router-eligible child would incorrectly fall through and
   perform the leader age check. The new logic adds an explicit check
   using `IsRouterEligible()` to ensure only router-eligible children
   monitor the leader's age.

By separating the logic into two blocks, the code is simplified and
we avoid the brittle fall-through behavior and ensure that all time
tick operations are consistently executed regardless of the device's
role or role transition state.
2026-04-08 16:13:09 -05:00
Abtin Keshavarzian 2a120a9ddf [nexus] remove redundant mInfraIf initializations (#12851)
This commit removes redundant calls to `mInfraIf.Init()` and
`mInfraIf.AddAddress()` from various Nexus test cases.

The infrastructure interface (`mInfraIf`) is automatically initialized
and assigned a link-local address by the core framework when a new
`Node` is added. The `InfraIf::Init()` method derives the link-local
address from the MAC address and adds it to the interface. Therefore,
these explicit manual calls in individual test scripts are unnecessary
and can be removed to simplify the test setup.
2026-04-08 16:09:17 -05:00
Yang Song d42343caa8 [cli] refine debug command list for better diagnostic output (#12799)
Removed redundant channel, panid, and extpanid commands. Their
information is now more comprehensively provided by the dataset active
-ns output.

Removed partitionid from the debug command list as it was redundant
with leaderdata.
2026-04-08 01:24:32 -05:00