Compare commits

...

2942 Commits

Author SHA1 Message Date
Tan Yan Quan b1a37932b1 [crypto] fix mbedtls version check for v3.6.6 2026-04-09 19:16:33 +08:00
Abtin Keshavarzian 9b887f6bd1 [srp-server] introduce LeaseTracker base class for Host and Service (#12628)
This commit extracts the common lease tracking variables (`mLease`,
`mKeyLease`, `mTtl`, and `mUpdateTime`) and their associated methods
from the `Srp::Server::Host` and `Srp::Server::Service` classes into a
new shared base class, `LeaseTracker`.

By having both `Host` and `Service` inherit from `LeaseTracker`, we
eliminate duplicated logic for calculating expiration times, handling
lease info, and processing TTL updates. This refactoring simplifies
the SRP server codebase and ensures consistent lease management
behavior across both entities.
2026-03-05 16:54:39 -06:00
Abtin Keshavarzian 08f7b370b3 [coap] remove Clone() method from Coap::Message (#12616)
This commit removes the redundant `Clone()` methods from `Coap::Message`.
These methods previously served to retain the `HeaderOffset` across the
cloned message, which was internally tracked by modifying `MeshDest`.
Since `ot::Message::Clone()` natively preserves the `MeshDest` property,
the specialized `Coap::Message::Clone()` wrappers are unnecessary.
Callers now directly use `ot::Message::Clone()` and type-cast the result
using `AsCoapMessagePtr()`.
2026-03-05 16:53:41 -06:00
Valerio Setti e4d97681c5 [mbedtls] add guards for crypto support dropped in Mbed TLS 4.x (#12459)
Starting from Mbed TLS 4.0 legacy crypto support (which now it's moved
into TF-PSA-Crypto) has been made internal so it shoudn't be referenced
anymore. This commit add guards for this change.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-03-05 16:27:58 -06:00
Valerio Setti b59baea4f4 [mbedtls] TLS functions do not require rng functions from Mbed TLS 4.0 (#12459)
Starting from Mbed TLS 4.0, TLS functions will use psa_generate_random()
inernally, so there is no need to specify it as parameter or through
mbedtls_ssl_conf_rng().

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-03-05 16:27:58 -06:00
Kevin Zhao 06e2cdbf5c [github-actions] fix pwn-request vulnerability in size.yml workflow (#12625)
The size.yml workflow used pull_request_target with git checkout
FETCH_HEAD, which replaced the entire working directory (including
scripts) with untrusted fork code. Since pull_request_target grants
a read/write GITHUB_TOKEN even from public forks, and the workflow
had no top-level permissions restriction, this allowed arbitrary
code execution with write access to the repository.

Fix by:
1. Adding top-level permissions: contents: read (consistent with
   all other workflows in this repository).
2. Replacing `git checkout FETCH_HEAD` with a fetch-only approach
   that passes the PR merge commit SHA via the OT_SHA_NEW environment
   variable. The check-size script uses git-archive to extract code
   by SHA, so it does not need the working directory to be switched.
   This ensures ./script/check-size always runs from the base branch.
3. Updating check-size to accept OT_SHA_NEW from the environment,
   falling back to git rev-parse HEAD when not set (preserving
   existing behavior for push-triggered and local runs).
2026-03-05 16:27:33 -06:00
Jonathan Hui 66fbd918d7 [tests] fix flakiness in Nexus test 1.2.LP.5.3.8 (#12629)
This commit stabilizes Nexus test 1.2.LP.5.3.8 by addressing timing
issues related to SSED polling during network transitions.

Key changes:
- In test_1_2_LP_5_3_8.cpp, added StopPolling() calls after MLE and
  MeshCoP exchanges to suppress immediate Data Requests triggered by
  these protocols. This ensures the SSED satisfies strict 'no Data
  Request' pass criteria.
- In verify_1_2_LP_5_3_8.py, updated criteria 13.2 to allow Data
  Requests on the Ternary Channel that occur during the initial
  network transition (re-attachment). The script now only strictly
  disallows Data Requests in the 1-second window immediately
  preceding the Echo Request.

These changes make the test robust against standard OpenThread
re-synchronization behavior while still verifying that Echo Requests
are received via CSL synchronization.
2026-03-05 16:26:59 -06:00
Jonathan Hui 92db989165 [nexus] fix flaky test 1.2.LP.5.3.2 and related verification issues (#12627)
- Fix pktverify index synchronization issues in Nexus tests.
  Previously, some verification scripts used (pkt.number, 0) as indices
  in pkts.range() calls. In Nexus tests where WPAN and ETH indices are
  synchronized, this could cause the advanced index to exceed the stop
  index of 0, resulting in a flaky AssertionError. Updated scripts to
  use (pkt.number, pkt.number) consistently.
- Reduce kAttachAsSsedTime from 20s to 5s in test_1_2_LP_5_3_2.cpp.
  The 20s wait was exactly matching the CSL Synchronized Timeout,
  causing SSED_1 to trigger an auto-synchronization Data Request
  immediately after the wait ended, violating test constraints.
  Providing more margin ensures stable test execution.
2026-03-05 13:17:28 -06:00
Jonathan Hui 939fdee791 [nexus] implement test 1.2.LP.5.3.8 for SSED CSL channel modification (#12614)
This commit implements and verifies Nexus test case 1.2.LP.5.3.8, which
validates that a Router (DUT) correctly supports a Synchronized Sleepy
End Device (SSED) that modifies its CSL Channel TLV.

Key changes:
- Created tests/nexus/test_1_2_LP_5_3_8.cpp to simulate the test
  topology (Leader, DUT, SSED_1) and execution steps.
- Implemented tests/nexus/verify_1_2_LP_5_3_8.py to perform automated
  packet verification of the test criteria.
- Integrated the new test into CMakeLists.txt and run_nexus_tests.sh.
- Used descriptive constants for CSL parameters and wait times to avoid
  magic numbers and ensure spec compliance (e.g., CSL timeout of 20s).
- Verified connectivity using ICMPv6 Echo exchanges across Primary,
  Secondary, and Ternary channels, ensuring the SSED only polls when
  expected.
2026-03-05 12:36:59 -06:00
Jesse Thompson 464ddcb9e6 [mle] child ID request timeout and state cleanups (#12584)
This commit addresses issues where child entries could remain in the
kStateChildIdRequest indefinitely in the sequence of events during
attachment.  Previously there was a timeout defined and saved for the
kStateChildIdRequest state, but will no longer be excluded from timing
out. This change additionally clears previous parents upon becoming a
router, as it could previously cause unnecessary messages to inform
previous parents.  Finally, this moves the transition to the valid
state to occur after success in queuing the Child ID Response.
2026-03-05 10:40:23 -06:00
Abtin Keshavarzian 75c554e9b1 [meshcop] integrate commissioner client classes (#12618)
This commit removes the standalone `AnnounceBeginClient`,
`EnergyScanClient`, and `PanIdQueryClient` classes, integrating their
methods and TMF message handlers directly into the
`MeshCoP::Commissioner` class.

Since these client classes contained minimal state and primarily
served as simple wrappers for sending specific requests and handling
callbacks, merging them into the main `Commissioner` class simplifies
the architecture, removes unnecessary auxiliary classes, and shrinks
the overall codebase size.
2026-03-05 10:37:35 -06:00
Abtin Keshavarzian 271c50a044 [dso] validate parsed TLV size in ProcessKeepAliveMessage() (#12609)
This commit updates the `Dso::Connection::ProcessKeepAliveMessage()`
method to use the `OffsetRange` class for parsing TLVs. This approach
robustly validates the size of each parsed TLV against the remaining
length of the received message. Utilizing `OffsetRange::Contains()`
ensures that the reported TLV size via `GetSize()` does not exceed the
available bytes in the message, preventing potential out-of-bounds
reads or infinite loops when iterating over subsequent TLVs.
2026-03-05 10:36:43 -06:00
Jonathan Hui 3ac4d4ac19 [nexus] implement link metrics support (#12621)
This commit implements Link Metrics support in the nexus platform,
similar to the simulation platform implementation.

Key changes include:
- Added 'LinkMetricsInfo' struct and management methods to 'Radio' in
  'nexus_radio'.
- Implemented 'otPlatRadioConfigureEnhAckProbing()' and Enhanced ACK IE
  generation in 'nexus_core' and 'nexus_radio'.
- Enabled Link Metrics initiator and subject configuration flags in
  'openthread-core-nexus-config.h'.
- Fixed spelling of 'kRadioSensitivity' in 'nexus_radio'.
- Added 'fflush(stdout)' to the logging utility in 'nexus_misc' to
  improve real-time log capture during tests.
2026-03-05 01:02:18 -06:00
Jonathan Hui 21837d72db [nexus] add test 1.2.LP.5.3.7 for SSED CSL Synchronized Timeout (#12611)
This commit adds a new Nexus test case 1.2.LP.5.3.7 to validate that a
Router (DUT) correctly supports a Synchronized Sleepy End Device
(SSED) modifying the CSL Synchronized Timeout TLV.

Specifically, this test verifies:
- Initial CSL synchronization with a 10s timeout.
- SSED successfully updating the timeout to 20s via MLE Child Update.
- DUT maintaining connectivity beyond the original 10s timeout.
- DUT correctly buffering frames when CSL synchronization expires
  after the timeout is reverted to 10s.
- Successful resynchronization and buffered frame delivery.

Detailed changes:
- tests/nexus/test_1_2_LP_5_3_7.cpp: Implemented the C++ test logic
  using the Nexus simulation framework.
- tests/nexus/verify_1_2_LP_5_3_7.py: Added a Python script to
  validate the packet traces and ensure protocol compliance.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
- tests/nexus/run_nexus_tests.sh: Included the test in the default
  Nexus test suite.
2026-03-04 23:53:47 -06:00
Jonathan Hui a57445cca1 [nexus] add test 1.2.LP.5.3.6 for SSED to MED transition (#12610)
This commit adds Nexus test case 1.2.LP.5.3.6, which validates that a
Router can support a child transitioning from a Synchronized Sleepy
End Device (SSED) to a Minimal End Device (MED) and back.

The test procedure involves:
- Forming a network with a Leader, DUT (Router), and SSED child.
- Verifying SSED attachment and initial CSL-based connectivity.
- Transitioning the child to MED mode and verifying the corresponding
  MLE Child Update exchange and connectivity.
- Transitioning the child back to SSED mode and verifying that CSL
  synchronization is resumed.

Changes:
- Implement tests/nexus/test_1_2_LP_5_3_6.cpp for test execution.
- Implement tests/nexus/verify_1_2_LP_5_3_6.py for pcap verification,
  with logic to distinguish between synchronization and polling Data
  Requests.
- Update tests/nexus/CMakeLists.txt to include the new test.
- Update tests/nexus/run_nexus_tests.sh to add the test to the default
  test list.
2026-03-04 22:09:58 -06:00
Jonathan Hui 858ad199c0 [nexus] add test 1.2.LP.5.3.5 for minimum SSED support (#12607)
This commit adds Nexus test 1.2.LP.5.3.5 to verify that a Router (DUT)
can reliably support a minimum of 6 Synchronized Sleepy End Device
(SSED) children simultaneously, with each child operating on a
distinct CSL channel.

The test implementation in test_1_2_LP_5_3_5.cpp (aligned with SPEC
Section 3.2.6.3.2) performs the following:
- Establishes a topology with a Leader, the DUT Router, and six SSED
  children.
- Configures SSEDs with varied CSL Synchronized Timeouts (10s, 20s,
  and 30s) and different radio channels, including primary (11),
  secondary (26), and random channels (12-15).
- Triggers CSL synchronization through MLE Child ID and Child Update
  exchanges.
- Validates bi-directional connectivity by sending ICMPv6 Echo
  Requests from the Leader to each SSED, ensuring they are correctly
  forwarded by the DUT.

The verification script verify_1_2_LP_5_3_5.py automates packet-level
checks, ensuring:
- Successful delivery of MLE Child ID and Child Update Response
  messages from the DUT.
- Correct radio channel selection for forwarded Echo Requests to
  SSED_1 and SSED_6.
- Absence of MAC Data Requests from SSED_1 prior to the arrival of
  the CSL-probed Echo Request, confirming active synchronization.
- Inclusion of CSL Period and Phase IEs in the 802.15.4 frame headers
  of Echo Replies from SSED_1 and SSED_6.
- Reliable forwarding of Echo Replies from all six SSEDs back to
  the Leader.

Changes also include registering the new test in CMakeLists.txt and
run_nexus_tests.sh.
2026-03-04 19:29:11 -06:00
Jonathan Hui e57dc6778a [gemini] add configuration for Gemini code review (#12619)
This commit adds the .gemini/config.yaml file to configure the Gemini
code review tool. The configuration includes settings for review
severity, comment limits, and automated review triggers for pull
requests.
2026-03-04 19:29:00 -06:00
Jonathan Hui 187b64a462 [nexus] fix race condition in test 1.1.7.1.4 verification (#12620)
The packet verification script for Nexus test 1.1.7.1.4 failed
sporadically because Step 5 (ROUTER_1 multicast MLE Data Response)
was being searched starting from the cursor position after Step 4
(Leader's MLE Data Response and CoAP ACK).

Depending on the timing/non-determinism from entropy, ROUTER_1's
response could arrive before the Leader's packets, causing it to
be skipped when searching from the Step 4 cursor.

This change saves the cursor position after Step 3 and uses it as
the starting point for the Step 5 search, ensuring the packet is
found regardless of its order relative to the Step 4 packets.
2026-03-04 19:28:39 -06:00
Jonathan Hui 67e8cfd31b [nexus] fix flakiness in test 1.1.6.1.4 (#12617)
This commit fixes an occasional failure in Nexus test 1.1.6.1.4
by introducing a controlled delay during the DUT attachment
process.

The test ensures the DUT picks a REED with better connectivity
as its parent. The failure was caused by a race condition where
the intended parent (router3) could upgrade from REED to active
router before the DUT completed its parent selection. This
resulted in the DUT attaching during the first Parent Request
(active routers only), rather than the second request (including
REEDs), which is required for specification compliance.

Changes:
- Added kParentSelectionTime constant (2000ms) to define the
  expected parent selection window.
- Updated test_1_1_6_1_4.cpp to use AdvanceTime() with this
  constant before allowing router3 to upgrade. This ensures
  router3 remains a REED long enough for the DUT to send the
  multicast Parent Request with the REED scan mask.
2026-03-04 17:41:43 -06:00
Jonathan Hui 6ea7f24e1c [nexus] add test 1.2.LP.5.3.4 for SSED CSL synchronization (#12606)
This commit adds Nexus test case 1.2.LP.5.3.4, which validates that a
Router (DUT) maintains a robust CSL connection with a Synchronized
Sleepy End Device (SSED) even when the SSED modifies its CSL Period.

The test verifies synchronization over multiple CSL period changes:
500ms -> 3300ms -> 400ms.

Changes:
- Added CSL period constants (500ms, 3300ms, 400ms) to shared utility
  modules: tests/nexus/verify_utils.py (Python) and
  tests/nexus/platform/nexus_utils.hpp (C++).
- Implemented tests/nexus/test_1_2_LP_5_3_4.cpp to execute the test
  procedure, including topology formation, SSED attachment, and
  triggering CSL period updates.
- Implemented tests/nexus/verify_1_2_LP_5_3_4.py to validate pcap
  output, ensuring the DUT correctly buffers and relays ICMPv6 Echo
  Requests and that SSED_1 does not send MAC Data Requests.
- Updated tests/nexus/CMakeLists.txt and tests/nexus/run_nexus_tests.sh
  to integrate the new test into the build system and test runner.
2026-03-04 17:30:39 -06:00
Jonathan Hui 2e8443e4f6 [nexus] implement test 1.2.LP.5.3.3 for SSED unsynchronization (#12605)
This commit implements Nexus test 1.2.LP.5.3.3, which validates the
behavior when a Synchronized Sleepy End Device (SSED) becomes
unsynchronized.

The test verifies that:
- When a SSED is CSL synchronized, the parent (DUT) relays frames
  using CSL transmission.
- When the SSED stops sending synchronization data polls and the CSL
  connection times out, the parent falls back to indirect
  transmission (buffering and waiting for a Data Request).
- Once the SSED resumes synchronization, the parent returns to using
  CSL transmission.

Changes:
- Add test_1_2_LP_5_3_3.cpp to implement the test logic using the
  Nexus simulation platform.
- Add verify_1_2_LP_5_3_3.py for automated packet verification,
  ensuring frames are sent via CSL or indirect transmission as
  appropriate.
- Register the new test in tests/nexus/CMakeLists.txt.
- Add the test to the default test list in
  tests/nexus/run_nexus_tests.sh.
2026-03-04 15:46:15 -06:00
Abtin Keshavarzian 26a9d6da3f [coap] rename message setup methods to use AllocateAndInit prefix (#12613)
This commit updates the names of several message allocation methods in
`CoapBase` to `AllocateAndInit*()`. This change helps to clearly
differentiate these methods from the `NewPriorityMessage()` and
`NetMessage()` overloads, which only allocate a new `Message`.

In contrast, the `AllocateAndInit` methods allocate the message and
fully prepare it by initializing the CoAP header, appending the URI
path option, the payload marker, leaving it ready for the payload.
This change clarifies the design by explicitly indicating that these
methods perform extra setup work.

All calls to these methods throughout the codebase have been updated
to reflect the new names.
2026-03-04 15:25:41 -06:00
Abtin Keshavarzian 1f6e339a9a [time] add DetermineRemainingDurationFrom() helper (#12608)
This commit introduces `DetermineRemainingDurationFrom(Time aNow)` to
the `Time` class. This method calculates the duration from a given
current time (`aNow`) to the `Time` instance, handling edge cases
where the target time is in the past by returning zero.

Several instances across the codebase (e.g., `Timer::Scheduler`,
`TcatAgent`, `Translator::Mapping`, `Srp::Server`) previously
duplicated this logic using manual checks and subtraction. They have
been updated to use this new centralized helper, improving
readability and reducing the likelihood of wrap-around or negative
duration bugs.
2026-03-04 15:23:52 -06:00
Jonathan Hui 15645d3799 [nexus] add test 1.2.LP.5.3.2 for CSL synchronized communication (#12604)
This commit adds Nexus test 1.2.LP.5.3.2 to validate that a Router
(DUT) can maintain a CSL connection with a Synchronized Sleepy End
Device (SSED) using various message types to trigger synchronization.

Changes:
- Implemented test_1_2_LP_5_3_2.cpp to simulate the topology of
  Leader, Router (DUT), and SSED.
- Added descriptive constants (kMsPerSecond, kUsPerMs, kEchoId,
  kCslWaitMultiplier) to test_1_2_LP_5_3_2.cpp to replace magic
  numbers.
- Implemented verify_1_2_LP_5_3_2.py for pcap-based verification of
  IEEE 802.15.4-2015 frames, CSL Information Elements, and timers.
- Updated test_1_2_LP_5_3_1.cpp to set CSL period and timeout
  explicitly using stack APIs instead of the removed kAsSsed mode.
- Removed kAsSsed JoinMode from Nexus::Node in favor of explicit
  CSL parameter configuration within test files.
- Added wpan.header_ie.csl.phase to verify_utils.py field mappings.
- Included the new test in CMakeLists.txt and run_nexus_tests.sh.
2026-03-04 14:07:43 -06:00
Jonathan Hui 49582b3d9f [nexus] refactor test 1.2.LP.5.3.1 and remove kAsSsed mode (#12615)
This commit refactors Nexus test 1.2.LP.5.3.1 to better align with
the specification and improves the robustness of the test logic and
verification script. It also removes the kAsSsed join mode to favor
explicit CSL configuration in tests.

Changes:
- Removed kAsSsed from Nexus::Node::JoinMode and Node::Join() to
  encourage tests to manage CSL parameters explicitly.
- Updated test_1_2_LP_5_3_1.cpp to join as a regular SED first and
  enable CSL after attachment. This matches the specification's
  requirement to establish synchronization via Child Update Request.
- Introduced constants in test_1_2_LP_5_3_1.cpp for CSL period,
  synchronization time, and other parameters to avoid magic numbers.
- Enhanced verify_1_2_LP_5_3_1.py with comprehensive checks for:
    - MLE Child Update Request/Response exchange.
    - IEEE 802.15.4-2015 frame versions.
    - ICMPv6 Echo Request/Response forwarding through the Leader.
    - Absence of MAC Data Requests after CSL synchronization.
- Fixed an issue in verify_1_2_LP_5_3_1.py where packet numbers
  were not correctly handled in pkts.range().
2026-03-04 12:04:56 -06:00
Abtin Keshavarzian 01d75f730f [pool] extract PoolBase and add ConfigPool (#12596)
This commit updates the object pool implementation to support dynamically
configured pool sizes without penalizing the memory footprint of
existing static usages.

A new `PoolBase` class is introduced to encapsulate the core linked-list
management logic (`Allocate()` and `Free()`), relying on a shared
`mFreeList`.

The existing `Pool` class is updated to inherit from `PoolBase`. It
retains its statically allocated `mPool` array, ensuring zero code-size
or RAM penalty for current users of fixed-size pools.

A new `ConfigPool` class is added, also inheriting from `PoolBase`.
This class allows a pool to be initialized at run-time with an
externally provided memory buffer (`mEntryArray`) and size
(`mNumEntries`). This enables future use cases where memory allocation
for pools can be provided dynamically by the system integrator.

This commit also includes unit tests for `ConfigPool` to verify its
allocation, deallocation, and initialization behavior.
2026-03-04 00:40:13 -06:00
Jonathan Hui e5169ea810 [nexus] add test 1.2.LP.5.3.1 for SSED attachment (#12594)
This commit adds a new Nexus test case 1.2.LP.5.3.1 which validates
SSED attachment and CSL synchronization.

Changes:
- Added kAsSsed JoinMode to Nexus::Node platform to support joining
  as a Synchronized Sleepy End Device with default CSL parameters.
- Implemented test_1_2_LP_5_3_1.cpp following the test specification
  for SSED attachment.
- Implemented verify_1_2_LP_5_3_1.py to verify pcap output, ensuring
  correct use of 802.15.4-2015 frames and CSL synchronization.
- Updated CMakeLists.txt and run_nexus_tests.sh to include the new
  test in the Nexus test suite.
2026-03-03 18:05:15 -06:00
Jonathan Hui 202d5df96d [nexus] implement CSL transmitter and receiver (#12595)
This commit implements CSL transmitter and receiver functionality in
the Nexus simulation platform. It enables the necessary OpenThread
configurations and provides the platform-level support for CSL.

It also implements the otPlatRadioGetNow platform API to provide a
high-resolution 64-bit microsecond time base, which is required for
accurate CSL timing and synchronization.

Changes:
- Added GetNowMicro64() to Nexus::Core to expose the raw 64-bit
  microsecond timer.
- Implemented otPlatRadioGetNow() in nexus_radio.cpp.
- Enabled OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE and
  OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE in Nexus config.
- Added otRadioContext to Nexus::Radio to track CSL parameters and
  manage security material for radio operations.
- Implemented otPlatRadioEnableCsl, otPlatRadioResetCsl,
  otPlatRadioUpdateCslSampleTime, and otPlatRadioGetCslAccuracy.
- Implemented otPlatRadioSetMacKey, otPlatRadioSetMacFrameCounter,
  and otPlatRadioSetAlternateShortAddress to keep radio context
  synchronized with OpenThread stack.
- Updated otPlatRadioSetExtendedAddress and otPlatRadioEnableCsl to
  use AsCoreType for better readability and project conventions.
- Moved Radio member initializations to the initializer list in its
  constructor.
- Refactored radio SFD processing: moved otMacFrameProcessTxSfd and
  UpdateFcs from otPlatRadioTransmit (radio platform) to
  Core::ProcessRadio (simulation engine), ensuring CSL IEs and
  security headers are updated exactly when transmission starts.
- Enhanced Nexus::Core::ProcessRadio to support generating Enhanced
  ACKs with CSL IEs for 802.15.4-2015 frames.
- Updated Nexus and fuzz build systems to include necessary Nexus
  platform and utils headers/utilities.
2026-03-03 15:32:05 -06:00
Jonathan Hui 26bcc07b31 [mac] fix infinite loop in GetHeaderIe() and GetThreadIe() (#12598)
This commit addresses a timeout issue reported by a fuzzer when
processing MAC frames with malformed Header IEs.

Specifically:
- In `FindPayloadIndex()`, added validation to ensure the returned
  index does not exceed `kMaxPsduSize` (254). If the index exceeds
  this value, it now returns `kInvalidIndex` (255). This prevents
  callers from experiencing wrap-around issues when they cast the
  result to `uint8_t`.
- In `GetHeaderIe()` and `GetThreadIe()`, changed the `index` and
  `payloadIndex` variables from `uint8_t` to `uint16_t`. This
  ensures that any increment during the loop does not wrap around,
  which was a primary cause of the infinite loop.
- Updated the loop condition from `index <= payloadIndex` to
  `index < payloadIndex`. Since `payloadIndex` points to the start
  of the payload (the byte after the last Header IE), a strict
  less-than comparison is correct and prevents the loop from
  attempting to parse the payload itself as a Header IE.

These changes ensure robust parsing of IEEE 802.15.4 frames, even
when they contain unexpected or malformed Information Elements.
2026-03-03 13:44:48 -06:00
Jonathan Hui 43d0022bd8 Revert "github-actions: bump nttld/setup-ndk from 1.5.0 to 1.6.0 (#12591)" (#12601)
This reverts commit 5ec1e40578.
2026-03-03 11:46:01 -06:00
dependabot[bot] 5ec1e40578 github-actions: bump nttld/setup-ndk from 1.5.0 to 1.6.0 (#12591)
Bumps [nttld/setup-ndk](https://github.com/nttld/setup-ndk) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/nttld/setup-ndk/releases)
- [Commits](https://github.com/nttld/setup-ndk/compare/afb4c9964b521afb97c864b7d40b11e6911bd410...ed92fe6cadad69be94a966a7ee3271275e62f779)

---
updated-dependencies:
- dependency-name: nttld/setup-ndk
  dependency-version: 1.6.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-03-02 20:59:01 -06:00
Abtin Keshavarzian cf1d23c11e [cli] add lease info to srp server host and srp server service (#12589)
This commit adds lease and remaining lease information to the output
of `srp server host` and `srp server service` CLI commands.

The information includes:
- `lease`: The total lease time in seconds.
- `key-lease`: The total key lease time in seconds.
- `remaining lease`: The remaining lease time in seconds (with
  millisecond precision).
- `remaining key-lease`: The remaining key lease time in seconds
  (with millisecond precision).

A new utility method `OutputMsecDurationInSec()` is added to `Utils`
class to format durations in milliseconds as seconds with a
fractional part.

The SRP server host and service output parsers in
`tests/scripts/thread-cert/node.py`, `tests/toranj/cli/cli.py`, and
`tools/otci/otci/otci.py` are updated to correctly handle the new
fields for both active and deleted entries.
2026-03-02 20:03:14 -06:00
Jonathan Hui d5b5f863d7 [nexus] fix occasional failures in test 1.1.9.2.9 (#12592)
This commit addresses occasional failures in Nexus Test 1.1.9.2.9 by:

1. Increasing the wait time in Step 10 from 60s to 200s
   (kAttachToRouterTime). This ensures Router 1 has enough time to
   upgrade from a child to a router role after attaching to the new
   partition formed by Router 2. The upgrade jitter can be up to 120s,
   so the previous 60s wait was insufficient. An explicit check for the
   Router role is also added.

2. Refactoring the verification script to handle out-of-order MLE
   packets. Some steps involve a multicast response and a triggered
   unicast request/response. The relative order of these packets is not
   guaranteed in the simulation. Using save_index() and a new helper
   function _verify_packet_in_group() allows searching for all required
   packets from the same base index within a group while reducing code
   duplication.

3. Improving the logic to advance the packet index after verifying a
   group of out-of-order packets. The script now tracks the maximum
   index found among all verified packets in a group to ensure no
   packets are skipped in subsequent searches.

These changes make the test robust against timing variations and
jitter in the simulated environment.
2026-03-02 19:48:15 -06:00
Abtin Keshavarzian 9d3852db4f [nexus] add test_srp_lease to validate SRP client/server interactions (#12588)
This commit adds a new Nexus test `test_srp_lease` to verify the
behavior of the SRP server and client regarding lease expirations and
state updates. The test creates a network with an SRP server and
multiple client nodes that randomly perform various SRP operations
including registering, updating, unregistering, and removing services,
as well as abruptly disconnecting. The test then validates that the
SRP server correctly updates the host and service states, such as
marking them as deleted or fully removing them when their leases
expire or when explicitly requested by the clients.
2026-03-02 18:10:34 -06:00
Abtin Keshavarzian 9682126aab [mac] move key material update to Init() (#12590)
This commit introduces an `Init()` method to the `Mac` class and
moves the invocation of `KeyManager::UpdateKeyMaterial()` from the
`Mac` constructor into this new method. `Mac::Init()` is then called
from `Instance::AfterInit()`, immediately after `KeyManager` is
initialized.

This ensures that `KeyManager` and other OpenThread core components
are fully constructed and properly initialized before attempting to
update the key material. The key material update interacts with
`SubMac` to configure the MAC keys. Performing this operation during
the `Mac` constructor phase can be problematic because the `KeyManager`
(under `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE`) may not be
fully initialized and ready yet.
2026-03-02 13:30:30 -06:00
Esko Dijk 07e79ba539 [cli][tcat] initialize TCAT from CLI with proper vendor app URL and fix TLV status to 'Unsupported' (#12340)
This updates the TCAT CLI to use the configured 'vendor app URL' by default as the
TCAT Provisioning URL, instead of a dummy value. It also updates the max length of
this URL to the configured vendor app URL max length as agreed by JIRA BHC-769.
Also 2 related minor validation fixes in TCAT agent code.

Furthermore, the Get Provisioning URL TLV TCAT command is fixed to return status 'Unsupported'
in case the URL is not configured (null or zero-length), to comply to the spec.
2026-03-02 12:34:32 -06:00
Abtin Keshavarzian 624634371e [srp-server] fix possible aHost memory leak when granted lease is zero (#12587)
This commit fixes a potential memory leak of the allocated `aHost`
object in `Server::CommitSrpUpdate()`.

Previously, when the granted key lease was zero (indicating a request
to remove the host), the code used `VerifyOrExit(existingHost != nullptr)`
before calling `aHost.Free()`. If `existingHost` was null (e.g., when
receiving a request to remove a non-existent host), the function
would exit early and skip freeing `aHost`, causing a memory leak.

This is updated to always call `aHost.Free()` when `grantedKeyLease`
is zero, ensuring the memory is freed regardless of whether
`existingHost` is null or not.
2026-03-02 12:05:38 -06:00
Abtin Keshavarzian f23519e531 [border-agent] add vendor name and model to advertised TXT data (#12578)
This commit updates `BorderAgent` to parse the provided extra vendor
TXT data (`otBorderAgentSetVendorTxtData()`) to check if the vendor
name (`vn`) and model (`mn`) keys are already present. If they are
absent, it would use and encode the values from `VendorInfo` into the
advertised TXT data. This harmonizes the use of `VendorInfo` values
across various modules, network diagnostics, and the `BorderAgent`
TXT data.

Note that this change only impacts the system when
`OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_ENABLE` is enabled,
meaning the Border Agent itself directly manages the registration and
updating of the mDNS MeshCoP service.

The generated TXT data from `otBorderAgentGetMeshCoPServiceTxtData()`
remains unchanged. This API is intended for use cases where the
next-layer code manages the publishing of the mDNS MeshCoP service,
and as documented, the TXT data from this API does not include any
vendor-specific information.

This commit updates `test_border_agent` to validate the newly
added behavior.
2026-03-02 12:04:08 -06:00
Abtin Keshavarzian 3289054650 [netif] consolidate multicast address tracking and MLR states (#12576)
This commit simplifies multicast address management within `Netif` by
merging the `ExternalMulticastAddress` class directly into the base
`MulticastAddress` class. The `otNetifMulticastAddress` structure is
updated to include `mAddressOrigin` and an opaque `mData` field.

The `mData` field is utilized to track the Multicast Listener
Registration (MLR) state when the `OPENTHREAD_CONFIG_MLR_ENABLE`
feature is enabled.

By consolidating these types, we eliminate the need for separate
internal and external multicast address iteration logic in
`MlrManager`, streamlining MLR subscription checks and updates.
Additionally, this provides a more unified way to track the origin of
multicast addresses natively.
2026-03-02 12:02:32 -06:00
Jonathan Hui 4866887933 [nexus] implement microsecond alarm platform APIs (#12580)
This commit implements the otPlatAlarmMicro* platform APIs in the
Nexus simulation environment. It also transitions the simulation's
internal time base from millisecond to microsecond granularity to
ensure that both millisecond and microsecond alarms operate on a
consistent and shared time reference.

Changes include:
- Enabled OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE in Nexus config.
- Updated Nexus::Core to use a 64-bit microsecond time base (mNow).
- Implemented otPlatAlarmMicroGetNow, otPlatAlarmMicroStartAt, and
  otPlatAlarmMicroStop.
- Refactored Nexus::Node to support separate millisecond and
  microsecond alarm instances (mAlarmMilli and mAlarmMicro).
- Updated radio timestamps and PCAP logging to use the new high-
  resolution microsecond time base.
- Adjusted simulation time advancement and alarm triggering logic to
  handle both alarm types correctly.
2026-03-02 11:31:27 -06:00
Jonathan Hui 709217aa8a [nexus] support channel-based pcap filtering in verification (#12586)
This commit enables channel-based filtering in Nexus simulation tests
by exporting node channel information and enhancing the pktverify
library to extract and use it.

Simulation Core:
- Export each node's PAN channel to the test JSON metadata in
  nexus_core.cpp.

Pktverify Library:
- Update packet.py to extract channel information from 'wpan-tap' or
  'wpan_tap' layers and normalize it into 'wpan.channel'.
- Update consts.py and layer_fields.py to support the new TAP layers
  and their channel fields.
- Enhance NullField to be callable and iterable, and update Bytes
  comparison to handle NullField, preventing script crashes when
  accessing missing layers or fields.

Verification Utilities:
- Automatically load channel information from test JSON into
  verification variables (e.g., {NODE_NAME}_CHANNEL).

Test Updates:
- Stabilize 1.1.9.2.14 by using channel-based filtering instead of
  relying solely on RLOC16s.
- Update 1.1.9.2.17 and 1.1.9.2.8 to use the normalized
  'wpan.channel' field instead of direct 'wpan_tap' access.
2026-02-28 21:15:00 -06:00
Jonathan Hui c9a153bdd8 [nexus] fix intermittent failure by initializing MeshCoP::Timestamp (#12581)
The MeshCoP::Timestamp class does not have a default constructor that
clears its members. When a Timestamp object is declared on the stack,
its members (seconds, ticks, and authoritative bit) contain garbage.

The SetSeconds() and SetTicks() methods only update their respective
fields and do not touch the authoritative bit. If the authoritative
bit happens to be set from stack garbage, the timestamp may be
incorrectly considered greater than another valid timestamp.

This caused intermittent failures in Nexus test 1.1.9.2.4 and others,
where a MGMT_ACTIVE_SET.req with an old timestamp was incorrectly
accepted by the Leader instead of being rejected.

This commit adds explicit Clear() calls to all MeshCoP::Timestamp
declarations in the affected Nexus tests to ensure they are properly
initialized.
2026-02-28 21:14:36 -06:00
Abtin Keshavarzian d0237f5e91 [dns] add MatchesKey() to Dns::TxtEntry (#12579)
This commit adds `MatchesKey()` method to `Dns::TxtEntry` class to
check if the entry's key matches a given key string using a
case-insensitive string comparison.

The new method properly handles the case where the entry's key is
`nullptr` (which can happen when the key is longer than the
recommended max length). It simplifies the TXT entry parsing logic in
`BorderAgent` and `Trel::PeerDiscoverer`.

The unit tests for `Dns::TxtEntry` are also updated to verify the new
method.
2026-02-27 18:55:35 -06:00
Abtin Keshavarzian be4ce643ec [dns] make name compression per-instance and enforce mDNS check (#12538)
This commit updates the DNS name compression setting to be a
per-instance property rather than a global static variable.

The `otDnsSetNameCompressionEnabled()` and
`otDnsIsNameCompressionEnabled()` C APIs are updated to take an
`otInstance` pointer. Internally, the `Instance` class now uses the
`mDnsNameCompressionEnabled` member variable instead of the static
`sDnsNameCompressionEnabled`.

Additionally, this commit enforces that DNS name compression cannot
be disabled when the OpenThread mDNS module is active. The
`otDnsSetNameCompressionEnabled()` function now returns an `otError`
and will return `OT_ERROR_NOT_CAPABLE` if a user attempts to disable
compression while mDNS is enabled. When the mDNS module is enabled,
it automatically sets name compression to true.

The CLI command and related documentation are updated to reflect
these changes.
2026-02-27 18:54:57 -06:00
Abtin Keshavarzian 05ef3b4d04 [coap] reorganize CoapBase::PendingRequests methods (#12577)
This commit moves all methods belonging to the `CoapBase::PendingRequests`
class into a dedicated section in `coap.cpp`. Recent PRs #12421 and #12527
introduced this class and shifted many methods into it, but kept them in
their original file locations to maintain reviewable `git` diffs. This
update completes the reorganization for better code structure without
any functional changes.
2026-02-26 23:25:04 -06:00
Tongze Wang 69fffdb52d [backtrace] add otSysRegisterCrashCallback to register crash callback function (#12552)
This commit adds `otSysRegisterCrashCallback` function which can be used
to register the callback function to be called when openthread crashes.
2026-02-26 23:22:46 -06:00
Jonathan Hui 425adf50f1 [nexus] add '1_1' prefix to nexus test filenames (#12569)
This commit renames all nexus test files and updates corresponding
configuration and source files to include a '1_1_' prefix.

The '1_1' prefix represents the Thread 1.1 test plan. This change
prepares the nexus test suite for the addition of tests from the
Thread 1.2, 1.3, and 1.4 test plans, ensuring a clear and organized
structure for multi-version specification testing.

Changes include:
- Renaming test_<num>.cpp to test_1_1_<num>.cpp.
- Renaming verify_<num>.py to verify_1_1_<num>.py.
- Updating CMakeLists.txt to reflect new test names.
- Updating run_nexus_tests.sh for default tests and variants.
- Updating hardcoded JSON output filenames in C++ test sources.
- Updating testcase name identification in Python verification
  scripts.
2026-02-26 22:31:05 -06:00
Esko Dijk bf23405ca7 [cli] CoAP blockwise PUT/POST to send Block1 option in final response (#12568)
This fixes the issue that the CLI CoAP server application was not
sending a Block1 option in its final 2.04 response for PUT/POST
methods. The CoAP CLI code is restructured to be more generic,
i.e. allow for NON-confirmable blockwise transfers as well as prepare
for a (future) update that supports the use of Block1/Block2
simultaneously in a POST transaction. Current code is updated to send
5.01 Not Implemented in case an (external) CoAP client would attempt
POST with both Block options together.

The number of returned blocks for this (demo) CLI is also raised to 3,
the minimum to see a start block, middle block and final block; which
is more useful for testing.

Closes #12559
2026-02-26 19:25:24 -06:00
Jonathan Hui 7c88bc716d [nexus] improve robustness of MLE and WPAN packet verification (#12571)
This commit addresses several issues in the Nexus verification scripts
to improve test reliability and prevent runtime errors.

- Fixed a TypeError caused by NullField in MLE command checks. When
  p.mle.cmd returns a NullField, it is unhashable and fails when checked
  against a set or list (e.g., 'p.mle.cmd in { ... }'). A truthiness
  check for p.mle.cmd was added to verify_5_6_4.py, verify_5_6_5.py,
  verify_6_2_2.py, and verify_7_1_5.py.

- Improved verify_6_2_2.py robustness:
  - Wrapped must_not_next() checks within 'with pkts.save_index()' to
    ensure the packet iterator remains at the correct position after
    verifying the absence of specific messages.
  - Refactored MLE command filtering into a helper function for better
    readability and consistency.
  - Updated connectivity checks to allow filtering by ROUTER_1_RLOC16
    and specifically look for WPAN Data Requests.

- Cleaned up verify_5_6_4.py by replacing the explicit 'nullField'
  comparison with a more idiomatic truthiness check.
2026-02-26 15:56:40 -06:00
Jonathan Hui 25761fb234 [nexus] improve robustness of test 9.2.6 verification (#12575)
This commit addresses an intermittent failure in Nexus test 9.2.6
where Step 18 (MGMT_PENDING_SET.req) was occasionally not found.

The failure occurred because the verification script started
searching for the MGMT_PENDING_SET.req packet from index12. In the
simulated Nexus environment, packet capture order from different
nodes can occasionally vary slightly when events occur at nearly
the same simulation time.

The fix expands the search range by starting from index9 (the
Leader's initial update), ensuring that the MGMT_PENDING_SET.req
packet is correctly identified regardless of minor capture order
variations. Since the URI is unique to this part of the test, this
remains a precise filter.

Additionally, this change ensures the global packet index moves
forward correctly by taking the maximum of all relevant child
filter indices.
2026-02-26 15:49:40 -06:00
Abtin Keshavarzian f03cecdff6 [tmf] introduce specialized SendMessageTo() methods in Tmf::Agent (#12548)
This commit introduces new helper methods in the `Tmf::Agent` class
(`SendMessageTo()`, `SendMessageToRloc()`, `SendMessageToLeaderAloc()`,
and `SendMessageAllowMulticastLoop()`) to simplify the transmission of
TMF messages.

Previously, callers of `Tmf::Agent::SendMessage()` were required to
manually configure a `Tmf::MessageInfo` object with the appropriate
socket and peer address information before sending a message. This led
to repetitive code across the various modules utilizing TMF.

By incorporating these address resolution and message info preparation
steps directly into `Tmf::Agent`, this change significantly reduces
boilerplate code. All existing calls to `SendMessage()` have been
updated to use the new flavors.
2026-02-26 15:26:45 -06:00
Jonathan Hui 3ea2dbe146 [nexus] increase merge wait time in test 5.5.4.1 (#12574)
This commit increases the kMergeWaitTime from 300 to 350 seconds in
Nexus test 5.5.4.1.

Detailed analysis of debug logs during intermittent failures showed
that the MLE partition merge process could take up to 250 seconds in
some scenarios, leaving very little margin with the previous 300-second
timeout. Increasing the timeout to 350 seconds provides a more robust
buffer for the network to stabilize and for partitions to merge before
the final connectivity verification.

The fix was verified by running 200 consecutive iterations of the test
without any failures.
2026-02-26 14:20:18 -06:00
Jonathan Hui f53b16472f [nexus] fix intermittent failure in test 5.6.6 (#12573)
This commit fixes an intermittent failure in Nexus test 5.6.6 by ensuring
that the OnMeshPrefixConfig object is properly initialized before use.

The OnMeshPrefixConfig object is declared on the stack and, if not
explicitly cleared, may contain garbage values in its bit-fields (such
as mDhcp or mPreference). This can cause the subsequent call to
AddOnMeshPrefix() to fail its IsValid() check, resulting in a
kErrorInvalidArgs error and a test failure.

Changes:
- Call config.Clear() after declaring the OnMeshPrefixConfig object
  in tests/nexus/test_5_6_6.cpp to ensure all fields are initialized
  to zero.

This aligns the test implementation with other Nexus tests and improves
the robustness of the test suite in simulation environments.

Verified to pass in the Nexus simulation environment.
2026-02-26 14:00:57 -06:00
Jonathan Hui a7c051f07a [tests] remove migrated thread-cert scripts (#12566)
This commit removes the certification test scripts in
tests/scripts/thread-cert/ that have been successfully migrated to
the Nexus test framework.

The following tests were migrated and are now available as Nexus
tests under tests/nexus/:
- 5.8.2, 5.8.3, 5.8.4
- 9.2.1 through 9.2.19

Migrating these tests to Nexus provides faster execution, better
reliability, and easier debugging compared to the old
simulation-based scripts.
2026-02-26 13:13:31 -06:00
Jonathan Hui bc4228286a [nexus] fix intermittent failure in test 9.2.14 (#12570)
This commit fixes an intermittent failure in Nexus test 9.2.14 caused by RLOC16 conflicts between independent partitions in the simulation.

When two independent partitions occasionally share the same RLOC16, the packet verification script could incorrectly match a MGMT_PANID_CONFLICT response from the wrong network, leading to out-of-order matching and PacketNotFound errors.

The fix adds a filter to the MGMT_PANID_CONFLICT verification steps to ensure the Channel Mask TLV matches the specific conflict being reported (Channel 20). This uniquely identifies the correct packet even if RLOC16s overlap.

Implementation details:
- tests/nexus/verify_9_2_14.py: Added filtering for the exact Channel Mask TLV value using a defined `CONFLICTING_CHANNEL_MASK` bytes constant in Step 3 and 5.
- Fixed a type mismatch by converting the constant to a `bytes` object and added documentation for the big-endian channel bitmask mapping.

The fix has been verified with 200 successful test runs in the Nexus simulation environment.
2026-02-26 13:12:39 -06:00
Abtin Keshavarzian 993cd25b8b [netdata-publisher] remove entry immediately when desired num is zero (#12550)
Update `Publisher::Entry::UpdateState()` to support quickly removing
a published entry when the desired number of entries is explicitly
set to zero. In this case, we bypass the random removal delay and
remove the entry immediately. This situation helps with SRP/DNS
unicast entries, where if any service data unicast or anycast entry
is seen, we set the desired number to zero and want to quickly
remove any previously added server data unicast entry.
2026-02-26 12:52:17 -06:00
Jonathan Hui 41d55e6976 [nexus] add test 9.2.12 Merging on Different Channels and PAN IDs (#12549)
This commit adds Nexus test case 9.2.12 which verifies that networks
on different channels and having different PAN IDs can merge using
the MLE Announce command.

Implementation details:
- tests/nexus/test_9_2_12.cpp: C++ test execution logic. Implements
  the 9.2.12 spec using direct core calls. Configures two distinct
  partitions with different PAN IDs and channels, then triggers
  an MLE Announce process via the Commissioner to merge them.
- tests/nexus/verify_9_2_12.py: PCAP verification script. Verifies
  MGMT_ANNOUNCE_BEGIN.ntf, multi-channel MLE Announces, and MLE
  Child ID Requests during re-attachment. Includes verification of
  MLE layer security and Key Identifier Mode for Announce messages.
- tests/nexus/verify_utils.py: Added support for MLE auxiliary
  security header fields in pktverify.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_12 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_12 to default test list.
2026-02-26 12:32:19 -06:00
Jonathan Hui fd9fc518ea [nexus] add test 9.2.19 and improve IPv6 verification (#12565)
This commit adds Nexus test case 9.2.19 which verifies that the DUT
can properly get Pending Operational Dataset parameters using the
MGMT_PENDING_GET.req command.

It also addresses review comments and improves the robustness of IPv6
address verification across several Nexus tests.

Implementation details:
- tests/nexus/test_9_2_19.cpp: Implemented the test procedure. Fixed
  incorrectly escaped newline characters.
- tests/nexus/test_9_2_3.cpp: Fixed incorrectly escaped newline
  characters.
- tests/nexus/verify_utils.py: Added a robust helper function
  'is_leader_aloc_or_rloc' using the 'ipaddress' module to identify
  Leader ALOC and RLOC addresses by their IID.
- tests/nexus/verify_9_2_19.py, tests/nexus/verify_9_2_3.py,
  tests/nexus/verify_9_2_5.py: Replaced fragile string-slicing and
  duplicated code with the shared helper in 'verify_utils.py'.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_19 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_19 to the test list.

The tests have been verified to pass in the Nexus simulation
environment.
2026-02-26 01:08:53 -06:00
Jonathan Hui 4a275b365c [nexus] add test 9.2.9 for Pending Dataset synchronization (#12545)
This commit adds Nexus test 9.2.9 which verifies synchronization of
Pending Operational Datasets when two network partitions merge.

The implementation covers:
- Formation of a single partition with Commissioner, Leader, and two
  Routers in a LINE topology.
- Initial Pending Operational Dataset configuration via Commissioner.
- Partition split using RF isolation and subsequent dataset updates
  in both partitions.
- Verification of dataset synchronization (Active and Pending) during
  partition merge per Thread specification 8.4.3.5.
- Validation of network connectivity (ICMPv6 Echo) after synchronization.

Implementation details:
- tests/nexus/test_9_2_9.cpp: C++ test execution logic. Implements the
  36-step test specification using direct core calls. Uses a LINE
  topology and adjusted timing parameters for partition stability.
- tests/nexus/verify_9_2_9.py: Python pcap verification script. Uses
  non-linear searching to handle interleaved post-merge updates and
  detailed TLV-level verification for MLE and CoAP messages.
- tests/nexus/verify_utils.py: Updated meshcop timestamp parsing to
  support multiple occurrences in a single packet.
- tests/nexus/verify_9_2_11.py: Updated to match timestamp parsing
  changes in verify_utils.py.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_9 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_9 to default test list.
2026-02-26 00:12:04 -06:00
Jonathan Hui e8e2c21a9f [nexus] add test 9.2.18 for active timestamp rollback (#12564)
This commit adds a new Nexus test case 9.2.18 that verifies the
rollback of the Active Timestamp via the Pending Operational Dataset
when a new Network Master Key is included.

Changes include:
- Implementation of test 9.2.18 in C++ using direct method calls.
- Implementation of verification script for 9.2.18 in Python.
- Extension of Nexus Core to support exporting multiple network keys.
- Update to verification utilities to handle multiple network keys.
- Addition of test 9.2.18 to the default Nexus test list.
- Fixes to Commissioner and Leader initialization in the Nexus test.
- Addition of AddNetworkKey() to Core to register keys for export.
- Update to SaveTestInfo() to export 'network_keys' list in JSON.
- Robust handling of multiple decryption keys in verify_utils.py.
2026-02-25 23:31:43 -06:00
Yakun Xu ec1eb19656 [spinel] fix wrong arguments for various data types in Logger (#12557)
This commit fixes improper argument usage for SPINEL_DATATYPE_DATA_WLEN_S,
SPINEL_DATATYPE_DATA_S, SPINEL_DATATYPE_EUI64_S, and SPINEL_DATATYPE_UTF8_S
in Logger::LogSpinelFrame.

Key changes:
- Use pointer-to-pointer for data and unsigned int pointer for length
  when using spinel_datatype_unpack with data types.
- Switch to spinel_datatype_unpack_in_place() when unpacking into local
  buffers or structures (e.g., for EUI-64 addresses and MAC keys).
- Remove redundant length arguments for SPINEL_DATATYPE_UTF8_S.
- Refactor SPINEL_PROP_RCP_MAC_KEY to use otMacKey and in-place unpacking.

These fixes prevent potential crashes, stack corruption, and incorrect
data parsing in the Spinel logging utility.
2026-02-25 21:44:29 -06:00
Jonathan Hui 3758ac4b48 [nexus] add test 9.2.17 Orphaned End Devices (#12548) (#12562)
This commit adds Nexus test case 9.2.17 which verifies the behavior of
an orphaned end device as it searches for a new parent using MLE
Announce messages.

Implementation details:
- tests/nexus/test_9_2_17.cpp: C++ test execution logic. Implements the
  3-node topology (Leader_1, Leader_2, ED_1) using direct method calls.
  Manages RF isolation by manipulating the Mac Filter AllowList. Sets
  log level to note. Uses MED mode for the DUT to enable MLE Announce
  behavior. Also explicitly sets the channel mask for Leader_2 for
  robustness.
- tests/nexus/verify_9_2_17.py: PCAP verification script. Verifies
  initial MLE Advertisements on separate channels, DUT sending MLE
  Parent Requests on the primary channel, followed by MLE Announce
  on the secondary channel. Verifies Leader_2 sending MLE Announce on
  the primary channel and DUT successfully attaching to Leader_2.
- tests/nexus/run_nexus_tests.sh: Added 9_2_17 to default test list.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_17 target.
- Included full test specification as inline comments in both C++ and
  Python code.
2026-02-25 21:41:18 -06:00
Yakun Xu 8612d40adf [posix] update mdns-socket to support one-shot multicast DNS queries (#12558)
This commit fixes the problem where OpenThread mDNS responder always
sends responses to port 5353, ignoring the source port of the query.

According to RFC 6762, a mDNS responder should support one-shot
multicast DNS queries by sending the response to the source address
and source port of the query.

Changes:
- Captured the actual source port from incoming queries in Simulation
  and POSIX platforms.
- Updated otPlatMdnsSendUnicast in Simulation platform to use the
  provided destination port.
- Verified that legacy unicast responses correctly cap TTL to 10
  seconds as required by RFC 6762 section 6.7.
2026-02-25 21:34:14 -06:00
Esko Dijk 88db238c50 [coap] clear M flag in Block2 request as required by RFC 7959 (#12563)
Closes #12560
2026-02-25 21:33:22 -06:00
Jonathan Hui 7c9600c4a5 [tests] add Nexus test 9.2.16 for dataset synchronization (#12556)
This commit adds Nexus test 9.2.16 which verifies synchronization of
Active and Pending Operational Datasets between nodes during attach.

The test case implementation covers:
- Formation of a network with Commissioner, Leader, and Router_1.
- Initial attachment of Router_2 (DUT) to synchronization datasets.
- Dataset updates (Pending and Active) via Commissioner while DUT is
  powered down, including PAN ID and Mesh-Local Prefix changes.
- Verification that DUT synchronizes both datasets correctly upon
  reattaching to the network with a new PAN ID.
- Validation of network connectivity (ICMPv6 Echo) after the dataset
  migration and reattachment.

Implementation details:
- tests/nexus/test_9_2_16.cpp: C++ test execution using direct method
  calls. Sets log level to note. Uses AllowList for topology control.
- tests/nexus/verify_9_2_16.py: Python pcap verification script.
  Implements robust filtering for CoAP and MLE messages.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_16 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_16 to default test list.
2026-02-25 20:00:48 -06:00
Jonathan Hui 11cea0697d [nexus] add test 9.2.13 Energy Scan Requests (#12551)
This commit adds Nexus test case 9.2.13 which verifies that the Thread
device properly accepts and processes Energy Scan Requests and sends
the corresponding Energy Scan Reports.

Implementation details:
- tests/nexus/test_9_2_13.cpp: C++ test execution logic. Implements
  the 9.2.13 spec using direct core calls. Manages two separate
  networks (Network 1 on channel 11 and Network 2 on channel 12).
  Configures a topology with Leader, Commissioner, Router, and FED
  nodes in Network 1, and Leader and SED nodes in Network 2.
- tests/nexus/verify_9_2_13.py: PCAP verification script. Verifies
  unicast and multicast MGMT_ED_SCAN.qry messages and the resulting
  MGMT_ED_REPORT.ans responses. Uses strict CoAP URI path and ICMPv6
  type filtering.
- tests/nexus/platform/nexus_core.hpp/cpp: Added an optional leader
  node parameter to SaveTestInfo() to allow specifying which network
  partition information (like Network Key and Mesh-Local Prefix)
  should be exported to the JSON file for verification. This ensures
  correct packet dissection in multi-partition test scenarios.
- tests/nexus/run_nexus_tests.sh: Added 9_2_13 to default test list.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_13 target.
2026-02-25 20:00:30 -06:00
Jonathan Hui 2202fae8a9 [nexus] fix and stabilize test 9.2.7 (#12553)
This commit fixes and stabilizes Nexus test case 9.2.7. It ensures full
compliance with the test specification and improves resilience against
timing variations in the simulated environment.

Changes:
- tests/nexus/test_9_2_7.cpp: Corrected the node sending the pending
  dataset update in Step 11 to the Router, matching the spec. Ensured the
  full Pending Operational Dataset is included in the request. Fixed
  misleading comments regarding timestamp values and ensured Step 11 uses
  a strictly higher active timestamp than Step 5.
- tests/nexus/verify_9_2_7.py: Relaxed delay timer verification slack to
  improve test stability. Added explicit checks for Active and Pending
  Timestamps in multicast MLE Data Responses. Corrected expected timestamp
  values and comments.
2026-02-25 19:49:49 -06:00
Jonathan Hui b354c62821 [nexus] fix flakiness in test 7.1.4 (#12561)
This commit fixes flakiness in Nexus test 7.1.4 by addressing a race
condition in the packet verification script.

The verification logic previously advanced the global packet index
after identifying the Border Router's multicast MLE Data Response.
However, if a child (MED_1) sent its Child Update Request slightly
before the multicast response was processed or captured in that
specific order, the verification script would miss it because the
index had already moved forward.

The fix refactors 'verify_7_1_4.py' to use 'pkts.copy()' for major
verification blocks (Steps 5 through 8). This ensures that each step
searches from a consistent base index, making the verification robust
against variations in packet delivery and capture order.

Additionally, this commit:
- Extracts the duplicated Child Update Request/Response exchange
  logic into a helper function '_verify_child_update_exchange' to
  improve code reuse and maintainability.
- Adds a destination filter to Step 7 to improve verification
  specificity for SED_1 notifications.
2026-02-25 19:49:34 -06:00
Jonathan Hui 201042d5d4 [nexus] add test 9.2.15 Attaching with different Pending Dataset (#12555)
This commit adds Nexus test case 9.2.15 which verifies the
synchronization of a Pending Operational Dataset between an attaching
Router and an existing Router.

Implementation details:
- tests/nexus/test_9_2_15.cpp: Implemented the test procedure using
  direct core method calls. Sets node connectivity via AllowList and
  log level to note. Implements power-down simulation by stopping MLE
  and bringing down the network interface. Extracted MGMT_PENDING_SET
  logic into a SendPendingSet helper function for better maintainability.
- tests/nexus/verify_9_2_15.py: Implemented robust verification logic
  to validate end-to-end CoAP MGMT_PENDING_SET and MGMT_ACTIVE_GET
  messages, along with MLE Parent Request/Response and Child ID
  Request/Response exchanges.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_15 target to the build
  configuration.
- tests/nexus/run_nexus_tests.sh: Added 9_2_15 to the default test list.
2026-02-25 14:37:53 -06:00
Jonathan Hui 272e9a738f [nexus] add test 9.2.14 PAN ID Query Requests (#12554)
This commit adds Nexus test case 9.2.14 which verifies that the DUT
properly accepts and processes PAN ID Query requests and responds
when a conflict is found.

Implementation details:
- tests/nexus/test_9_2_14.cpp: C++ test execution logic. Implements
  a 4-node topology (Leader_1, Router_1, Commissioner, Leader_2).
  Leader_2 forms a separate network on a secondary channel with the
  same PAN ID. Test uses direct core method calls and sets log level
  to note.
- tests/nexus/verify_9_2_14.py: Python pcap verification script.
  Verifies MGMT_PANID_QUERY requests (unicast and multicast) from
  the Commissioner and MGMT_PANID_CONFLICT responses from Router_1.
  Ensures correct TLVs are present in CoAP payloads.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_14 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_14 to default test list.

The test has been verified to pass in the Nexus simulation environment.
2026-02-25 12:57:01 -06:00
Abtin Keshavarzian 2f975ae86b [tmf] remove redundant SetSockPortToTmf() calls (#12544)
This commit removes calls to `SetSockPortToTmf()` from the Border
Agent prior to sending messages via `Tmf::Agent`. Setting the
local socket port is unnecessary because the `Tmf::Agent` is already
bound to the TMF port number when sending CoAP messages.

Additionally, since these removals eliminate the last uses of the
`SetSockPortToTmf()` method within the codebase, the method itself
has been completely removed from `Tmf::MessageInfo` class to clean up
dead code.
2026-02-25 00:13:45 -06:00
Jonathan Hui 89276c01fc [tests] add Nexus test 9.2.11 for Leader Delay Timer Management (#12547)
This commit adds Nexus test 9.2.11 which verifies the Leader's
management of the Delay Timer during Pending Dataset updates.

The test case implementation covers:
- Formation of a network with Leader (DUT), Commissioner, Router,
  MED, and SED.
- Simulation of MGMT_PENDING_SET.req via otDatasetSetPending on the
  Leader node.
- Verification of multicast MLE Data Responses triggered by dataset
  updates.
- Propagation of Pending Operational Dataset information across the
  network.
- Validation of network stability and connectivity (ICMPv6 Echo)
  across long wait periods defined by the Delay Timer.

Stable network timing and polling parameters were adjusted to ensure
reliable execution in the Nexus simulation environment.

Files modified:
- tests/nexus/test_9_2_11.cpp: C++ test execution logic.
- tests/nexus/verify_9_2_11.py: Python pcap verification script.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_11 target.
- tests/nexus/run_nexus_tests.sh: Added 9_2_11 to the test list.
2026-02-24 23:13:04 -06:00
Jonathan Hui cb5426743f [nexus] add test 5.8.4 Security Policy TLV (#12480)
This commit adds Nexus test case 5.8.4 which verifies the Security Policy
TLV bits (O, N, R, B) being disabled and the resulting network behavior.

Implementation details:
- tests/nexus/test_5_8_4.cpp: Implemented the test procedure using
  direct core method calls. The test procedure implements all 20 steps
  from the specification with cumulative Security Policy bit updates.
  Removed unused constant kExternalCommissioningMask to fix build error.
- tests/nexus/verify_5_8_4.py: Implemented robust Python verification
  logic that handles out-of-order packets and verifies individual
  Security Policy and Discovery Response bits.
- tests/nexus/verify_utils.py: Enhanced the parser to support granular
  Security Policy bits and Discovery Response Native Commissioning bit.
  Replaced magic numbers with constants and registered additional
  Security Policy flags (C, e, p) for completeness.
- tests/nexus/platform/nexus_core.cpp: Refactored SaveTestInfo to
  use the Leader node as the authoritative source for network keys
  and prefixes, ensuring correct decryption in verification scripts.
- Included full test specification as inline comments in both C++ and
  Python code.
2026-02-24 21:51:17 -06:00
Jonathan Hui fd24a5da64 [nexus] add test 9.2.10 Delay timer persistent at partitioning (#12546)
This commit adds Nexus test case 9.2.10 which verifies that the Thread
device maintains a delay timer after partitioning.

Implementation details:
- tests/nexus/test_9_2_10.cpp: C++ test execution logic. Implements the
  5-node topology (Commissioner, Leader, Router_1, MED_1, SED_1) using
  direct method calls. Manages RF isolation by manipulating the Mac Filter
  AllowList. Sets log level to note.
- tests/nexus/verify_9_2_10.py: PCAP verification script. Verifies
  MGMT_PENDING_SET.req/rsp, MLE Data Response dissemination, and
  network-wide channel/PAN ID migration across partitions.
- tests/nexus/run_nexus_tests.sh: Added 9_2_10 to default test list.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_10 target.
2026-02-24 20:39:33 -06:00
Jonathan Hui 41dddb5ed3 [nexus] fix intermittent failures in test 7.1.8 (#12543)
This commit fixes occasional failures in Nexus test 7.1.8 by making
the verification script more robust against interleaved packets.

The implementation details:
- tests/nexus/verify_7_1_8.py: Refactored Step 3 to use separate
  filter copies to find the Leader's MLE Data Response and CoAP ACK
  independently of their order.
- Correctly updated the main packet filter index to ensure that
  subsequent verification steps proceed from the point after both
  packets have been identified.
2026-02-24 18:03:53 -06:00
Jonathan Hui e6003bc9af [nexus] add test 9.2.8 Persistent Active/Pending Operational Datasets (#12539)
This commit adds Nexus test case 9.2.8 which verifies that the Leader
correctly manages and persists both Active and Pending Operational
Datasets, including behavior across node re-attachments.

Implementation details:
- tests/nexus/test_9_2_8.cpp: C++ test execution logic. Implements
  the 9.2.8 spec using direct core calls. Simulates power down using
  Node::Reset() to verify parameter persistence across a full stack
  re-initialization. Standardized node initialization by removing
  explicit extended address and network key configuration, relying on
  platform defaults and GenerateRandom(). Aligned leader startup to use
  Up() and Start() for consistency with other tests.
- tests/nexus/verify_9_2_8.py: PCAP verification script. Verifies
  MGMT_PENDING_SET.req/rsp, MGMT_ACTIVE_SET.req/rsp, and MLE
  dissemination. Uses relaxed address filtering to handle short
  address usage in Child ID Requests. Updated to use constants from
  pktverify.consts. Improved verification robustness by checking
  each DUT individually for re-attachment and connectivity.
- tests/nexus/verify_utils.py: Added support for parsing Pending
  Timestamp and Delay Timer TLVs in CoAP payloads. Patched pktverify
  to support wpan_tap layer for channel verification.
- tests/nexus/run_nexus_tests.sh: Added 9_2_8 to default test list.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_8 target.
2026-02-24 16:27:12 -06:00
Jonathan Hui 523f5015bc [docs] update GEMINI.md with Nexus test instructions (#12542)
This commit updates GEMINI.md to include instructions for building and
running Nexus tests. Nexus is a test framework that enables faster and
more scalable network simulations within a single process.

The updated documentation provides:
- A brief overview of the Nexus test framework.
- The command to build Nexus tests using 'tests/nexus/build.sh'.
- Commands to run all Nexus tests or a specific test using
  'tests/nexus/run_nexus_tests.sh'.
- A reference to 'tests/nexus/README.md' for further details.
2026-02-24 15:38:44 -06:00
Abtin Keshavarzian c83f924a3d [bbr] update Manager::SendBackboneAnswer() to use InitAsPost() (#12537)
This commit updates `Manager::SendBackboneAnswer()` to use
`Coap::Message::InitAsPost()`, which automatically determines the
CoAP message type (Confirmable vs. Non-Confirmable) based on whether
the destination address is multicast. This simplifies the code and
removes the need for the local `proactive` boolean variable.
2026-02-24 15:11:40 -06:00
Abtin Keshavarzian d8dc2a41d8 [address-resolver] simplify SendAddressError() and its usage (#12536)
This commit updates `AddressResolver::SendAddressError()` to accept the
destination address as a `const Ip6::Address &` instead of a pointer.
This allows the implementation to be simplified by using
`Coap::Message::InitAsPost()`, which automatically determines the
CoAP message type (confirmable vs. non-confirmable) based on whether
the destination address is multicast.

All callers of `SendAddressError()` are updated accordingly. When
sending to all routers, `GetRealmLocalAllRoutersMulticast()` is now
explicitly passed.
2026-02-24 15:11:14 -06:00
Abtin Keshavarzian 65c1b97342 [logging] introduce Log{Level}OnError macros and update core (#12533)
This commit introduces a new set of logging macros, `LogCritOnError`,
`LogWarnOnError`, `LogNoteOnError`, `LogInfoOnError`, and
`LogDebgOnError`, to provide a consistent and streamlined way to log
errors across the codebase.

The new macros automatically prepend "Failed to " and append the error
string (using `ErrorToString()`) to the log message, reducing
boilerplate code and ensuring a uniform log format. These macros only
emit a log if the provided `Error` is not `kErrorNone`.

This change improves code readability and maintainability by
consolidating error logging logic into the logging framework.
2026-02-24 15:10:33 -06:00
Abtin Keshavarzian 632669f1c1 [cli] enhance batracker agents to display parsed txt data (#12521)
This commit enhances the `batracker agents` command to display parsed,
human-readable information from the Border Agent TXT data by default.
This allows users to easily inspect the Border Agent State Bitmap
(Connection Mode, Thread Interface Status, Availability, Role, etc.)
and other fields like Thread Version, Network Name, Vendor Name,
or Vendor Model without manually decoding the raw bytes.

The `rawtxt` argument is introduced to optionally display the TXT data
in the raw key/value pair format.

To support this, new public APIs are added to convert Border Agent
State Bitmap enum values to their string representations.
2026-02-24 15:09:51 -06:00
Jonathan Hui ecd4b01422 [nexus] add test 9.2.7 and fix pktverify timestamp parsing (#12535)
This commit adds Nexus test 9.2.7 and improves the pktverify framework
to correctly handle Thread timestamp parsing.

The implementation includes:
- tests/nexus/test_9_2_7.cpp:
  - C++ execution logic using direct core method calls.
  - Implements a real Commissioner session to correctly authorize
    Dataset updates.
  - Documents a deviation in Step 5 where the Active Timestamp is set
    to 15s (instead of 20s) to satisfy strictly increasing timestamp
    requirements for subsequent steps.
- tests/nexus/verify_9_2_7.py:
  - Python verification with strict field checks for timestamps and
    timers.
  - Handles interleaved traffic using save_index().
  - Updates verification logic to accommodate timer decrements.
- Integration:
  - tests/nexus/CMakeLists.txt: Added nexus_9_2_7 target.
  - tests/nexus/run_nexus_tests.sh: Added 9_2_7 to default test list.

The pktverify fixes include:
- tests/scripts/thread-cert/pktverify/layer_fields.py:
  - Added _thread_timestamp parser to handle raw 8-byte Thread timestamps,
    avoiding fragility and timezone issues associated with date string
    parsing.
  - Fixed _auto parser to use calendar.timegm() for UTC date strings
    instead of time.mktime(), ensuring correct epoch values regardless
    of the local system timezone.
  - Mapped active and pending timestamp fields to use the new
    _thread_timestamp parser.
2026-02-24 14:54:51 -06:00
Jonathan Hui 0058adf160 [nexus] update README.md with build and run instructions (#12541)
This commit updates 'tests/nexus/README.md' to provide detailed
instructions on how to build and run the Nexus tests, including
the recently added automated testing and packet verification
scripts.

Changes:
- Added instructions for building TREL tests using 'build.sh trel'.
- Added a section on automated testing and packet verification
  using the 'run_nexus_tests.sh' script.
- Explained how to run individual C++ tests and Python verification
  scripts manually.
- Clarified the usage of topology names and JSON output filenames
  as arguments for Nexus C++ tests.
2026-02-24 12:55:46 -06:00
Jonathan Hui 33c81d4d1d [nexus] fix intermittent failures in test 7.1.7 (#12540)
This commit fixes intermittent failures in Nexus test 7.1.7 by
improving test stability and making the verification script more
robust.

Implementation details:
- tests/nexus/test_7_1_7.cpp: Added a 500ms external poll period for
  SED_1 to ensure it remains active and reachable during the test.
  Replaced the magic number with a named constant `kSedPollPeriod`.
  Added a stabilization delay after Step 17 to ensure network data
  updates are fully propagated.
- tests/nexus/verify_7_1_7.py: Added source filtering for the Leader
  (DUT) in network data update checks to avoid matching packets from
  other nodes. Used Border Router sub-TLV count checks to reliably
  distinguish between initial prefix additions and subsequent
  removals. Improved CoAP ACK verification to handle interleaved
  packets and ensure correct destination filtering. Refactored
  verification chains to follow project-specific formatting standards.
2026-02-24 12:51:06 -06:00
Jonathan Hui b81da07ace [nexus] add test 9.2.6 Commissioning Dissemination (#12532)
This commit adds Nexus test case 9.2.6 which verifies that the Leader
properly collects and disseminates Active and Pending Operational
Datasets through the Thread network.

Implementation details:
- tests/nexus/test_9_2_6.cpp: C++ test execution logic. Includes both
  MED_1 and SED_1 in the topology to simultaneously verify
  dissemination to different child types in a single run. Uses direct
  core calls and sets a 500ms external poll period for SED_1.
- tests/nexus/verify_9_2_6.py: PCAP verification script. Implements
  robust MLE and CoAP filtering to handle short address usage and out-
  of-order packet delivery. Includes monkey-patching for MeshCoP TLV
  parsing in CoAP. Improved MGMT_PENDING_SET filter robustness and
  removed full range reset in Step 18.
- tests/nexus/verify_9_2_4.py: Fixed regressions in MGMT_ACTIVE_SET
  verification logic introduced during refactoring.
- tests/nexus/verify_utils.py: Added support for parsing
  mesh_local_prefix and NM_FUTURE_TLV in CoAP payloads.
- tests/scripts/thread-cert/pktverify/consts.py: Added NM_FUTURE_TLV.
- tests/nexus/run_nexus_tests.sh: Added 9_2_6 to default test list.
- tests/nexus/CMakeLists.txt: Added nexus_9_2_6 target.
2026-02-23 22:35:10 -06:00
Abtin Keshavarzian fd372a900a [coap] decouple callback from queue iteration in PendingRequests (#12528)
This commit updates `PendingRequests::HandleTimer()` and
`PendingRequests::AbortAllMatching()` to perform request finalization
(which invokes user callbacks) outside of the main loop iterating over
the `mRequestMessages` queue.

Iterating over `mRequestMessages` while invoking user callbacks is
unsafe because the callback may modify the request queue (e.g., abort
other transactions), potentially invalidating the iterator. This change
protects against this by moving requests to be finalized into a separate
local `MessageQueue`. The requests in the local queue are then
finalized and freed after the main loop finishes.
2026-02-23 21:00:35 -06:00
Jonathan Hui 3e0bff98ca [nexus] fix test 9.2.5 flakiness and align with spec (#12534)
This commit fixes intermittent failures in Nexus test 9.2.5 and aligns
its implementation and documentation with the authoritative test
specification.

Intermittent failures were caused by disruptive network identity
changes (Extended PAN ID and Network Name) that resulted in
inconsistent node detachment and re-attachment in the simulation.
Wait times and timeouts were adjusted to improve stability.

Changes:
- Updated operational dataset values in 'test_9_2_5.cpp' to match
  'Cert_9_2_05_ActiveDataset.py'.
- Adjusted 'kResponseTime' and 'kEchoTimeout' for better reliability.
- Enhanced 'verify_9_2_5.py' to strictly verify all mandated TLV
  types in 'MGMT_ACTIVE_SET.req' payloads.
- Aligned inline comments and print statements in both C++ and Python
  files with the authoritative spec in 'test-9-2-5.txt'.
- Corrected a typo note in the Step 5 description as per the spec.
2026-02-23 18:47:08 -06:00
Jonathan Hui c7bbcb823e [nexus] fix flakiness in test 9.2.4 (#12531)
Test 9.2.4 could occasionally fail due to the random selection of
the initial channel by the Leader. If the randomly selected channel
matched the 'Secondary' channel (12) used in MGMT_ACTIVE_SET.req in
step 6, the request would be accepted instead of rejected, causing
a verification failure.

This commit fixes the issue by explicitly configuring the Leader's
initial Operational Dataset with a fixed set of parameters (Channel
11, PAN ID 0xABCD, etc.) that are guaranteed to be different from
the parameters tested in the MGMT_ACTIVE_SET.req steps.

The fix was verified by running the test 20 times in a loop without
any failures.
2026-02-23 16:45:38 -06:00
Jonathan Hui 7f5aab9717 [tests] replace IgnoreError with SuccessOrQuit in Nexus tests (#12530)
This commit replaces instances of IgnoreError with SuccessOrQuit in
several Nexus test files to ensure that errors from core methods are
properly handled and cause test failure if they occur.

Modified files:
- tests/nexus/test_5_1_5.cpp
- tests/nexus/test_5_1_9.cpp
- tests/nexus/test_5_1_10.cpp
- tests/nexus/test_5_6_4.cpp
- tests/nexus/test_6_1_5.cpp
- tests/nexus/test_7_1_2.cpp
- tests/nexus/test_7_1_8.cpp
2026-02-23 16:34:09 -06:00
Jonathan Hui b3d169dc54 [nexus] add test 9.2.5 Updating Active Operational Dataset (#12526)
This commit adds a new Nexus test case 9.2.5 which verifies the DUT's
behavior when receiving MGMT_ACTIVE_SET.req from an active Thread node.
The test ensures that the Leader (DUT) correctly processes updates to
Active Operational Dataset parameters and disseminates them via MLE.

The test implementation includes:
- tests/nexus/test_9_2_5.cpp:
  - C++ execution logic using direct core method calls.
- tests/nexus/verify_9_2_5.py:
  - Python script to verify pcap output against the test specification.
  - Implements strict validation of CoAP payload TLVs and response states.
- Infrastructure improvements:
  - tests/nexus/verify_utils.py: Added parsing for MeshCoP TLVs in CoAP.
  - tests/scripts/thread-cert/pktverify/layer_fields.py: Fixed ISO timestamp
    parsing for compatibility with newer tshark versions.
2026-02-23 14:30:05 -06:00
Martin Girardot ac36d9de87 [spinel] add libopenthread-radio-spinel GN library (#12466)
Signed-off-by: Martin Girardot <martin.girardot@nxp.com>
2026-02-23 14:22:47 -06:00
Jonathan Hui 088154d12b [tests] remove cert scripts migrated to Nexus (#12516)
This commit removes several Thread certification test scripts from
tests/scripts/thread-cert/ that have been migrated to the Nexus
testing framework. These tests are now implemented as Nexus tests
under tests/nexus/.

The following test scripts were removed:

- Leader Reboot:
  - Cert_5_5_01_LeaderReboot.py
  - Cert_5_5_02_LeaderReboot.py
  - Cert_5_5_03_SplitMergeChildren.py
  - Cert_5_5_04_SplitMergeRouters.py
  - Cert_5_5_05_SplitMergeREED.py
  - Cert_5_5_07_SplitMergeThreeWay.py

- Network Data:
  - Cert_5_6_01_NetworkDataRegisterBeforeAttachLeader.py
  - Cert_5_6_02_NetworkDataRegisterBeforeAttachRouter.py
  - Cert_5_6_03_NetworkDataRegisterAfterAttachLeader.py
  - Cert_5_6_04_NetworkDataRegisterAfterAttachRouter.py
  - Cert_5_6_05_NetworkDataRegisterAfterAttachRouter.py
  - Cert_5_6_06_NetworkDataExpiration.py
  - Cert_5_6_07_NetworkDataRequestREED.py
  - Cert_5_6_09_NetworkDataForwarding.py

- COAP Diag:
  - Cert_5_7_01_CoapDiagCommands.py
  - Cert_5_7_02_CoapDiagCommands.py
  - Cert_5_7_03_CoapDiagCommands.py

- Router/REED Attach:
  - Cert_6_1_01_RouterAttach.py
  - Cert_6_1_02_REEDAttach.py
  - Cert_6_1_03_RouterAttachConnectivity.py
  - Cert_6_1_04_REEDAttachConnectivity.py
  - Cert_6_1_05_REEDAttachConnectivity.py
  - Cert_6_1_06_REEDAttachLinkQuality.py
  - Cert_6_1_07_RouterAttachLinkQuality.py

- Partition and Reattach:
  - Cert_6_2_01_NewPartition.py
  - Cert_6_2_02_NewPartition.py
  - Cert_6_3_01_OrphanReattach.py
  - Cert_6_3_02_NetworkDataUpdate.py
  - Cert_6_4_01_LinkLocal.py
  - Cert_6_4_02_RealmLocal.py
  - Cert_6_5_01_ChildResetReattach.py
  - Cert_6_5_02_ChildResetReattach.py
  - Cert_6_5_03_ChildResetSynchronize.py

- Key Increment:
  - Cert_6_6_01_KeyIncrement.py
  - Cert_6_6_02_KeyIncrementRollOver.py

- Border Router:
  - Cert_7_1_01_BorderRouterAsLeader.py
  - Cert_7_1_02_BorderRouterAsRouter.py
  - Cert_7_1_03_BorderRouterAsLeader.py
  - Cert_7_1_04_BorderRouterAsRouter.py
  - Cert_7_1_05_BorderRouterAsRouter.py
  - Cert_7_1_06_BorderRouterAsLeader.py
  - Cert_7_1_07_BorderRouterAsLeader.py
  - Cert_7_1_08_BorderRouterAsFED.py
2026-02-23 14:05:42 -06:00
Abtin Keshavarzian c28002707d [key-manager] move initialization to Instance::AfterInit (#12476)
Currently, `KeyManager` generates and stores a random `NetworkKey` in its
constructor when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is
enabled. This invokes `StoreNetworkKey()`, which interacts with
`KeyRefManager`. Accessing other components during construction can be
unsafe if they are not yet fully initialized.

This commit introduces a `KeyManager::Init()` method to handle this
initialization. This method is called from `Instance::AfterInit()`,
ensuring that the `Instance` and all dependencies, such as
`KeyRefManager`, are fully constructed before the `KeyManager` attempts
to access them.
2026-02-23 13:00:53 -06:00
Jonathan Hui e20bfbc591 [nexus] add test 9.2.4 Update Active Dataset via Commissioner (#12525)
This commit adds Nexus test 9.2.4 which verifies that the Active
Operational Dataset can be updated via the Commissioner using
MGMT_ACTIVE_SET.req.

The test implementation includes:
- test_9_2_4.cpp: C++ test execution for both Topology A (DUT as
  Leader) and Topology B (DUT as Commissioner). It performs 22
  steps, including various validation cases for MGMT_ACTIVE_SET.req
  (invalid TLVs, old timestamps, invalid session ID, steering data,
  and future TLVs).
- verify_9_2_4.py: Python script to verify the pcap output from the
  test against the specification. It includes a custom CoAP TLV
  parser to handle MeshCoP TLVs.

Key implementation details:
- Use direct method calls instead of OpenThread public APIs.
- Configure node connectivity using AllowList between Leader and
  Commissioner.
- Set log level to 'note' for detailed output.
- Include full test specification as inline comments in both C++
  and Python code.
- Added 9_2_4 to CMakeLists.txt and the default test list in
  run_nexus_tests.sh.
2026-02-23 12:58:35 -06:00
Jonathan Hui 37dc3d6239 [nexus] add test 7.1.7 Network data updates – BR device rejoins (#12519)
This commit adds a new Nexus test case 7.1.7 which verifies that
network data is properly updated when a server (Border Router)
leaves and rejoins the network with modified information.

The test verifies that:
- The Leader (DUT) correctly processes CoAP Server Data
  Notifications from two Border Routers.
- The Leader multicasts updated network data to neighbors and MEDs.
- The Leader sends unicast updates (Child Update Request or Data
  Response) to SEDs.
- When a Border Router (Router 2) leaves and starts its own
  partition, then rejoins with a new prefix (Prefix 2), the Leader
  correctly updates the network data and disseminates it.
- Connectivity is maintained via ICMPv6 Echo Requests to addresses
  based on the new prefixes.
- When a prefix is removed, the network data is correctly updated.

Summary of changes:
- Created tests/nexus/test_7_1_7.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for specified links (Leader-Router1,
      Leader-Router2, Leader-MED1, Leader-SED1).
    - Includes 1-line log outputs for each test step.
    - Adheres to block comment formatting and 120-char line limits.
- Created tests/nexus/verify_7_1_7.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates prefix updates and disseminations.
    - Follows Python filter formatting style and 120-char limits.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_7 to the
  default test list.
2026-02-23 12:13:10 -06:00
dependabot[bot] b8f0c7910f github-actions: bump docker/login-action from 3.6.0 to 3.7.0 (#12529)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.6.0 to 3.7.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/5e57cd118135c172c3672efd75eb46360885c0ef...c94ce9fb468520275223c153574b00df6fe4bcc9)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.7.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-02-23 10:44:35 -06:00
Jonathan Hui ada63f2a3e [nexus] add test 9.2.3 Getting the Active Operational Dataset (#12519) (#12524)
This commit adds a new Nexus test case for 'Getting the Active
Operational Dataset' (9.2.3) as specified in the Thread test
specification.

The test verifies that the active Commissioner can read Active
Operational Dataset parameters direct from the Leader using the
MGMT_ACTIVE_GET.req command, and that the Leader responds correctly
with the requested TLVs.

Summary of changes:
- Implemented Nexus test 9.2.3:
    - Added tests/nexus/test_9_2_3.cpp: Implements the test execution
      for both Topology A (DUT as Leader) and Topology B (DUT as
      Commissioner). Uses direct core method calls and sets log level
      to note. Configures the link between Leader and Commissioner
      using AllowList.
    - Added tests/nexus/verify_9_2_3.py: PCAP verification script
      validating the MGMT_ACTIVE_GET request/response handshake for
      various payload configurations (empty, specific TLVs, and mixed
      allowed/not-allowed TLVs).
- Enhanced MeshCoP TLV support in nexus test framework:
    - Updated verify_9_2_3.py with a monkey-patch for CoapTlvParser
      to support MeshCoP TLV Request (Get) TLVs.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 9_2_3 in the
      default test list and expanded tests loop.
2026-02-23 10:28:37 -06:00
Jonathan Hui aba889547a [nexus] fix intermittent failure in test 5.5.5 (#12523)
This commit fixes an intermittent failure in Nexus test 5.5.5. The
failure occurred when Router_1 performed a late upgrade from child to
router after re-attaching to the DUT. This caused a mismatch between
the RLOC16 in the captured ping packets and the RLOC16 saved in the
test info JSON at the end of the test.

Changes:
- Disabled router eligibility for Router_1 in test_5_5_5.cpp after it
  becomes isolated. This ensures it remains a child of the DUT and
  maintains a consistent RLOC16 for the duration of the test.
2026-02-23 10:28:14 -06:00
Abtin Keshavarzian 5d92992b78 [coap] enhance PendingRequest and move request management functionality (#12527)
This commit enhances the `PendingRequest` class by moving more functionality
regarding the management of pending CoAP requests into this nested class
within `CoapBase`.

Specifically, this change moves the handling of the retransmission timer,
retransmission of requests, finalizing a request, and aborting all or a
subset of requests. This helps organize the code and simplifies the
`CoapBase` class implementation.
2026-02-23 10:27:29 -06:00
Abtin Keshavarzian d7000862e8 [message] update SetOffset() and MoveOffset() to clamp offset (#12522)
Updates `SetOffset()` to ensure the offset is always clamped to the
current message length. This guarantees that the offset remains valid
and does not exceed the message size.

Updates `MoveOffset()` to accept `int16_t` as the delta and ensures
the calculated new offset is clamped within `0` and
`NumericLimits<uint16_t>::kMax` before setting it.

Updates `SetLength()` to rely on the new `SetOffset()` behavior to
automatically adjust the offset when the message length is reduced.
2026-02-23 10:26:30 -06:00
Abtin Keshavarzian 404c80455a [message] add DetermineLengthAfterOffset() helper method (#12508)
This commit adds `DetermineLengthAfterOffset()` helper method to
`Message` which returns the number of bytes in the message from the
current offset to the end of the message. This pattern is commonly used
in many places to determine the remaining length of the payload.

This commit updates various core modules including MeshCoP, 6LoWPAN,
IPv6, TCP, and MeshForwarder to use this new helper.
2026-02-21 22:45:22 -06:00
Abtin Keshavarzian ecc57f765c [message] enhance Clone() to support different reserved header size (#12440)
This commit enhances the `Message::Clone()` method to support a custom
configuration. This allows callers to specify a different length and
reserved header size for the cloned message via the new overload
`Clone(uint16_t aLength, uint16_t aReserveHeader)`.

The existing `Clone()` overloads have been updated to utilize this new
configuration mechanism. Additionally, `Coap::Message::Clone()`
methods are updated to align with these changes.

A new unit test `TestCloning()` is added to `test_message.cpp` to
verify the behavior of `Clone()` with various configurations.
2026-02-21 22:44:34 -06:00
Jonathan Hui 7d10faea6f [nexus] add test 7.1.8 Network data propagation - BR as FED (#12520)
This commit adds a new Nexus test case 7.1.8 which verifies that
when global prefix information is set on a Full End Device (FED),
the DUT (Router) properly disseminates the associated network data.
It also verifies that the DUT sends revised server data information
to the Leader when the FED is removed.

The test setup uses:
- Leader: Forms the network.
- Router 1 (DUT): Attached to the Leader.
- FED 1: Attached to the DUT.

The test verifies that:
- FED 1 sends a CoAP Server Data Notification to the Leader after
  prefixes (2001::/64 stable and 2002::/64 non-stable) are added.
- The Leader and DUT multicast MLE Data Responses containing the
  new network data.
- When FED 1 is removed, the DUT unicasts a CoAP Server Data
  Notification to the Leader containing only the removed server's
  RLOC16.

Summary of changes:
- Created tests/nexus/test_7_1_8.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for specified links (Leader-Router1,
      Router1-FED1).
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting and line length.
- Created tests/nexus/verify_7_1_8.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates CoAP and MLE message exchanges.
    - Follows requested Python filter and line length formatting.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_8 to the
  default test list.
2026-02-21 22:06:28 -06:00
Jonathan Hui 63482204ab [nexus] add test 5.6.9 Router Behavior - External Route (#12518)
This commit adds Nexus test 5.6.9 which verifies that a router
properly forwards data packets to a Border Router based on
Network Data information.

The test implementation includes:
- test_5_6_9.cpp: C++ test execution that sets up the topology
  using Leader, two Routers (one as DUT), a MED, and a SED. It
  configures external routes and triggers ICMPv6 Echo Requests.
- verify_5_6_9.py: Python script to verify the pcap output
  against the test specification.

Key implementation details:
- Use direct method calls instead of OpenThread APIs where
  applicable.
- Configure node connectivity using AllowList.
- Set log level to 'note'.
- Follow specific comment and logging formats as required by the
  nexus test framework.
- Avoid magic numbers by using constants for time and identifiers.
- Added 5_6_9 to CMakeLists.txt and run_nexus_tests.sh default list.
2026-02-21 21:59:36 -06:00
Jonathan Hui bc6f2da3dd [nexus] add test 9.2.2 On Mesh Commissioner - MGMT_SET (#12511)
This commit adds a new Nexus test case for 'On Mesh Commissioner -
MGMT_COMMISSIONER_SET.req & rsp' (9.2.2) as specified in the Thread
test specification.

Summary of changes:
- Implemented Nexus test 9.2.2:
    - Added tests/nexus/test_9_2_2.cpp: Implements the test execution
      for Topology A (Leader DUT). The test verifies Leader's behavior
      when receiving MGMT_COMMISSIONER_SET.req directly from the active
      Commissioner, including validation of missing or invalid TLVs.
      Uses MeshCoP::SteeringData and Tmf::MessageInfo for more idiomatic
      implementation as per review feedback.
    - Added tests/nexus/verify_9_2_2.py: PCAP verification script
      validating the MGMT_COMMISSIONER_SET request/response handshake
      and subsequent MLE Data Response.
- Enhanced MeshCoP TLV support in nexus test framework:
    - Updated tests/nexus/verify_utils.py to robustly parse MeshCoP TLVs
      (Commissioner Session ID, State, Steering Data, etc.) and handle
      type overlaps with existing Diagnostic TLVs.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 9_2_2 in the
      default test list.
2026-02-21 20:31:34 -06:00
Jonathan Hui a6c4acce13 [nexus] add test 7.1.6 Network data propagation - BR leaves/rejoins (#12515)
This commit adds a new Nexus test case 7.1.6 which verifies network
data propagation when a Border Router leaves the network, rejoins,
and updates its server data.

The test verifies that when the DUT (Border Router) leaves, its
registered prefixes are removed from the network data after a timeout.
Upon rejoining and updating its server data, the test ensures that
the new prefixes are correctly propagated to other routers and
their children (MED and SED).

Summary of changes:
- Created tests/nexus/test_7_1_6.cpp:
    - Implements the 17-step test specification.
    - Handles DUT reset and rejoin as a Router (FED).
    - Uses direct OpenThread core method calls.
    - Configures AllowList for controlled topology.
    - Addressed review comments by using more idiomatic `FromString()`
      and removing redundant constants.
- Created tests/nexus/verify_7_1_6.py:
    - Implements PCAP-based verification of the test steps.
    - Validates prefix removal and subsequent propagation of updated
      data.
    - Uses non-sequential packet search for robust verification.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to include 7_1_6 in the
  default test list.
2026-02-21 19:07:44 -06:00
Jonathan Hui d5996e2a57 [nexus] add test 5.6.7 Request Network Data Updates – REED device (#12517)
This commit adds a new Nexus test case 5.6.7 which verifies that a
REED device (DUT) correctly identifies an outdated version of the
Network Data and automatically requests an update from its parent
after hearing an incremented Data Version in MLE Advertisements.

The test setup uses:
- Leader: Configured as a Border Router.
- Routers 1-15: Attached to the Leader to form a network with 16
  active routers.
- REED 1 (DUT): Attached to Router 1.

The test verifies that:
- The DUT correctly handles RF isolation during Network Data updates.
- The DUT identifies the incremented Data Version in its parent's
  (Router 1) MLE Advertisements.
- The DUT sends an MLE Data Request to its parent with a TLV Request
  TLV for the Network Data TLV.
- The DUT receives the updated Network Data and subsequently
  broadcasts its own MLE Advertisement with an incremented Data
  Version in the Leader Data TLV.

Summary of changes:
- Created tests/nexus/test_5_6_7.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for specified links to create the
      required topology.
    - Includes 1-line log outputs for each test step.
- Created tests/nexus/verify_5_6_7.py:
    - Implements pcap-based verification of PASS criteria.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_6_7 to the
  default test list.
2026-02-21 18:59:39 -06:00
Jonathan Hui eca4f1bef1 [tests] improve CoAP TLV disambiguation in packet verification (#12514)
This commit implements a more robust mechanism to differentiate between
overlapping TLV types in CoAP payloads, specifically for TLV type 8,
which is used for both NM_STEERING_DATA_TLV (MeshCoP) and
DG_IPV6_ADDRESS_LIST_TLV (Diagnostic).

The logic previously relied solely on TLV length, which was fragile
and caused 16-byte Steering Data TLVs to be misinterpreted.

Key changes:
- Enhanced CoapTlvParser.parse() and CoapLayer to accept and pass the
  CoapLayer instance as context during parsing.
- Added a 'uri_path' property to CoapLayer for easier access to the
  CoAP URI path (recon).
- Updated thread_coap_tlv_parse in verify_utils.py to use the URI path
  to correctly identify Diagnostic TLVs (if URI starts with '/d/') vs.
  MeshCoP or other Thread TLVs.
- Updated verify_9_2_1.py monkey-patches to match the new parser
  signature.
2026-02-20 23:54:18 -06:00
Jonathan Hui c5006b09b9 [nexus] add test 5.6.6 Network data expiration (#12506)
This commit adds a new Nexus test case for 'Network data expiration'
(5.6.6) as specified in the test specification.

The test verifies that network data is properly updated when deleting
a prefix or removing a server from the network.

Summary of changes:
- Implemented Nexus test 5.6.6:
    - Added tests/nexus/test_5_6_6.cpp: Implements the test execution
      including topology formation, on-mesh prefix configuration, and
      silent power-off of a border router. The test uses direct method
      calls, sets log level to note, and uses AllowList for
      connectivity.
    - Added tests/nexus/verify_5_6_6.py: PCAP verification script.
      Validates CoAP Server Data notifications, MLE Data Responses,
      and Child Update exchanges, ensuring correct network data
      propagation and expiration.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5_6_6 in the
      default test list.
2026-02-20 23:21:27 -06:00
Jonathan Hui 12f155c3b9 [nexus] add test 7.1.5 Network data updates - 3 Prefixes (#12513)
This commit adds a new Nexus test case 7.1.5 which verifies that the
DUT (Router) correctly sends a Server Data Notification CoAP frame when
a third global prefix is configured. It also verifies that the DUT
properly propagates the updated Network Data to its children (MED and
SED) and handles their address registration.

The test setup uses:
- Leader: Forms the network.
- Router 1 (DUT): Attached to the Leader. Acts as a Border Router with
  three prefixes:
    - Prefix 1 (stable)
    - Prefix 2 (non-stable)
    - Prefix 3 (stable)
- MED 1: Attached to the DUT, configured to require complete data.
- SED 1: Attached to the DUT, configured to request only stable data.

Summary of changes:
- Created tests/nexus/test_7_1_5.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for Router1-Leader, Router1-MED1, and
      Router1-SED1 links.
    - Sets poll period for SED 1 to ensure timely communication.
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting and line length.
- Created tests/nexus/verify_7_1_5.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode (MED
      receives all prefixes, SED receives only stable prefixes 1 and 3).
    - Verifies Server Data Notification and subsequent Child Update
      exchanges.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_5 to the default
  test list.
2026-02-20 23:16:10 -06:00
Jonathan Hui fe9492fce6 [nexus] add test 7.1.4 Network data propagation - BR as Router (#12512)
This commit adds a new Nexus test case 7.1.4 which verifies that
global prefix information can be set on the DUT (Router) after the
network is formed, and that the DUT correctly notifies the Leader
via CoAP and propagates the updated Network Data (stable/non-stable)
to its attached children (MED and SED).

The test setup uses:
- Leader: Already formed network.
- Router 1 (DUT): Attached to the Leader.
- MED 1: Attached to the DUT, requires complete network data.
- SED 1: Attached to the DUT, requests only stable network data.

The test verifies that:
- The DUT unicasts a CoAP Server Data Notification to the Leader
  after prefixes (2001::/64 stable and 2002::/64 non-stable) are
  added.
- The Leader multicasts the new network data.
- The DUT propagates the updated data to its children.
- MED 1 receives both prefixes and registers its addresses.
- SED 1 receives only the stable prefix (Prefix 1) and registers
  its addresses.

Summary of changes:
- Created tests/nexus/test_7_1_4.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for specified links (Router1-Leader,
      Router1-MED1, Router1-SED1).
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting.
- Created tests/nexus/verify_7_1_4.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_4 to the
  default test list.
2026-02-20 18:00:48 -06:00
Jonathan Hui 2c7e344c0b [nexus] add test 5.6.5 Network data updates – Router as BR (#12505)
This commit adds a new Nexus test case for 'Network data updates –
Router as BR' (5.6.5) as specified in the test specification.

The test verifies that the DUT, as Leader, properly updates and
disseminates network data after receiving new information from a
Router acting as a Border Router with three prefix configurations.

Summary of changes:
- Implemented Nexus test 5.6.5:
    - Added tests/nexus/test_5_6_5.cpp: Implements test execution.
      The test forms a network with a Leader (DUT), Router 1 (BR),
      MED 1, and SED 1. It configures Router 1 as a BR with three
      on-mesh prefixes and verifies the Leader disseminates this
      information. The test uses direct method calls, sets log
      level to note, and uses AllowList for connectivity.
    - Added tests/nexus/verify_5_6_5.py: PCAP verification script.
      Validates CoAP Server Data Notification, CoAP Response, MLE
      Data Responses (multicast and unicast), and MLE Child Update
      exchanges, ensuring all required TLVs and prefix information
      are present.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5_6_5 in
      the default test list.
2026-02-20 17:03:08 -06:00
Jonathan Hui a40401029f [tests] fix inconsistent casing in Thread Nodes multicast address constants (#12484)
Renames LINK_LOCAL_All_THREAD_NODES_MULTICAST_ADDRESS to
LINK_LOCAL_ALL_THREAD_NODES_MULTICAST_ADDRESS and
REALM_LOCAL_All_THREAD_NODES_MULTICAST_ADDRESS to
REALM_LOCAL_ALL_THREAD_NODES_MULTICAST_ADDRESS across the test
scripts to ensure consistent ALL_CAPS_WITH_UNDERSCORES casing
for constants, adhering to PEP 8 and project conventions.
2026-02-20 16:44:23 -06:00
Jonathan Hui 525d9e6250 [nexus] add test 9.2.1 Commissioner - MGMT_COMMISSIONER_GET (#12510)
This commit adds a new Nexus test case for 'Commissioner -
MGMT_COMMISSIONER_GET.req & rsp' (9.2.1) as specified in the Thread
test specification.

Summary of changes:
- Implemented Nexus test 9.2.1:
    - Added tests/nexus/test_9_2_1.cpp: Implements the test execution
      for both Topology A (DUT as Leader) and Topology B (DUT as
      Commissioner). The test verifies that MGMT_COMMISSIONER_GET
      requests can retrieve the entire Commissioner Dataset or specific
      TLVs.
    - Added tests/nexus/verify_9_2_1.py: PCAP verification script.
      Uses custom monkey-patching to correctly parse and verify MeshCoP
      TLVs within CoAP payloads.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 9_2_1 in the
      default list and handle its A/B topologies.
2026-02-20 11:38:40 -06:00
Li Cao 382e486c65 [ncp] implement ncp platform dnssd srv resolve (#12462)
This commit implements otPlatDnssdStartSrvResolver and
otPlatDnssdStopSrvResolver to support service discovery on NCP.

This commit contains these changes:
* Add new spinel property for starting / stopping service resolver
* Implement encoding/decoding of the new property
* Add unit test for encoding/decoding
* Implement ncp version of dnssd platform API
  otPlatDnssdStartSrvResolver and otPlatDnssdStopSrvResolver
* Add property handler to get resolver result on NCP side
* Add unit test to verify that the resolver callback is correctly
  invoked after getting resolver result.
2026-02-20 11:18:10 -06:00
Abtin Keshavarzian a737be4f3a [message] add ReadAtAndAdvanceOffset() helper method (#12503)
This commit adds `ReadAtAndAdvanceOffset()` to the `Message` class to
simplify reading data from the message at the current message offset
and then advancing the message offset. This pattern is commonly used
when processing message headers sequentially. The new method helps
reduce code verbosity and ensures the offset is always advanced by
the correct size.

The new helper is adopted in various core modules including DHCPv6,
IPv6, 6LoWPAN, MLE, and UDP processing.
2026-02-20 11:12:36 -06:00
Abtin Keshavarzian 49ba31d43b [udp] use LinkedList::ContainsMatching() in IsPortInUse() (#12498)
This commit simplifies `IsPortInUse()` by using `LinkedList` helper
`ContainsMatching()` instead of manually iterating over the
list of sockets. A `SocketHandle::Matches(uint16_t aSockPort)`
is added to support this.
2026-02-20 11:11:27 -06:00
Jonathan Hui c73c600cdc [nexus] add test 5.6.4 Network data propagation – Router as BR (#12504)
This commit adds a new Nexus test case for 'Network data propagation –
Router as Border Router' (5.6.4) as specified in the test
specification.

Summary of changes:
- Implemented Nexus test 5.6.4:
    - Added tests/nexus/test_5_6_4.cpp: Implements the test execution
      for the DUT acting as a Border Router. The test verifies that
      prefixes added by the DUT are properly propagated to Router 1
      and its children (MED and SED). The test uses direct method
      calls, sets log level to note, and uses AllowList for
      connectivity.
    - Added tests/nexus/verify_5_6_4.py: PCAP verification script.
      Validates the propagation of stable and non-stable prefixes
      via MLE Data Response messages from Router 1 to its children,
      and verifies subsequent Child Update Request/Response
      exchanges for address registration.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5_6_4 in the
      default test list.
2026-02-20 10:52:59 -06:00
Jonathan Hui 964c1ebe4f [nexus] add test 7.1.3 Network data propagation - Border Router as Leader (#12507)
This commit adds a new Nexus test case 7.1.3 which verifies that global
prefix information can be set on the DUT (Leader) and that the DUT
correctly sets and propagates the Network Data (stable/non-stable) to
neighbors and children in an already formed network.

The test setup uses a Leader (DUT) configured as a Border Router with
both stable (2001::/64) and non-stable (2002::/64) prefixes. It
verifies that neighbors and MED_1 (requesting complete data) receive
both prefixes via MLE Data Response, while SED_1 (requesting only
stable data) receives only the stable prefix via MLE Child Update
Request.

Summary of changes:
- Created tests/nexus/test_7_1_3.cpp:
    - Implements test logic using direct core method calls.
    - Sets log level to note.
    - Configures AllowList for Leader-Router1, Leader-MED1, and
      Leader-SED1 links.
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting.
- Created tests/nexus/verify_7_1_3.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode.
    - Verifies MLE Child ID and Child Update exchanges.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_3 to the
  default test list.
2026-02-20 01:30:28 -06:00
Jonathan Hui d4e2c6441a [nexus] add test 5.6.3 Network data propagation - Leader as BR (#12500)
This commit adds a new Nexus test case 5.6.3 which verifies that
the DUT, as a Router, correctly collects network data information
(stable/non-stable) from the Leader (acting as Border Router) and
propagates it properly to its children (MED and SED).

The test setup uses:
- Leader: Configured as a Border Router with both stable
  (2001::/64) and non-stable (2002::/64) prefixes.
- Router 1 (DUT): Attached to the Leader.
- MED 1: Attached to the DUT, requests complete network data.
- SED 1: Attached to the DUT, requests only stable network data.

The test verifies that:
- The DUT multicasts both prefixes received from the Leader.
- MED 1 receives and registers both prefixes.
- SED 1 receives and registers only the stable prefix (Prefix 1).
- The selective propagation follows either MLE Child Update Request
  or MLE Data Response paths.

Summary of changes:
- Created tests/nexus/test_5_6_3.cpp:
    - Implements test logic using direct C++ method calls.
    - Configures AllowList for specified links.
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting.
- Created tests/nexus/verify_5_6_3.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_6_3 to the
  default test list.
2026-02-20 01:15:06 -06:00
Jonathan Hui 790ac564ca [nexus] fix duplicate alarm firing in simulation core (#12509)
This commit fixes an issue in the Nexus simulation core where alarms
could fire multiple times at the same simulation timestamp. This occurred
because the `mScheduled` flag was not cleared upon firing, and if the
simulation time remained static (e.g., due to pending tasklets), the
`ShouldTrigger` condition would remain true across multiple iterations
of the simulation loop.

By clearing the `mScheduled` flag before invoking the fired callback,
we ensure that each scheduled alarm triggers exactly once unless it is
explicitly rescheduled by the stack. This improvement stabilizes Nexus
tests (such as 6.2.2) that were previously flaky due to this
non-deterministic behavior.
2026-02-20 01:04:05 -06:00
Jonathan Hui c85ce4eec3 [nexus] add test 6.5.3 and fix SED polling verification (#12496)
This commit adds a new Nexus test case for 'Child Synchronization
after Reset - MLE Child Update Request' (6.5.3) as specified in the
Thread test specification.

It also corrects and improves the verification of Sleepy End Device
(SED) polling behavior across Nexus tests.

Summary of changes:
- Implemented Nexus test 6.5.3:
    - Added tests/nexus/test_6_5_3.cpp: Implements the test
      execution for Topology B (SED_1). The test simulates a DUT
      reset for a time shorter than its Child Timeout and verifies
      correct synchronization with its parent.
    - Added tests/nexus/verify_6_5_3.py: PCAP verification script
      validating the MLE Child Update Request and SED polling.
- Fixed SED polling verification:
    - Updated verify_6_5_3.py and verify_6_5_1.py to correctly
      check for MAC Data Request frames (WPAN_DATA_REQUEST) instead
      of MLE Data Requests.
    - Switched to RLOC16-based filtering for MAC Data Requests to
      reliably match packets even when 64-bit addresses are not
      available due to encryption or short addressing.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_5_3.
2026-02-20 00:33:50 -06:00
Jonathan Hui 0d446ae788 [nexus] add test 6.5.2 Child Sync after Reset - No Parent Response (#12494)
This commit adds a new Nexus test case for 'Child Synchronization
after Reset - No Parent Response' (6.5.2) as specified in the test
specification.

Summary of changes:
- Implemented Nexus test 6.5.2:
    - Added tests/nexus/test_6_5_2.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy
      End Device 'SED_1'). The test simulates a DUT reset and a
      subsequent parent failure (Router 1), verifying that the DUT
      correctly reattaches to a different parent (Leader). The test
      uses direct method calls, sets log level to note, and uses
      AllowList for connectivity.
    - Added tests/nexus/verify_6_5_2.py: PCAP verification script.
      Validates the MLE Child Update Request TLVs, confirms the DUT
      resumes polling if it is a SED, and verifies the subsequent
      reattachment handshake with the Leader and ICMPv6 connectivity.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_5_2 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 22:43:50 -06:00
Jonathan Hui 9a525c46e4 [nexus] only print logs for failed tests in run_nexus_tests.sh (#12502)
This commit updates run_nexus_tests.sh to improve the readability
and utility of test execution:
- Capture test execution output in a log file.
- Only print the captured logs if the test fails.
- Provide a concise one-line status (PASSED/FAILED) for each test.
- Automatically clean up temporary work directories for passing tests.
- Preserve artifacts (PCAP, JSON, logs) for failed tests and print
  the path to the preserved artifacts.
2026-02-19 19:54:26 -06:00
Jonathan Hui be867deea6 [nexus] clear OnMeshPrefixConfig before use in tests (#12501)
This commit ensures that the NetworkData::OnMeshPrefixConfig structure
is cleared using config.Clear() before it is used in Nexus tests.

Since OnMeshPrefixConfig is a local variable on the stack, its fields
can contain garbage values if not explicitly initialized. The core
validity check OnMeshPrefixConfig::IsValid() fails if both mDhcp and
mSlaac are set to true, which can happen with uninitialized memory.

Updated tests:
- tests/nexus/test_6_3_2.cpp: Fixed RunTest6_3_2.
- tests/nexus/test_5_6_1.cpp: Fixed RunTest5_6_1.
2026-02-19 19:33:52 -06:00
Jonathan Hui f277297514 [nexus] add test 7.1.2 Network data propagation - Border Router as Router (#12499)
This commit adds a new Nexus test case 7.1.2 which verifies that when
global prefix information is set on the DUT (Router), it properly
unicasts information to the Leader using CoAP (Server Data Notification)
and that the DUT correctly propagates the aggregated Network Data to its
children during the attach procedure.

The test setup uses Router_1 (DUT) configured as a Border Router with
both stable (2001::/64) and non-stable (2002::/64) prefixes. It
verifies that MED_1 (requesting complete data) receives both prefixes,
while SED_1 (requesting only stable data) receives only the stable
prefix.

Summary of changes:
- Created tests/nexus/test_7_1_2.cpp:
    - Implements test logic using direct C++ method calls.
    - Sets log level to note.
    - Configures AllowList for Router1-Leader, Router1-MED1, and
      Router1-SED1 links.
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting.
- Created tests/nexus/verify_7_1_2.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode.
    - Verifies MLE Child ID and Child Update exchanges.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 7_1_2 to the
  default test list.
2026-02-19 19:10:52 -06:00
Jonathan Hui 894e060ae5 [nexus] add test 6.1.6 Attaching to a REED with Better Link Quality (#12493)
This commit adds a new Nexus test case for 'Attaching to a REED with
Better Link Quality' (6.1.6) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.1.6:
    - Added tests/nexus/test_6_1_6.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy
      End Device 'SED_1'). The test configures a topology where the
      DUT has a bad link (LQ=1) to an active Router and a good link
      (LQ=3) to a REED. It verifies that the DUT correctly sends a
      second Parent Request including REEDs when the initial attempt
      yields a poor quality parent. The test uses direct method calls,
      sets log level to note, and uses AllowList for connectivity.
    - Added tests/nexus/verify_6_1_6.py: PCAP verification script.
      Validates that the DUT sends the first Parent Request with Scan
      Mask set for Routers only, followed by a second Parent Request
      with Scan Mask set for both Routers and REEDs. It then confirms
      the DUT attaches to the REED via a Child ID Request.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_1_6 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 19:07:27 -06:00
Jonathan Hui 6c63700484 [nexus] add test 6.6.2 Key Increment of 1 with Roll-over (#12490) (#12497)
This commit adds a new Nexus test case for 'Key Increment of 1 with
Roll-over' (6.6.2) as specified in the test specification.

The test verifies that the DUT properly decrypts MAC and MLE packets
secured with a Key Index incremented by 1 (causing a rollover) and
switches to the new key.

Summary of changes:
- Implemented Nexus test 6.6.2:
    - Added tests/nexus/test_6_6_2.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy
      End Device 'SED_1'). The test initializes the network with
      KeySequenceCounter = 127, then increments it to 128 to force
      a key switch and rollover. The test uses direct method calls,
      sets log level to note, and uses AllowList for connectivity.
    - Added tests/nexus/verify_6_6_2.py: PCAP verification script.
      Validates MLE Child ID Request and ICMPv6 Echo packets use the
      expected Key Index (128 then 1), Key Source (127), and
      Key ID Mode.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_6_2 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 17:31:54 -06:00
Jonathan Hui 7ca1991764 [nexus] add test 6.1.7 End Device Synchronization (#12495)
This commit adds a new Nexus test case for 'End Device Synchronization'
(6.1.7) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.1.7:
    - Added tests/nexus/test_6_1_7.cpp: Implements the test execution
      for DUT as a Full End Device (FED). The test verifies that the DUT
      automatically sends Link Requests to neighboring routers after
      attaching to the Leader. The test uses direct method calls, sets
      log level to note, and uses AllowList for connectivity.
    - Added tests/nexus/verify_6_1_7.py: PCAP verification script.
      Validates the MLE Child ID Request to the Leader and subsequent
      unicast Link Requests to Router 1, 2, and 3, ensuring they contain
      all required TLVs. Also verifies receipt of Link Accepts from the
      routers.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_1_7 in the
      default test list.
2026-02-19 17:01:02 -06:00
Jonathan Hui ada7bada48 [nexus] add test 6.6.1 Key Increment of 1, Single Hop (#12489)
This commit adds a new Nexus test case for 'Key Increment of 1,
Single Hop' (6.6.1) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.6.1:
    - Added tests/nexus/test_6_6_1.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy
      End Device 'SED_1'). The test verifies that the DUT properly
      decrypts MAC and MLE packets secured with a Key Index
      incremented by 1 and switches to the new key. The test uses
      direct method calls to KeyManager, sets log level to note,
      and uses AllowList for connectivity.
    - Added tests/nexus/verify_6_6_1.py: PCAP verification script.
      Validates MLE Child ID Request and ICMPv6 Echo packets use the
      expected Key Index (1 then 2) and Key ID Mode.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_6_1 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 15:37:40 -06:00
Jonathan Hui de4b7f20de [nexus] add test 6.4.2 Realm-Local Addressing (#12487)
This commit adds a new Nexus test case for 'Realm-Local Addressing'
(6.4.2) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.4.2:
    - Added tests/nexus/test_6_4_2.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy End
      Device 'SED_1'). The test verifies ICMPv6 Echo Request/Reply
      using Realm-Local addresses (ML-EID, All-Nodes, and All Thread
      Nodes). Fragmented (1200 bytes) and non-fragmented packets are
      tested. The test uses direct method calls, sets log level to
      note, and uses AllowList for connectivity (Leader <-> Router 1
      <-> DUT).
    - Added tests/nexus/verify_6_4_2.py: PCAP verification script.
      Validates the exchange of ICMPv6 Echo packets for ML-EID,
      Realm-Local All-Nodes (FF03::1), and Realm-Local All Thread
      Nodes addresses. Correctly derives the Realm-Local All Thread
      Nodes address from the mesh-local prefix.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_4_2 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 13:36:37 -06:00
Jonathan Hui 0c003f1043 [nexus] add test 5.6.2 Network data propagation – Router as BR (#12485)
This commit adds a new Nexus test case 5.6.2 which verifies that
the DUT, as Leader, collects network data information (stable/
non-stable) from the network and propagates it properly during
the attach procedure.

The test setup uses Router_1 configured as a Border Router with
both stable (2001::/64) and non-stable (2002::/64) prefixes. It
verifies that SED_1 (requesting stable data) and MED_1 (requesting
complete data) receive the correct subset of network data during
the attach procedure to the Leader (DUT).

Summary of changes:
- Created tests/nexus/test_5_6_2.cpp:
    - Implements test logic using direct C++ method calls.
    - Configures AllowList for Leader-Router1, Leader-MED1, and
      Leader-SED1 links.
    - Includes 1-line log outputs for each test step.
    - Adheres to requested block comment formatting.
- Created tests/nexus/verify_5_6_2.py:
    - Implements pcap-based verification of PASS criteria.
    - Validates selective prefix propagation based on child mode.
    - Verifies MLE Child ID and Child Update exchanges.
    - Follows requested Python filter formatting style.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_6_2 to the
  default test list.
2026-02-19 13:36:10 -06:00
Jonathan Hui c60b4fc01c [nexus] add test 6.5.1 Child Synchronization after Reset - Reattach (#12488)
This commit adds a new Nexus test case for 'Child Synchronization after
Reset - Reattach' (6.5.1) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.5.1:
    - Added tests/nexus/test_6_5_1.cpp: Implements the test execution
      for both Topology A (Minimal End Device 'MED_1') and Topology B
      (Sleepy End Device 'SED_1'). The test simulates a DUT reset for
      a time longer than its Child Timeout and verifies that it
      correctly reattaches to its parent (Leader). The test uses direct
      method calls, sets log level to note, and uses AllowList for
      connectivity.
    - Added tests/nexus/verify_6_5_1.py: PCAP verification script.
      Validates the MLE Child Update Request TLVs, handles the 'Error'
      status response from the Leader, and confirms the subsequent
      reattachment handshake and ICMPv6 connectivity. Patches
      pktverify to support the mle.tlv.status field.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_5_1 in the
      default test list and added expansion logic for A/B topologies.
2026-02-19 11:49:14 -06:00
Łukasz Duda 04f719e7f7 [crypto] PSA API: introduce default OpenThread crypto platform port (#12324)
This commit adds a default implementation of the OpenThread crypto
platform API for the PSA Crypto API.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-02-19 10:48:44 -06:00
Jonathan Hui d44de4e418 [nexus] add test 7.1.1 Network Data Propagation (#12492)
This commit adds a new Nexus test case for 'Network data propagation'
(7.1.1) as specified in the Thread Test Specification.

The test verifies that the DUT, acting as a Border Router and Leader,
correctly sets Network Data (stable and non-stable) and successfully
propagates it to various child types (Router, MED, and SED) during the
attach and child update processes.

Summary of changes:
- tests/nexus/test_7_1_1.cpp: Implements the test logic.
    - Configures a network with a Leader (DUT), Router_1, MED_1, and
      SED_1.
    - Sets up On-Mesh Prefixes on the Leader (one stable, one non-stable)
      and registers them.
    - Sequentially attaches Router_1, SED_1, and MED_1.
    - Advances time to allow for MLE Child ID and Child Update
      exchanges.
    - Uses direct core method calls and sets log level to note.
- tests/nexus/verify_7_1_1.py: Python PCAP verification script.
    - Verifies MLE Advertisements from the Leader.
    - Validates MLE Child ID Responses to Router_1 and MED_1 contain
      both prefixes.
    - Validates MLE Child ID Response to SED_1 contains only the stable
      prefix and ensures P_border_router_16 is 0xFFFE.
    - Verifies the Child Update exchange with required TLVs for MED_1
      and SED_1.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
- tests/nexus/run_nexus_tests.sh: Added 7_1_1 to the default test list.
2026-02-19 00:34:42 -06:00
Jonathan Hui afbc7efbd8 [nexus] add test 6.3.2 network data update (#12490)
This commit adds a new nexus test that implements the test
specification for 6.3.2 Network Data Update.

The test covers both Topology A (Minimal End Device - MED) and
Topology B (Sleepy End Device - SED). It validates that the child
device correctly identifies updated network data and requests the
full network data if necessary.

Changes:
- Added tests/nexus/test_6_3_2.cpp to execute the test.
- Added tests/nexus/verify_6_3_2.py to verify packet captures.
- Updated tests/nexus/CMakeLists.txt to build the new test.
- Updated tests/nexus/run_nexus_tests.sh to include 6_3_2.

The C++ code uses direct core method calls and handles RF isolation
between node pairs using AllowList/UnallowList. The Python script
performs rigorous verification of MLE Data Response, Child Update
Request/Response, and Data Request packets, including Address
Registration TLV content verification.
2026-02-19 00:33:01 -06:00
Jonathan Hui 091414e6ac [nexus] add test 6.1.5 Attaching with Better Link Quality (#12486)
This commit adds a new Nexus test case for 'Attaching to a Router with
Better Link Quality' (6.1.5) as specified in the test specification.

Summary of changes:
- Added tests/nexus/test_6_1_5.cpp:
    - Implements test 6.1.5 using direct method calls from the core.
    - Sets up a topology with a Leader, one Router, and one REED.
    - Uses AllowList to configure connectivity as specified.
    - Adjusts RSSI between DUT and REED to ensure lower link quality.
    - Sets log level to note and includes 1-line log output for each
      test step.
    - Avoids magic numbers by using descriptive constants.
- Added tests/nexus/verify_6_1_5.py:
    - PCAP verification script for test 6.1.5.
    - Validates MLE Parent Request and Child ID Request TLVs.
    - Verifies that the DUT selects Router 1 (better link quality) as
      its parent.
    - Confirms ICMPv6 Echo connectivity between Router 1 and the DUT.
    - Follows one-condition-per-line style for verification logic.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to include nexus_6_1_5.
    - Updated tests/nexus/run_nexus_tests.sh to add 6_1_5 to the
      default test list.
2026-02-19 00:32:44 -06:00
Jonathan Hui 932791805f [nexus] fix occasional failure in test 6.1.4 (#12491)
Increase kAttachToChildTime to 100s to ensure neighbor discovery
completes for REEDs. Also set kReedThreshold to 0 to prevent
premature router upgrades during the discovery phase.
2026-02-19 00:31:00 -06:00
Abtin Keshavarzian 7f8e04a352 [tests] update seeker unit test (#12475)
This commit updates `tests/unit/test_seeker.cpp` to use `ot::Array`
instead of C-style arrays with initializer lists for passing expected
selection orders in `CheckSelection()`.

The previous approach of passing initializer lists to a function
expecting a reference to a constant array caused compilation issues
on certain toolchains due to template deduction rules or temporary
object handling. By explicitly populating an `ot::Array` and passing
it, the test code becomes more portable and robust across different
compilers.
2026-02-18 15:13:42 -06:00
Jonathan Hui ab0c978ab3 [nexus] add test 6.3.1 Orphan Reattach (#12471)
This commit adds a new Nexus test case for 'Orphan Reattach' (6.3.1)
as specified in the Thread Test Specification.

The test validates that the DUT (ED or SED) will correctly detach
and re-attach to the Leader after its parent (Router_1) is silently
removed from the network.

Summary of changes:
- tests/nexus/test_6_3_1.cpp: Implements the test logic.
    - Sets up a network with Leader, Router_1, and DUT.
    - Initially attaches DUT to Router_1.
    - Silently stops Router_1 to simulate parent loss.
    - Advances time to allow the DUT to detect the loss and re-attach
      to the Leader.
    - Verifies connectivity via ICMPv6 Echo between Leader and DUT.
- tests/nexus/verify_6_3_1.py: Python PCAP verification script.
    - Validates optional Child Update Request or Data Request
      messages sent during the detachment phase.
    - Exhaustively verifies the MLE attach sequence (Parent Request,
      Parent Response, Child ID Request, Child ID Response) with the
      new parent (Leader).
    - Verifies the final ICMPv6 Echo Request/Reply exchange.
- tests/nexus/CMakeLists.txt: Integrated the new test into the build
  system.
- tests/nexus/run_nexus_tests.sh: Added 6_3_1_A and 6_3_1_B to the
  default test list.
2026-02-18 12:36:41 -06:00
Jonathan Hui 4888911cd5 [nexus] add test 6.4.1 Link-Local Addressing (#12483)
This commit adds a new Nexus test case for 'Link-Local Addressing'
(6.4.1) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 6.4.1:
    - Added tests/nexus/test_6_4_1.cpp: Implements the test execution
      for both Topology A (End Device 'ED_1') and Topology B (Sleepy End
      Device 'SED_1'). The test verifies unicast and multicast ICMPv6 Echo
      Request/Reply using Link-Local addresses. Fragmented and
      non-fragmented packets are tested. The test uses direct method
      calls, sets log level to note, and uses AllowList for
      connectivity.
    - Added tests/nexus/verify_6_4_1.py: PCAP verification script.
      Validates the exchange of ICMPv6 Echo packets for unicast
      (Extended Address-based LLA) and multicast (All Thread Nodes and
      All Nodes) addresses.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_4_1 in the
      default test list and added expansion logic for A/B topologies.
2026-02-18 09:05:13 -06:00
Jonathan Hui ebc7d86b41 [nexus] add test 6.1.4 Attaching to a REED with Better Connectivity (#12481)
This commit adds a new Nexus test case for 'Attaching to a REED with
Better Connectivity' (6.1.4) as specified in the test specification.

Summary of changes:
- Added tests/nexus/test_6_1_4.cpp:
    - Implements test 6.1.4 using direct method calls from Mle class.
    - Sets up a topology with a Leader, one Router, and two REEDs.
    - Uses AllowList to configure connectivity so REED_1 (Router 3)
      has better connectivity than REED_2 (Router 2).
    - Sets log level to note and includes 1-line log output for each
      test step.
    - Avoids magic numbers by using constants for router upgrade
      thresholds.
- Added tests/nexus/verify_6_1_4.py:
    - PCAP verification script for test 6.1.4.
    - Validates MLE Parent Request TLVs (Scan Mask) in steps 2 and 4.
    - Verifies that the DUT selects REED_1 as its parent and sends a
      unicast Child ID Request with required TLVs.
    - Confirms ICMPv6 Echo exchange between REED_1 and the DUT.
    - Follows requested style for line continuation and logging.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to include nexus_6_1_4.
    - Updated tests/nexus/run_nexus_tests.sh to add 6_1_4 to the
      default test list.
2026-02-18 09:04:54 -06:00
Jonathan Hui fd2bcdafdc [nexus] add test 5.6.1 Network data propagation – Leader as BR (#12450)
This commit adds a new Nexus test case 5.6.1 which verifies that
the DUT correctly sets the Network Data (stable/non-stable) received
during the attaching procedure and propagates it properly to
devices that attach to it.

The test setup uses a Leader configured as a Border Router with
both stable and non-stable prefixes. It verifies that children
attaching to the DUT (Router_1) receive the appropriate network
data based on their requested mode (full vs. stable-only).

Summary of changes:
- Created tests/nexus/test_5_6_1.cpp:
    - Implements test execution using direct C++ method calls.
    - Uses AllowList to define specific node links.
    - Includes 1-line log outputs for each test specification step.
- Created tests/nexus/verify_5_6_1.py:
    - Implements pcap-based verification of PASS criteria.
    - Checks for stable/non-stable Network Data propagation.
    - Validates 6LoWPAN fragmentation and MAC security.
    - Verifies address registration and ICMPv6 connectivity.
- Updated tests/nexus/CMakeLists.txt to include the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_6_1 to the default
  test list.
2026-02-18 09:04:29 -06:00
Jonathan Hui 6501c88c07 [nexus] update tshark to 4.6.2 or later (#12482)
This commit updates the Nexus workflow to install TShark version 4.6.2
or later by adding the 'wireshark-dev/stable' PPA. This is required
to support modern Wireshark features in Nexus tests.
2026-02-18 09:04:08 -06:00
Jonathan Hui c29d3ccebc [nexus] add test 6.2.2 Connectivity when Parent Joins Partition (#12479)
This commit adds a new Nexus test case for 'Connectivity when Parent
Joins Partition' (6.2.2) as specified in the Thread Test
Specification.

The test verifies that a Child (End Device or Sleepy End Device)
maintains connectivity when the current Leader is removed and its
parent Router joins a new partition created by another Router.

Summary of changes:
- tests/nexus/test_6_2_2.cpp: C++ test execution script.
    - Implements support for Topology A (MED) and Topology B (SED).
    - Sets up a network with a Leader, Router_1, Router_2, and the
      DUT attached to Router_1.
    - Configures Router_2 with a shorter NETWORK_ID_TIMEOUT and a
      maximum Partition ID preference.
    - Simulates Leader removal and verifies that Router_2 creates a
      new partition and Router_1 joins it.
    - Verifies that the DUT maintains connectivity via MLE Child
      Update (MED) or periodic data requests (SED).
    - Verifies bidirectional connectivity using ICMPv6 Echo Request.
- tests/nexus/verify_6_2_2.py: Python PCAP verification script.
    - Validates that Router_2 creates a new partition with the
      expected maximum Partition ID.
    - Validates that Router_1 joins the new partition.
    - For MED, verifies the MLE Child Update Request contains correct
      TLVs (Source Address, Leader Data, Mode) and Partition ID.
    - For SED, verifies periodic connectivity to the parent.
    - Validates the ICMPv6 Echo Request and Reply exchange.
- tests/nexus/run_nexus_tests.sh: Updated test runner.
    - Added 6_2_2 to the default test list.
    - Added expansion logic to run both A and B topologies.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
2026-02-17 23:23:59 -06:00
Abtin Keshavarzian db2d99176c [nexus] extend Node::Join() to allow specifying network data type on SED (#12451)
This commit updates `Node::Join()` to allow specifying whether a node
joining as an SED should request the full network data or only the
stable subset via the `JoinMode` parameter.

Previously, `kAsSed` implicitly requested full network data. This
change updates `kAsSed` to request only the stable subset (the
default behavior for an SED). A new `kAsSedWithFullNetData` mode is
introduced to explicitly request full network data when joining as
an SED.

This change provides more flexibility in test scenarios, allowing
validation of SEDs with different network data requirements.
2026-02-17 22:50:48 -06:00
Jonathan Hui d5e57a44e6 [nexus] add test 5.7.3 CoAP Diagnostic Query and Answer – Router, FED (#12477)
This commit adds a new Nexus test case for 'CoAP Diagnostic Query and
Answer Commands – Router, FED' (5.7.3) as specified in the test
specification.

Summary of changes:
- Implemented Nexus test 5.7.3:
    - Added tests/nexus/test_5_7_3.cpp: Sets up a network topology
      with a Leader, Router 1, and three children (FED 1, MED 1,
      SED 1) attached to Router 1. Implemented internal callback
      to validate that diagnostic responses contain essential TLVs
      (MAC Address, RLOC16, Mode) and verified that at least two
      nodes (Router and FED) respond.
    - Added tests/nexus/verify_5_7_3.py: PCAP verification script.
      Validates the multicast query and the subsequent answers from
      the Router and FED DUTs. Performed deep validation of returned
      TLVs (MAC Address, RLOC16, Mode, Leader Router ID, IPv6 Address
      List, Child Table).
- Enhanced packet verification utilities:
    - Updated tests/nexus/verify_utils.py to support parsing and
      registering more Thread Diagnostic TLVs (MAC Address, IPv6
      Address List, Child Table, Channel Pages).
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt and run_nexus_tests.sh to
      include the new test.

Review fixes:
- tests/nexus/test_5_7_3.cpp: Use Tlv::Find() for more concise and
  idiomatic parsing of Network Diagnostic TLVs.
- tests/nexus/verify_5_7_3.py: Include MED_1 in Router 1's child table
  verification.
2026-02-17 22:02:56 -06:00
Jonathan Hui 6962c90cad [nexus] add test 6.1.3 Attaching to a Router with better connectivity (#12478)
This commit adds a new Nexus test case for 'Attaching to a Router
with better connectivity' (6.1.3) as specified in the test
specification.

Summary of changes:
- Implemented Nexus test 6.1.3:
    - Added tests/nexus/test_6_1_3.cpp: Sets up a topology with a
      Leader, three Routers (Router 1, 2, 3), and a DUT (ED/SED).
      Configures the AllowList so that Router 3 has better
      connectivity than Router 2. Executes the test sequence for
      both Topology A (End Device) and Topology B (Sleepy End
      Device). Sets log level to note. Refactored 'main' to reduce
      code duplication.
    - Added tests/nexus/verify_6_1_3.py: PCAP verification script.
      Validates that the DUT sends a MLE Parent Request to the
      All-Routers multicast address with required TLVs, and
      subsequently sends a unicast MLE Child ID Request to Router 3
      due to better connectivity. Also verifies ICMPv6 Echo
      Request/Reply between Router 3 and the DUT.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 6_1_3 in the
      default test list and added expansion logic for A/B topologies.
- Code cleanup and review fixes:
    - Refactored 'main' in test_6_1_3.cpp to improve topology and
      JSON filename handling.
    - Removed redundant include of 'mac/data_poll_sender.hpp'.
    - Fixed code style issues identified by 'make-pretty'.
2026-02-17 21:45:36 -06:00
Abtin Keshavarzian 6c7c0dae42 [nexus] use kAsFed in Node::Join (#12454)
Updates various Nexus test cases to utilize the `kAsFed` `JoinMode`
when calling `Node::Join`. Previously, these tests manually called
`Mle::SetRouterEligible(false)` before joining to configure the device
as a Full End Device (FED). Using the `kAsFed` parameter simplifies
the test code and leverages the existing logic within `Node::Join` to
handle the configuration.
2026-02-17 21:18:47 -06:00
Jonathan Hui 41a569bf0e [nexus] add test 6.2.1 Connectivity when Parent Creates Partition (#12470)
This commit adds a new Nexus test case for 'Connectivity when Parent
Creates Partition' (6.2.1) as specified in the Thread Test
Specification.

The test verifies that a Child (End Device or Sleepy End Device)
maintains connectivity or reattaches to its parent when the current
Leader is removed and the parent Router creates a new partition.

Summary of changes:
- tests/nexus/test_6_2_1.cpp: C++ test execution script.
    - Implements support for Topology A (ED) and Topology B (SED).
    - Sets up a network with a Leader, Router_1, and the DUT.
    - Simulates Leader power-down and verifies that Router_1 becomes
      the new Leader.
    - Confirms the DUT remains attached or reattaches to Router_1.
    - Verifies bidirectional connectivity using ICMPv6 Echo Request.
- tests/nexus/verify_6_2_1.py: Python PCAP verification script.
    - Validates the network formation and DUT attachment.
    - Verifies that Router_1 creates a new partition with a new ID
      after the Leader is removed.
    - Validates the ICMPv6 Echo Request and Reply exchange between
      Router_1 and the DUT.
- tests/nexus/run_nexus_tests.sh: Updated test runner.
    - Added 6_2_1_A and 6_2_1_B to the default test list.
    - Added expansion logic to run both topologies for 6_2_1.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
2026-02-17 17:49:07 -06:00
Jonathan Hui c5177f8a43 [nexus] add test 5.7.2 CoAP Diagnostic Get/Reset – REED (#12469)
This commit adds a new Nexus test case for 'CoAP Diagnostic Get
Query and Answer Commands – REED' (5.7.2) as specified in the
test specification.

Summary of changes:
- Implemented Nexus test 5.7.2:
    - Added tests/nexus/test_5_7_2.cpp: Sets up a topology with a
      Leader, 15 Routers, and 1 REED (DUT) attached to Router 1.
      Executes the test sequence by sending CoAP Diagnostic Get,
      Reset, and Query commands using direct method calls to the
      Network Diagnostic Client. Uses AllowList for topology
      management and sets log level to note.
    - Added tests/nexus/verify_5_7_2.py: PCAP verification script.
      Validates that the REED DUT correctly handles diagnostic
      requests, ensuring the Timeout TLV is absent in responses
      and verifying MAC counter reset functionality. Also validates
      multicast query and unicast answer flows.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5.7.2 in
      the default test list.
2026-02-17 16:43:36 -06:00
dependabot[bot] ce3d24657d github-actions: bump actions/setup-python from 5.6.0 to 6.2.0 (#12465)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.6.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/a26af69be951a213d495a4c3e4e4022e16d87065...a309ff8b426b58ec0e2a45f0f869d46889d02405)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-17 16:21:36 -06:00
Abtin Keshavarzian 416bb890a5 [mac] introduce ScanResult to encapsulate scan results (#12453)
This commit introduces the `ScanResult` class, which inherits from
`otActiveScanResult`. This new class provides C++ idiomatic getter
methods that return core OpenThread types (e.g., `ExtAddress`,
`ExtendedPanId`, `NetworkName`) instead of raw C structures.

The logic for parsing a received Beacon frame and populating the
result fields is moved into `ScanResult::PopulateFromBeacon()`.
This centralizes the parsing logic and allows it to be reused
across different modules.

Consequently, `Mac`, `DiscoverScanner`, `Seeker`, and
`PanIdQueryServer` are updated to utilize `ScanResult`. The `Mac`
class is also updated to use the `Callback` template for the active
scan handler, replacing the previous raw function pointer and context.
2026-02-17 15:20:37 -06:00
Jonathan Hui 75db779969 [nexus] fix flake in test 5.8.3 Key Increment of 1 With Roll-over (#12473)
Step 6 of test 5.8.3 requires the DUT to send an MLE Advertisement
reflecting the updated Key Sequence Counter. The previous 10-second
simulation time in this step was occasionally insufficient, as the
default MLE advertisement interval can be up to 32 seconds.

This commit increases the simulation time in Step 6 to 35 seconds
(kMaxAdvertisementTime) to ensure that at least one periodic MLE
Advertisement is captured in the pcap for verification.
2026-02-17 14:59:01 -06:00
Abtin Keshavarzian 50325acde2 [coap] introduce Request and PendingRequests (#12421)
This commit introduces a new nested class `Request` within `CoapBase`
to represent a pending CoAP request. The `Request` class encapsulates
the `Message` pointer and its associated `Metadata`, providing helper
methods to manage the metadata stored in the message footer.

It also introduces the `PendingRequests` helper class to manage the
queue of pending requests. This class wraps the underlying
`MessageQueue` and provides typed access to `Request` objects, along
with methods to add, remove, and search for requests.

`CoapBase` is updated to utilize these new classes for tracking
pending requests. This streamlines the logic in
`HandleRetransmissionTimer`, `ProcessReceivedResponse`, and other
methods by abstracting the low-level message and metadata manipulations.
`FinalizeCoapTransaction` is renamed to `FinalizeRequest`.
2026-02-17 14:48:52 -06:00
Jonathan Hui e0614c6963 [nexus] fix intermittent failure in test 6.1.2 (#12472)
This commit fixes an intermittent failure in Nexus test 6.1.2 by
setting the REED's router upgrade threshold to 0.

By default, a REED may attempt to upgrade to a Router if the number of
active routers in the network is below a certain threshold. In this
test scenario, we want to ensure the REED remains a child until the
appropriate point in the test sequence. Setting the threshold to 0
prevents premature promotion due to low router count, ensuring more
deterministic test behavior.
2026-02-17 14:39:38 -06:00
Jonathan Hui 56be53f9fc [nexus] fix intermittent failure in Test 5.5.5 (#12461) (#12468)
This commit fixes an intermittent failure in Nexus Test 5.5.5 where
the verification script failed to find the Address Solicit Request.

The failure was caused by two main factors:
1. Re-attachment timing: The original 120s re-attachment window in
   the C++ test was occasionally too short for Router 1 to detect
   isolation, perform a new parent search, and complete attachment,
   especially when combined with protocol jitter and router timeout.
2. Packet ordering: The Python verification script searched for the
   Address Solicit Request only after the Child ID Request. However,
   due to randomized router selection jitter, the DUT (REED 1) could
   occasionally send the Address Solicit Request before Router 1 had
   finished its attachment process.

To fix this:
- Increased kReattachTime from 120s to 140s in the C++ test to
  provide a safer margin for re-attachment.
- Updated the verification script to search for the Address Solicit
  Request and Link Request starting from the beginning of the
  re-attachment process (Step 4), using cascade=False to maintain
  the sequential search index for other mandatory packets.

Verified by running multiple repeated iterations of the test.
2026-02-17 14:21:33 -06:00
Abtin Keshavarzian f97674ed6e [border-router] fix stop behavior in PdPrefixManager (#12442)
Previously, `PdPrefixManager::Stop()` was implemented as a call to
`Evaluate()`. The `Evaluate()` method calls `UpdateState()`, which
checks `RoutingManager::IsRunning()` to determine if the state should
be switched to `kDhcp6PdStateStopped`.

However, `RoutingManager::Stop()` calls `PdPrefixManager::Stop()`
before updating its own running state (setting `mIsRunning` to
`false`). As a result, `PdPrefixManager` would incorrectly remain in
`Running` or `Idle` state instead of stopping.

This commit updates `PdPrefixManager::Stop()` to explicitly set the
state to `kDhcp6PdStateStopped`.
2026-02-17 13:28:25 -06:00
Jonathan Hui cba01ecd41 [nexus] add test 6.1.2 Attaching to a REED (#12464)
This commit adds a new Nexus test case for 'Attaching to a REED'
(6.1.2) as specified in the Thread Test Specification.

The test verifies that both an End Device (ED) and a Sleepy End Device
(SED) can successfully attach to a network through a Router Eligible
End Device (REED). The test ensures that the REED correctly upgrades
to a Router to serve as the device's parent.

Summary of changes:
- tests/nexus/test_6_1_2.cpp: C++ test execution script.
    - Refactored to support topology selection via command-line arguments.
    - Saves topology-specific JSON metadata (e.g., test_6_1_2_A.json).
- tests/nexus/verify_6_1_2.py: Python PCAP verification script.
    - Topology-aware verification supporting both ED and SED keep-alives.
- tests/nexus/run_nexus_tests.sh: Updated test runner.
    - Added support for sub-tests with topology suffixes (e.g., 6_1_2_A).
    - Automatically expands '6_1_2' into both '6_1_2_A' and '6_1_2_B' runs.
    - Isolates artifacts (JSON/PCAP) for each topology run.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
2026-02-17 00:00:36 -06:00
Jonathan Hui d095f594f6 [nexus] add test 5.8.3 Key Increment of 1 With Roll-over (#12458)
This commit adds a new Nexus test case for 'Key Increment of 1 With
Roll-over' (5.8.3) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.8.3:
    - Added test_5_8_3.cpp: Sets up a network with a Leader and a
      Router_1 (DUT). Initializes the network with
      KeySequenceCounter = 127. Verifies initial MLE and MAC security
      parameters. Increments KeySequenceCounter by 1 to trigger a key
      rollover and verifies that the DUT correctly switches to the new
      key (Key Index = 1).
    - Added verify_5_8_3.py: PCAP verification script for test 5.8.3.
      Validates MLE Auxiliary Security Header (Key ID Mode, Key
      Source, Key Index) and MAC Auxiliary Security Header in Echo
      Replies.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.8.3 test executable.
    - Updated run_nexus_tests.sh to include 5.8.3 in the default test
      list.
2026-02-16 23:48:49 -06:00
Jonathan Hui 295bd70514 [nexus] add test 5.7.1 CoAP Diagnostic Get, Response, and Reset (#12456)
This commit adds a new Nexus test case for 'CoAP Diagnostic Get
Request, Response and Reset Commands' (5.7.1) as specified in the
test specification.

Summary of changes:
- Implemented Nexus test 5.7.1:
    - Added test_5_7_1.cpp: Sets up a network topology with a Leader,
      Router 1 (DUT), and various child nodes (FED, MED, SED, REED).
      Executes the 8-step test sequence by sending CoAP Diagnostic
      Get and Reset commands from the Leader to the DUT using direct
      method calls. Uses AllowList for topology management and sets
      log level to note.
    - Added verify_5_7_1.py: PCAP verification script for test 5.7.1.
      Validates the presence and values of requested Network
      Diagnostic TLVs in CoAP requests and responses. Ensures the
      DUT correctly handles requests for MAC Counters, Timeout
      (omitted), and Child Table, and verifies the reset functionality.
- Enhanced verification utilities:
    - Updated verify_utils.py: Added length checks during Thread TLV
      parsing in CoAP payloads to handle overlapping TLV types
      correctly and prevent verification failures.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.7.1 test executable.
    - Updated run_nexus_tests.sh to include 5.7.1 in the default test
      list.
2026-02-16 21:35:59 -06:00
Jonathan Hui 1d97236a88 [nexus] add test 6.1.1 Attaching to a Router (#12463)
This commit adds a new Nexus test case for 'Attaching to a Router'
(6.1.1) as specified in the Thread Test Specification.

The test verifies that both an End Device (ED) and a Sleepy End Device
(SED) can successfully attach to a network.

Summary of changes:
- tests/nexus/test_6_1_1.cpp: C++ test execution script.
    - Refactored to support topology selection via command-line arguments.
    - Saves topology-specific JSON metadata (e.g., test_6_1_1_A.json).
- tests/nexus/verify_6_1_1.py: Python PCAP verification script.
    - Topology-aware verification supporting both ED and SED.
- tests/nexus/run_nexus_tests.sh: Updated test runner.
    - Added support for sub-tests with topology suffixes (e.g., 6_1_1_A).
    - Automatically expands '6_1_1' into both '6_1_1_A' and '6_1_1_B' runs.
    - Isolates artifacts (JSON/PCAP) for each topology run.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
2026-02-16 20:27:58 -06:00
Jonathan Hui 9eb38664a1 [nexus] add test 5.8.2 Key Increment Of 1 (#12457)
This commit adds a new Nexus test case for 'Key Increment Of 1' (5.8.2)
as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.8.2:
    - Added tests/nexus/test_5_8_2.cpp: Sets up a network topology
      with a Leader and Router_1 (DUT). Verifies proper decryption
      of MAC and MLE packets secured with an incremented key index.
    - Added tests/nexus/verify_5_8_2.py: PCAP verification script for
      test 5.8.2. Validates key index transitions in MLE Parent Request,
      Child ID Request, ICMPv6 Echo, and MLE Advertisements.
- Enhanced pktverify framework:
    - Added 'number' property to Packet class and 'frame' object to filter
      evaluation context, enabling 'frame.number' checks in verification scripts.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5.8.2 in the
      default test list.
2026-02-16 18:48:05 -06:00
Jonathan Hui eaae5dc3ce [nexus] add test case 5.5.7 Split/Merge Routers: Three-way Separated (#12449)
This commit implements Nexus test case 5.5.7 which verifies the
behavior of a Thread network when three routers are separated from
the leader and eventually merge back into a single partition.

Test details:
- Topology: Leader and three Routers (Router 1, Router 2, Router 3).
- Description: The Leader acts as the sole link between each router.
  When the Leader is removed for longer than the leader timeout,
  each router forms its own partition. When the Leader returns, it
  reattaches to any available router, and eventually all routers
  merge back.

Implementation:
- Added tests/nexus/test_5_5_7.cpp for C++ test logic.
    - Updated Step 12 to include exhaustive bidirectional connectivity
      verification between the leader and all router nodes.
- Added tests/nexus/verify_5_5_7.py for pcap-based verification.
    - Updated rejoin steps to correctly handle non-deterministic parent
      selection by the leader.
    - Improved pcap verification robustness by using pkts.copy() and
      handling potential NullFields.
    - Added _verify_ping helper to refactor ping verification logic.
    - Updated Step 12 to verify full bidirectional connectivity.
- Updated CMakeLists.txt and run_nexus_tests.sh to include the test.
2026-02-16 16:58:04 -06:00
Jonathan Hui 95780fd03f [nexus] fix flakiness in Test 5.5.1 (#12460)
This commit fixes a flakiness issue in Nexus Test 5.5.1 where valid
MLE Advertisements from the Leader were occasionally caught by the
"must not send advertisements" check during reset.

The issue was caused by using the ICMPv6 Echo Request as the start
boundary for the "no advertisement" check. Since there is a small
delay between the Echo Request and the actual Leader reset, the
Leader might send a perfectly valid advertisement during this window.

To fix this, the verification script now:
1. Captures the Echo Reply to ensure the network is responsive
   before the reset.
2. Uses the Echo Reply timestamp plus a 2.0-second buffer as the
   actual start time for the "no advertisement" check.
3. Filters advertisements in the reset range to only trigger if
   they occur after this buffered reset time.

This approach robustly distinguishes between pre-reset and
post-reset packet flows, even with timing jitter or pcap delivery
delays.
2026-02-16 16:57:37 -06:00
Jonathan Hui 8d793aeb12 [nexus] add test 5.5.5 Split and Merge with REED (#12448)
This commit adds a new Nexus test case for 'Split and Merge with REED'
(5.5.5) as specified in the Thread Test Specification.

The test demonstrates that a REED will upgrade to a Router when it
becomes a necessary parent for an isolated Router after its previous
neighbor (Router 3) is removed from the network.

Summary of changes:
- tests/nexus/test_5_5_5.cpp: C++ test execution script.
    - Sets up a topology with 16 active routers total.
    - Uses AllowList to specify exact links between nodes.
    - Powerdowns Router 3 to isolate Router 1.
    - Verifies REED 1 (DUT) upgrades to router and Router 1 reattaches.
    - Includes 1-line log outputs for each test step.
    - Uses mesh-local EID for ICMP Echo connectivity verification.
- tests/nexus/verify_5_5_5.py: Python PCAP verification script.
    - Verifies all MLE messages and CoAP Address Solicit Request.
    - Ensures proper TLVs are present in MLE and CoAP messages.
    - Tracks ICMPv6 Echo Request/Reply hop-by-hop through the DUT.
    - Follows "one condition per line" style for better readability.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
- tests/nexus/run_nexus_tests.sh: Added 5_5_5 to the default test list.
2026-02-15 22:00:15 -06:00
Jonathan Hui 65793564f8 [nexus] add test 5.5.4.2 Split and Merge with Routers (#12436)
Adds a new Nexus test case for 'Split and Merge with Routers' (5.5.4.2)
as specified in the test specification. This test verifies that the
DUT (Router_1) correctly joins a new higher-priority partition when
the Leader is removed and later merges back when the Leader returns.

Summary of changes:
- Implemented Nexus test 5.5.4.2:
    - Added test_5_5_4_2.cpp: Sets up a topology with a Leader,
      DUT (Router_1), Router_2, Router_3, and Router_4. Verifies
      partitioning behavior, ensuring the DUT joins the higher-priority
      partition formed by Router_3 and later merges with the original
      Leader. Uses direct method calls, sets log level to note, and
      defines links via AllowList.
    - Added verify_5_5_4_2.py: PCAP verification script for test
      5.5.4.2. Ensures properly formatted MLE Advertisements, verifies
      the DUT does not join a lower-priority singleton partition
      prematurely, and validates the reattachment and merge process.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.5.4.2 test executable.
    - Updated run_nexus_tests.sh to include 5_5_4_2 in the default test
      list.
2026-02-14 23:49:23 -06:00
Jonathan Hui 97004e84f8 [nexus] fix flakiness in test 5.5.4.1 (#12455)
This commit addresses the occasional failure of Nexus test 5.5.4.1 by
increasing the merge wait time and improving the robustness of the
packet verification script.

Summary of changes:
- In test_5_5_4_1.cpp, increased kMergeWaitTime from 200s to 300s.
  This provides sufficient time for all nodes to synchronize their
  Mesh-Local Prefix and update their routing tables after the network
  partitions merge.
- In verify_5_5_4_1.py, updated Step 6 verification to filter ICMPv6
  Echo Request and Reply packets by their specific identifier (0xabcd).
  This ensures that the verifier correctly identifies the packets from
  the intended test step and avoids matching stale or transient
  packets from earlier parts of the test.
2026-02-14 23:48:46 -06:00
Jonathan Hui 31f9693a6c [nexus] update Node::SetName() to use underscore as separator (#12452)
This commit updates the Nexus::Node::SetName(prefix, index) method
to use an underscore ('_') instead of a space between the prefix
and the index when generating the node name.

Corresponding verification scripts verify_5_2_3.py and
verify_5_2_4.py are also updated to match the new naming convention
when looking up nodes in the test environment.

All Nexus tests have been verified to pass with this change.
2026-02-13 20:25:37 -06:00
Jonathan Hui 4437e600cc [nexus] add test 5.5.4.1 Split and Merge with Routers (#12435)
This commit adds a new Nexus test case for 'Split and Merge with
Routers' (5.5.4.1) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.5.4.1:
    - Added test_5_5_4_1.cpp: Sets up a network topology with a Leader
      (DUT), Router_1, Router_2, Router_3, and Router_4. Verifies
      MLE Advertisements from the DUT. Resets the DUT to trigger
      network partitions and then merges them back. Uses direct method
      calls, AllowList for topology management, and ping markers for
      accurate verification.
    - Added verify_5_5_4_1.py: PCAP verification script for test
      5.5.4.1. Verifies DUT advertisements and ensures they stop during
      the reset period. Validates successful communication after the
      network merges.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.5.4.1 test executable.
    - Updated run_nexus_tests.sh to include 5.5.4.1 in the default test
      list.
2026-02-13 18:03:14 -06:00
Abtin Keshavarzian da64c7cc95 [nexus] add Node::FindMatchingAddress() helper (#12437)
This commit adds the `Node::FindMatchingAddress()` helper method to the
`Nexus::Node` class. This method simplifies the process of finding a
unicast address on a node that matches a given IPv6 prefix.
2026-02-13 15:15:32 -06:00
Jonathan Hui 3ea572212e [nexus] add test 5.5.3 Split and Merge: Branch with Child (#12434)
This commit adds a new Nexus test case for 'Split and Merge: Branch
with Child' (5.5.3) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.5.3:
    - Added tests/nexus/test_5_5_3.cpp: Sets up a network topology
      with a Leader, two Routers, and two MEDs. Simulates a network
      split by stopping the Leader and allows Routers to form new
      partitions. Reintroduces the Leader and verifies that partitions
      successfully merge back together. Uses direct method calls,
      sets log level to note, and uses AllowList for topology.
    - Added tests/nexus/verify_5_5_3.py: PCAP verification script for
      test 5.5.3. Ensures correct MLE Advertisement, Parent Request,
      Child ID Request, and Address Solicit exchanges during split
      and merge. Validates end-to-end ICMPv6 Echo connectivity after
      the merge.
- Updated build and execution scripts:
    - Modified tests/nexus/CMakeLists.txt to build the new 5.5.3 test.
    - Updated tests/nexus/run_nexus_tests.sh to include 5.5.3 in the
      default test list.
2026-02-13 14:26:05 -06:00
Jonathan Hui 86efe4927a [nexus] add test case 5.5.2 Leader Reboot > timeout (#12432)
This commit implements Nexus test case 5.5.2 which verifies the
behavior of a Thread network when the Leader reboots and remains
offline longer than the leader timeout.

Test details:
- Topology: Leader, Router_1, and MED (attached to Router_1).
- Description: When the Leader is restarted and stays rebooted
  longer than the leader timeout, Router_1 becomes the new Leader.
  When the original Leader returns, it reattaches to the network as
  a Router.

Implementation:
- Added tests/nexus/test_5_5_2.cpp for C++ test logic.
- Added tests/nexus/verify_5_5_2.py for pcap-based verification.
- Updated CMakeLists.txt and run_nexus_tests.sh to include the test.
2026-02-13 12:00:40 -06:00
Abtin Keshavarzian 2d13e58787 [cli] use ToYesNo() in ba admitter output (#12439)
This commit updates the `ba admitter` command output to use the
newly added `ToYesNo()` helper method.
2026-02-13 09:29:24 -06:00
Jonathan Hui 3d5b59b6f1 [nexus] add test 5.5.1 Leader Reboot < timeout (#12431)
This commit adds a new Nexus test case for 'Leader Reboot < timeout'
(5.5.1) as specified in the Thread Test Specification.

The test demonstrates that when a Leader reboots for a period shorter
than the leader timeout, it successfully reattaches to the network
and remains the Leader without causing partition changes.

Summary of changes:
- tests/nexus/test_5_5_1.cpp: C++ test execution script.
    - Sets up a topology with a Leader and a Router.
    - Reboots the Leader for 80 seconds (less than the 120s timeout).
    - Uses direct method calls and block comments.
    - Includes 1-line log outputs for each test step.
- tests/nexus/verify_5_5_1.py: Python PCAP verification script.
    - Verifies MLE Advertisements and correct TLVs.
    - Ensures Leader stops advertisements during reboot.
    - Validates multicast Link Request formatting after reboot.
    - Confirms no Parent Request is sent by the Leader.
    - Verifies ICMPv6 connectivity after reattachment.
- tests/nexus/CMakeLists.txt: Added the new test to the build system.
- tests/nexus/run_nexus_tests.sh: Added 5_5_1 to the default test list.
2026-02-13 09:18:10 -06:00
Jonathan Hui 83eb368bff [nexus] remove redundant CoAP ACK code checks in verify scripts (#12445)
This commit removes redundant `p.coap.code == consts.COAP_CODE_ACK`
checks in several Nexus test verification scripts.

The `filter_coap_ack()` function in the `pktverify` framework already
filters for CoAP ACK messages, which involves checking the message
type and the CoAP code. Therefore, adding a manual filter for the same
CoAP code is redundant and can be removed for conciseness.

Summary of changes:
- tests/nexus/verify_5_1_1.py: Remove redundant CoAP ACK code check.
- tests/nexus/verify_5_1_5.py: Remove redundant CoAP ACK code checks.
- tests/nexus/verify_5_1_6.py: Remove redundant CoAP ACK code check.
- tests/nexus/verify_5_2_3.py: Remove redundant CoAP ACK code checks.
- tests/nexus/verify_5_2_6.py: Remove redundant CoAP ACK code check.
2026-02-13 02:12:16 -06:00
Jonathan Hui 2bf7cb12e2 [pktverify] add filter_ipv6_src() to PacketFilter class (#12444)
This commit adds the filter_ipv6_src() method to the PacketFilter
class in the pktverify framework. This method improves the symmetry
of the filtering API, complementing the existing filter_ipv6_dst().

The new method is used to update several verification scripts in
tests/nexus, replacing manual lambda filters for IPv6 source
addresses with a cleaner and more readable API call.

Updated scripts:
- tests/nexus/verify_5_3_3.py
- tests/nexus/verify_5_3_7.py
- tests/nexus/verify_5_3_8.py
- tests/nexus/verify_5_3_10.py
2026-02-13 02:12:07 -06:00
Jonathan Hui 6122986233 [tests] remove thread-cert tests replaced by Nexus (#12443)
This commit removes the Python-based thread-cert tests for sections 5.1,
5.2, and 5.3. These tests have been replaced by C++ Nexus tests in
tests/nexus/, which offer better performance, reliability, and
integration with the core OpenThread codebase.

The following Python scripts have been removed from
tests/scripts/thread-cert/:
- Cert_5_1_01 through Cert_5_1_13
- Cert_5_2_01, Cert_5_2_03 through Cert_5_2_07
- Cert_5_3_01 through Cert_5_3_11

The corresponding Nexus tests are available in tests/nexus/ along with
their respective PCAP verification scripts.
2026-02-13 02:11:57 -06:00
Jonathan Hui ede310de75 [nexus] add test 5.3.11 Address Query Timeout Intervals (#12430)
Adds a new Nexus test case 5.3.11 to validate 'AQ_TIMEOUT' and
'AQ_RETRY_TIMEOUT' intervals in the Address Query transmission
algorithm.

The test verifies that the DUT:
- Correctly generates Address Query Requests on behalf of its MED
  child when sending Echo Requests to a non-existent mesh-local
  address.
- Correctly implements the retry delay by NOT initiating a new Address
  Query frame if a subsequent Echo Request is sent before the
  'ADDRESS_QUERY_INITIAL_RETRY_DELAY' expires.
- Initiates a new Address Query Request if an Echo Request is sent
  after the 'ADDRESS_QUERY_INITIAL_RETRY_DELAY' has expired.

Summary of changes:
- tests/nexus/test_5_3_11.cpp: Implemented test logic using direct
  method calls and 'AllowList' for topology control.
- tests/nexus/verify_5_3_11.py: Added PCAP verification ensuring correct
  Address Query generation and retry interval logic.
- tests/nexus/CMakeLists.txt: Included the new test in the build system.
- tests/nexus/run_nexus_tests.sh: Added 5_3_11 to the default nexus
  test list.
2026-02-13 00:58:02 -06:00
Jonathan Hui 75b39f0a82 [nexus] add test 5.3.10 Address Query - SLAAC GUA (#12429)
Adds a new Nexus test case 5.3.10 to validate that the DUT (Router_2)
correctly generates Address Query messages and responds with Address
Notification messages for SLAAC Global Unicast Addresses (GUAs).

The test verifies that:
- The DUT correctly generates Address Query Requests on behalf of its
  child (MED_1) to find Router_1's GUA.
- The DUT properly responds to Address Query Requests from the Border
  Router for MED_1's GUA with a CON POST Address Notification.
- The DUT correctly caches mappings and avoids redundant Address Queries
  for subsequent requests.
- The DUT removes cached entries when the target's Router ID expires.
- The DUT does not respond with Address Notification after its child
  (MED_1) has timed out.

Summary of changes:
- tests/nexus/test_5_3_10.cpp: Implemented test logic using direct
  method calls and kLogLevelNote.
- tests/nexus/verify_5_3_10.py: Added PCAP verification script with
  robust RLOC16 and IID-based packet identification.
- tests/nexus/CMakeLists.txt: Included the new test in the build system.
- tests/nexus/run_nexus_tests.sh: Added 5_3_10 to the default list.
2026-02-12 23:12:31 -06:00
Jonathan Hui d9a4d98359 [nexus] add test 5.3.9 Address Query - DHCP GUA (#12427)
This commit adds a new Nexus test case for 'Address Query - DHCP GUA'
(5.3.9) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.3.9:
    - test_5_3_9.cpp: Sets up a topology with Leader (DHCPv6 Border
      Router), Router_1, DUT (Router_2), Router_3, and SED_1
      (attached to DUT). Configures DHCPv6 prefixes 2001:: and 2002::
      as on-mesh prefixes. Implements test logic using direct method
      calls and sets log level to NOTE. Verifies Address Query
      generation on behalf of child, Address Notification responding,
      caching, and cache eviction.
    - verify_5_3_9.py: PCAP verification script for test 5.3.9.
      Ensures correct formatting of Address Query (NON POST /a/aq) and
      Address Notification (CON POST /a/an) messages. Verifies that
      DUT correctly caches addresses and evicts them when Router ID
      is expired by the Leader. Also verifies that DUT does not respond
      to Address Query for a child that has timed out.
- Updated supporting files:
    - CMakeLists.txt: Added building of the 5_3_9 test executable.
    - run_nexus_tests.sh: Added 5_3_9 to the default test list.

The test verifies that the DUT is able to generate Address Query
messages on behalf of its children and properly respond with Address
Notification messages to other routers, while correctly managing its
address cache for DHCPv6 GUA addresses.
2026-02-12 20:12:41 -06:00
Abtin Keshavarzian 16cb5ff87d [seeker] optimize candidate storage and connection strategy (#12389)
This commit updates `Seeker` to use `MessageBackedArray` for storing
discovered candidates. This moves candidate storage from statically
allocated RAM in the `Seeker` instance to a `Message` buffer,
reducing the resident memory footprint.

The connection logic is enhanced to prioritize network diversity. The
`Seeker` now attempts to connect to the most favored candidate of
each unique network (Extended PAN ID) first. After exhausting unique
networks, it proceeds to remaining backup candidates. This improves
the likelihood of finding the correct network quickly in multi-network
environments.

The candidate storage policy is updated to limit entries per network
(defined by `kMaxCandidatesPerNetwork`). When storage is full, the
`Seeker` evicts a redundant entry from a well-represented network to
accommodate new network discoveries.

A detailed unit test `test_seeker` is included to validate candidate
tracking and selection order under various scenarios.
2026-02-12 18:46:59 -06:00
Jonathan Hui 81ad265139 [nexus] refactor all verify_5_*.py scripts to use standard code style (#12438)
Updated the code style in all tests/nexus/verify_5_*.py files to use one
condition per line with the dot operator at the end of the line.
This aligns the scripts with the established pattern in verify_5_1_1.py
and improves readability.
2026-02-12 18:43:39 -06:00
Abtin Keshavarzian 7f3ab64dce [cli] add ToYesNo() helper to convert boolean to string (#12424)
This commit introduces a new helper method `Utils::ToYesNo()` in the
CLI module to convert boolean values into "yes" or "no" strings.

Previously, this conversion was performed using inline ternary
operators (e.g., `val ? "yes" : "no"`) scattered throughout the CLI
implementation. This change replaces these instances with the new
helper method, improving code readability and consistency.
2026-02-12 16:55:36 -06:00
Abtin Keshavarzian 6875a7811c [cli] add ba admitter commands (#12410)
This commit adds CLI support for the Border Agent Admitter feature.
The new commands allow users to enable/disable the admitter, check
its state, configure the joiner UDP port, and list active enrollers
and their accepted joiners.

This change also includes the corresponding documentation in
`src/cli/cli_ba.cpp` and `src/cli/README.md`.
2026-02-12 16:54:43 -06:00
Jonathan Hui 7f837031ed [tests] add nexus test 5.3.8 (MTD Child Address Set) (#12426)
This commit adds a new Nexus test implementing test specification 5.3.8
(MTD Child Address Set).

The test validates that the DUT MTD Child Address Set can hold at least
4 IPv6 non-link-local addresses and that the DUT does not send Address
Query requests for target addresses that should be in its child address
set.

Changes:
- Add tests/nexus/test_5_3_8.cpp to implement the test logic.
- Add tests/nexus/verify_5_3_8.py to verify pcap output.
- Update tests/nexus/CMakeLists.txt to include the new test.
- Update tests/nexus/run_nexus_tests.sh to include 5.3.8 in the default
  test list.
2026-02-12 16:33:17 -06:00
Jonathan Hui 5d8ba73b8a [nexus] add test 5.3.7 Duplicate Address Detection (#12419)
This commit adds a new Nexus test case for 'Duplicate Address Detection'
(5.3.7) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.3.7:
    - Added test_5_3_7.cpp: Sets up a network topology with a Leader
      (DUT), two Routers, two MEDs, and one SED. Configures an on-mesh
      prefix and assigns the same IPv6 address to two different nodes
      (MED_1 and SED_1). Instructs MED_2 to send an Echo Request to
      the duplicate address and verifies the resulting Address Query
      and Address Error Notification exchanges. Uses direct method calls
      and sets log level to note.
    - Added verify_5_3_7.py: PCAP verification script for test 5.3.7.
      Ensures that the Leader sends MLE Advertisements, multicasts an
      Address Query (/aq) to FF03::2, receives Address Notifications
      (/an) from Routers, and finally multicasts an Address Error
      Notification (/ae) to FF03::2.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.3_7 test executable.
    - Updated run_nexus_tests.sh to include 5_3_7 in the default test
      list.
2026-02-12 12:06:43 -06:00
Jonathan Hui 8489fb3727 [nexus] add test 5.3.6 Router ID Mask (#12417)
Adds a new Nexus test case for 'Router ID Mask' (5.3.6) as specified
in the test specification. This test verifies that the router ID mask
is managed correctly as connectivity to routers is lost and regained.

Summary of changes:
- Implemented Nexus test 5.3.6:
    - Added test_5_3_6.cpp: Sets up a Leader (DUT) and two Routers.
      Verifies that the Leader correctly removes Router IDs from its
      routing table after connectivity is lost for a prolonged period
      and updates them when routers reattach. Uses direct method calls
      and AllowList for topology management.
    - Added verify_5_3_6.py: PCAP verification script for test 5.3.6.
      Ensures MLE Advertisements correctly reflect the addition and
      removal of Router IDs from the ID mask.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.3.6 test executable.
    - Updated run_nexus_tests.sh to include 5.3.6 in the default test
      list.
2026-02-12 10:00:56 -06:00
Abtin Keshavarzian b0f6a855e0 [ip6] expose static multicast address getters and remove wrapper methods (#12416)
This commit updates `Ip6::Address` to expose `static` getter methods for
common multicast addresses (e.g., `GetLinkLocalAllNodesMulticast()`)
as public API.

Consequentially, the wrapper `SetTo...` and `Is...` methods for these
multicast addresses are removed. Callers are updated to use the
`static` getters directly. This change simplifies usage by allowing
direct access to the constant address instances, often eliminating
the need for local `Ip6::Address` variables.
2026-02-12 09:00:26 -06:00
Jonathan Hui dcc6b2158d [nexus] add test 5.3.5 Routing - Link Quality (#12415)
This commit adds a new Nexus test case for 'Routing - Link Quality'
(5.3.5) as specified in the Thread Test Specification.

The test validates that the DUT properly routes traffic when link
qualities between nodes are adjusted. It ensures that the shortest
path is chosen based on link costs and that direct neighbors are
prioritized for equal-cost paths.

Summary of changes:
- Implemented Nexus test 5.3.5:
    - Added test_5_3_5.cpp: Sets up a multi-hop topology using
      AllowList (Leader, DUT, Router 2, Router 3). Adjusts RSSI
      to simulate Link Quality levels 3, 2, 1, and 0 between the
      Leader and DUT. Initiates pings from Router 3 to Leader.
    - Added verify_5_3_5.py: PCAP verification script that validates
      multi-hop paths and ensures the 'hopsLft' field in the 6LoWPAN
      Mesh Header is correctly maintained.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.3.5 test executable.
    - Updated run_nexus_tests.sh to include 5.3.5 in the default list.
2026-02-12 08:25:59 -06:00
Jonathan Hui cb50246d47 [nexus] add test 5.3.4 MTD EID-to-RLOC Map Cache (#12413)
Adds a new Nexus test case 5.3.4 to validate that an MTD (Router_1
acting as DUT) correctly maintains an EID-to-RLOC Map Cache for its
Sleepy End Device (SED) child.

The test verifies that the DUT:
- Correctly generates Address Query Requests on behalf of its SED
  child when the child sends Echo Requests to multiple MED nodes.
- Properly caches the EID-to-RLOC mappings after receiving Address
  Notifications from the Leader.
- Reuses the cached mappings for subsequent Echo Requests from the
  SED, without sending additional Address Queries.

Summary of changes:
- tests/nexus/test_5_3_4.cpp: Implemented test logic, refactored with
  loops for maintainability.
- tests/nexus/verify_5_3_4.py: Added order-independent verification
  for Address Queries and Notifications.
- tests/nexus/CMakeLists.txt: Included the new test in the build
  system.
- tests/nexus/run_nexus_tests.sh: Added 5_3_4 to the default nexus
  test list.
2026-02-12 06:53:27 -06:00
Abtin Keshavarzian 85597120cd [nexus] use OT_CFLAGS for stricter build-time checks & fix warnings (#12420)
This commit updates `tests/nexus/CMakeLists.txt` to include
`${OT_CFLAGS}` in `target_compile_options` for `ot-nexus-platform`
and test executables. This enables stricter compiler warnings and
errors during the build process.

It also addresses issues exposed by the new flags, including unused
variables and constants, shadow variable declarations, and member
variable initialization order in constructors.
2026-02-12 00:23:14 -06:00
Jonathan Hui 173ce37f5d [nexus] add test 5.3.3 Address Query - ML-EID (#12407)
Adds a new Nexus test case for 'Address Query - ML-EID' (5.3.3) as
specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.3.3:
    - test_5_3_3.cpp: Sets up a topology with Leader, Router_1, DUT
      (Router_2), Router_3, and MED_1 (attached to DUT). Implements
      the test logic using direct method calls and sets log level to
      NOTE. Verifies Address Query generation, Address Notification
      responding, caching, and cache eviction.
      Note: Step 6 is modified to use ML-EID instead of GUA 2001::
      as 2001:: is not configured as an on-mesh prefix in the test.
    - verify_5_3_3.py: PCAP verification script for test 5.3.3.
      Ensures correct formatting of Address Query (NON POST /a/aq) and
      Address Notification (CON POST /a/an) messages. Verifies that
      DUT correctly caches addresses and evicts them when Router ID
      is expired by the Leader.
- Updated supporting files:
    - verify_utils.py: Added support for parsing 'NL_ML_EID_TLV' in
      CoAP payloads.
    - CMakeLists.txt: Added building of the 5_3_3 test executable.
    - run_nexus_tests.sh: Added 5_3_3 to the default test list.

The test verifies that the DUT is able to generate Address Query
messages on behalf of its children and properly respond with Address
Notification messages to other routers, while correctly managing its
address cache.
2026-02-12 00:12:58 -06:00
Jonathan Hui 333d720c44 [nexus] fix flaky test 5.2.3 by increasing downgrade threshold (#12418)
This commit fixes a flakiness in Nexus test 5.2.3 'Leader rejects CoAP
Address Solicit (2-hops from Leader)'.

The test builds a topology with 32 routers (the maximum allowed).
Occasionally, some routers would spontaneously downgrade to REEDs
during the setup phase because the default Router Downgrade Threshold
is 23. This led to failures when the test verified that all 31 joining
nodes had become routers.

The fix sets both 'RouterUpgradeThreshold' and 'RouterDowngradeThreshold'
to 'kMaxRouters' (32) for the leader and all routers, ensuring they
remain in the router role throughout the test.

Additionally, this commit wraps the 'BecomeRouter' call with
'SuccessOrQuit' to resolve a compiler warning and ensure the
operation's success is verified.

Summary of changes:
- Modified tests/nexus/test_5_2_3.cpp to set appropriate router
  thresholds and use SuccessOrQuit for role transition.
2026-02-11 17:31:42 -06:00
Jonathan Hui 9137223384 [nexus] add test 5.3.2 Realm-Local Addressing (#12405)
Adds a new Nexus test case for 'Realm-Local Addressing' (5.3.2) as
specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.3.2:
    - Added test_5_3_2.cpp: Sets up a topology with a Leader,
      Router 1, Router 2 (DUT), and SED 1. Verifies that the DUT
      correctly handles and responds to ICMPv6 Echo Requests sent to
      its ML-EID and various Realm-Local multicast addresses
      (FF03::1, FF03::2, and Realm-Local All Thread Nodes).
    - Added verify_5_3_2.py: PCAP verification script for test 5.3.2.
      Ensures that the DUT MUST NOT forward multicast Echo Requests
      (FF03::1, FF03::2) to the SED, and that it MUST use IEEE
      802.15.4 indirect transmissions to forward the Realm-Local All
      Thread Nodes multicast packet to the SED.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.3.2 test executable.
    - Updated run_nexus_tests.sh to include 5.3.2 in the default
      test list.
2026-02-11 17:21:03 -06:00
Jonathan Hui f7061af035 [nexus] fix flaky test 5.2.1 by allowing out-of-order events (#12411)
This commit fixes a flakiness in Nexus test 5.2.1 'REED Attach'.
The test occasionally failed due to the non-deterministic timing of the
REED_1 upgrade process. In some runs, REED_1 would upgrade to a router
(Step 7) before MED_1 sent its initial Parent Request (Step 6),
causing a mismatch in the strict chronological packet sequence
expected by the verification script.

The verification script is updated to handle Step 6 and Steps 7/8
independently. It now uses separate packet filter copies to find both
sets of events regardless of their relative order. The main packet
index is then advanced to the end of all confirmed activities.

Summary of changes:
- Modified tests/nexus/verify_5_2_1.py to implement flexible order
  verification for MED_1 join and REED_1 upgrade events.
2026-02-11 13:43:03 -06:00
Jonathan Hui 934ce8af89 [nexus] add test 5.3.1 Link-Local Addressing (#12404)
Adds a new Nexus test case for 'Link-Local Addressing' (5.3.1) as
specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.3.1:
    - Added test_5_3_1.cpp: Sets up a Leader and a Router (DUT)
      topology. Leader sends various ICMPv6 Echo Requests (standard and
      fragmented, unicast and multicast) to the DUT. Verifies that the
      DUT responds with ICMPv6 Echo Replies. Uses direct method calls to
      access the core stack.
    - Added verify_5_3_1.py: PCAP verification script for test 5.3.1.
      Ensures that all Echo Request/Reply exchanges are present in the
      pcap and use the correct source and destination addresses.
      Follows the one-condition-per-line style for packet filters.
- Updated verify_utils.py to dynamically update the All Thread Nodes
  multicast address based on the mesh-local prefix.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.3.1 test executable.
    - Updated run_nexus_tests.sh to include 5.3.1 in the default test
      list.
- Cleaned up unused constants kEchoResponseTime and kEchoIdentifier in
  test_5_3_1.cpp.
2026-02-11 13:37:18 -06:00
Abtin Keshavarzian 27a242f248 [nexus] address incorrect check in border admitter test (#12409)
This commit fixes a logic error in `test_border_admitter` where the
assignment operator `=` was used instead of the equality operator
`==` inside `VerifyOrQuit()` checks.
2026-02-11 12:14:17 -06:00
Jonathan Hui dd19659ab3 [nexus] add test 5.2.7 REED Synchronization (#12400)
Adds a new Nexus test case for 'REED Synchronization' (5.2.7) as
specified in the test specification.

The test validates the REED's Synchronization procedure after
attaching to a network with multiple Routers. A REED must process
incoming Advertisements and perform a one-way frame-counter
synchronization with at least 3 neighboring Routers.

Summary of changes:
- Implemented Nexus test 5.2.7:
    - Added test_5_2_7.cpp: Sets up a topology with 16 active
      routers (Leader + 15 Routers) and adds a REED last.
      Verifies the REED joins and remains a child.
    - Added verify_5_2_7.py: PCAP verification script for test
      5.2.7, ensuring the REED sends Link Requests and receives
      Link Accepts from at least three distinct neighbors with
      mandatory TLVs.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.2.7 test
      executable.
    - Updated run_nexus_tests.sh to include 5.2.7 in the default
      test list.
2026-02-11 00:15:04 -06:00
Jonathan Hui 066856d27c [nexus] add test 5_2_6 Router Downgrade Threshold - REED (#12397)
This commit adds a new Nexus test case 5_2_6 which implements the
"Router Downgrade Threshold - REED" test specification.

The test verifies that a router (DUT) will downgrade to a REED when
the network becomes too dense (exceeding the Router Downgrade
Threshold).

Summary of changes:
- Added tests/nexus/test_5_2_6.cpp to execute the test.
- Added tests/nexus/verify_5_2_6.py to verify the pcap output.
- Updated tests/nexus/CMakeLists.txt to include the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_2_6 to default tests.

The test builds a topology with 23 initial routers and then adds a 24th
router to trigger the downgrade condition on the DUT, which uses
default thresholds (16/23).
2026-02-10 22:26:37 -06:00
Jonathan Hui baa3df86b4 [nexus] add test case 5.2.5 Address Query – REED (#12396)
This commit adds a new Nexus test case 5.2.5 which validates that
a Router Eligible End Device (REED) correctly generates Address
Notification messages in response to Address Query messages.

The test implementation includes:
- test_5_2_5.cpp: Sets up a 16-router topology using AllowList
  constraints and executes the test procedure.
- verify_5_2_5.py: Verifies the resulting pcap to ensure correct
  Address Notification format (Target EID, RLOC16, and ML-EID TLVs)
  and Echo Reply sequence.

Summary of changes:
- Added tests/nexus/test_5_2_5.cpp and tests/nexus/verify_5_2_5.py.
- Updated tests/nexus/CMakeLists.txt to include the new test.
- Updated tests/nexus/run_nexus_tests.sh to add 5_2_5 to default tests.
- Enabled OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE and
  OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE in
  tests/nexus/openthread-core-nexus-config.h to support DHCPv6
  prefixes used in the test.
2026-02-10 20:34:40 -06:00
Abtin Keshavarzian b347195b15 [nexus] add helpers for sending and validating ICMPv6 echo exchange (#12408)
This commit adds helper methods in Nexus to simplify ICMPv6 echo
exchanges:
- `Node::SendEchoRequest()`: sends an ICMPv6 Echo Request with
  configurable parameters such as payload size and hop limit.
- `Core::SendAndVerifyEchoRequest()`: sends an Echo Request and
  validates the matching Echo Reply within a timeout.

This commit also update various certification tests to use these
helpers, removing duplicate local utility functions.
2026-02-10 16:57:48 -08:00
Jonathan Hui 348b2f671e [nexus] check return value of AddRssIn in test 5.1.11 (#12403)
This commit updates Test5_1_11 in tests/nexus/test_5_1_11.cpp to
properly check the return value of AddRssIn() calls using the
SuccessOrQuit() macro. This ensures that any failure in configuring
the RSSI filters during the test setup is immediately caught.
2026-02-10 14:08:09 -08:00
Jonathan Hui 7215d063f4 [nexus] add test 5.2.4 Router Upgrade Threshold - REED (#12395)
Adds a new Nexus test case for 'Router Upgrade Threshold - REED' (5.2.4)
as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.2.4:
    - test_5_2_4.cpp: Sets up a topology with 16 routers (including Leader)
      and verifies that a REED DUT does not upgrade to a router until a
      minimal end device (MED) attempts to attach to it.
    - verify_5_2_4.py: PCAP verification script for test 5.2.4, ensuring
      correct MLE advertisements, Parent/Child ID exchange, Address Solicit
      Request formatting, and ICMPv6 Echo connectivity.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5_2_4 test executable.
    - Updated run_nexus_tests.sh to include 5_2_4 in the default test list.

The test verifies that the DUT correctly manages the router upgrade
threshold and transitions to the router role when required to support a
child.
2026-02-09 17:16:19 -08:00
Jonathan Hui 462425c0e8 [nexus] improve robustness of test 5.2.1 (#12402)
Changes 'IsChild()' check to 'IsAttached()' for REED_1 in test 5.2.1.
REED_1 may quickly transition beyond the child state (e.g., to router)
after attaching, causing 'IsChild()' to occasionally fail depending
on the timing of the check. Using 'IsAttached()' ensures the node is
successfully connected to the network regardless of its specific role.
2026-02-09 16:34:43 -08:00
Jonathan Hui 4c5d8f6a60 [nexus] add test 5.2.3 Leader rejects Address Solicit (2-hops away) (#12392)
Adds a new Nexus test case for 'Leader rejects CoAP Address Solicit
(2-hops from Leader)' (5.2.3) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.2.3:
    - Added test_5_2_3.cpp: Sets up a topology with a Leader, 31 routers
      (fully connected to Leader), and a 32nd router (Router 32) that is
      2-hops away from the Leader via Router 1. Verifies that the Leader
      rejects the Address Solicit Request from the 33rd router with a
      'No Address Available' status (1).
    - Added verify_5_2_3.py: PCAP verification script for test 5.2.3.
      Ensures the Address Solicit Request is sent by Router 32 to the
      Leader, and that the Leader responds with a CoAP ACK containing
      a Status TLV with value 1 (NL_NO_ADDRESS_AVAILABLE).
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.2.3 test executable.
    - Updated run_nexus_tests.sh to include 5.2.3 in the default test
      list.
2026-02-09 15:23:58 -08:00
Abtin Keshavarzian 66c7272eef [border-agent] implement Border Admitter (#12201)
This commit introduces the Border Agent Admitter feature , which
enhances Thread MeshCoP.

A Border Admitter is an enhanced Border Agent that functions as a
traditional BA while enabling new behaviors. It acts as a proxy and
dispatcher, allowing multiple external Enrollers to connect to it. It
then petitions to become the single Active Commissioner on the Thread
mesh, forwards new joiner requests to connected Enrollers, and
manages the session between joiners and multiple Enrollers

The implementation includes three main components:

- `Admitter`: The main class that orchestrates the feature, managing
  enroller sessions and aggregating steering data.

- `Arbitrator`: A distributed election mechanism that runs among
  Border Admitters on the mesh to select a single "Prime Admitter" by
  publishing a new Border Admitter service in the Thread Network
  Data.

- `CommissionerPetitioner`: A sub-component responsible for
  petitioning the Leader to be granted the commissioner role. It
  handles conflicts if another commissioner is already active.

New public APIs are added in `openthread/border_agent_admitter.h`.

This commit also introduces a suite of comprehensive tests for the
Border Admitter functionality under the `nexus` test framework. It
covers various scenarios including:
- Prime Admitter election and role management
- Enroller registration, keep-alive, and timeout interactions
- Handling of commissioner conflicts and petitioner retry mechanisms
- Support for multiple enroller sessions and combined steering data
- Forwarding of Joiner `RelayRx` and `UdpProxy` messages
- Joiner acceptance, release, and expiration tracking
2026-02-09 14:31:34 -08:00
Jonathan Hui e4ffaf347f [nexus] add test 5.2.1 REED Attach (#12388)
Adds a new Nexus test case for 'REED Attach' (5.2.1) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.2.1:
    - Added test_5_2_1.cpp: Sets up a Leader, REED_1, and MED_1 (DUT) topology.
      Ensures REED_1 upgrades to a Router when the DUT attaches. Verifies
      connectivity from the Leader to the DUT via REED_1 using ICMP Echo.
    - Added verify_5_2_1.py: PCAP verification script for test 5.2.1,
      ensuring MLE Parent Requests, Address Solicit/Responses, and ICMP
      Echo Request/Replies are correctly exchanged and forwarded.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.2.1 test executable.
    - Updated run_nexus_tests.sh to include 5.2.1 in the default test list.
2026-02-09 13:42:50 -08:00
Abtin Keshavarzian 968ae74341 [tests] add timeout to cert suite execution (#12379)
Currently, the `run_cert()` function in `run_cert_suite.py` invokes
test scripts using `subprocess.check_call()` without a timeout. This
can cause the test suite to hang indefinitely if a test script fails
to terminate.

This commit updates `run_cert_suite.py` to support a configurable
`--timeout` argument. It passes this timeout to `check_call()` and
handles `subprocess.TimeoutExpired` to log failure and print output
upon timeout.

Additionally, this commit updates `script/test` to pass the
`TEST_TIMEOUT` environment variable to the test runner and updates
GitHub workflow configurations to define specific timeout values for
various test jobs.
2026-02-09 11:38:18 -08:00
Abtin Keshavarzian ebba0b39a5 [nexus] support ctest labels to categorize tests (#12367)
Updates the `ot_nexus_test` macro to accept a list of labels for each
test case. This allows for categorizing tests and executing specific
subsets using `ctest -L`.

The tests are now assigned labels such as `core`, `cert`, and `trel`.
The `core` label is used for tests that verify OpenThread core logic
and behavior, distinguishing them from `cert` tests which cover
certification scenarios.

The GitHub workflow is updated to utilize `ctest -L` for running the
tests, replacing the previous `ninja test` command.
2026-02-09 11:37:37 -08:00
Abtin Keshavarzian 62a2d794d4 [common] add MessageBackedArray class (#12341)
This commit adds `MessageBackedArray`, which implements a dynamic
array backed by a `Message` for data storage.

The new array class supports:
- Pushing new elements to the end.
- Reading and writing elements at specific indices.
- Searching in the array to find matching entries.
- Iterating over array elements.
- Clearing the array and freeing the underlying message.

Unit tests are added in `tests/unit/test_msg_backed_array.cpp` to
verify its functionality.
2026-02-09 11:36:53 -08:00
dependabot[bot] 1b523d7adf github-actions: bump step-security/harden-runner from 2.14.1 to 2.14.2 (#12399)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.14.1 to 2.14.2.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/e3f713f2d8f53843e71c69a996d56f51aa9adfb9...5ef0c079ce82195b2a36a210272d6b661572d83e)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.14.2
  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>
2026-02-09 11:00:08 -08:00
Abtin Keshavarzian 3f11074f1e [joiner] refresh ID from EUI-64 in Start() when discerner is empty (#12393)
This commit updates `Joiner::Start()` to explicitly call
`SetIdFromIeeeEui64()` when `mDiscerner` is empty. This ensures that
the Joiner ID is freshly derived from the current IEEE EUI-64 address,
guaranteeing correctness even if the address was not ready during
initialization or has changed since the instance was created.
2026-02-07 20:37:00 -08:00
Abtin Keshavarzian 54b3573761 [coap] optimize retransmission timer scheduling (#12366)
This commit optimizes the CoAP retransmission timer logic by removing
the `ScheduleRetransmissionTimer()` method, which iterated over all
pending requests to determine the next fire time.

The logic is updated as follows:
- `HandleRetransmissionTimer()` now determines the next fire time
  while iterating over the `mPendingRequests` list to process
  retransmissions. This avoids a redundant second pass over the list.
- `NextFireTime` is used to track the earliest fire time.
- `CopyAndEnqueueMessage()` uses `Timer::FireAtIfEarlier()` to
  update the timer only if the new message's fire time is earlier
  than the current schedule.
- `DequeueMessage()` no longer triggers a schedule update. If the
  dequeued message was the next to expire, the timer will fire,
  perform no actions, and then reschedule itself.
2026-02-07 20:36:06 -08:00
Jonathan Hui c457b6b283 [pktverify] remove excessive print output in Bytes comparison (#12391)
This commit removes a debug print statement in the Bytes.__eq__
method that was causing excessive output to stderr during packet
verification. The print statement was logging every byte comparison,
leading to cluttered logs and potentially impacting performance or
causing issues with log analysis.

- Removed print statement from Bytes.__eq__ in
  tests/scripts/thread-cert/pktverify/bytes.py.
2026-02-07 19:27:22 -08:00
Abtin Keshavarzian 52bd082596 [joiner] fix potential message leak when Start() fails (#12394)
This commit updates `FreeJoinerFinalizeMessage()` to remove the state
check, allowing the message to be freed regardless of the current
state. It also removes the redundant cleanup in
`PrepareJoinerFinalizeMessage()` since `Joiner::Start()` handles the
cleanup upon error.

The `Joiner::Start()` method allocates the Joiner Finalize message and
then transitions the state to `kStateDiscover` before starting the
Seeker. If starting the Seeker fails, the exit label performs
cleanup, including calling `FreeJoinerFinalizeMessage()`. Previously,
`FreeJoinerFinalizeMessage()` checked that the state was `kStateIdle`
before freeing the message. Since the state had already been updated
to `kStateDiscover`, the message would not be freed, leading to a
message leak on failure.
2026-02-07 18:59:13 -08:00
Jonathan Hui c0090877ae [nexus] add error handling to SetRouterEligible calls (#12390)
Adds SuccessOrQuit() around SetRouterEligible() calls in Nexus tests to
properly handle potential errors and ensure test robustness.

Summary of changes:
- Modified tests/nexus/test_5_1_8.cpp, test_5_1_9.cpp, test_5_1_10.cpp,
  and test_5_1_11.cpp to wrap SetRouterEligible(false) calls in SuccessOrQuit().
- Verified that tests build and pass correctly with these changes.
2026-02-07 17:38:34 -08:00
Jonathan Hui 47e9bf7319 [nexus] add test 5.1.13 Router Synchronization after Reset (#12385)
Adds a new Nexus test case for 'Router Synchronization after Reset' (5.1.13)
as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.13:
    - test_5_1_13.cpp: Sets up a Leader and Router_1 topology,
      simulates a router reset, and verifies successful re-synchronization.
    - verify_5_1_13.py: PCAP verification script for test 5.1.13, ensuring
      correct MLE advertisements, Link Request/Accept exchange, and
      proper response timing and TLV validation.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.13 test executable.
    - Updated run_nexus_tests.sh to include 5.1.13 in the default test list.
2026-02-07 17:38:25 -08:00
Jonathan Hui f983585e9e [nexus] add test 5.1.12 New Router Neighbor Synchronization (#12384)
Adds a new Nexus test case for 'New Router Neighbor Synchronization' (5.1.12)
as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.12:
    - Added test_5_1_12.cpp: Sets up a topology with a Leader, Router_2,
      and DUT. DUT and Router_2 first attach to the Leader, then the
      harness enables a direct link between them to trigger the
      New Router Neighbor Synchronization procedure.
    - Added verify_5_1_12.py: PCAP verification script for test 5.1.12,
      ensuring that the DUT sends properly formatted MLE Advertisements
      and exchanges Link Request/Accept messages with Router_2 as
      required by the specification.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.12 test executable,
      inserting it after 5.1.6.
    - Updated run_nexus_tests.sh to include 5.1.12 in the default test list.
2026-02-06 16:51:19 -08:00
Jonathan Hui af762f1e01 [nexus] add test 5.1.11 Attaching to a REED with better link quality (#12383)
Adds a new Nexus test case for 'Attaching to a REED with better link
quality' (5.1.11) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.11:
    - Added test_5_1_11.cpp: Sets up a topology with Leader, REED_1,
      Router_2, and Router_1 (DUT). Configures RSSI to ensure REED_1
      has a higher link quality than Router_2. Verifies that the DUT
      attaches to REED_1 as its parent.
    - Added verify_5_1_11.py: PCAP verification script for test 5.1.11,
      validating the MLE Parent Request sequence (Routers then REEDs)
      and the final attachment to REED_1.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.11 test executable.
    - Updated run_nexus_tests.sh to include 5.1.11 in the default test list.
2026-02-06 14:51:34 -08:00
Jonathan Hui 9a5527ddd8 [nexus] add test 5.1.10 Parent Selection - Superior Link Quality (#12382)
Adds a new Nexus test case for 'Parent Selection - Superior Link Quality'
(5.1.10) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.10:
    - Added test_5_1_10.cpp: Sets up a Leader, Router_1, Router_2, and
      Router_3 (DUT) topology. Uses AddRssIn to configure Router_1 with
      superior link quality (LQ3) and Router_2/Leader with LQ2 relative
      to the DUT. Verifies that the DUT selects Router_1 as its parent
      during attachment.
    - Added verify_5_1_10.py: PCAP verification script for test 5.1.10,
      ensuring that the MLE Parent Request contains the mandatory TLVs
      and that the Child ID Request is correctly sent to the superior
      link-quality router (Router_1).
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.10 test executable.
    - Updated run_nexus_tests.sh to include 5.1.10 in the default test
      list.
2026-02-06 13:14:35 -08:00
Jonathan Hui 6f045ef8ab [nexus] add test 5.1.9 Attaching to a REED with better connectivity (#12378)
Adds a new Nexus test case for 'Attaching to a REED with better
connectivity' (5.1.9) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.9:
    - Added test_5_1_9.cpp: Sets up a Leader, Router_1, REED_1, REED_2, and
      Router_2 (DUT). Configures REED_1 with better connectivity (links to
      both Leader and Router_1) than REED_2 (link only to Leader). Verifies
      that the DUT selects REED_1 as its parent.
    - Added verify_5_1_9.py: PCAP verification script for test 5.1.9,
      verifying MLE Parent Requests (Scan Masks 0x80 and 0xC0), Key ID Mode
      0x02 in Step 5, ensuring REEDs do not respond to the first Parent
      Request, comparing Connectivity TLV contents in Parent Responses to
      ensure REED_1 is correctly selected, and ensuring Address Registration
      TLV is absent in the Child ID Request.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.9 test executable.
    - Updated run_nexus_tests.sh to include 5.1.9 in the default test list.
2026-02-06 11:08:34 -08:00
Abtin Keshavarzian fef1426221 [test] fix and enhance test_coap_block.py (#12386)
This commit fixes and enhances `test_coap_block.py`. Previously, the
test masked failures by using multiple trials and suppressing
exceptions. It appeared to pass even though an incorrect regex match
in `coap_wait_request()` caused it to consistently fail.

The regex in `coap_wait_request()` is updated to correctly match CLI
output and capture the CoAP method (GET, PUT, POST, DELETE).

The test script is enhanced by:

- Removing trial/retry logic and exception suppression that masked
  previous failures.
- Verifying both request and response messages for GET, PUT, and
  POST.
- Validating source IPv6 addresses in requests and responses.
- Ensuring the payload presence matches the expected behavior for each
  CoAP method.
2026-02-06 09:43:24 -08:00
Jonathan Hui 5b0925ffab [nexus] add test 5.1.8 Attaching to a Router with better connectivity (#12376)
Adds a new Nexus test case for 'Attaching to a Router with better
connectivity' (5.1.8) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.8:
    - Added test_5_1_8.cpp: Sets up a multi-router topology (Leader <-> R3 <->
      R1 <-> R2). Uses AllowList to enforce path costs, verifying that the
      DUT (Router_4) selects R3 as its parent since it has the best
      connectivity (1 hop to Leader).
    - Added verify_5_1_8.py: PCAP verification script for test 5.1.8,
      ensuring MLE Parent Request, Parent Responses, and Child ID Request
      follow the specification. Validates mandatory TLVs and the absence
      of the Address Registration TLV in the Child ID Request.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.8 test executable.
    - Updated run_nexus_tests.sh to include 5.1.8 in the default test list.
2026-02-06 09:29:54 -08:00
Abtin Keshavarzian e150c30f62 [cli] fix BlockwiseTransmitHook to be stateless (#12380)
This commit updates `Coap::BlockwiseTransmitHook` to calculate the
current block count based on the block position (`aPosition`) and
block length (`*aBlockLength`), rather than relying on a `static`
variable.

The previous implementation used a `static uint32_t blockCount` to
track the progress of the block-wise transfer. This approach caused
issues when multiple transfers occurred concurrently or when the
process persisted across test retries (as in the simulation
environment). In such cases, the static variable could become out of
sync, leading to incorrect transfer termination or infinite loops.

By deriving `blockCount` from `aPosition`, the hook becomes stateless
and correctly handles retransmissions and concurrent transfers.
2026-02-06 07:24:56 -08:00
Jonathan Hui b38881eb21 [nexus] add test 5.1.7 Minimum Supported Children – IPv6 Datagram Buffering (#12375)
Adds a new Nexus test case for 'Minimum Supported Children – IPv6 Datagram
Buffering' (5.1.7) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.7:
    - Added test_5_1_7.cpp: Sets up a Leader, Router_1 (DUT), 4 MEDs, and 6
      SEDs. Verifies the DUT can handle the minimum required number of
      children and buffers multiple concurrent IPv6 datagrams (including
      a 1280-octet MTU packet) destined for SEDs.
    - Added verify_5_1_7.py: PCAP verification script for test 5.1.7,
      ensuring proper MLE attachment, correct forwarding of ICMPv6 Echo
      Requests/Replies, and verification of buffered traffic to SEDs.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.7 test executable.
    - Updated run_nexus_tests.sh to include 5.1.7 in the default test list.
2026-02-05 23:38:36 -08:00
Abtin Keshavarzian 0f96d51e92 [coap] add payload marker when block-wise transfer starts (#12381)
This commit updates `CoapBase::ProcessBlockwiseSend()` to ensure a
Payload Marker is appended before adding the first block of data.

`SendMessage()` always calls `ParseHeaderAndOptions()` with
`kRemovePayloadMarkerIfNoPayload`, which removes any existing payload
marker if the message body is empty. However, for block-wise transfers,
the payload is added later via the block-wise transmit hook in
`ProcessBlockwiseSend()`. If the marker was removed, the first
block would be appended directly after the options without a
separator, resulting in a malformed CoAP message.

This change ensures that `ProcessBlockwiseSend()` explicitly restores
or adds the payload marker before appending the block data. The
documentation for `Message::AppendPayloadMarker()` is also updated to
clarify that the method is idempotent, making no changes if a marker
is already present.
2026-02-05 22:05:19 -08:00
Jonathan Hui c815ca4ca3 [nexus] add test 5.1.6 Leader removes Router ID (#12374)
Adds a new Nexus test case for 'Leader removes Router ID' (5.1.6) as
specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.6:
    - Added test_5_1_6.cpp: Sets up a Leader and Router_1 (DUT) topology.
      Verifies that when the Leader de-allocates a Router ID, the DUT
      automatically re-attaches.
    - Added verify_5_1_6.py: PCAP verification script for test 5.1.6,
      ensuring that MLE Parent Request, MLE Child ID Request, and
      Address Solicit Request messages follow the specification.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.6 test executable.
    - Updated run_nexus_tests.sh to include 5.1.6 in the default test list.
2026-02-05 21:57:46 -08:00
Jonathan Hui a393e510cd [nexus] add test 5.1.5 Router Address Timeout (#12372)
Adds a new Nexus test case for 'Router Address Timeout' (5.1.5) as
specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.5:
    - Added test_5_1_5.cpp: Sets up a Leader (DUT) and Router_1 topology.
      Verifies that after deallocating a Router ID, the Leader does not
      reassign that same Router ID for at least ID_REUSE_DELAY seconds.
      Uses direct core method calls and nexus.AdvanceTime() for precise
      timing control.
    - Added verify_5_1_5.py: PCAP verification script for test 5.1.5,
      ensuring that the Address Solicit Response contains a different
      Router ID when requested before ID_REUSE_DELAY, and the requested
      Router ID when requested after ID_REUSE_DELAY.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.5 test executable.
    - Updated run_nexus_tests.sh to include 5.1.5 in the default test list.
2026-02-05 18:31:12 -08:00
Esko Dijk 12c80e8171 [script] fix to make 'run-clang-tidy' findable for 'make-pretty-clang' (#12373)
Required to get `make-pretty clang` working after the `bootstrap`
script, on Ubuntu 24.04.
2026-02-05 17:09:30 -08:00
Jonathan Hui 07cbcee9c9 [nexus] add test 5.1.4 Router Address Reallocation (#12368)
Adds a new Nexus test case for 'Router Address Reallocation – DUT creates
new partition' (5.1.4) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.4:
    - Added test_5_1_4.cpp: Sets up a Leader, Router_1 (DUT), and Router_2
      topology. Uses AllowList to dynamically control connectivity,
      verifying that Router_1 creates a new partition when the original
      Leader is removed and Router_1 fails to reattach.
    - Added verify_5_1_4.py: PCAP verification script for test 5.1.4,
      verifying MLE Parent Requests (reattach attempts), new partition
      creation, and Address Solicit Response.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.4 test executable.
    - Updated run_nexus_tests.sh to include 5.1.4 in the default test list.
2026-02-05 07:38:37 -08:00
Abtin Keshavarzian 3fec404eff [seeker] introduce new otSeeker APIs (#12357)
This commit introduces Seeker APIs in OpenThread. An earlier commit
extracted the discovery and candidate selection logic from the `Joiner`
role into a new, standalone `Seeker` module.

The `Seeker` is responsible for performing MLE Discover Scans to find
nearby Joiner Router candidates. It prioritizes these candidates based
on RSSI and steering data (indicating whether the Joiner is preferred)
and manages the list of candidates for connection attempts.

This separation allows the `Seeker` functionality to be utilized
independently of the full `Joiner` role, enabling the development of
custom joining mechanisms over Thread.

A new configuration option `OPENTHREAD_CONFIG_SEEKER_ENABLE` has been
added to control the presence of `otSeeker` APIs.
2026-02-04 15:54:54 -08:00
Jonathan Hui 69c45ce55d [nexus] add test 5.1.3 Router Address Reallocation (#12365)
Adds a new Nexus test case for 'Router Address Reallocation – DUT attaches
to new partition' (5.1.3) as specified in the test specification.

Summary of changes:
- Implemented Nexus test 5.1.3:
    - Added test_5_1_3.cpp: Sets up a Leader, Router_1 (DUT), and Router_2
      topology. Uses AllowList to dynamically control connectivity,
      verifying that Router_1 reattaches to a new partition formed by
      Router_2 after the original Leader is removed. Uses direct core
      method calls and avoids magic numbers.
    - Added verify_5_1_3.py: PCAP verification script for test 5.1.3,
      ensuring MLE Parent Requests, Child ID Requests, and Address Solicit
      messages follow the specification.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.3 test executable.
    - Updated run_nexus_tests.sh to include 5.1.3 in the default test list.
2026-02-04 14:19:46 -08:00
Abtin Keshavarzian 5144638a63 [coap] add helper methods to CoapBase::Metadata (#12364)
This commit adds methods to `CoapBase::Metadata` to encapsulate logic
related to initialization, retransmission checks, and updating
retransmission counters. It also renames member variables for brevity
(e.g., `mRetransmissionsRemaining` to `mRetxRemaining`) and moves
`IsObserveSubscription()` to be a method of `Metadata`.

These changes simplify implementation by delegating metadata-specific
operations to the `Metadata` struct itself.
2026-02-04 12:59:11 -08:00
Abtin Keshavarzian dd0d8311f8 [border-router] detect DHCPv6-PD prefix conflict with route prefixes (#12361)
This commit enhances the DHCPv6 PD prefix conflict detection logic
to check against Route Information Options (RIOs) present in received
Router Advertisements, in addition to the existing check against
on-link prefixes (PIOs).

The conflict detection behavior is event-driven to correctly handle
network propagation delays and valid advertisements:

1. On new prefix assignment (`kPdPrefixChanged`): A strict check is
   performed. If the prefix matches any existing RIO from another
   router, it is flagged as a conflict.

2. On RA table updates (`kRxRaPrefixTableChanged`): The check focuses
   on conflict resolution. Crucially, it ignores new RIO matches
   appearing after the prefix has been adopted. This is necessary
   because once the BR publishes the PD prefix in Thread Network
   Data as the OMR prefix, other BRs will naturally start
   advertising it as a RIO to announce reachability.

The unit test `TestDhcp6PdConflict` is updated to verify both the
detection of conflict, its resolution, and that the subsequent RIO
advertisements do not cause a conflict after PD prefix is published
as OMR.
2026-02-04 12:55:55 -08:00
Abtin Keshavarzian 848918df32 [joiner] introduce Seeker to handle discovery and candidate tracking (#12325)
This change introduces a new `Seeker` class to encapsulate the logic
for discovering and prioritizing Joiner Router candidates.

The `Joiner` class is updated to use the `Seeker` to perform the
discovery scan. The `Joiner` provides a callback `EvaluateScanResult`
to the `Seeker` to filter and evaluate scan results based on
Steering Data, preserving the existing behavior.

This change separates the discovery mechanism from the `Joiner` state
machine. This simplifies the `Joiner` implementation and facilitates
future enhancements to the joining process.

This commit makes to changes to how the Joiner Router candidates are
tracked or prioritized.
2026-02-04 12:51:57 -08:00
Jonathan Hui 7577311aa4 [nexus] add test 5.1.2 and refactor nexus test infrastructure (#12363)
Adds a new Nexus test case for 'Child Address Timeout' (5.1.2) and
performs several refactorings to improve the nexus test framework.

Summary of changes:
- Implemented Nexus test 5.1.2 (Child Address Timeout):
    - Added test_5_1_2.cpp: Sets up a Leader, Router (DUT), MED, and SED
      topology with restricted connectivity using AllowList. Verifies
      that the parent stops responding to Address Queries for children
      after their timeout interval expires.
    - Added verify_5_1_2.py: PCAP verification script for test 5.1.2.
- Refactored Nexus verification infrastructure:
    - Created verify_utils.py: Shared module for common verification
      logic, including monkey-patches for CoapTlvParser and
      which_tshark, and a generic 'run_main' test runner function.
    - Updated verify_5_1_1.py and verify_5_1_2.py to use verify_utils.py,
      significantly reducing boilerplate code.
    - Cleaned up imports in verify_utils.py by removing unused logging.
- Updated build and execution scripts:
    - Modified CMakeLists.txt to build the new 5.1.2 test executable.
    - Updated run_nexus_tests.sh to include 5.1.2 in the default test list.
2026-02-03 21:44:05 -08:00
Jonathan Hui 1a0023d119 [nexus] add GitHub Actions workflow for Nexus tests (#12362)
Automates the execution of Nexus tests on CI using Ubuntu 24.04.
The workflow installs necessary dependencies including ninja-build,
tshark, and pyshark to support both simulation and packet-level
verification.
2026-02-03 18:14:03 -08:00
Jonathan Hui daf7fa615e [nexus] add script to run tests and verify results (#12359)
This script provides a unified entry point for executing Nexus C++
simulations and their corresponding Python packet verification scripts.
It supports running individual test cases or a default suite, handles
PCAP logging, and ensures proper error propagation.
2026-02-03 16:24:02 -08:00
tanyanquan d97ec73c3f [uptime] move otConvertDurationInSecondsToString to FTD/MTD block (#12336)
The fix moves the necessary includes outside the FTD/MTD conditional block:
- Added explicit include: #include "common/uptime.hpp" is now included
  when OPENTHREAD_CONFIG_UPTIME_ENABLE is defined, regardless of
  FTD/MTD mode.
- Extended namespace usage: The using namespace ot; directive now
  applies when either FTD/MTD is enabled OR uptime is enabled,
  ensuring the namespace is available for the uptime functions.

This ensures that when OPENTHREAD_CONFIG_UPTIME_ENABLE is enabled, the
required headers are included even in RADIO mode, allowing the uptime
functionality to work correctly across all device types.
2026-02-03 11:38:28 -08:00
Jonathan Hui a7362c1a45 [tests] fix build error in nexus_discover_scan test (#12360)
This commit updates `tests/nexus/test_discover_scan.cpp` to use
`MeshCoP::NetworkIdentity` instead of `MeshCoP::ExtendedPanIdManager`.
The latter was renamed in the core codebase, leading to a build
failure in the nexus discovery scan test.
2026-02-03 11:09:55 -08:00
Abtin Keshavarzian d388095b66 [mle] add config and test for discovery request callback (#12284)
Introduces `OPENTHREAD_CONFIG_MLE_DISCOVERY_SCAN_REQUEST_CALLBACK_ENABLE`
to conditionally compile the MLE Discovery Request callback feature.
Disabling this feature allows for code size reduction on builds where
it is not needed.

A new Nexus test (`test_discover_scan.cpp`) is added to directly
validate the `otThreadSetDiscoveryRequestCallback()` API behavior.

This new test replaces a now-removed CLI-based test which used
 (`discover reqcallback`). This CLI command was originally added for
testing purposes. The CLI command is not helpful as an async event
would produce unsolicited output in the CLI. The new direct C++ test
is a cleaner approach.
2026-02-03 07:58:39 -08:00
Jonathan Hui 0bbe9dc350 [nexus] add packet verification for test case 5.1.1 (Attaching) (#12358)
This commit adds a Python script to perform automated packet verification
for the Nexus test case 5.1.1 (Attaching), following the Thread
certification specification.

Changes:
- Added tests/nexus/verify_5_1_1.py:
    - Implements all steps (1-11) of the 5.1.1 test specification.
    - Includes a custom CoAP TLV parser to extract Thread-specific fields
      (Status, RLOC16, Router Mask) from CoAP payloads.
    - Automatically configures Wireshark preferences for decryption
      based on the test's JSON output.
    - Includes the full test specification as inline comments.
- Updated tests/scripts/thread-cert/pktverify/layer_fields.py:
    - Enhanced the _auto parser to handle boolean strings ('True', 'False')
      returned by newer versions of tshark, preventing parsing errors
      during verification.
2026-02-03 07:54:57 -08:00
Abtin Keshavarzian 7c87684f1b [border-router] detect DHCPv6-PD prefix conflict with on-link prefixes (#12346)
This commit updates `RoutingManager` to detect if a delegated DHCPv6
PD prefix conflicts with any on-link prefix advertised on the
infrastructure link.

This protects against potential DHCPv6 server misbehavior and bugs
where the same prefix might be assigned to multiple requesters.

If a conflict is detected, the delegated PD prefix is marked as
conflicted and is no longer used as the OMR prefix. Instead, we
revert to using the locally generated OMR prefix. If the conflict
is resolved, the delegated PD prefix is used again.

A new unit test `TestDhcp6PdConflict()` is added to verify this
behavior.
2026-02-03 07:53:22 -08:00
Yakun Xu 54b936367d [test] conditionally test RCP restoration (#12339)
This commit makes the
`shouldNotDuplicateSrcMatchEntriesOnRestoreProperties` test
conditional, because RCP restoration is not always enabled.
2026-02-02 17:31:34 -08:00
Yakun Xu 7cdbce5929 [gn] define macros to 1/0 instead of true/false (#12345)
This commit converts the boolean flags to `1`/`0` which may cause build
failures when `true`/`false` is not correctly defined.
2026-02-02 17:30:38 -08:00
Yakun Xu e5d2c5860e [gn] add cli_uart (#12345)
This commit adds the `cli_uart` for applications to integrate OpenThread
CLI based on UART APIs. One of the example is OTNS.
2026-02-02 17:30:38 -08:00
Jonathan Hui b8f5a6f2b6 [nexus] add support for writing test_info.json (#12355)
This commit adds support for writing test_info.json in the Nexus platform.
The test_info.json file contains information about the test topology,
including node names, roles, and addresses. This information is used by
the packet verification framework to verify the behavior of the network.

Changes:
- Added `Core::SaveTestInfo` to `nexus_core.cpp` to write node information to JSON.
- Added `SetName` and `GetName` to `Node` class in `nexus_node.hpp`.
- Updated `test_5_1_1.cpp` to set node names and call `SaveTestInfo`.
2026-02-02 17:27:04 -08:00
dependabot[bot] 0f6f831352 github-actions: bump step-security/harden-runner from 2.13.1 to 2.14.1 (#12356)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.13.1 to 2.14.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a...e3f713f2d8f53843e71c69a996d56f51aa9adfb9)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.14.1
  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-02-02 10:19:19 -08:00
Jonathan Hui 60813b8ccc [nexus] add test case 5.1.1 (Attaching) (#12353)
This commit adds a new Nexus test case to verify the "5.1.1 Attaching"
scenario from the Thread certification specification.

The test case verifies that:
1. A node can form a network and become a Leader.
2. A second node can join the network and become a Router.
3. Connectivity between the Leader and Router is functional using ICMPv6 Echo
   to Link-Local addresses, verifying both roles as DUT.

The test ensures basic network formation and attachment functionality
within the Nexus simulation environment.
2026-01-31 17:23:54 -08:00
Jonathan Hui 5051fd1808 [nexus] enable PCAP output (#12350)
This commit enables PCAP output in the Nexus platform by adding a
Nexus::Pcap utility class and integrating it into the Nexus::Core.
PCAP logging can be enabled by setting the OT_NEXUS_PCAP_FILE
environment variable.
2026-01-30 12:52:06 -08:00
Esko Dijk 3318ae688e [thread-cert] simulator: mark virtual-time node 'awake' whenever an event was sent to it (#12333)
This marks a simulation node as 'awake' whenever an event is sent to
it. This is required because the event will induce processing on the
node followed by an alarm-event sent back to the simulator.  The
simulator needs to wait to properly catch this final alarm-event;
otherwise, this alarm-event may be mistakenly processed as
confirmation of a newer event that follows later, in case the OT node
process is lagging in processing as may happen typically in CI
environments.

Also the case of unknown event type is now raised as an exception, to
avoid undetected errors in the simulation. This could cause an event
to be not sent to the node at all while the node's time is updated by
the simulator (using `self.devices[port]['time'] = event_time`) as if
the node is up to date on the latest virtual time, which it isn't,
because an event is not sent to the node.

Also fixes a potential undefined local variable 'data' flagged by the
IDE.
2026-01-30 11:02:01 -08:00
Abtin Keshavarzian 266fa62c91 [meshcop] introduce NetworkIdentity class (#12343)
This commit introduces `NetworkIdentity` class to track the network
identity parameters, specifically Extended PAN ID, Network Name and
Domain Name.

The new class replaces the `ExtendedPanIdManager` and
`NetworkNameManager` which are removed by this commit.

This change simplifies `extended_panid.hpp` and `network_name.hpp`.
They now contain only basic type definitions (`ExtendedPanId` and
`NetworkName`). This allows these headers to be included in other
modules without pulling in unnecessary header dependencies.
2026-01-30 10:55:41 -08:00
Jonathan Hui 78cf6967bc [nexus] fix IEEE 802.15.4 FCS calculation in nexus radio (#12349)
The IEEE 802.15.4 standard specifies that the FCS is a 16-bit ITU-T
CRC calculated over the bits in the order they are transmitted (LSB
first). The previous implementation used the CrcCalculator with the
CCITT polynomial but processed bytes in an MSB-first manner, which is
incorrect for 802.15.4.

This commit updates Radio::Frame::UpdateFcs() to implement the
reflected CRC-16-CCITT algorithm correctly by processing bits LSB-first
using the reflected polynomial 0x8408.
2026-01-29 16:43:45 -08:00
Jonathan Hui b4d6b52f93 [nexus] update transmit frames with IEEE 802.15.4 FCS (#12347)
This commit adds IEEE 802.15.4 FCS (Frame Check Sequence) computation
to the Nexus radio driver. Each frame to be transmitted is updated
with the proper CRC16-CCITT before being passed to the simulation.

Motivation for this change is to ensure that frames captured from
the Nexus simulation have a valid FCS, enabling proper decoding and
display in Wireshark when using pcap output.
2026-01-29 13:49:29 -08:00
Alan Wyss 8614dc01a1 [mesh-forwarder] avoid forwarding multicast messages back to SED originator (#12329) 2026-01-29 08:11:04 -08:00
Abtin Keshavarzian 397f5b4291 [coap] simplify response handler and use Msg class (#12338)
This commit updates `Coap::ResponseHandler` to use a single
`Coap::Msg` pointer instead of separate `Message` and `MessageInfo`
pointers. The `Msg` class encapsulates both the CoAP message and its
associated IP message info, simplifying the handler signature and
usage.

It retains support for the legacy `otCoapResponseHandler` signature
(which uses separate parameters) for the public API by introducing
`SendMessageWithResponseHandlerSeparateParams`. This ensures that
public APIs like `otCoapSendRequest` continue to work without
breaking changes while allowing internal modules to benefit from the
simplified interface.

It introduces `CoapBase::SendCallbacks` to consolidate the storage and
invocation logic for different callback types, including the new
`ResponseHandler`, the legacy `ResponseHandlerSeparateParams`, and
block-wise transfer hooks.

All internal modules (MLE, MeshCoP, Network Data, etc.) are updated to
define their response handlers using the new `ResponseHandler`
signature with `Msg` input.
2026-01-29 07:55:26 -08:00
Abtin Keshavarzian 2a76e91081 [meshcop] add GenerateRandom() to ExtendedPanId class (#12342)
This commit adds a `GenerateRandom()` method to the `ExtendedPanId`
class, enabling the generation of a cryptographically secure random
Extended PAN Identifier.
2026-01-29 07:54:03 -08:00
Abtin Keshavarzian 8da5e193c7 [mac] remove redundant ExtAddress::operator==() (#12344)
The `ExtAddress` class inherits from `Equatable<ExtAddress>`, which
already provides an `operator==` implementation that compares
the object's memory content.
2026-01-28 18:34:33 -08:00
Yakun Xu 36906a04ce [ai] add GEMINI.md for project context (#12282)
This commit adds the context file for Gemini, generated by Gemini
scanning this project. This should make Gemini work faster in
OpenThread.
2026-01-28 18:34:12 -08:00
Yang Song 8c74262dda [api] clarify NAT64 prefix discovery priority in api doc (#12180)
This commit adds a `@note` to the documentation of
`otPlatInfraIfDiscoverNat64Prefix` functions to make it clear that any
prefix it supplies will have a lower priority than one discovered via
RA PREF64 option (RFC 8781).
2026-01-27 15:59:11 -08:00
Esko Dijk f121ebcffa [tcat] enable TCAT Commissioner to receive Alerts/TLV events over TLS and improve connection mgmt (#12011)
This enables the TCAT Commissioner to receive data such as TLS Alerts,
or asynchronously sent 'event' TLVs, over TLS.  Processing TLS Alert
is required to detect the sending of Alert by the TCAT Device, which
is a requirement to be verified in cert tests. An async background
process is started to receive and log the received events.

Also some minor improvements in connection state management: when
certain commands are given after the TCAT link is disconnected, or
when a TCAT link could not be established, a message will be printed
to clearly say it's disconnected, instead of a cryptic error. Error
messages are now clearly prefixed with 'Error:'.

The CA certificate store for CommCert3 is extended with an additional
CA certificate, so that it can be verified in cert tests that a TCAT
Device rejects a wrong Commissioner with a TLS Alert (previously this
couldn't be tested).

Also includes a fix of the pyproject.toml such that Poetry does not
display the long warning on installation.

Also includes an improvement of TLV displaying to the user with a
STRING field, if the value is a string.

Also includes some syntax fixes that were flagged by the IDE, such as
missing return types for methods, or member variables that were not
initialized in the __init__().
2026-01-27 14:24:48 -08:00
Abtin Keshavarzian 179f77021d [api] add otMessageClone and enhance UDP docs (#12326)
This commit introduces a new `otMessageClone()` API to create a
full clone/copy of a message.

Additionally, the documentation for the `otUdpReceive` and
`otUdpHandler` callbacks is polished to improve clarity on message
ownership and lifetime.
2026-01-26 12:01:23 -08:00
dependabot[bot] 8a1482c0e0 github-actions: bump actions/setup-go from 5.5.0 to 6.2.0 (#12335)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.5.0 to 6.2.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/d35c59abb061a4a6fb18e82ac0862c26744d6ab5...7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-26 11:15:45 -08:00
Esko Dijk a68b30ac80 [cli] joiner start to use correct VendorInfo data (#12332)
This updates the Joiner CLI to use the correct VendorInfo data which
is configured in the build or set at runtime. Benefit is that this
data is also length-checked.  Previously, the command could fail when
PACKAGE_VERSION was length > 16.
2026-01-26 11:15:21 -08:00
Abtin Keshavarzian 13277e803d [mesh-forwarder] evict lower priority msg on direct tx queue limit (#12320)
This commit updates `ApplyDirectTxQueueLimit()` to improve how the
direct tx queue handles frame limits.

Previously, when the direct tx queue reached its configured frame
count threshold, the code attempted to remove aged messages. If this
was insufficient, the new incoming message was dropped.

With this change, after attempting to remove aged messages, the code
now attempts to evict an existing lower-priority message (and all its
frames) from the direct tx queue to make room for a new higher
priority message. If no existing message can be evicted (i.e., all
messages are of higher or equal priority), the new message is
dropped.
2026-01-26 10:35:39 -08:00
Abtin Keshavarzian 558aea761f [coap] update Interceptor to use Msg (#12331)
This commit updates the `CoapBase::Interceptor` function pointer type
to accept `const Msg &` instead of separate `const Message &` and
`const Ip6::MessageInfo &` arguments. It also reorders the `void *`
to match other CoAP callbacks.

Implementations in `BackboneTmfAgent::Filter` and `Agent::Filter`
have been updated to match the new signature.
2026-01-26 10:33:00 -08:00
Abtin Keshavarzian 0c4f22d69a [core] introduce VendorInfo class for vendor parameters (#12328)
This commit introduces a new `VendorInfo` class to encapsulate
vendor-related information such as vendor name, model, and software
version.

Previously, these parameters were managed within the `NetworkDiagnostic`
module. Moving them to a dedicated class facilitates sharing and
utilization by other modules across the OT core (e.g., Border Agent,
TCAT, Joiner).
2026-01-23 10:54:07 -08:00
Abtin Keshavarzian 5cae26e22b [coap] simplify Coap::Message implementation (#12313)
This change simplifies the `Coap::Message` implementation and removes
the fragile `HelpData` struct which was used to cache header
information within reserved portion of message.

The `Coap::Msg` class is updated to hold the parsed CoAP header
information (type, code, message ID, token). It now inherits from a
new `HeaderInfo` class which contains the parsed fields. This change
helps to simplify many of the call sites which previously had to parse
the header information themselves.

The key changes are:
- The `HelpData` struct is removed from `Coap::Message`.
- `Coap::Msg` is updated to track parsed header info in `HeaderInfo`.
- `otCoapMessageInit()` and `otCoapMessageInitResponse()` now return an
  `otError`.
- Methods are renamed to harmonize their names.
- A new unit test `test_coap_message.cpp` is added to verify the
  `Coap::Message` implementation.
2026-01-23 10:52:42 -08:00
Abtin Keshavarzian 3b676fb6f3 [ip6] skip MPL processing on SEDs and detect self-sent multicast (#12323)
This commit updates `Mpl::ProcessOption()` to skip MPL processing on
Sleepy End Devices (SEDs) as an optimization. Along with this it
introduces a check to prevent SEDs from processing their own
multicast messages.

Since MPL is now skipped on SEDs, they no longer have a mechanism
for multicast duplicate detection. This can cause an issue when an
SED sends a multicast message to a group it is subscribed to, as its
parent can forward the message back to the SED.

To handle this, `Ip6::DetermineAction()` is updated. For SEDs, it now
checks if the source address of a subscribed multicast message
belongs to the device itself. If it does, the message is not
received, preventing the SED from processing its own looped-back
messages.

The behavior for non-sleepy devices remains unchanged. They continue
to rely on MPL for duplicate suppression.
2026-01-23 10:40:22 -08:00
Esko Dijk 3061fa19de [otns] add default (weak) OTNS platform API implementation in core (#12308)
A default OTNS platform API function otPlatOtnsStatus() is now
provided that writes the status push to the log always (regardless of
configured log level). This is useful as a default handling for apps
built with -DOT_OTNS=ON, avoiding linker errors while not mandating
each platform to implement the API by itself.

Specifically it enables the Posix CLI app ot-cli to be built with OTNS
support, which is required to run Posix nodes in OTNS and receive the
status-push events via stdout logging.

The logging is emitted from the module named "Otns" so that a
simulator or other tool can easily detect the OTNS format status push
events in the log output.
2026-01-22 10:49:37 -08:00
Abtin Keshavarzian cda1a0cf05 [tlvs] use Tlv::Info for reading TLV values (#12322)
This change moves the TLV value reading logic from static methods in
the `Tlv` class to member methods of the nested `Tlv::Info` class.

The new methods `Tlv::Info::ReadValue()`, `Tlv::Info::ReadStringValue()`,
`Tlv::Info::ReadUintValue()`, and the templated `Tlv::Info::Read<T>()`
operate on an existing `Tlv::Info` object that has already parsed a
TLV from a message.

This improves the API design by having the read operations use the
pre-parsed and validated state within a `Tlv::Info` instance. It
avoids the need to pass the TLV offset to read functions and
eliminates redundant re-parsing of the TLV header on each read,
making the code cleaner and more efficient.

The previous static methods `Tlv::Read<T>()`, `Tlv::ReadStringTlv()`,
and `Tlv::ReadUintTlv()` are removed, and all call sites are updated
to the new pattern.
2026-01-22 09:23:34 -08:00
Esko Dijk 213745a81f [cli] provide default 'APP' log output implementation in CLI module (#12309)
Refactors the example CLI app and the CLI module code to provide a
default implementation of the 'APP' log output option for any CLI
apps. This default is used when log output is configured to 'APP'
output and the CLI application itself does not provide its own
implementation of `otPlatLog()`.

This extends the current logging option (syslog) for the Posix app
ot-cli with the option to direct the log output to the CLI app, which
then prints it in stdout. This logging option can be enabled using the
existing -DOT_LOG_OUTPUT=APP. Previously, this gave a build error for
the Posix platform. This logging method is useful/required for running
NCPs in OTNS, such that the simulator can capture all log output and
at the same time syslog is not overly burdened on the host machine.
2026-01-21 12:30:29 -08:00
dependabot[bot] 9a40380a47 github-actions: bump github/codeql-action from 4.31.9 to 4.31.10 (#12312)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.9 to 4.31.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/5d4e8d1aca955e8d8589aabd499c5cae939e33c7...cdefb33c0f6224e58673d9004f47f7cb3e328b89)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.10
  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>
2026-01-20 08:20:24 -08:00
Abtin Keshavarzian bd773fdbf6 [message] add IncreaseLength() helper method (#12305)
This commit adds a new helper `Message::IncreaseLength()` to
grow the message by increasing its length by a given number of
bytes.
2026-01-16 16:54:49 -08:00
Abtin Keshavarzian 5f7aa17460 [tlv] improve encapsulation and docs for Tlv::Info (#12301)
This change renames `Tlv::ParsedInfo` to `Tlv::Info` to make it more
concise and to better reflect its purpose as a metadata holder for a
TLV in a message.

The member variables of `Tlv::Info` are made private and public
accessor methods are introduced to interact with the object's
contenet. This helps ensure that the internal representation of the
parsed TLV information is not modified directly by external modules.
All existing caller are updated to use the new name and the public
helper getter methods.

The Doxygen comments of `Tlv::Info` are also improved for better
clarity. Unit test `test_tlv` is also updated to validate all the
new methods.
2026-01-16 16:53:32 -08:00
Abtin Keshavarzian b3d3b5c3c7 [netdiag] require 'RD:' prefix for vendor name on reference devices (#12233)
When `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is active, this
change mandates that the vendor name string MUST begin with the "RD:"
prefix. This ensures that reference devices are clearly and
consistently identifiable through network diagnostic queries.

The enforcement is applied at two levels:

- A compile-time `static_assert` is added to validate the default
  `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_NAME` at build time. This uses a
  new `constexpr` helper utility `CheckConstStringPrefix()`.

- A runtime check is added to `otThreadSetVendorName()`, which will
  now return `OT_ERROR_INVALID_ARGS` if an invalid name is provided
  on a reference device build.

All related test configurations (`scan-build`, `toranj`, `nexus`) and
CLI tests are updated to reflect this new requirement and validate
it.
2026-01-16 10:20:13 -08:00
puddly 5fd62a9acf [spinel] clear source match tables before recovery (#12222)
Radio recovery that does not fully reset the firmware leads to tables
filling up with duplicate entries. After a few resets, future resets no
longer work. Clearing the tables before inserting entries allows for
their state to be consistent during recovery.
2026-01-15 20:21:54 -08:00
Łukasz Duda 5c9eeb1ce8 [crypto] mbedtls: refactor mbedtls-config.h for better readability (#12292)
Group mbedTLS configuration macros into logical sections and improve
formatting.

This commit helps prepare for PSA API backend introduction.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-01-15 07:44:32 -08:00
Abtin Keshavarzian 0e72f56941 [mle] introduce Connectivity and ConnectivityTlvValue types (#12300)
This change separates the Connectivity TLV value format from its
logical structure by introducing `ConnectivityTlvValue` (raw format)
and `Connectivity` (parsed info). This replaces the `ConnectivityTlv`
class and enables value format sharing between MLE and Network
Diagnostics (without improper TLV inheritance).

It also updates `ParentCandidate` to use the new `Connectivity` class
for better field encapsulation. It also updates `ConnectivityTlvValue`
parsing to handle optional fields and enforce spec-defined minimums
for these fields.
2026-01-15 07:43:01 -08:00
Abtin Keshavarzian e3b565cc40 [mbedtls] fix build failure by including crypto.h (#12297)
Replace the include of `<openthread/platform/memory.h>` with
`<openthread/platform/crypto.h>` in the mbedTLS config header file.

Recent PR #12290 introduced `otPlatCryptoCAlloc()` and
`otPlatCryptoFree()` platform APIs and updated the mbedTLS config to
use them. This commit ensures the correct header is included to
prevent build errors regarding use of undeclared functions
(e.g. "error: use of undeclared identifier 'otPlatCryptoCAlloc'").
2026-01-15 07:38:48 -08:00
Jonathan Hui 8406751ecb [tests] update test_detach to be more robust (#12299)
The router processes its child table every second. After a child
gracefully detaches, wait some time to ensure that the router has
processed the child table entry.
2026-01-14 18:14:12 -08:00
Abtin Keshavarzian 0d1cca30da [net-diag] use Tlv helper to parse from message (#12294)
This change simplifies the TLV parsing logic within the
`Client::GetNextDiagTlv()` method.

The manual parsing of basic and extended TLVs is replaced by using the
`Tlv::ParsedInfo` helper method. This encapsulates the parsing
logic, making the `GetNextDiagTlv()` method cleaner and easier to
follow.

Additionally, the `TlvInfo` typedef is renamed to `DiagTlv` to
prevent any confusion with the new `Tlv::ParsedInfo tlvInfo` variable
and to better reflect its purpose.
2026-01-14 10:22:57 -08:00
Abtin Keshavarzian 41ecb75b83 [discover-scan] simplify and enhance discovery response parsing (#12293)
This commit enhances the parsing of discovery response messages in
`DiscoverScanner::HandleDiscoveryResponse()`.

The parsing logic is updated to first restrict the message to the
content of the `Discovery` TLV. This allows for a simpler and more
robust processing of the nested MeshCoP sub-TLVs. Instead of looping
through all sub-TLVs, the new approach directly looks for each expected
sub-TLV.

This change provides a clearer distinction between required TLVs
(`DiscoveryResponseTlv`, `ExtendedPanIdTlv`, `NetworkNameTlv`) and
optional ones. The handling of optional TLVs like `JoinerUdpPortTlv`
and `SteeringDataTlv` is improved to explicitly manage the case where
they are not found.

Additionally, this commit includes minor cleanups to `SteeringDataTlv`
to simplify its implementation.
2026-01-14 10:20:20 -08:00
Abtin Keshavarzian f4816375c0 [coap] introduce Coap::Msg to simplify method calls (#12285)
This commit introduces `Coap::Msg`, a class that encapsulates
`Coap::Message` and its associated `Ip6::MessageInfo`.

`Coap` methods and TMF resource handlers are updated to use
`Coap::Msg` when handling received messages. This change simplifies
method signatures by reducing the number of parameters and enables
future extensibility for tracking additional information related to
received CoAP messages.
2026-01-14 10:18:17 -08:00
Łukasz Duda 8bdc6cf339 [crypto] PSA API: introduce platform API for crypto dynamic memory mgmt (#12290)
This commit introduces two new platform functions:
- otPlatCryptoCAlloc()
- otPlatCryptoFree()

It also provides a default implementation using the OpenThread Heap.

This API is necessary for the upcoming work related to PSA API

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-01-13 18:46:00 -08:00
Łukasz Duda 103b601384 [crypto] PSA API: extend Crypto platform API to support HKDF-SHA256 (#12291)
This commit adds PSA API support for HKDF-SHA256 for TREL in OpenThread
platform API.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-01-13 13:50:08 -08:00
Abtin Keshavarzian 0c68f3ad8b [tlv] introduce LeaderDataTlvValue to share TLV format (#12289)
This commit introduces `LeaderDataTlvValue` as a distinct type to
represent the content of a Leader Data TLV. This allows the same value
format to be shared between the MLE and Network Diagnostic modules.

Previously, `NetworkDiagnostic::LeaderDataTlv` inherited from
`Mle::LeaderDataTlv` to reuse the implementation of the value format.
This inheritance was semantically incorrect, as a Network Diagnostic
TLV is not a specialization of an MLE TLV. The new approach of using
a shared `LeaderDataTlvValue` type provides a cleaner and more
accurate design.

With this change, `LeaderDataTlv` in both modules is now defined as a
`SimpleTlvInfo` type. This enables replacing manual TLV manipulation
with the generic `Tlv::Append<T>()` and `Tlv::Find<T>()` helpers,
making the code at the call sites cleaner and less error-prone.
2026-01-12 15:59:43 -08:00
Abtin Keshavarzian a32e1f752e [meshcop] simplify Discovery Request or Response TLV processing (#12279)
This change simplifies `DiscoveryRequestTlv` and `DiscoveryResponseTlv`
generation and processing.

New types `DiscoveryRequestTlvValue` and `DiscoveryResponseTlvValue` are
introduced to represent the value (payload) of these TLVs. This s
simplifies the call sites by using the generic `Tlv::Append<T>()` and
`Tlv::Read<T>()`.
2026-01-12 14:43:20 -08:00
Abtin Keshavarzian c9665886fa [joiner] add build config for for experimental Joiner Adv feature (#12276)
This change introduces a new build-time configuration flag,
`OPENTHREAD_CONFIG_JOINER_ADV_EXPERIMENTAL_ENABLE`, to control the
inclusion of the experimental Joiner Advertisement feature.

This behavior was first added in PR #5299. It allows optional
inclusion of a newly proposed Joiner Adv TLV in an MLE Discovery Scan
Request message.

This is an experimental feature and is not part of the Thread
specification. OpenThread's implementation is limited and partial: it
only provides the mechanism for a Joiner to include a new Joiner Adv
TLV in its emitted Discovery Scan Request messages, but does not
include the corresponding logic for the receiver of Scan Request to
read or parse this TLV.

The new flag conditionally compiles this behavior. It allows for the
entire feature to be compiled out, reducing code size and memory
usage for devices that do not require this experimental
functionality. Additionally, this change clarifies the experimental
status of the feature in the documentation.

By default, this is now disabled. It is enabled under posix build for
`toranj` tests so that it is covered in GitHub CI.
2026-01-12 12:13:42 -08:00
Yang Song 61e2f2877d [posix] handle infra interface index change (#12059)
This change updates the netlink message handling for the infra link on
the POSIX platform to be more robust and efficient for `RTM_NEWLINK`
and `RTM_DELLINK` messages.

The logic for handling infra index changes is:

1. On `RTM_DELLINK`, the code verifies `ifinfo->ifi_index` is for the
currently infra index `mInfraIfIndex`.

2. On `RTM_NEWLINK`, it identifies the infra by its name
`if_indextoname(ifinfo->ifi_index)` and updates `mInfraIfIndex`.
2026-01-12 12:10:18 -08:00
Arkadiusz Bałys 5d21b406a3 [cmake] Fix a wrong ot_option usage for OT_STEERING_DATA (#12287)
There was a mistake with the ot_option macro usage. It shall not
contain `,` between arguments.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2026-01-12 12:08:52 -08:00
dependabot[bot] 8193434595 github-actions: bump codecov/codecov-action from 5.5.1 to 5.5.2 (#12286)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.5.1 to 5.5.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/5a1091511ad55cbe89839c7260b706298ca349f7...671740ac38dd9b0130fbe1cec585b89eea48d3de)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.5.2
  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>
2026-01-12 12:08:34 -08:00
Abtin Keshavarzian f9aeacfd4d [cli] add commands for ephemeral key TAP generation and validation (#12267)
This change introduces two new CLI commands to the Border Agent module
for managing Thread Administration One-Time Passcodes (TAPs).

The new commands are:

- `ba ephemeralkey generate-tap`: This command generates and outputs a
  cryptographically secure random TAP string. Note that it does not
  start ephemeral key use with this TAP string.

- `ba ephemeralkey validate-tap <keystring>`: This command validates a
  given TAP string by checking its length, character set, and the
  Verhoeff checksum.

The change also includes documentation updates and a new test case to
verify the functionality.
2026-01-12 10:35:47 -08:00
Yakun Xu 0b0cdc83cf [github-actions] install gn by apt (#12283)
This commit installs `gn` by the system's package manager instead of
directly downloading which seems not working now.
2026-01-12 10:33:15 -08:00
Abtin Keshavarzian 356ff345fe [core] remove unnecessary forward declarations of class ThreadNetif (#12278)
Removes unnecessary `class ThreadNetif;` forward declarations in
`meshcop.hpp`, `child_supervision.hpp`, and `jam_detector.hpp`.
2026-01-09 16:47:41 -08:00
Abtin Keshavarzian 1b86eb87d4 [meshcop] move SteeringData to its own source files (#12277)
The `SteeringData` class and its related methods are moved from
`meshcop.hpp` and `meshcop.cpp` to new dedicated files
`steering_data.hpp` and `steering_data.cpp`.

This change addresses a circular include dependency issue, allowing
`SteeringData` to be included more easily in other parts of the
codebase, such as `meshcop_tlvs.hpp`, without requiring forward
declarations or pulling in unnecessary dependencies from the larger
`meshcop.hpp` header.
2026-01-09 16:46:19 -08:00
Abtin Keshavarzian 7354c57adb [coap] introduce otCoapToken to improve token handling (#12273)
This commit introduces a new `otCoapToken` struct and a corresponding
`Coap::Token` class to provide a clear and type-safe representation
of a CoAP message token.

The CoAP APIs are updated to use these new types, replacing the use
of raw `uint8_t` pointers and separate length parameters. This
encapsulation enhances robustness and reduces the potential for
errors in token handling.

The following new APIs are added:

- `otCoapMessageReadToken()`
- `otCoapMessageWriteToken()`
- `otCoapMessageAreTokensEqual()`

Importantly, several older APIs are now marked as deprecated (some
returned pointers directly into `otMessage` data which is unsafe).
While these APIs remain supported for now, their use is discouraged,
and applications should migrate to the new APIs. Deprecated APIs:

- `otCoapMessageGetTokenLength()`
- `otCoapMessageGetToken()`
- `otCoapMessageSetToken()`

The internal implementation is updated to utilize the new `Token`
class, and the CLI implementation is updated to use the new public
APIs. Additionally, Doxygen documentations are updated for the new
and updated APIs.
2026-01-09 16:45:14 -08:00
Yakun Xu 6a9d92545b [gn] fix build with openthread_enable_core_config_args is false (#12265)
This commit fixes building with gn when
openthread_enable_core_config_args is false, which causes
openthread_config_tcp_enable undefined.
2026-01-08 11:19:40 -08:00
Yakun Xu 093531d37c [doxygen] expand OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK (#12274)
This commit fixes incorrect return type in doxygen generated doc by
telling doxygen `OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK` should be
expanded. Doxygen got confused with macros following function
declarations.
2026-01-08 11:16:40 -08:00
Tongze Wang b47664b452 [posix] use default when passing nullptr to SettingsFile::SetSettingsPath (#12268)
This commit adds the nullptr check in `SettingsFile::SetSettingsPath`.
If the nullptr is passed to `SettingsFile::SetSettingsPath`, it will
set the settings path to a default path
(OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH).
2026-01-08 11:16:10 -08:00
Abtin Keshavarzian b838d67954 [coap] clean up coap.h header and API definitions (#12259)
This commit improves the structure and readability of the CoAP public
API header(`coap.h`) and its implementation (`coap_api.cpp`).

- Reorganizes function and type declarations in `coap.h` and their
  corresponding definitions in `coap_api.cpp` into logical groups to
  improve clarity. For example, group all block-wise transfer APIs
  together. There is no change to the API documentation.
- Moves the definitions of several `static inline` functions
  (e.g., `otCoapSendRequest`, `otCoapSendResponse`, and block-wise
  transfer variants) from `coap.h` to `coap_api.cpp`.
- Updates `otCoapOptionContentFormat` enum comments to use the `///<`
  style for better consistency and alignment.
2026-01-08 11:14:30 -08:00
Yakun Xu 31631142c2 [build] add format-nonliteral to missed code (#12251)
This commit enables the format-nonliteral check for code missed in
`#12236`. This commit also enables the format-nonliteral warnings in
CMake to catch such warnings in future in CMake build.
2026-01-06 14:53:38 -08:00
Abtin Keshavarzian bcc41e9b44 [coap] improve CoAP message Header processing logic (#12264)
This change enhances the CoAP message implementation by enhancing
the nested `Message::Header` class.

This class encapsulates the logic for parsing and managing CoAP
header fields, including version, type, token, code, and message ID.
The main `Message` class methods are updated to delegate header
manipulation to the `Header` class.

The direct bitwise operations for header fields are replaced with the
`ReadBits<>()` and `WriteBits<>()` utility functions for better
clarity and maintainability.
2026-01-05 17:41:30 -08:00
Abtin Keshavarzian f28d5da161 [cli] improve docs for 'ba enable/disable' commands (#12232)
This change enhances the Doxygen documentation for the `ba enable` and
`ba disable` CLI commands.
2026-01-05 17:25:03 -08:00
Yakun Xu 240a96362d [style] declare exported headers (#12255)
This commit adds IWYU pragma to declare exported header files, so that
IWYU won't complain about our current include style.
2026-01-05 14:27:54 -08:00
xusiyu 946af205a1 [mac] clear mode2 key only on mac destruction (#12243)
This commit adjusts how the `MAC Mode2 key` is cleared to avoid
invalidating it in certain runtime flows.

In the previous behavior, when the OpenThread instance is initialized,
Mac is constructed and sets the Mode2 key. If
otInstanceErasePersistentInfo is called afterwards, the call chain
reaches KeyManager::DestroyTemporaryKeys(), where the Mode2 key is
cleared. However, there is no subsequent point where the Mode2 key is
re-set. If Thread is then enabled and a frame using Key ID Mode 2 is
received, the Mode2 key remains invalid, which can lead to incorrect
behavior.

To fix this, this commit removes the Mode2 key clearing from
`KeyManager::DestroyTemporaryKeys()` and clears the Mode2 key in the
Mac destructor. This ensures that the Mode2 key stays valid for the
lifetime of the Mac (and thus the OpenThread instance) after
initialization, and is only cleared when Mac is destroyed.
2026-01-05 13:14:00 -08:00
dependabot[bot] 2bb49ea22e github-actions: bump github/codeql-action from 4.31.4 to 4.31.9 (#12261)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.4 to 4.31.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/e12f0178983d466f2f6028f5cc7a6d786fd97f4b...5d4e8d1aca955e8d8589aabd499c5cae939e33c7)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.9
  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>
2026-01-05 11:44:26 -08:00
Abtin Keshavarzian 8255afe861 [common] add enum-to-string conversion utility (#12257)
This commit introduces a new `DefineEnumStringArray` macro to simplify
the conversion of enums to their string representations. This
utility uses the X-Macro pattern to generate a `constexpr` lookup
array and validates the enum-to-string mapping at compile time using
`static_assert` checks.

This approach replaces a more verbose and error-prone pattern that
required manual definition of a string array and a separate code for
validation.
2026-01-05 11:30:22 -08:00
Abtin Keshavarzian ac6cdb02f7 [coap] improve block-wise transfer handling (#12248)
This commit enhances the CoAP block-wise transfer implementation by
removing the `BlockWiseData` struct within `Message::HelpData` and its
associated getter/setter methods (e.g., `GetBlockWiseBlockNumber()`,
`SetBlockWiseBlockNumber()`). The `Message` object is no longer
responsible for carrying temporary state related to block-wise transfers,
addressing the fragility of the previous design which used the reserved
header portion of the `Message` to store these properties.

A new `BlockInfo` struct has been introduced to cleanly encapsulate the
three pieces of information from a Block option: `mBlockNumber`,
`mBlockSzx` (size exponent), and `mMoreBlocks` flag. It also includes
utility methods like `GetBlockSize()` and `GetBlockOffsetPosition()` to
simplify calculations.

All methods involved in block-wise transfers in `coap.cpp` (e.g.,
`ProcessBlockwiseSend`, `SendNextBlock1Request`) have been updated to
use the new `BlockInfo` struct. They now create local `BlockInfo`
variables and call `ReadBlockOptionValues()` to populate them.

This commit also includes minor cleanups and improvements:

- "Block size" is now used consistently instead of block length (e.g.,
  `kMaxBlockLength` is renamed to `kMaxBlockSize`).
- `OffsetRange` is now used to read the payload in
  `SendNextBlock2Request` and `ProcessBlock1Request`, simplifying the
  code.
2026-01-05 11:26:55 -08:00
Abtin Keshavarzian f4c51b8232 [coap] simplify CoAP observe logic (#12241)
This commit extracts observe-related logic from several methods into
new dedicated helper functions `ProcessObserveSend()` and
`IsObserveSubscription()`.

This change improves the clarity and maintainability of the main CoAP
methods:

- `SendMessage()` now delegates observe cancellation logic to
  `ProcessObserveSend()`.
- `ScheduleRetransmissionTimer()` and `HandleRetransmissionTimer()`
  use the new `IsObserveSubscription()` helper to determine if a
  pending request is an active subscription that should not time
  out.
- `ProcessReceivedResponse()` is simplified by separating the control
  flow for observe notifications from multicast responses.
2026-01-05 11:25:04 -08:00
dependabot[bot] 073b9b3607 github-actions: bump docker/metadata-action from 5.9.0 to 5.10.0 (#12247)
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5.9.0 to 5.10.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](https://github.com/docker/metadata-action/compare/318604b99e75e41977312d83839a89be02ca4893...c299e40c65443455700f0fdfc63efafe5b349051)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: 5.10.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-12-31 15:53:20 -08:00
Tongze Wang f32beac574 [posix] allow set settings path at runtime (#12176)
This commit allows users to pass the settings path through a command
line flag (`--data-path`) when starting the daemon / cli.
- It introduces `ot::Posix::PlatformSettingsGetPath()` and
  `ot::Posix::PlatformSettingsSetPath` to unify the method of getting
  / setting the settings file path.
- If users doesn't not set this flag, the settings path will be
  default to OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH.
2025-12-31 15:06:30 -08:00
Abtin Keshavarzian d7d4fc0a5a [tlvs] add helper to append an empty TLV (#12253)
Introduces a new helper `Tlv::AppendEmptyTlv()` and a templated
version `Tlv::AppendEmpty<TlvType>()` to simplify appending empty TLVs
to a message.

This avoids repetitive manual construction of empty TLVs in different
parts of the codebase.
2025-12-31 14:49:51 -08:00
Abtin Keshavarzian ca738afc8f [core] use Tlv::AppendTlv helper to simplify TLV appends (#12252)
This commit updates various modules to use the `Tlv::AppendTlv` helper
method when appending a TLV with its value to a `Message`.
2025-12-31 14:49:01 -08:00
Abtin Keshavarzian da1f792770 [tlvs] add Start/End/AdjustTlv methods for staged writing (#12250)
This commit introduces a new set of static methods to simplify
writing TLVs with variable lengths to a `Message`.

The new mechanism consists of three methods:
- `Tlv::StartTlv()`: Appends a placeholder TLV header and returns a
  `Bookmark`.
- `Tlv::AdjustTlv()`: Optionally promotes the TLV to an extended TLV
  if the length grows beyond the standard TLV limit. This is an
  optimization to avoid large copies within a message.
- `Tlv::EndTlv()`: Calculates the final length and updates the TLV
  header, promoting to an extended TLV if necessary.

This new set replaces the common but cumbersome pattern of manually
saving the start offset, appending data, and then back-patching the
length field.

The existing code is updated to use this new, simpler, and more
robust mechanism.

This commit also adds unit tests to validate the new functionality.
2025-12-31 14:48:00 -08:00
Abtin Keshavarzian b4ad385737 [test] increase simulator.go() time in key sequence jump test (#12249)
Increase the simulation wait time from 2 to 5 seconds in the
`test_mle_msg_key_seq_jump` after child restart.

This larger time window accounts for randomness in the timing of the
Child Update transmission. This makes the test more robust by ensuring
the child has sufficient time to send its "Child Update Request".
2025-12-31 14:42:10 -08:00
Abtin Keshavarzian bd897509f5 [coap] move blockwise transfer logic to dedicated methods (#12240)
This change reorganizes the CoAP blockwise transfer implementation to
improve code structure and readability.

The logic for handling blockwise transfers is extracted from
`ProcessReceivedRequest()` and `ProcessReceivedResponse()` into two new
private helper methods: `ProcessBlockwiseRequest()` and
`ProcessBlockwiseResponse()`.

This separation makes the main request and response processing methods
simpler and more focused on their primary role, delegating the
complexities of blockwise transfers to dedicated functions.

Additionally, this change introduces `Message::UriPathStringBuffer` as a
`typedef` to provide a clear and consistent type for handling URI path
string buffers.
2025-12-31 14:40:35 -08:00
Abtin Keshavarzian ed6235304b [joiner] enhance string TLV input validation (#12245)
This commit introduces a new generic method `Tlv::ValidateStringValue()`
to provide a unified way of validating string values intended for use
in string-valued TLVs.

This new method checks that a given C string is a valid UTF-8 string
and that its length does not exceed the maximum length defined by the
`StringTlvType`.

The `Joiner::Start()` method is updated to use this new validation
method, which simplifies the code by replacing several explicit and
repetitive checks. This improves code clarity and maintainability by
centralizing the string validation logic.

This commit also adds missing validation for `aVendorModel` in
`Joiner::Start()`
2025-12-26 20:10:12 -08:00
Abtin Keshavarzian 045ea0636b [meshcop] enhance Joiner class details and style (#12244)
This commit contain style fixes for the `Joiner` for improved
clarity and consistency. Changes include:

- Rename `mCallback` to `mCompletionCallback` and introduce a new
  `CompletionCallback` typedef for `otJoinerCallback` to more clearly
  indicate its purpose.
- Improve Doxygen comments for the `State` enum to make them more
  descriptive.
- Replace the use of `OPENTHREAD_CONFIG_JOINER_MAX_CANDIDATES` macro
  with a new private constant `kMaxJoinerRouterCandidates`.
- Reorder private method and member variable declarations in
  `joiner.hpp` to follow a more consistent style.
2025-12-26 20:02:19 -08:00
Abtin Keshavarzian f69e6ba80a [coap] simplify SendMessage() for block-wise transfers (#12239)
This commit simplifies the block-wise transfer implementation within
`CoapBase::SendMessage()`.

It extract the logic for handling the initial block of an outgoing
block-wise transfer from `CoapBase::SendMessage()` into a new private
method, `ProcessBlockwiseSend()`. This improves readability and
maintainability while removing code duplication when processing
block-wise sends for different message types.

It also cleans up `coap.hpp` by consolidating several declarations
related to block-wise transfers under a single
`OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE` block.
2025-12-26 19:59:55 -08:00
Abtin Keshavarzian c6b120e258 [coap] enhance block-wise transfer BlockSzx handling (#12237)
This change improves the internal implementation of CoAP block-wise
transfers.

Introduces an internal `Coap::BlockSzx` enum to mirror the public
`otCoapBlockSzx` enum, improving the separation between the API and
the implementation. All internal functions are updated to use the new
`BlockSzx` enum.

The logic from `otCoapBlockSizeFromExponent()` is moved into a new
core `Coap::BlockSizeFromExponent()` function. The public function
becomes a simple wrapper.

A new helper function, `CoapBase::DetermineBlockSzxFromSize()`, is
added to replace a `switch` statement, simplifying the logic for
determining block size from a given buffer length.

`ResourceBlockWise` is updated to inherit from `LinkedListEntry`,
aligning it with the common pattern used for managing resource lists.
2025-12-24 21:05:42 -08:00
Yakun Xu 40e693762d [build] add printf literal string format checks for va_list functions (#12236)
This commit introduces enhanced format string checking. It activates a
new compiler warning to identify potential issues with non-literal
format strings and systematically applies format attribute macros to
functions that handle variable arguments.
2025-12-23 19:31:08 -08:00
Abtin Keshavarzian 4c152b91aa [coap] simplify Coap::TxParameters validation (#12235)
This commit simplifies the validation of `Coap::TxParameters`.

The primary `SendMessage()` method is updated to accept `TxParameters`
as a pointer, where `nullptr` is mapped to the default `TxParameters`.
The user-provided `TxParameters` are now validated in the primary
`SendMessage()` method by calling `TxParameters::ValidateFor()` replacing
checks previously performed in `coap_api.cpp` source file.

This commit also adds a set of `static_assert()` checks to validate the
default `TxParameters` at compile-time, ensuring all its properties are
within valid ranges and that duration calculations will not cause
an overflow.

This approach simplifies the API by removing the `TxParameters::From()`
helper and centralizes `TxParameters` selection and validation logic
within the core `CoapBase` class.
2025-12-23 19:25:52 -08:00
Yakun Xu c222f582b4 [gn] no propagating diagnostic flags (#12219)
This commit moves the diagnostic flags into the toolchain itself,
preventing these flags being propagated to OpenThread dependents.
2025-12-22 21:21:37 -08:00
tanyanquan a12ff0d0f5 [csl] account for accuracy drift for next CSL window (#11602)
This commit improves the accuracy of CSL timer fire time by taking
into account the accuracy drift introduced between the current CSL
window and next CSL window.

Original implementation:
- calculate CSL window edges based on current elapsed time
- CSL window edges used to obtain next CSL timer fireAt time
- does not account for additional drift due to accuracy from now until
  next CSL window
- undesired outcome: if CSL period is large (e.g. 10s) and accuracy is
  poor (e.g. 200ppm), then the additional accuracy drift could be
  significant (e.g. 2ms) and the SSED may wake up too late

Suggested implementation:
- calculate the additional expected drift between now and next CSL
  window (i.e. periodUs) and account for this difference by setting
  CSL timer to fireAt earlier
2025-12-22 13:55:41 -08:00
dependabot[bot] 97c7cb66b3 github-actions: bump umbrelladocs/action-linkspector from 1.3.7 to 1.4.0 (#12234)
Bumps [umbrelladocs/action-linkspector](https://github.com/umbrelladocs/action-linkspector) from 1.3.7 to 1.4.0.
- [Release notes](https://github.com/umbrelladocs/action-linkspector/releases)
- [Commits](https://github.com/umbrelladocs/action-linkspector/compare/874d01cae9fd488e3077b08952093235bd626977...652f85bc57bb1e7d4327260decc10aa68f7694c3)

---
updated-dependencies:
- dependency-name: umbrelladocs/action-linkspector
  dependency-version: 1.4.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-12-22 13:44:02 -08:00
Abtin Keshavarzian b5737b4f2b [script] add script to check, enforce, and update header guards (#12227)
This commit introduces a new script `update-header-guards.py` which
checks for the presence of header guards in `.h` and `.hpp` files and
automatically updates them, standardizing the header guard name format
across the codebase.

The new format for header guards is derived from the full path of the
file. For example, `src/core/common/notifier.hpp` will use
`OT_CORE_COMMON_NOTIFIER_HPP_`. The guard name includes additional
prefixes such as `OT_` or `OPENTHREAD_` to ensure uniqueness.

This new naming format handles cases where the same filename may be used
in different folders, such as the two `heap.hpp` files located in
`src/core/common` and `src/core/utils`.

It also ensures that public and platform OpenThread headers under
`include/openthread` have uniquely distinct header guard names to avoid
conflicts when these headers are included in other projects.

The new script helped identify issues with existing header files that
lacked header guards (e.g., `posix/system.hpp`) or had improper guards
(e.g., `openthread/link_metrics.h`).

This commit also introduces a new check script `check-header-guards` to
validate that all header guards are correctly formatted. This check is
added to the GitHub CI actions to ensure consistency moving forward.

All existing header files have been updated (using the new script)
to apply the new guard name format.
2025-12-22 13:43:41 -08:00
Abtin Keshavarzian 1d25510d57 [coap] reorder block-wise related methods for improved readability (#12228)
This commit reorders block-wise related methods in both header and
source files to group them within the same `#if` block. This is a
purely stylistic change to improve code organization and readability
and do not alter any functionality.
2025-12-22 13:33:11 -08:00
Abtin Keshavarzian 7d23c9009a [hist-tracker] use Tlv::ParsedInfo for robust TLV parsing (#12229)
This commit updates `Server::PrepareAndSendAnswers()` to utilize
`Tlv::ParsedInfo` for more robust TLV parsing and validation. This
ensures correct validation and size calculation for both standard and
extended TLVs when iterating over TLVs through the received message.

This change also adds an explicit check to skip over extended TLVs,
ensuring the implementation correctly handles cases where extended
TLVs may be present.
2025-12-19 12:16:44 -08:00
Abtin Keshavarzian f8d74d8951 [coap] improve ResponseCache design and implementation (#12225)
This change improves the design and implementation of the CoAP response
caching mechanism.

The main changes are:

- `ResponsesQueue` is renamed to `ResponseCache` to better reflect its
  purpose.
- `ResponseCache` is moved to be a private nested class within
  `CoapBase` to improve encapsulation.
- The responsibility of sending a cached response is moved into the
  `ResponseCache` class. A new `SendCachedResponse()` method handles
  finding, cloning, and sending the cached response, which simplifies
  the `ProcessReceivedRequest()` method in `CoapBase`.
- Method names within `ResponseCache` are updated for better clarity
  (e.g., `DequeueAllResponses()` to `RemoveAll()`).
- Comments are updated to align with the new design.

This change results in a cleaner design with better-defined
responsibilities for the `ResponseCache` and `CoapBase` classes.
2025-12-19 09:32:18 -08:00
Abtin Keshavarzian 65059ebbeb [tmf] add overloads of SendMessage accepting OwnedPtr<Message> (#12217)
This change introduces new overloads for `Coap::SendMessage()` that
accept an `OwnedPtr<Message>`, transferring ownership of the message
to the CoAP layer upon being called.

The modules `BorderAgent` and `Commissioner` are  updated to use this
new method. The use of `OwnedPtr<Message>` simplifies the message
allocation and cleanup. This removes the need for manual clean up
calls(e.g., `FreeMessageOnError()`) and makes the code safer.
2025-12-19 09:31:45 -08:00
Yakun Xu bded2cc885 [style] use OT_FALL_THROUGH (#12226)
This commit replaces `// Fall through` with `OT_FALL_THROUGH` because
the former is not recognized by some compilers.
2025-12-18 16:59:35 -08:00
Abtin Keshavarzian cc48d3d752 [nat64] add otNat64StateToString() (#12218)
This commit introduces a new public NAT66 related API function,
`otNat64StateToString()`, to convert an `otNat64State` enum value
into a human-readable string.

The `nat64 state` CLI command is updated to use this new function,
removing its local and duplicated enum-to-string logic.
2025-12-18 13:49:45 -08:00
Rongli Sun e905049eb2 [posix] add kernel version check for route metric (#12221)
This commit adds a compile-time check to ensure that
the Linux kernel version is 4.18 or newer for prefix
route metric as `IFA_RT_PRIORITY` attribute for netlink
messages was introduced in v4.18.

`OPENTHREAD_POSIX_CONFIG_INSTALL_OMR_ROUTES_ENABLE` can
be an alternative for prioritizing Off-Mesh-Routable (OMR)
prefixes for older kernels.
2025-12-18 08:54:51 -08:00
Abtin Keshavarzian dbdb2be2d1 [unit-test] enhance TestMessage() to cover different reserved lengths (#12224)
This commit enhances the `TestMessage()` unit test by parameterizing
it to run with various reserved length values. The test is now
executed in a loop with a set of different headroom reservation
values.

This change improves test coverage for the `Message` class by
verifying that all its core operations function correctly when
messages are allocated with various initial reserved header lengths.
2025-12-17 20:00:38 -08:00
Abtin Keshavarzian 7bbff74893 [coap] ensure InvokeResponseFallback() adheres to style guide (#12223)
This commit moves the implementation of `InvokeResponseFallback()` to
the `cpp` file. It also ensures that the implementation follows the
style guide requirement of single `return` from any method/function.
2025-12-17 19:59:55 -08:00
Abtin Keshavarzian b9bbf71d34 [num-utils] add SafeMultiply() for overflow-safe multiplication (#12220)
This commit introduces `SafeMultiply()` in `num_utils.hpp` as a
centralized and safe way to multiply two unsigned integers while
checking for overflow.

It updates `Coap::TxParameters::IsValid()` to use this new helper for
validating `TxParameters`, replacing a less robust local `Multiply`
implementation.

It also updates `Heap::CAlloc()` to use this function for safely
calculating the total allocation size.

Unit tests are updated to verify `SafeMultiply()` implementation.
2025-12-17 13:01:36 -08:00
Abtin Keshavarzian 79d973dce6 [border-agent] move border agent ephemeral key APIs to a separate header (#12215)
This change moves all public APIs related to the Border Agent's
ephemeral key feature out of `border_agent.h` and into a new,
dedicated header file `border_agent_ephemeral_key.h`.

The corresponding C API implementations are also moved from
`border_agent_api.cpp` into a new dedicated
`border_agent_ephemeral_key_api.cpp` file.

This improves the organization and modularity of the public API,
making the codebase easier to navigate and understand.
2025-12-17 10:31:03 -08:00
Abtin Keshavarzian 20585616d2 [cli] move border agent commands to a separate module (#12214)
This change moves the CLI implementation for the Border Agent from
the main `cli.cpp` into a new dedicated `Ba` class within
`cli_ba.cpp` and `cli_ba.hpp`.

The new `Ba` module is integrated into the main `Interpreter` class,
following the same pattern used by other CLI modules such as `Bbr`
and `Br`. This improves code organization and modularity, making the
CLI codebase easier to navigate and maintain.

The functionality of the `ba` commands remains unchanged.
2025-12-17 10:27:21 -08:00
Yakun Xu 7c9de986c7 [gn] add tcplp (#12205)
This commit adds the tcp support in gn build for projects relying on
OpenThread.
2025-12-17 08:07:31 -08:00
Yakun Xu f38c0a6774 [build] clean intermediates on GitHub actions (#12204)
This commit enhances the build process by introducing a mechanism to
automatically clean intermediate build artifacts. Specifically, it
configures the build script to remove object and archive files, a
process that is conditionally activated, primarily within GitHub
Actions workflows, to optimize build environments and manage disk
space more efficiently.
2025-12-17 08:05:00 -08:00
Jonathan Hui 62ad025d88 [fuzz] update build script to checkout submodules (#12216) 2025-12-17 07:56:54 -08:00
dependabot[bot] 069e09f91e github-actions: bump actions/upload-artifact from 5.0.0 to 6.0.0 (#12212)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5.0.0 to 6.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/330a01c490aca151604b8cf639adc76d48f6c5d4...b7c566a772e6b6bfb58ed0dc250532a479d7789f)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-15 15:05:15 -08:00
Abtin Keshavarzian 47f557a822 [dnssd] correct DNS upstream query cancellation documentation (#12210)
This commit clarifies the expected platform behavior for handling a
DNS upstream query cancellation.

The previous documentation was inconsistent. The documentation of
`otPlatDnsStartUpstreamQuery()` incorrectly stated that the platform
must not call `otPlatDnsUpstreamQueryDone()` on a cancelled
transaction, while the opposite was mentioned in
`otPlatDnsCancelUpstreamQuery()`.

This is now corrected to state that the platform MUST always invoke
the `otPlatDnsUpstreamQueryDone()` callback for every
`otPlatDnsStartUpstreamQuery()`, even if the query is cancelled using
`otPlatDnsCancelUpstreamQuery()`.
2025-12-15 14:53:53 -08:00
xusiyu 47f041790d [message] add platform deinit hook and MessagePool dtor (#12202)
Add a MessagePool destructor that calls the new
`otPlatMessagePoolDeinit` hook so platform-managed buffer pools get
torn down.
2025-12-12 09:26:43 -08:00
Yang Song cfe47541ea [posix] improve infra interface state detection (#12194)
This commit enhances the robustness of interface management with two
improvements:

1. The `SendIcmp6Nd` function now explicitly handles `EADDRNOTAVAIL`
and `ENODEV` errors from the `sendmsg()` system call. These errors
often indicate that the interface is down or has lost its
addresses. Upon that, we trigger an immediate re-evaluation of the
interface's state by calling `otPlatInfraIfStateChanged()`.

2. The `GetFlags` function has been updated to also verify mInfraIndex
and mInfraName not changed.
2025-12-10 11:32:58 -08:00
Abtin Keshavarzian 075f4f7d0e [border-agent] add Thread Admin One-Time Passcodes (TAP) APIs (#12188)
This commit introduces new APIs to handle Thread Administration
One-Time Passcodes (TAP).

The new `otBorderAgentEphemeralKeyGenerateTap()` API generates a
cryptographically secure 9-character TAP string. This consists of
eight random numeric digits and a final check digit calculated using
the Verhoeff algorithm for error detection.

The corresponding `otBorderAgentEphemeralKeyValidateTap()` API
validates a given TAP string by checking its length, ensuring it
contains only digits, and verifying the Verhoeff checksum.

A new test is added to ensure the correctness of both the generation
and validation logic, covering success and failure scenarios.
2025-12-09 12:20:04 -08:00
Abtin Keshavarzian 0c592029ba [history-tracker] add client/server for remote query (#11757)
This commit introduces a client/server mechanism to the History
Tracker module. This allows a device to query history information
from another device over the Thread network using TMF messages.

The new functionality is composed of three main parts:

- Server (`HistoryTracker::Server`): This component is responsible for
  handling incoming TMF query requests (`h/qy`). It collects the
  requested local history entries (e.g., Network Info), formats them
  into TLVs, and sends them back to the requester in one or more TMF
  answer messages (`h/an`). It can fragment large responses into
  multiple messages.

- Client (`HistoryTracker::Client`): This provides a new public API
  (`otHistoryTrackerQueryNetInfo`) to send a query to a remote
  device. It handles sending the request and processing the received
  answer(s), passing the retrieved history entries to the user via a
  callback. A function to cancel an ongoing query
  (`otHistoryTrackerCancelQuery`) is also added.

- TLVs (`history_tracker_tlvs`): New TLVs are defined for the
  query/answer protocol, including `RequestTlv` to specify the query
  parameters, `AnswerTlv` to manage multi-message responses,
  `NetworkInfoTlv` to carry the data, and `QueryIdTlv` to correlate
  requests and responses.

A new CLI command, `history query netinfo`, is added to use the new
client API. The existing `history netinfo` output logic is refactored
into helper methods to be shared by both the local and remote history
commands.

The new feature can be enabled/disabled using two new configuration
flags:
- `OPENTHREAD_CONFIG_HISTORY_TRACKER_SERVER_ENABLE`
- `OPENTHREAD_CONFIG_HISTORY_TRACKER_CLIENT_ENABLE`
2025-12-09 10:34:06 -08:00
Yakun Xu a3b8361a19 [simulation] set virtual UART at runtime (#12199)
This commit changes the virtual UART to be configured at runtime, which
eliminates a build variants, which causes code coverage process problem.
2025-12-09 08:48:37 -08:00
dependabot[bot] b800b1ad8e github-actions: bump actions/github-script from 7.0.1 to 8.0.0 (#12197)
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.0.1 to 8.0.0.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/60a0d83039c74a4aee543508d2ffcb1c3799cdea...ed597411d8f924073f98dfc5c65a23a2325f34cd)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-08 15:43:34 -08:00
Li Cao 10c882d27c [posix] remove sanitizer code in entropy (#12196)
The sanitizer code won't be used on posix platform.
2025-12-04 19:16:16 -08:00
Li Cao d7fe525415 [github-actions] disable Discovery Proxy in the otbr Backbone CI (#12195)
This commit disables Discovery Proxy in otbr Backbone CI.

Because in this item, `BORDER_ROUTING` is explicitly disabled and it
is required by OT discovery proxy.

This commit removes `"-DOTBR_DNS_UPSTREAM_QUERY=ON"` in build script
because this option will automatically handled in the cmake options
file and it also depends on BORDER_ROUTING. Force it to be ON will
cause a conflict when BORDER_ROUTING is OFF.
2025-12-04 08:24:35 -08:00
Abtin Keshavarzian 32ef52f06a [mdns] handle allocation failure in RxMessage::Init() (#12193)
This commit updates `RxMessage::Init()` to handle failures when
reserving capacity for the questions array. Previously, an allocation
failure would trigger an assertion.

By switching to `SuccessOrExit`, the method can now gracefully handle
the allocation failure by returning an error and dropping the
message. This aligns with the general error handling strategy for
received messages and makes the implementation more robust against
out-of-memory conditions.
2025-12-03 12:40:41 -08:00
Abtin Keshavarzian 3335928a5d [utils] detect and handle overflow in Heap::CAlloc() (#12192)
This commit fixes an issue with `Utils::Heap::CAlloc()` method. This
method performs a multiplication of `aCount` and `aSize` input and
then casts the result to `uint16_t`. This commit adds a check to
ensure that this conversion does not result in an integer overflow,
which would cause the size to warp to an unexpected smaller value.
2025-12-03 12:39:40 -08:00
Abtin Keshavarzian 97598f88e8 [border-agent] add commissioner eviction API (#12174)
This change adds `EvictActiveCommissioner()` to the Border Agent,
which sends a `LeaderKeepAlive` TMF message with a `StateTlv` of
`kReject` to the Leader, causing the current active commissioner
to be evicted.

The feature is exposed through:
- A new public C API `otBorderAgentEvictActiveCommissioner()`.
- A new CLI command `ba evictcommissioner`.

The entire feature is guarded by a new configuration flag,
`OPENTHREAD_CONFIG_BORDER_AGENT_COMMISSIONER_EVICTION_API_ENABLE`,
which is disabled by default.

This provides an administrator-level tool to remove a stale or
misbehaving commissioner, which is particularly useful when the
commissioner is connected through a different border agent and cannot be
managed locally.

A new test is also added to verify the eviction behavior.
2025-12-02 21:26:10 -08:00
Abtin Keshavarzian 7a76650d8b [mdns] add validation for names in browser and resolver APIs (#12184)
This commit introduces validation for names provided to mDNS browser,
resolver, and querier start and stop functions.

New `ValidateNamesIn()` overloads are added to check the validity of
service types, instance names, and host names passed to APIs like
`otMdnsStartBrowser()`, `otMdnsStartSrvResolver()`, etc.
2025-12-02 16:30:00 -08:00
Abtin Keshavarzian 8274fb4ec1 [meshcop] introduce new public APIs for SteeringData (#12148)
This commit introduces a set of public APIs to allow manipulation
of `otSteeringData`. The new APIs are provided when the configuration
`OPENTHREAD_CONFIG_MESHCOP_STEERING_DATA_API_ENABLE` is enabled.

The internal `SteeringData` is also improved to enhance robustness.
Methods such as `Init()`, `UpdateBloomFilter()` now return an `Error`
to signal failures on invalid arguments (e.g., invalid length)
instead of asserting.
2025-12-02 12:43:14 -08:00
rwrozelle bc70f705dc [coap] block2 fix PrepareNextBlockRequest to not return error (#12098) 2025-12-01 15:07:27 -08:00
Tongze Wang 923bf40134 [posix] allow set POSIX TUN device at runtime (#12175)
This commit allows users to pass the POSIX TUN device path
through a command line flag when starting the daemon / cli
when `OT_PLATFORM_NETIF` is enabled.
2025-12-01 12:23:22 -08:00
dependabot[bot] 774dc2b1e9 github-actions: bump github/codeql-action from 3.30.6 to 4.31.4 (#12181)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.30.6 to 4.31.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/64d10c13136e1c5bce3e5fbde8d4906eeaafc885...e12f0178983d466f2f6028f5cc7a6d786fd97f4b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.4
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-01 11:35:53 -08:00
Abtin Keshavarzian c0f4cccc65 [tmf] introduce DeclareTmfResponseHandlerIn helper macros (#12187)
This commit introduces two new macros, `DeclareTmfResponseHandlerIn`
and `DeclareTmfResponseHandlerFullParamIn`, to simplify the
definition of TMF/CoAP response handlers.

These macros generate the boilerplate code for the `static` callback
method within a class and delegate the call to a non-static member
method with the same name. This removes the repetitive pattern of
manually defining the `static` wrapper in each class.

The existing response handlers across various core components are
updated to use the new helper macros.
2025-12-01 10:21:01 -08:00
Abtin Keshavarzian 578467b78c [uri-path] remove UriEnumCheck checking order of Uri enum values. (#12179)
This commit removes the build-time check for the order of the `Uri`
enum values. This check is now redundant as the `static_assert` calls
added in #12017 use `AreConstStringsEqual()` to validate the
correctness of the `kEntries` array, ensuring that each URI path is
correctly associated with its corresponding enum value.
2025-12-01 10:17:53 -08:00
Yang Song 9a10e22e91 [border-agent] meshcop to advertise multi-AIL state in state bitmap (#12157)
This change introduces the Multi-AIL (Adjacent Infrastructure Link) detection state into the Border Agent's state bitmap, which is advertised in the MeshCoP service TXT data.

The new state is encoded in the `sb` (state bitmap) key and has the following values:

0: Multi-AIL detection is disabled.
1: Multi-AIL detection is enabled, but not detected.
2: Multi-AIL detection is enabled, and is detected.
2025-11-26 09:38:17 -08:00
Esko Dijk 4f38928041 [ble][tcat] improve error handling for BLE packets and TCAT TLVs (#12029)
Updates in error handling to ensure that recoverable BLE errors are
logged, failures don't lead to partial TLVs being generated or
processed, and internal allocation failures lead to a GeneralError
status response back to the TCAT Commissioner. In case of likely
unrecoverable TLV damage, or cases where the GeneralError status
response even couldn't be generated, the secure TLS connection is
closed (Disconnect).

BLE ATT MTU handling is updated to use default MTU 23 if fetching the
MTU fails; and more clear check on min MTU. If the platform reports a
very high MTU (above max) this is not seen as an error, but BleSecure
will simply uses the highest usable MTU that it has configured,
whether the platform's report is correct or not.

Close #11536
2025-11-22 08:41:40 -05:00
Abtin Keshavarzian b83f7b5813 [uptime] introduce UptimeMsec and UptimeSec types (#12177)
This change improves type safety and code clarity when handling uptime
values. It introduces two new named types in the `ot` namespace:
- `UptimeMsec`:  representing uptime in milliseconds (`uint64_t`)
- `UptimeSec`: representing uptime in seconds (`uint32_t`).

To complement this, the `Uptime` class is renamed to `UptimeTracker` to
clarify its role as the entity that tracks uptime.

The methods within `UptimeTracker` and member variables and parameters
throughout the codebase are updated to use these new, more descriptive
types instead of generic integer types.

Additionally, `UptimeToString()` is now a free function within the `ot`
namespace.
2025-11-22 08:38:59 -05:00
Li Cao de3788c66f [api] fix api param of otBorderAgentSetId (#12172)
The parameter is a `in` instead of `out`.
2025-11-20 22:17:10 -08:00
Abtin Keshavarzian 041c25acbb [meshcop] adding SteeringData::MergeBloomFilterWith() (#12145)
This commit adds a new method, `MergeBloomFilterWith()`, to
`SteeringData` to allow combining two Bloom filters.

The method performs a bitwise OR operation between the current
Steering Data Bloom filter and a given one. It handles cases where
the given filter to merge has a shorter length than the target Bloom
filter. It requires the target filter's length to be a multiple of
the source's length.

A new unit test, `TestSteeringDataBloomFilterMerge()`, is included to
validate the merge logic with various filter length combinations.
2025-11-20 22:10:56 -08:00
Abtin Keshavarzian 9483553c44 [border-agent] improve logging and add session index (#12171)
This commit introduces a session index tracked by each session
(`CoapDtlsSession`) to uniquely identify sessions in log messages.
The `Manager` now maintains a counter to assign a new index to each
session upon allocation.

Logs are added to track the lifecycle of a session (allocation,
connection, disconnection, deletion, and timeout), with each event
including the session's unique index.

A new templated helper, `Log<kUri>()`, is added to standardize logging
for TMF messages, including response handling. The session index is
included in such logs to provide clearer insight into the processing
of specific TMF commands by Border Agent sessions.
2025-11-20 21:52:55 -08:00
Zhangwx e5b159a20f [csl] update CSL sync time whenever CSL parameters are re-initialized (#12161)
When the CSL feature is first enabled on a child device, the
OpenThread stack starts CSL sampling before sending the Child Update
Request packet. The last CSL sync sample time, initialized as `0`, is
updated only when the Child Update Request is sent. However, since CSL
sampling begins earlier, the first CSL receive operation calculates
the elapsed time in `GetCslWindowEdges` using `0` as the last sync
time.

Similarly, when CSL parameters are re-initialized, the stack should
update `mCslLastSync`. Continuing to use an outdated sync time results
in inaccurate calculations and is not reasonable behavior.

This commit fixed this issue.
2025-11-20 21:50:52 -08:00
rwrozelle ae5075682b [coap] block2 fix PrepareNextBlockRequest to provide token from next request (#12097) 2025-11-20 21:46:54 -08:00
Abtin Keshavarzian ce1a751d62 [dataset] move DelayTimerMinimal to PendingDatasetManager (#12162)
This change relocates the `mDelayTimerMinimal` member and its
associated accessor methods, `GetDelayTimerMinimal()` and
`SetDelayTimerMinimal()`, from the `MeshCoP::Leader` class to the
`PendingDatasetManager` class.

This functionality is specific to the handling of the pending
operational dataset. Placing it within `PendingDatasetManager`
improves code structure and cohesion by grouping related parameters
together.
2025-11-19 14:40:12 -08:00
Li Cao 6acb3ff430 [mbedtls] bump mbedtls version to 3.6.5 (#12152) 2025-11-19 13:45:51 -08:00
Yang Song 06bc952f09 [nat64] improve naming for platform-discovered NAT64 prefix (#12167)
This change renames the `mInfraIfPrefix` in Nat64PrefixManager to
`mPlatformPrefix`.

The original name was ambiguous because both the RA-discovered prefix
`mRaTrackerPrefix` and this prefix are sourced from the infrastructure
link. The new name `mPlatformPrefix` clarifies that this prefix is
discovered through a platform-specific mechanism (e.g., DNS-based
discovery per RFC 7050), distinguishing it from prefixes discovered
directly via RA.
2025-11-19 10:00:44 -08:00
Yakun Xu 0fb573177c [style] upgrade yapf to the latest version (#12169)
This commit upgrades yapf which fixes the issue of deprecated lib2to3.
2025-11-19 08:14:33 -08:00
Yang Song 5ce409830b [cli] add new cli br nat64prefixtable command (#12090)
This commit introduces a new API
`otBorderRoutingGetNextNat64PrefixEntry`, which allows iterating
through the table of RA-discovered NAT64 prefixes on the
infrastructure link.

The `br nat64prefixtable command` is added to the CLI to display the
contents of the RA-discovered NAT64 prefix table.
2025-11-19 08:12:25 -08:00
Thanh Nguyen 5dbc1b8dbc [ncp] enable DHCPv6 PD support on the NCP (#12108) 2025-11-19 08:10:43 -08:00
Abtin Keshavarzian 973680045a [border-agent] centralize active commissioner session management (#12160)
This change moves the state and logic for managing the active
commissioner from `CoapDtlsSession` to the `BorderAgent::Manager`
class.

Previously, each `CoapDtlsSession` instance tracked whether it was the
active commissioner using its own `mIsActiveCommissioner` flag, and
managed its own `mCommissionerAloc` and `mUdpReceiver`.

This commit introduces a single `mCommissionerSession` pointer in the
`Manager` to act as the sole source of truth for the currently active
commissioner. The responsibility for managing the commissioner ALOC and
the associated UDP receiver is also moved to the `Manager`.

This approach reinforces the Thread mesh rule of a single active
commissioner at a time and simplifies the code by centralizing ALOC and
UDP receiver management in one place.
2025-11-18 22:24:39 -08:00
Yakun Xu 3e0920c575 [simulation] add APIs for select() based event loop (#12135)
This commit adds select API so that simulation and be integrated with
other mainloops.

This commit also adds a flag to disable UART on simulation platform.
2025-11-18 22:19:04 -08:00
Esko Dijk 76f3418796 [tcat] fix in authorization for CommCert4 used in cert test TCAT-13.7, step 19 Decommission (#12151) 2025-11-18 11:00:15 -08:00
Esko Dijk 3dd2d471ea [cli][coap] fix CoAP-observe messaging and add test (#12103)
This commit contains some improvements and fixes to the CoAP-observe
(RFC 7641) messaging model implementation.

It also adds an 'expect' test for using the CoAP-observe related CLI
commands.

Specific items:
- ensure that a NON observe request is not acknowledged with an Ack.
- enable a NON observe request to never time out, unless cancelled
  explicitly, or unless 0 observe responses are received within the
  NON request's timeout period. This fixes an issue that responses
  were not recognized anymore by the client after some time.
- allow an observe request to be silently cancelled by the client,
  which is the suggested way per RFC 7641, in case a new observe
  request is started and the CLI user did not explicitly cancel the
  previous observe.  This leaves the choice to the CLI user whether to
  explicitly cancel or just forget the request.
- ensure that the client accepts CON notifications which are
  interspersed with NON notifications per RFC 7641.  Previously, this
  caused the client to send RST instead of ACK.
- avoids the error 28 ResponseTimeout popping up in various cases by
  keeping the observe request active.
- implements the mandatory interspersing of CON notifications when a
  NON observe relation is ongoing, per RFC 7641. This is done by
  sending a CON notification after every 5 NON notifications, same as
  done by libcoap.  When such CON notification times out
  (i.e. undelivered/unack'ed) then the observe subscription is
  automatically cleared after all its retries have been made. During
  this effort of trying to deliver the notification, the NON
  notifications (in case these follow) are still being sent in
  fire-and-forget mode as usual.
- if already one subscription is ongoing, the server will ignore
  further subscription requests (Observe Option) per RFC 7641 Section
  4.1 and treat the request normally.
- log message at server side when a subscriber is cancelled.

Fixes #11971
2025-11-18 10:35:54 -08:00
Abtin Keshavarzian 249ce78cf9 [mdns] add config to persist state on post-probe conflict (#12156)
This commit introduces a new mDNS OpenThread configuration,
`OPENTHREAD_CONFIG_MULTICAST_DNS_PERSIST_STATE_ON_POST_PROBE_CONFLICT`,
to control behavior when a late conflict is detected for an already
registered mDNS entry.

When this option is enabled (the default), the mDNS entry remains in
the `kRegistered` state, and the device continues to advertise and
answer for the name. This prioritizes advertisement stability, which
is desirable in use cases like the SRP Advertising Proxy where
post-probe conflicts can be transient. If the option is disabled,
the entry's state transitions to `kConflict`, and the device stops
advertising the name.

Regardless of this configuration, the conflict callback is still
invoked, informing other modules (such as the module that requested
the registration) so they can decide on a higher-level resolution
action.
2025-11-18 08:13:44 -08:00
Abtin Keshavarzian b349c44e6f [border-agent] check StateTlv in forwarded keep-alive response (#12153)
This commit updates `BorderAgent` to correctly handle the `StateTlv`
in a forwarded response from the leader specifically for the response
to a forwarded `kUriLeaderKeepAlive` message.

The leader can reject a previously accepted active commissioner in the
Keep-Alive response by including the `StateTlv` with a `kReject`
status.

This commit ensures that if the `StateTlv` indicates the commissioner
is rejected, the session is properly cleaned up. This cleanup
involves removing the previously added commissioner ALOC and marking
the session as no longer the active commissioner.
2025-11-17 14:55:14 -08:00
Abtin Keshavarzian b81c0e5ec1 [meshcop] use milliseconds for leader petition timeout constant (#12154)
This commit replaces `kTimeoutLeaderPetition` (in seconds) with
`kLeaderPetitionTimeout` (in milliseconds). This change avoids
repeated calls to `Time::SecToMsec()` when starting the commissioner
session timer.
2025-11-17 12:53:10 -08:00
Abtin Keshavarzian b03053b485 [border-agent] move EphemeralKeyManager to its own files (#12138)
Moves `EphemeralKeyManager` class and its implementation from
`border_agent.hpp` and `border_agent.cpp` to their own separate files
`border_agent_ephemeral_key.hpp/cpp`.

This is a structural change to improve code organization and does not
introduce any functional changes.
2025-11-17 12:52:25 -08:00
Abtin Keshavarzian bb21e0af00 [mdns] allow initial queries to continue indefinitely with backoff (#12092)
This commit updates the mDNS initial query logic to allow queries to
continue indefinitely (for shared resource records), instead of
stopping after a fixed number of initial attempts. This is applicable
while there are active browsers/resolvers associated with the query.

The previous implementation already used an exponential backoff but
was limited by `kNumberOfInitialQueries = 3`

This change removes that limit. The exponential backoff strategy is
retained, doubling the query retry interval from 1 second up to a
max of 1 hour, after which queries continue at the max interval. A
random jitter of `1/32` of the interval is also applied to each
retry interval.
2025-11-17 12:50:32 -08:00
Esko Dijk a5bc905275 [thread-cert] enable test_srp_register_500_services.py (#12158)
Enables the test by setting +x executable on the file.
2025-11-17 10:49:06 -08:00
tanyanquan 714aeeb700 [mac] force rx_on_when_idle to true during active scan (#12147)
This commit forces mLinks.SetRxOnWhenIdle to true when performing an
active scan.

Previously, when we have an SED which is connected to a thread network
(i.e. state == child), it is unable to perform scan command because rx
is turned off.
2025-11-14 16:17:19 -08:00
Abtin Keshavarzian c0c7b11fd4 [routing-manager] fix typo in method and constant names (#12149)
Fixes the typo `Inital -> Initial`.
2025-11-14 16:02:16 -08:00
Yakun Xu df3da9b859 [gn] adding build flags according to args (#12141)
This commit updates the gn BUILD file so that it's guaranteed to build
according to gn args instead of ignoring them based on default value
assumptions. This ensures setting a gn argument would take effect when
building OpenThread.

This commit also sorts the source file lists.
2025-11-13 11:09:48 +01:00
Abtin Keshavarzian cdc61f6c60 [border-agent] handle Proxy/Relay TX TMF when active commissioner (#12142)
This commit adds checks in `BorderAgent::HandleTmfProxyTx()` and
`BorderAgent::HandleTmfRelayTx()` to verify that the session belongs
to the current active commissioner rather than a candidate.

Specifically, `HandleTmfProxyTx()` uses the commissioner ALOC as
the sender address, which is available only when commissioner
petition is accepted.
2025-11-13 11:03:47 +01:00
Abtin Keshavarzian eb51d4be51 [multi-ail-detector] allow detector to run independently of Border Routing (#12078)
This commit updates the Multi-AIL Detection feature to operate
independently of the Border Routing Manager. This fundamental change
allows the detector to be enabled/disabled on its own, rather than
being tied to the Border Routing Manager's state.

This change also moves the Multi-AIL detection API into a separate
`openthread/multi_ail_detection.h` header and introduces new APIs to
control the detector independently. Corresponding CLI commands are
also added.

The `test-505-multi-ail-detection.py` is also updated to validate
this new independent behavior. In particular that a device that is
not enabled to act as a BR can independently run multi-AIL detection
and determine whether, if it becomes a BR, it will cause multi-AIL
issues.
2025-11-12 22:09:42 +01:00
Abtin Keshavarzian 61e43cffb9 [fuzz] fix warning when building fuzzer source files (#12130)
Add `SuccessOrQuit()` to check the return `Error` value of
`RoutingManager::SetEnabled()` in `fuzz_*.cpp` source files. This
addresses warnings about ignoring the return value.
2025-11-12 20:37:17 +01:00
Yakun Xu 01aba923ad [test] stabilize rcp restoration test (#12140) 2025-11-12 15:58:19 +01:00
Abtin Keshavarzian beeef5f8a6 [energy-scan-server] reject scan request with zero channel mask (#12137)
This commit validates that the Channel Mask TLVs in a TMF Energy
Scan request are non-zero.

Additionally, this commit clamps the Count TLV value to the valid
range (1, 2, and 3) as required by the Thread specification.
The `test_otci` is updated to use count 3 (previously 4).

An Energy Scan request with a zero `Channel Mask` is invalid and
can cause the device to start a scan that takes a long time or
never completes. This change rejects such requests, preventing the
device from getting stuck. This was discovered by
fuzzer test.
2025-11-12 09:21:29 +01:00
Yakun Xu 372fe4fbf1 [iwyu] fix IWYU public header checker (#12132)
This commit fixes the issue failing to catch headers would cause
iwyu to exit with errors.
2025-11-12 09:19:43 +01:00
Yakun Xu f2462b7401 [gn] add build option for TCP (#12134)
This commit adds an option to allow disable building TCP.
2025-11-12 08:53:16 +01:00
Li Cao 02295b035f [mbedtls] change mbedtls to git submodule (#12107)
This commit changes the mbedtls repo in openthread from source code to
git submodule.

This makes it easier for mbedtls version upgrade. This PR doesn't
upgrade the mbedtls version. v.3.6.0 is stil used to ensure nothing is
broken. The original OT specific build files (BUILD.gn, CMakeLists.txt
and config) are kept and unchanged. I've verified that the headers and
sources in the list of BUILD.gn are correct.
2025-11-12 08:10:56 +01:00
Esko Dijk 9842f4bd25 [tcat] surface hash calculation internal errors to TCAT Commissioner (#12136)
Small change to surface any internal errors in the hash calculations
to the TCAT Commissioner as general error. If not done, such errors
are silently ignored and hard to diagnose in products.
2025-11-10 23:54:19 +01:00
Suvesh Pratapa 2fd9b5a8d7 [style] IWYU for border_agent_tracker.h (#12131) 2025-11-10 23:41:11 +01:00
Abtin Keshavarzian bbf2588a56 [mdns] restart probing on Register() if in conflict state (#12128)
This commit enhances mDNS to allow reprobing for registrations
currently in a conflict state. Upon an explicit `Register()` call,
the mDNS module will now restart the probing process. This allows the
device to attempt to claim the name again if the conflict has been
resolved on the network.

Unit tests are updated to verify this behavior.
2025-11-10 23:39:48 +01:00
dependabot[bot] ce1887a597 github-actions: bump docker/metadata-action from 5.8.0 to 5.9.0 (#12133)
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5.8.0 to 5.9.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](https://github.com/docker/metadata-action/compare/c1e51972afc2121e065aed6d45c65596fe445f3f...318604b99e75e41977312d83839a89be02ca4893)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: 5.9.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-11-10 11:44:35 +01:00
Yakun Xu a50d1a74dc [gn] enable warnings (#12121)
This commit suppresses the undefined warnings in mbedtls. To detect
such warnings in OpenThread, this commit also enables warnings check
for gn BUILD and fixes issues found.
2025-11-08 11:34:48 -08:00
Abtin Keshavarzian cfe2999c94 [dns] update Name::ValidateName() for max-length names (#12127)
`ValidateName()` did not correctly handle names that were exactly the
maximum allowed length (`kMaxNameLength`). A name of this length is
only valid if it ends with a trailing dot. Otherwise, when encoded,
the added root label causes the encoded name to exceed the
`kMaxEncodedLength` of 255 bytes.

This commit updates `ValidateName()` to enforce that any name with
length equal to `kMaxNameLength` must end with a dot character.

It also updates the `TestDnsName` unit test to verify this corrected
behavior, ensuring `ValidateName()` and `AppendName()` handle such
names consistently.
2025-11-08 11:25:23 -08:00
Abtin Keshavarzian 6cc2a57742 [fuzz] rename fuzzer source files and update cmake macro (#12125)
Rename all fuzzer source files in `tests/fuzz` from `{name}.cpp` to
`fuzz_{name}.cpp`.

Update the `ot_nexus_test` macro in `tests/fuzz/CMakeLists.txt` to
reflect this change, using `fuzz_{name}.cpp` as the source file while
naming the test `{name}-fuzzer`.

This change improves consistency and makes it easier to distinguish
fuzzer source files from other similarly named files during searches.
2025-11-08 11:02:48 -08:00
Abtin Keshavarzian ced33033e9 [dns-client] add config to bind socket to thread netif (#12085)
This commit introduces a new configuration option
`OPENTHREAD_CONFIG_DNS_CLIENT_BIND_UDP_TO_THREAD_NETIF` to control
which network interface the DNS client's UDP socket binds to.

When this config is set to 1, the socket is bound to the Thread
network interface (`Ip6::kNetifThreadInternal`).

When the config is set to 0, the socket is bound to the unspecified
network interface (`Ip6::kNetifUnspecified`), allowing DNS messages
to be sent and received over any available network interface. By
default this new config is disabled.

A new CMake option `OT_DNS_CLIENT_BIND_UDP_THREAD_NETIF` is also added
to allow easy configuration of this feature.

The test configurations are updated to ensure both behaviors are
covered.
2025-11-08 11:02:07 -08:00
Abtin Keshavarzian 75c5d220de [border-agent] inline ForwardContext::ToHeader() (#12118)
Remove the `CoapDtlsSession::ForwardContext::ToHeader()` helper method
and move its logic directly into the `HandleCoapResponse()` method.
This simplifies the implementation by removing an unnecessary function
call for a single-use case.

Additionally, convert `ForwardContext` from a `class` to a `struct`.
This change makes the constructor public, removing the need for a
`friend` declaration for `Heap::Allocatable`, and better reflects its
role as a simple data structure.
2025-11-07 14:22:27 -08:00
Abtin Keshavarzian 74ba475914 [border-agent] move TXT data management to TxtData class (#12120)
Moves the management of MeshCoP service TXT data from the
`BorderAgent::Manager` class into the `TxtData` class.

This change improves separation of concerns by isolating all TXT
data-related logic, including vendor TXT data, change callbacks, and
notifier event handling, within the `TxtData` class. The
`BorderAgent::Manager` is simplified and its responsibilities are
more focused.

A new public method, `Refresh()`, is introduced on `TxtData` to
provide a clear API for other modules to signal that the MeshCoP
service TXT data needs to be re-evaluated and updated.
2025-11-07 14:21:10 -08:00
Abtin Keshavarzian 324f27dd44 [border-agent] rename callback to HandleLeaderResponseToFwdTmf (#12119)
The `HandleCoapResponse` callback in `CoapDtlsSession` is renamed to
`HandleLeaderResponseToFwdTmf`.

The new name more clearly indicates that this callback is used to
handle the response from the leader for a forwarded TMF message.
This improves code readability and makes the role of the callback
more explicit.
2025-11-07 10:33:28 -08:00
Zhanglong Xia 959dcc258a [child] convert Neighbor to const void* for the address comparison (#12116)
When using some special configurations, the ot-cli-ftd will crash. The
crash path is `MessageFramer::PrepareMacHeaders()` ->
`Get<NeighborTable>().FindNeighbor()` ->
`Get<ChildTable>().Contains()`. The crash happens in the
`ChildTable::Contains()`. Here is the system crash message: `kernel:
traps: ot-cli-ftd[122376] trap invalid opcode ip:5640b7713b8e
sp:7ffd6425c5f0 error:0 in ot-cli-ftd[313b8e,5640b7400000+426000]`.

The root cause of the crash is that the CandidateParent is a 4 bytes
aligned class and the Child is a 8 bytes aligned class. When
converting the CandidateParent to Neighbor and then converting the
Neighbor to Child, the program will crash due to the alignment issues.

This commit replace the static_cast with the reinterpret_cast in
ChildTable::Contains() to convert a Neighbor to a Child.
2025-11-07 07:13:38 -08:00
Abtin Keshavarzian 4a0543956e [border-agent] simplify SendErrorMessage in CoapDtlsSession (#12115)
Consolidates the two overloaded `SendErrorMessage()` methods in the
`CoapDtlsSession` class into a single implementation.

The new `SendErrorMessage()` method now accepts the token information
directly, rather than a `Coap::Message` or a `ForwardContext` object.
This simplifies the call sites and removes the now-unused
`CoapCodeFromError()` helper function (the conversion is now done
in the consolidated `SendErrorMessage()`).
2025-11-07 07:11:45 -08:00
Zhanglong Xia 32f6629f84 [test] add adb interface support to expect script (#12075)
This commit adds the adb interface support to expect scripts, so that
we can easily run all expect scripts on Android devices.

Example usages: `spawn_node ${node_id} "adb" "${adb_serial_num}"`.
2025-11-05 13:38:10 -08:00
Yang Song 3c6097bf8f [nat64] enhance nat64 prefix unit test with prefix table check (#12091)
This commit enhances the `TestNat64PrefixSelection` unit test by
adding more detailed verification of the RA-discovered NAT64 prefix
table managed by `RxRaTracker`.
2025-11-05 08:24:10 -08:00
Abtin Keshavarzian 241f6cfef0 [border-agent] simplify forwarding logic to leader (#12114)
This commit simplifies the CoAP message forwarding logic within the
`CoapDtlsSession` by removing the `mPetition` and `mSeparate` boolean
flags from the `ForwardContext`.

The `Uri` of the request is now stored directly in `ForwardContext`
and used to determine the logic flow, making the code more explicit
and easier to understand.

The `ForwardToLeader()` is only used with `kUriLeaderPetition` and
`kUriLeaderKeepAlive`, both of which requires a separate
non-confirmable response in addition to an immediate CoAP Ack
(i.e., as if `mSeperate` is `true`).

This change removes the need for intermediate flags and simplifies the
implementation of `ForwardToLeader()`, `SendErrorMessage()`, and the
`ForwardContext` constructor and `ToHeader()` method. The CoAP
message initialization is now more direct, always using
`kTypeNonConfirmable` for forwarded responses and error messages.
2025-11-05 08:08:53 -08:00
Abtin Keshavarzian 8f11e4a886 [border-agent] use OwnedPtr for message management (#12104)
This commit updates the `BorderAgent` implementation to consistently
use `OwnedPtr` for managing the lifecycle of `Coap::Message` and
`Message` objects.

This change improves memory safety and simplify the code. Message
objects are now automatically deallocated when the `OwnedPtr` goes
out of scope, which eliminates all manual calls to `FreeMessage()`
and `FreeMessageOnError()`, preventing potential memory leaks and
making the code more robust.
2025-11-04 09:17:08 -08:00
Abtin Keshavarzian 916533d301 [rx-ra-tracker] use a new Events struct for callbacks (#12084)
This commit enhances `RxRaTracker` by introducing a new `Events`
struct for handling callbacks. This change replaces the previous
`HandleRxRaTrackerDecisionFactorChanged()` method with a more
versatile `HandleRxRaTrackerEvents()` that accepts the `Events`
struct as an argument.

The new `Events` struct includes boolean flags for:
- `mInitialDiscoveryFinished`
- `mDecisionFactorChanged`
- `mLocalRaHeaderChanged`

This allows `RxRaTracker` to communicate more specific events to
`RoutingManager` and `MultiAilDetector`, enabling them to take
the proper action based on the events. The `SignalTask` has been
renamed to `EventTask` to better reflect its new role in handling
these events.
2025-11-03 21:15:51 -08:00
Abtin Keshavarzian 2e25607eec [core] fix typo in rloc16 variable name (#12102)
This commit corrects a typo in the variable name `rloc16` which was
incorrectly written as `rlco16`.
2025-11-03 21:10:03 -08:00
tanyanquan 11d389fcea [csl] restart CSL timer when update last sync timestamp (#11601)
This commit involves a small enhancement for CSL to optimize for power
consumption after receiving a frame.

Original implementation: 
- schedule next CSL window during current CSL timer handle
- even if a frame is received, the scheduled CSL timer is not reset
- SSED wakes up much earlier than required if elapsed time is large

Suggested implementation:
- recalculate CSL timer during `UpdateCslLastSyncTimestamp` if it is
  currently running
- SSED can use updated mCslLastSync so that it does not wake up much
  earlier after receiving a frame
2025-11-03 21:09:47 -08:00
dependabot[bot] 111db8a8a6 github-actions: bump ossf/scorecard-action from 2.4.2 to 2.4.3 (#12095)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.2 to 2.4.3.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/05b42c624433fc40578a4040d5cf5e36ddca8cde...4eaacf0543bb3f2c246792bd56e8cdeffafb205a)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.3
  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-11-03 08:05:43 -08:00
Abtin Keshavarzian 687cc36648 [mdns] use different default TTLs for addr and service records (#12086)
This commit updates the default TTL values used for mDNS records to
better align with the recommendations.

Previously, a single `kDefaultTtl` of 120 seconds was used for all
records when the registered entry did not explicitly specify the TTL
to use. This commit introduces separate default TTLs:

- `kDefaultAddrTtl` for address records (`AAAA`, `A`) is kept at
  120 seconds.
- `kDefaultServiceTtl` for all service records (`PTR`, `SRV`, `TXT`)
  is set to 4500 seconds.
- `kDefaultKeyTtl` is also updated to 4500 seconds for `KEY` records.

The code is updated to use the appropriate default TTL based on the
record type.
2025-10-31 10:19:05 -07:00
Li Cao bbc73280ba [ncp] implement ncp platform dnssd discovery methods (#12068)
This commit implements `otPlatDnssdStartBrowser` and
`otPlatDnssdStopBrowser` to support service discovery on NCP.

The platform APIs are intended to be used by
`ServiceDiscovery::Server::DiscoveryProxy` for discovery
functionality. This commit only supports browser for now and will
suppport Srv/Txt/Address resolver in other commits to avoid this
commit from being too large.

This commit contains these changes:
* Add new spinel property for starting / stopping service browser
* Implement encoding/decoding of the new property
* Add unit test for encoding/decoding
* Implement ncp version of dnssd platform API
  `otPlatDnssdStartBrowser` and `otPlatDnssdStopBrowser`
* Add property handler to get browser result on NCP side
* Add unit test to verify that the browser callback is correctly
  invoked after getting browser result.
2025-10-31 07:37:18 -07:00
Yang Song 4e2a570d0e [nat64] add support for RFC8781 NAT64 prefix (#12012)
This commit introduces support for discovering NAT64 prefixes as
specified in RFC 8781.

The key changes include:
- New `Nat64PrefixInfoOption`: A new `Nat64PrefixInfoOption` class is
  added to represent the PREF64 option in ND messages. This handles
  parsing the prefix and its lifetime from incoming RAs.
- `RxRaTracker` Enhancement: The `RxRaTracker` is updated to process
  `Nat64PrefixInfoOption` from RAs. It now maintains a list of
  discovered NAT64 prefixes from routers on the infrastructure link
  and determines a "favored" prefix among them.
- `RoutingManager` Update: The `Nat64PrefixManager` is enhanced to
  utilize the RA-discovered prefix.
- `test_routing_manager` Update: The `TestNat64PrefixSelection` is
  updated to include cases with RA-discovered prefixes.
2025-10-31 07:35:36 -07:00
Abtin Keshavarzian 537d790c0d [rx-ra-tracker] add state to track initial router discovery process (#12080)
Adds a new state, `mInitialDiscoveryFinished`, to `RxRaTracker` to
track the completion of the initial router discovery (RS transmission)
process. A new method, `IsInitialRouterDiscoveryFinished()`, exposes
this state.

This new method replaces `IsRsTxInProgress()`, which previously
checked if any RS transmission was ongoing. The new model ensures
the initial discovery is tracked only once after `RxRaTracker`
starts, rather than every time RS messages are sent (e.g., due to
stale timer expiration).

Additionally, the `RoutingManager` now checks this state and ignores
incoming RS messages until the initial router discovery is complete.
This prevents the BR from replying to its own RS messages or sending
an RA prematurely with incomplete information before all routers
are discovered and decision factors are determined.
2025-10-31 07:14:34 -07:00
xusiyu 9190f961f6 [ip6] bypass filtering for multicast addresses larger than RealmLocal (#12074)
Multicast addresses with scope larger than `RealmLocal` are no longer
subject to the standard receive filter. They are passed directly to
the host callback, allowing delivery and forwarding by the host.

This fixes a scenario where a `Thread Border Router` receives a
larger-scope multicast from a `Thread Device`. Previously, if the
Border Router was listening on the same multicast address and port,
the receive filter could drop the packet, preventing it from being
forwarded to other interfaces.
2025-10-30 13:34:43 -07:00
Esko Dijk e4479fb6b1 [tcat] add TCAT_ENABLE.req TMF command (#12013)
This adds support for the TMF command to enable TCAT remotely.  A test
is added that uses the 'UDP send' mechanism to send the new TMF
command to a target node.

Some fixes/additions to the test framework are made to support the new
test, including a new argument for udp_send() to send a specific byte
array and udp_rx() to receive data by a UDP client on a node.
2025-10-29 08:29:09 -07:00
Abtin Keshavarzian 13e7c4e702 [multi-ail-detector] use direct callback from RxRaTracker (#12077)
This commit introduces a direct callback mechanism from `RxRaTracker`
to `MultiAilDetector` to signal changes in decision factors. This is
in preparation of future changes allowing `MultiAilDetector` to run
independently of `RoutingManager`.

Previously, `RxRaTracker` would signal `RoutingManager`, which in turn
would call `MultiAilDetector::Evaluate()`. This commit refactors this
interaction by adding a new `HandleRxRaTrackerDecisionFactorChanged()`
method to `MultiAilDetector`.
2025-10-28 14:54:59 -07:00
Abtin Keshavarzian 3e9aeae1b6 [rx-ra-tracker] use mIsRunning in stale timer callback (#12076)
`RxRaTracker` can run independently of `RoutingManager`. Its stale timer
callback should check its own running state (`mIsRunning`) instead of
`RoutingManager`'s state.

This commit corrects the logic in `HandleStaleTimer()` to use the local
`mIsRunning` flag.
2025-10-28 14:53:52 -07:00
Abtin Keshavarzian eede70c0ef [mle] use ChildUpdateResponseInfo to pass parameters (#12073)
This commit introduces the `ChildUpdateResponseInfo` struct to
encapsulate parameters for sending "Child Update Response" messages.

The new struct holds the list of TLVs to include, the received
challenge, and the destination address.

Related methods such as `SendChildUpdateResponse()` are updated to use
the new struct. This simplifies the method signatures by reducing the
number of arguments and improves code clarity by grouping related
data.
2025-10-28 14:17:01 -07:00
Abtin Keshavarzian ca3e4d50fc [mle] ensure sender and destination are link-local in HandleUdpReceive (#12072)
Verifies that the peer and socket addresses in `Mle::HandleUdpReceive`
are link-local. This ensures that MLE messages are only processed
from link-local addresses, which is a requirement of the Thread
specification.
2025-10-28 12:32:47 -07:00
Zhanglong Xia 4cced2e81e [mac] adds the wake-up identifier to the Connection IE (#11907)
The P2P peer can be woken up using the wake-up identifier. The wake-up identifier
is included in the Connection IE. This commit implements methods to the Connection IE
and Frame to process wake-up identifier.
2025-10-28 11:01:19 -07:00
Abtin Keshavarzian ce17d9e6a9 [doc] add API re-entrancy and error handling rules (#12057)
Adds two important notes to the main API documentation header to clarify
critical usage rules for all OpenThread APIs.

- The first note states that all API calls and callbacks must be
invoked from the same OS context (e.g., the same thread).
- The second note clarifies the behavior of output parameters when an
  API call returns an error.
2025-10-28 08:56:04 -07:00
Abtin Keshavarzian a495e4a395 [border-router] call RxRaTracker message handlers from InfraIf (#12055)
This change modifies the handling of incoming ICMPv6 ND messages on the
infrastructure interface. `InfraIf::HandledReceived()` now inspects the
message type and calls the appropriate handler directly.

- Router Advertisement (RA) and Neighbor Advertisement (NA) messages are
  now passed directly to `RxRaTracker::HandleRouterAdvertisement()` and
  `RxRaTracker::HandleNeighborAdvertisement()` respectively.

- The generic `RoutingManager::HandleReceived()` method is removed.
  `RoutingManager` now only handles Router Solicit (RS) messages via
  `RoutingManager::HandleRouterSolicit()`.

This simplifies code and gives `RxRaTracker` direct ownership of RA
and NA processing, which aligns better with its role of tracking
information from received RAs and allowing it to run independently of
the `RoutingManager`.
2025-10-28 08:47:45 -07:00
jamesluo11 f52cf29454 [readme] add Beken to who-supports-openthread list (#12035) 2025-10-27 17:03:27 -07:00
Abtin Keshavarzian 5a39715e0c [border-router] move MultiAilDetector to separate files (#12067)
This change moves the `MultiAilDetector` class from being a nested
class within `RoutingManager` to its own dedicated `.hpp` and `.cpp`
files.

An instance of `MultiAilDetector` is now owned by the top-level
`Instance` class, making it a sibling component to `RoutingManager`
and other core components.

This is purely a code organization change and introduces no functional
or logic changes. This prepares for future changes where
`MultiAilDetector` may operate independently of `RoutingManager`.
2025-10-27 16:55:46 -07:00
Abtin Keshavarzian 4fdd08111e [border-router] manage RxRaTracker state via multiple requesters (#12050)
This change introduces a mechanism to control the `RxRaTracker` from
multiple sources.

A new method `RxRaTracker::SetEnabled()` is added, which accepts a
`Requester` enum. The tracker now maintains separate enable flags for
each requester (e.g., `RoutingManager`).

The `RxRaTracker` will start only when at least one requester has
enabled it AND the infrastructure interface is initialized and running.
It stops when all requesters have disabled it or when the interface
goes down.

The `Start()` and `Stop()` methods are now private, managed by a new
`UpdateState()` method to centralize the state logic. `InfraIf` is
updated to notify `RxRaTracker` of state changes.
2025-10-27 16:54:47 -07:00
Li Cao ad3035b91d [tests] add dnssd api implementations in FakePlatform (#12070)
This commit adds fake implementations for OT dnssd platform APIs.

The background is that I'm trying to enable the OT Dnssd Server
functions (Discovery Proxy) in ot-br-posix by default. Once it's
enabled, `openthread-ftd` needs implemenation of dnssd platform
APIs. To make some unit tests (in ot-br-posix) build successfully,
these fake implementations are required.
2025-10-27 16:52:02 -07:00
dependabot[bot] 138eda225b github-actions: bump actions/upload-artifact from 4.6.2 to 5.0.0 (#12069)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.2 to 5.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/ea165f8d65b6e75b540449e92b4886f43607fa02...330a01c490aca151604b8cf639adc76d48f6c5d4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-27 11:22:42 -07:00
Abtin Keshavarzian ae54e4a133 [mle] centralize ChildUpdate reject response logic (#12066)
Introduces a new private method `Mle::SendChildUpdateRejectResponse()`
to consolidate the logic for sending a reject response to a
"Child Update Request".

This new method creates a response containing the Source Address TLV,
Status TLV, and (if applicable) Response TLV.

The new method is now used in `Mle::HandleChildUpdateRequestOnChild()`
when the device is not a parent of the sender, and in
`Mle::HandleChildUpdateRequestOnParent()` when a request from an
unknown child is received. This change removes duplicated code from
both locations.
2025-10-27 10:57:47 -07:00
Zhanglong Xia fc71e69f92 [meshcop] check mbedtls version to ensure mbedtls_ssl_key_export_type is defined (#12053)
The macro MBEDTLS_SSL_EXPORT_KEYS is added to OT in PR #7025, it is used to
ensure mbedtls_ssl_key_export_type is defined. However, the macro
MBEDTLS_SSL_EXPORT_KEYS has been removed from the mbedtls since mbedtls-3.1.0.
If developers use external mbedtls repo with version 3.1.0 or higher
versions, and missed to define MBEDTLS_SSL_EXPORT_KEYS, it will cause
the KEK won't be set to the KeyManager.

This commit checks whether the mbedtls version is equal to or higher than
3.1.0 to ensure mbedtls_ssl_key_export_type is defined.
2025-10-27 10:54:26 -07:00
Abtin Keshavarzian 76f905bfac [mle] reuse challenge during child role restoration (#12065)
Ensure the same challenge is used for all "Child Update Request"
messages sent to the parent while trying to restore the previous
child role.

The challenge is now generated once when the child role restoration
process starts in `PrevRoleRestorer::Start`. This prevents a
situation where a new challenge from a retry could invalidate a
delayed but valid response from the parent that contained the
previous challenge.
2025-10-27 10:31:04 -07:00
Abtin Keshavarzian 9520760ff1 [mle] simplify MLE StatusTlv (#12064)
This commit simplifies the `StatusTlv` definitions. It introduces a
new `Status` enum representing the the MLE status values.
2025-10-27 10:30:28 -07:00
Yang Song ed0a6d46a5 [cmake] add build option for minimum DHCPv6 PD lifetime (#12063)
Add `OT_BORDER_ROUTING_DHCP6_PD_MIN_LIFETIME ` cmake build option, to
allow customizing the dhcpv6 pd client's minimum lifetime requirement
for different network environments or testing scenarios.
2025-10-27 09:27:32 -07:00
Zhanglong Xia 317321fef2 [api] add API to extract an extended address from an IPv6 address (#11933)
The application of the P2P module may only record the P2P peer's
link-local address for communication. This commit adds an API to
convert the peer's link-local unicast address to the peer's extended
address for tearing down the P2P link.
2025-10-27 09:26:31 -07:00
Abtin Keshavarzian 35cacd6d5f [nexus] enable CLI logging for fuzz tests (#12058)
Adds CLI related configs within the Nexus test build
(`openthread-core-nexus-config.h`) to support fuzz testing of
the CLI module.

The following configurations are added:

- `OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH` is increased to 800 to
  handle potentially long input strings generated by the fuzzer
  without truncation.

- `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled to log all
  input and output through the CLI. This is helpful for debugging
  and analyzing fuzzer-generated logs.
2025-10-24 08:12:51 +08:00
Abtin Keshavarzian b492922a9c [border-router] centralize infra-if management in InfraIf (#12046)
This change moves the management of the infrastructure interface state
out of the `RoutingManager` and centralizes it within the `InfraIf`
class. This makes `InfraIf` a more self-contained component and
simplifies the logic in `RoutingManager`.

The `RoutingManager` now depends on an initialized `InfraIf`. Its
`Init()` method is simplified and is now called from
`InfraIf::Init()`.

The public API `otBorderRoutingInit()` now directly initializes the
`InfraIf`. The `InfraIf::Init()` method is updated to support
re-initialization, allowing to switch to a new interface. When
switching, it ensures that components on the previous interface are
stopped before restarting on the new one.
2025-10-24 06:55:11 +08:00
tanyanquan 36b14d3ef7 [dhcp6-pd-client] allow custom values for kMinPreferredLifetime and kMaxPreferredLifetime (#12054) 2025-10-22 16:18:20 +08:00
Zhanglong Xia 6469b1e816 [api] add API to convert an extended address to a link-local unicast IPv6 address (#11932)
After the P2P link is established, the P2P peer's extended address is
returned as the P2P handle. This commit adds an API to convert the
peer's extended address to the peer's link-local unicast address.
2025-10-22 16:16:45 +08:00
Yang Song 0a4e509f79 [cli] fix br nat64prefix documentation (#12051)
This commit corrects example for the second `br nat64prefix` to `br
nat64prefix local` as it gets only the local prefix.
2025-10-22 09:58:42 +08:00
Abtin Keshavarzian ad1cfb749e [border-agent] introduce Border Agent TXT Data Parser (#12009)
This commit introduces a new feature to parse the MeshCoP service TXT
data from a Border Agent.

The new API `otBorderAgentTxtDataParse()` allows parsing the raw TXT
data into a structured `otBorderAgentTxtDataInfo` object. This can be
used by applications to inspect the capabilities and status of a
discovered Border Agent.

Config `OPENTHREAD_CONFIG_BORDER_AGENT_TXT_DATA_PARSER_ENABLE` controls
this new feature.

The existing test for the Border Agent is updated to validate the new
parser and its output.
2025-10-22 09:40:18 +08:00
dependabot[bot] ecd29ced66 github-actions: bump actions/download-artifact from 4.1.8 to 5.0.0 (#12052)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.8 to 5.0.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4.1.8...634f93cb2916e3fdff6788551b99b062d0335ce0)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-21 09:03:33 +08:00
Abtin Keshavarzian 8e58e8a8ca [mle] enhance ChildUpdateResponse content (#12048)
This change refines the content of the `ChildUpdateResponse` message
to avoid sending additional TLVs when rejecting a request.

The `ChildUpdateResponse` message is now tailored based on the
triggering `ChildUpdateRequest`. Specifically:

- When rejecting a `ChildUpdateRequest` (and including a Status TLV),
  the response will only include a Source Address TLV, a Status TLV,
  and, if sent in response to a `ChildUpdateRequest` that contained a
  Challenge TLV, a Response TLV.

- The reject response will no longer include the Leader Data, MLE
  Frame Counter, and Link Frame Counter TLVs.

- Any requested TLVs (from the `TLV Request TLV` in the
  `ChildUpdateRequest`) are now only included in the response when
  the request is accepted.
2025-10-21 08:01:59 +08:00
Abtin Keshavarzian 4fde897064 [srp-client] use proportional jitter for retry timer (#12044)
This change updates the jitter calculation for the SRP client's retry
mechanism.

Previously, a fixed jitter value was used. This could lead to
synchronized retries from multiple clients, especially as the retry
interval grows.

The new implementation calculates the jitter as a fraction of the
current retry interval (1/5th), ensuring that the jitter scales with
the wait time. This helps to better decorrelate retries from different
clients.

A new constant `kRetryJitterDivisor` is introduced for this
calculation. The jitter is clamped to a minimum value given by
`kRetryIntervalJitter`.
2025-10-21 07:57:46 +08:00
Yang Song 64e064ffc1 [cli] update cli br command and help list (#12041) 2025-10-18 13:46:46 -07:00
Jonathan Hui bc198bc867 [docs] remove empty lines (#12049) 2025-10-17 21:29:02 -07:00
Abtin Keshavarzian 99f510a16c [mdns] add validation for DNS names in mDNS APIs (#12039)
This commit adds `Dns::Name::ValidateName()` and `ValidateLabel()`
helper methods to validate a DNS name or label.

These methods are used at the entry of the mDNS `Register*()` and
`Unregister*()` public APIs to validate the provided host, service,
and key names. This prevents issues with malformed names and improves
the robustness of the mDNS module.

Includes unit tests for the new validation methods.
2025-10-17 21:25:42 -07:00
Yakun Xu ca9a731e4f [cmake] add CMakePresets (#11945)
This commit adds CMake Presets. The features used in this CMake Presets
requires CMake 3.25. This allows good integration with IDEs including VS
Code.

These presets also works in command line:

```bash
cmake --preset simulation
cmake --build --preset simulation
ctest --preset simulation -R ot-test-message
```
2025-10-16 09:14:27 +02:00
Abtin Keshavarzian 0b0930f1b8 [netdata] add validation for incoming network data TLVs (#12040)
Introduces a new method `ValidateTlvs()` on `NetworkData` to perform
structural validation of all TLVs within the network data.

This new validation is invoked from `Leader::SetNetworkData()` when
receiving new network data. If the new data fails validation, it is
rejected, and the previous network data is restored. This prevents a
device from accepting and propagating malformed network data, which
could lead to parsing errors or undefined behavior on devices.

The validation checks include:
- All TLVs and sub-TLVs are within the network data buffer bounds.
- Known TLV types like `PrefixTlv` and `ServiceTlv` are well-formed
  by calling their respective `IsValid()` methods.
- Container TLVs like `BorderRouterTlv` and `HasRouteTlv` have a
  length that is an exact multiple of their entry size.
2025-10-16 09:13:27 +02:00
Yang Song d23da65a48 [nat64] use RLOC16 to check NAT64 prefix publisher (#12028)
This commit removes a misleading TODO comment in the NAT64 prefix
manager.

The TODO suggested changing the NAT64 prefix publisher check to use
the RLOC16 of the entry in the Network Data. However, this approach is
flawed in scenarios with multiple Border Routers.

When multiple BRs publish the same NAT64 prefix with the same
preference, `FindPreferredNat64Prefix()` may return an entry published
by a different BR. An RLOC16 check would then incorrectly cause the
current BR to believe it did not publish the prefix, potentially
leading it to withdraw its entry and cause network instability.
2025-10-14 16:45:53 +02:00
Yang Song f19864a2ac [nat64] rename NAT64 discovery handlers for clarity (#12034)
This commit renames NAT64 prefix discovery handler functions in
`RoutingManager` and `Nat64PrefixManager` to be more specific. This is
a non-functional refactoring that improves code clarity and
maintainability.

The new names, `HandleInfraIfDiscoverNat64PrefixDone` and
`HandleInfraIfDiscoverDone`, clarify that these handlers are for NAT64
prefixes discovered on the infrastructure interface.

This change makes the code easier to understand and prepares it for
potential future enhancements, such as discovering NAT64 prefixes from
Router Advertisements.
2025-10-14 16:35:31 +02:00
Abtin Keshavarzian 46f728b64c [border-router] use friend for InfraIf callbacks (#12032)
This commit makes the callback handlers in `InfraIf` private and
declares the C-style platform functions as friends.

This change improves encapsulation by restricting the visibility of
these internal handler methods. The public API of `InfraIf` is made
cleaner, and only the intended callers (the platform callbacks) are
granted access.
2025-10-14 16:32:51 +02:00
Abtin Keshavarzian ef058d5bbb [mle] allow processing of "Child Update Request" while restoring child role (#12007)
This change modifies `HandleChildUpdateRequest()` to allow a detached
child that is restoring its previous role to process a "Child Update
Request" from its former parent.

When in this state, the device will respond to the request but will
not save any of the content (TLVs) from the message, as the child has
not yet established trust with any device (including its former
parent) and therefore cannot authenticate the freshness of the
received request.

This change handles the scenario where a child and its parent may be
reset simultaneously. It allows the parent to first restore its link
with the child through a "Child Update" exchange, which can then be
followed by the child sending its own "Child Update Request" to
re-establish the link. Without this change, a communication impasse
could occur where the parent rejects the child's request (as the
child is not yet valid), and the child ignores the parent's request
(as it is not yet attached). This change prevents devices from
resorting to a full re-attachment, thereby improving network
resilience and recovery time.

A new test is added to emulate this scenario and verify that the child
restores its role correctly without performing a full attach.
2025-10-14 16:31:53 +02:00
Abtin Keshavarzian 1f20dbc0af [dns-client] add destructor to ensure proper cleanup (#12026)
Adds a destructor to the `Dns::Client` class to ensure that `Stop()`
is called when a `Client` object is destroyed (freeing all allocated
queries).

This change prevents false memory leak reports from fuzzer tests when
an `ot::Instance` is destroyed during ongoing DNS queries (retries).
2025-10-13 15:02:31 +02:00
Abtin Keshavarzian a9d1103d41 [border-router] move InfraIf from RoutingManager to Instance (#12031)
This commit moves the `InfraIf` member from `RoutingManager` to be
owned directly by the `Instance`.

This change aligns the ownership of `InfraIf` with other core
components and simplifies dependencies. Decoupling `InfraIf` from
`RoutingManager` allows it to be accessed separately.
2025-10-13 14:56:43 +02:00
Abtin Keshavarzian a4605e44ef [border-router] conditionally compile NAT64 InfrIf methods (#12030)
This change makes the NAT64-related method in `InfraIf`
conditionally compiled based on the configuration
`OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE`.

The methods `DiscoverNat64Prefix()`, `DiscoverNat64PrefixDone()`,
and are now entirely excluded from the build when NAT64 border
routing is disabled.
2025-10-13 14:56:14 +02:00
Abtin Keshavarzian e1fd751eb8 [tmf] add compile-time validation for URI paths lookup array (#12017)
This change introduces compile-time validation for the `kEntries`
array in `uri_paths.cpp` to ensure the array's order matches the
`Uri` enum definitions.

A new `constexpr` function, `AreConstStringsEqual()`, is added to allow
for string comparisons at compile time, which is necessary for use
within `static_assert` in C++11.

A series of `static_assert()` checks are added to `uri_paths.cpp`.
These assertions verify that each URI path string in the `kEntries`
lookup table is correctly placed at the index corresponding to its
`UriPath` enum value.

This prevents potential bugs caused by accidental reordering of either
the enum or the array, ensuring the mapping between them remains
correct. If the order is changed incorrectly, the build will now fail,
immediately alerting the developer.
2025-10-13 14:55:42 +02:00
dependabot[bot] f8d6319368 github-actions: bump docker/login-action from 3.5.0 to 3.6.0 (#12036)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.5.0 to 3.6.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/184bdaa0721073962dff0199f1fb9940f07167d1...5e57cd118135c172c3672efd75eb46360885c0ef)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.6.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-10-13 12:55:13 +02:00
Jonathan Hui 09fc123cd0 [github-actions] remove code spell check (#12027)
Rely on AI-based code review tools instead.
2025-10-11 12:27:19 -07:00
Thomas 7e3deb891e [cli] fix prints when OT_COAP_BLOCK is enabled (#12021)
`cli_coap.cpp` and `cli_coap_secure.cpp` both try to print `uint32_t`
values with `%i`, which causes build errors on some systems.
This commit uses `%lu` together with `ToUlong` to fix this and make
the code more portable.

Additionally, `%u` was used to print unsigned values instead of `%i`
2025-10-10 14:32:03 -07:00
Abtin Keshavarzian 6f0993065e [border-agent] introduce TxtData class (#12005)
This commit introduces a new `MeshCoP::BorderAgent::TxtData` class to
encapsulate the logic for preparing the Border Agent's MeshCoP
service TXT data.

The TXT data generation logic is moved from the `BorderAgent::Manager`
into the new `TxtData` class. This refactoring improves modularity
and maintainability and prepares for the future addition of a MeshCoP
TXT data parser.
2025-10-10 12:59:33 -07:00
Abtin Keshavarzian 5180438303 [border-router] move RsSender to RxRaTracker (#12015)
This change moves the `RsSender` class from `RoutingManager` to
`RxRaTracker`.

The `RxRaTracker` is responsible for tracking received Router
Advertisements (RAs). Since sending Router Solicitations (RS) is the
mechanism to discover routers and solicit RAs, it is more appropriate
for `RxRaTracker` to own the `RsSender`.

This improves the separation of concerns by centralizing the logic for
both sending RS messages and processing the resulting RAs within the
`RxRaTracker` class. The `RoutingManager` is now decoupled from the
details of the RS transmission process.

The `IsRsTxInProgress()` method is also moved to `RxRaTracker` and its
Doxygen documentation is improved to provide more detail on the RS
transmission process.
2025-10-10 12:58:46 -07:00
Abtin Keshavarzian e07ed85620 [border-router] rename RxRaTracker callback for clarity (#12019)
Renames the callback used by `RxRaTracker` to inform `RoutingManager`
to `HandleRxRaTrackerDecisionFactorChanged()`.

This name more accurately reflects the triggering condition, as the
callback is invoked whenever any of the "decision factors" change,
not just when the on-link prefix table is updated.

For consistency, the related method in `OnLinkPrefixManager` is also
renamed to `HandleRxRaTrackerChanged()`.
2025-10-10 12:56:54 -07:00
Abtin Keshavarzian 989727feae [core] use kNullChar constant instead of '\0' literal (#12018)
This change replaces all instances of the null character literal
'\0' with the `kNullChar` constant throughout the `src/core/` files.
This improves code readability and consistency, making the intent
of the code more explicit.
2025-10-10 12:55:04 -07:00
Abtin Keshavarzian 7086ea0dad [border-router] make RxRaTracker handle netdata events directly (#12016)
This change makes the `RxRaTracker` a direct listener of network data
change events from the `Notifier`.

Previously, the `RoutingManager` would receive the network data change
event and then call `RxRaTracker::HandleNetDataChange()`. This
created an unnecessary dependency between the two components.

By making `RxRaTracker` a direct listener, we decouple it from
`RoutingManager`. The `HandleNetDataChange()` method in `RxRaTracker`
is also made private as it is now only called from within the class.
2025-10-10 12:54:14 -07:00
Ashish c65811fee5 [ncp] fix link error when building ot-daemon with OT_CANNEL_MONITOR=0 (#12004) 2025-10-09 11:23:39 -07:00
Jonathan Hui 67d2cfb757 [netdiag] fix calls to RxRaTracker methods (#12010) 2025-10-09 09:50:42 -07:00
Abtin Keshavarzian 2176ef719b [netdiag] add support for new BR Diagnostic TLVs (#11951)
This commit introduces new Network Diagnostic TLVs to report Border
Router information. It implements the server and client side logic to
support these new TLVs:

- BR state (38) - `uint8` value as `otBorderRoutingState`.
- BR Infra Interface Addresses (39) - list of IPv6 addresses
- BR Local OMR Prefix (40) - local (ULA) OMR prefix
- BR DHCPv6-PD OMR prefix (41) - DHCPv6-PD prefix (if any)
- BR Local On-link Prefix (42) - local on-link prefix
- BR Favored On-link Prefix (43) -favored discovered on-link on AIL

The various BR prefix TLV values are encoded as a fixed 8 bytes value
corresponding to the IPv6 prefix bytes (`/64`) in big-endian order.

This commit updates the `networkdiagnostic get` CLI command to display
the information from these new TLVs.

It also includes a test (added in `test-503-peer-tbr-discovery.py`) to
verify the new TLVs and the CLI commands.
2025-10-08 19:11:44 -07:00
Abtin Keshavarzian af6279f606 [border-agent] introduce BorderAgent namespace (#12002)
This change reorganizes the `BorderAgent` related classes into a new
`MeshCoP::BorderAgent` namespace to improve code structure and clarity.

The following changes are included:

- `MeshCoP::BorderAgent` class is renamed to `Manager` and placed
  within the new `MeshCoP::BorderAgent` namespace.
- `MeshCoP::BorderAgentTracker` is renamed to `Tracker` under the
   new namespace.
- `EphemeralKeyManager` is moved from being a nested class in
  `BorderAgent` to `MeshCoP::BorderAgent::EphemeralKeyManager`.
- `EphemeralKeyManager` is now a direct member of the `Instance` class,
  simplifying accessing it.

All related calls and test files are updated to reflect these
changes.
2025-10-08 12:47:30 -07:00
Abtin Keshavarzian e18a5a9cd7 [border-router] separate RxRaTracker into its own class (#12001)
This commit separates the `RxRaTracker` logic from `RoutingManager`
into its own class and source files.

Previously, `RxRaTracker` was a nested class within `RoutingManager`.
This change moves it to `src/core/border_router/rx_ra_tracker.hpp`
and `src/core/border_router/rx_ra_tracker.cpp`, making it a
standalone class within the `ot::BorderRouter` namespace.

This separation improves modularity and prepares for future changes
where `RxRaTracker` may operate independently of `RoutingManager`.
2025-10-08 12:25:00 -07:00
Abtin Keshavarzian c5971f7080 [border-agent] check that BA is enabled in RegisterService() (#11993)
This change adds a check at the beginning of `RegisterService()`
to ensure that the border agent is enabled before attempting to
register a service.

Previously, methods like `SetServiceBaseName()` would call
`RegisterService()` regardless of whether the agent was enabled,
leading to unintended service registration attempts on a disabled
agent.

This commit also adds a new test case to verify that changing the
service base name on a disabled border agent does not result in a
service being registered.
2025-10-07 14:49:16 -07:00
Esko Dijk d732acc6c6 [tcat] fix missing Python modules in tcat-ble-client pyproject.toml; bump module versions (#11984)
This fixes the issue that some required Python modules were missing in
pyproject.toml. To avoid Python version conflicts with the
cryptography module, the minimum Python version is raised to
3.10. Also, the name, version and description of the project are
updated. Module versions are updated to recent (2025) versions.

For Windows, a platform-specific import of pyreadline3 is added. Due
to this conditional dependency, the poetry.lock file is removed from
the repository: it is now necessarily specific to each platform and
has to be locally generated.
2025-10-07 10:45:31 -07:00
Ashish 3e4fa78f9d [cmake] add build command flag to set RCP time sync interval (#11979)
host-RCP time sync interval is in configuration file.
Added in cmake to use user defined RCP time sync internval during build.

Signed-off-by: ashish <ashish.vara@nxp.com>
2025-10-07 09:43:20 -07:00
Abtin Keshavarzian 2af369e844 [meshcop] add BorderAgentTracker to discover Border Agents (#11985)
Introduces a new `BorderAgentTracker` module to discover and track
Border Agents on the infrastructure link.

The tracker browses for the `_meshcop._udp` mDNS service and maintains
a list of discovered Border Agents. For each discovered service, it
resolves the port, host name, TXT record, and host addresses.

This change also adds new public otBorderAgentTracker APIs,
corresponding `batracker` CLI commands, and a new Nexus test case to
validate the behavior.
2025-10-06 21:10:36 -07:00
Abtin Keshavarzian 2596c9486b [fuzz] increase wait time in CLI fuzzer (#11999)
Increases the `nexus.AdvanceTime()` in the CLI fuzzer test from 10 to
60 seconds to make the test more robust.

For example, the previous 10-second wait was not sufficient for
`Dns::Client` operations to complete, especially considering retries.
This could cause false fuzzer memory leak reports.
2025-10-06 20:26:03 -07:00
Abtin Keshavarzian 0cbac5319a [border-router] introduce br_log for logging helpers (#11998)
This change introduces new files `br_log.cpp` and `br_log.hpp` to
house common logging helper functions for the border router modules.

Helper functions for logging Router Advertisement (RA) headers, Prefix
Information Options (PIO), Route Information Options (RIO), and other
related options are moved into this new module.

The log module name is also updated from `RoutingManager` to a more
general `BorderRouting`.

This change improves code structure by decoupling logging
functionalities from the `RoutingManager`.
2025-10-06 20:25:40 -07:00
Abtin Keshavarzian cfd1d085b3 [border-router] introduce br_types.hpp for common types (#11992)
Introduces a new `br_types.hpp` header and `br_types.cpp` source
file to centralize common data structures and type definitions used
across border router modules.

This change moves several classes from `routing_manager.hpp` to the
new `br_types.hpp` header. The moved classes include
`LifetimedPrefix`, `OnLinkPrefix`, `RoutePrefix`, `RdnssAddress`,
`IfAddress`, `OmrPrefix`, and `FavoredOmrPrefix`.

Additionally, common `typedef`s (e.g., `RoutePreference`,
`PrefixTableEntry`) and helper functions like `IsValidOmrPrefix()` are
relocated to the new files.

This improves the code structure by decoupling these shared types from
the main `RoutingManager` class, making them more reusable and easier
to maintain.
2025-10-06 17:05:23 -07:00
Tom Rebbert 792971d554 [mle] remove all queued parent responses when starting to attach (#11996)
When handling a parent request, a response is not sent if the device
is not attached, or if it is attaching. However if the device starts
the attachment process between queuing the parent response and
actually sending it, the parent response will be sent from an invalid
state.

This commit causes all queued parent response messages to be removed
when the device begins the attachment process, to avoid stale messages
from being sent on the link.
2025-10-06 15:07:56 -07:00
Abtin Keshavarzian 23c3bd4323 [mle] improve DelayedSender::Match() and logging (#11997)
This change enhances the `DelayedSender::Match()` method to support a
wildcard destination address. When the unspecified address (`::`) is
provided, the address check is skipped, allowing a match against any
destination.

A new private helper method, `LogRemove()`, is introduced to ensure
accurate logging when removing a delayed message schedule. Previously,
`RemoveMatchingSchedules()` would log the address passed to it, which
could be the wildcard `::` address. The new `LogRemove()` method
logs the actual destination from the scheduled message header
before it is removed.
2025-10-06 13:14:48 -07:00
Esko Dijk 6e6086e2dc [tcat] bugfix to allow repeated commissioning/decommissioning cycles (#11802) 2025-10-06 12:27:01 -07:00
Esko Dijk d28ced5a9a [ble][tcat] add BLE 'non-advertising' state, TCAT active/standby states, and timed activation (#11802)
This adds a BLE 'non-advertising' state in which BLE is enabled for connections, but not advertising.
- If the TCAT agent is not started and BLE is started, BLE advertising will be enabled by default.
- If the TCAT agent is started, then BLE advertising is under control of the TCAT agent - depending on its state.

The TCAT agent, while started, can be now in standby mode or in active mode. In standby, it doesn't
advertise and doesn't allow incoming TCAT connections. In active mode, it allows both advertising and incoming
connections. Timed activation of the active mode is also possible. CLI commands are added to test the new modes and
timed activation.

Existing architecture is not changed (BLE-Secure is in control and has all APIs to access TCAT agent).
It also fixes some (API) documentation and clarifies this where needed. Also, an error-value bugfix is done.

The TcatAgent is now added to instance.hpp/cpp, because that is required to use a timer from within
TcatAgent.

Log messages of TcatAgent are shortened and more often try to use an identical constant string value.
This saves memory in the binary, due to string re-use.

The "join callback" is clarified and extended to support callback to the application when the TCAT Commissioner
instructs the TCAT Device to try join a Thread network, or leave a Thread network.
2025-10-06 12:27:01 -07:00
Esko Dijk 710fbe07a9 [cli][tcat] fix 'devid' command output to comply to README file description and default OT CLI style (#11802) 2025-10-06 12:27:01 -07:00
Esko Dijk 392ac442b7 [cli][tcat] bugfix to enable 'tcat certid' CLI command, which was implemented but wasn't enabled yet (#11802) 2025-10-06 12:27:01 -07:00
Esko Dijk 911820471e [tcat] improve TCAT Commissioner output logging for SSL errors (#11906)
This commit provides more structured logging for ssl.py errors, and
displays the OpenSSL verify error code. This is used for certification
to validate reasons of handshake failure.
2025-10-06 10:02:40 -07:00
dependabot[bot] e77d798bcb github-actions: bump github/codeql-action from 3.30.3 to 3.30.6 (#11995)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.30.3 to 3.30.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/192325c86100d080feab897ff886c34abd4c83a3...64d10c13136e1c5bce3e5fbde8d4906eeaafc885)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.30.6
  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-10-06 09:30:45 -07:00
francoismichel 6d93c7fc96 [rcp] add support for OTNS (#11637)
This commit allows compiling the OpenThread RCP in OTNS mode.
This allows OTBR to attach seamlessly to OTNS.

 * Add the mOtns attribute to Instance::Instance when compiled
   with OPENTHREAD_RADIO=1
 * Add src/core/utils/otns.cpp to the RCP build.
   Only the necessary functions are compiled in RCP mode.
   Other functions such as EmitPingRequest and EmitPingReply
   that require IPv6 stack support are not compiled in RCP
   and are therefore moved into adequate
   `#if OPENTHREAD_MTD || OPENTHREAD_FTD` guards.
 * Ensure the RCP emits the needed events in src/core/radio/radio.cpp
   when compiled with OTNS support.
2025-10-03 11:45:17 -07:00
Jonathan Hui 3e9c7285c8 [fuzz] fix bounds checking in cli-fuzzer (#11991) 2025-10-02 15:59:05 -07:00
Abtin Keshavarzian a534551efe [border-agent] read NetName and XPanId from active dataset for TXT data (#11989)
This change updates `BorderAgent::PrepareServiceTxtData()` to read the
Network Name (`nn` key) and Extended PAN ID (`xp` key) from the
Active Dataset, after verifying that the dataset is valid and has an
active timestamp.

Previously, these values were read directly from `NetworkNameManager`
and `ExtendedPanIdManager`, which could provide default or initial
values (during stack initialization). Reading from the Active Dataset
ensures that the advertised service TXT data is consistent with the
dataset currently in use by the device.

The `ValidateMeshCoPTxtData()` test is updated to reflect this
behavior.
2025-10-02 11:02:48 -07:00
Nick Bertoldi e83f3e11b1 [instance] expose multi-instance getter as instance API (#11914)
This commit adds public getter functions to acquire a pointer for
the single OpenThread instance or one associated with a provided index.

An index to instance reference getter function was previously implemented
in the core instance interface, but this capability was not publicly accessible.
The accessor function introduced in this commit will now allow for platforms
or application code to perform this mapping. Corresponding changes for the
single instance case are also included.
2025-10-01 14:59:34 -07:00
Li Cao 430b47b62f [spinel] add udp port to the epskc state property (#11975)
This commit adds a field UDP port in the property
SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_STATE.

Similar as `SPINEL_PROP_BORDER_AGENT_MESHCOP_SERVICE_STATE`, NCP needs
to sync the UDP port number to the host as well so that the UDP proxy
on the host can correctly map the port and forward the UDP packet to
the NCP.

I missed the field in the previous commit. But since the spinel
property was just added recently and it hasn't been put into usage, I
think it's fine to change the existing spinel protocol.
2025-10-01 12:41:21 -07:00
Tom Rebbert ceb992bbdc [mle] don't allow FTD upgrade to Router while Leader is attaching (#11982)
This prevents the leader from allowing FTD devices' address solicit to
succeed while it is in the attaching state.

Upon processing an advertisement from a different partition, the
leader may evaluate it's own partition to be a singleton vs another
partition with routers and choose to start attaching. If a router is
upgraded during that time, the leader is committed to leaving already
and the other devices on that partition may get stranded if the router
is upgraded.

i.e. The router and other devices may now see the partition as
non-singleton, and if it has a higher partition ID than other
partitions, they will be stuck for the duration of the network ID
timeout.
2025-10-01 12:39:33 -07:00
Abtin Keshavarzian c8ccc84b3b [num-utils] add SetToUintMax() to prevent type-mismatch bugs (#11969)
Introduces a new template helper function `SetToUintMax()` in
`common/num_utils.hpp`. This function sets a given unsigned integer
variable to its maximum possible value.

The `SetToUintMax()` function infers the type of the variable,
ensuring that the correct `NumericLimits<...>::kMax` is used. This
prevents potential bugs where a variable could be assigned the max
value of a wrong `uint` type.

Existing code across different modules is updated to use this new
helper function, improving code safety and robustness.
2025-09-30 16:59:39 -07:00
Yang Song 05c0009046 [routing-manager] make getter methods const (#11986)
Make `RoutingManager::GetNextRdnssAddrEntry()` and
`RoutingManager::GetNextIfAddrEntry()` const.

These methods are simple getters that do not modify the state of
`RoutingManager` and call const methods on `mRxRaTracker`. This change
makes them consistent with other similar getter methods in
RoutingManager like `GetNextPrefixTableEntry()` and
`GetNextRouterEntry()`.
2025-09-30 12:34:05 -07:00
Jason Zhang f6f14a7d4a [posix] use LogInfo if SPI reset device is not given (#11978)
Change LogNote to LogInfo for consistency with other informational logs.
2025-09-29 19:00:32 -07:00
Zhanglong Xia fab01a7f0f [simulation] use the CSL receiver's peer address to include CSL IE (#11905)
The description of the method `otPlatRadioEnableCsl()` requires the platform
to include the CSL IE in the enhanced ACK when the received data frame's source
address matches the CSL receiver's peer address. This commit implements this
requirement in the simulation radio.
2025-09-29 18:24:38 -07:00
dependabot[bot] e72d19387e github-actions: bump codecov/codecov-action from 5.4.3 to 5.5.1 (#11980)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.3 to 5.5.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/18283e04ce6e62d37312384ff67231eb8fd56d24...5a1091511ad55cbe89839c7260b706298ca349f7)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.5.1
  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-09-29 18:23:37 -07:00
Li Cao 96a733b433 [routing-manager] remove confusing log of nat64 prefix discovery (#11973)
Note that `otPlatInfraIfDiscoverNat64Prefix` has an empty
implementation now and it always returns UNIMPLEMENTED error. So now
we constantly see the warn log on devices, which is confusing.
2025-09-29 18:13:22 -07:00
Yang Song ef89b0832e [cli] update debug command list for comprehensive diagnostics (#11959)
Expands and reorganizes the `cli debug` commands list to provide a
more comprehensive diagnostic snapshot of a device's state.

Key enhancements include:

- Expanded State Information: Adds commands for general device state
  (uptime, netstat), detailed neighbor connection times, and mesh
  topology diagnostics.

- Comprehensive Border Router Data: Includes detailed information for
  multi-AIL status, discovered peer BRs, infrastructure routers, and
  DNS-SD tables.

- Detailed Counters & History: Adds specific counters for IP, MAC,
  MLE, and BR modules, along with network history for prefixes,
  routes, and neighbors.
2025-09-29 18:09:58 -07:00
Abtin Keshavarzian f560204bcc [trel] simplify Peer::Matches() for name matching (#11976)
Consolidates the two overloaded `Peer::Matches()` methods for service
and host name matching into a single method.

This change introduces a new `NameMatchType` enum, which is used to
specify whether to match against a service name or a host name. This
removes the need for the now-unnecessary `ServiceNameMatcher` and
`HostNameMatcher` structs, simplifying the calling code and the `Peer`
class.
2025-09-29 18:08:40 -07:00
Abtin Keshavarzian 7bbdbc69ce [br-tracker] enhance NetDataBrTracker to support filtering (#11964)
This change enhances `NetDataBrTracker` to support filtering of Border
Routers.

The `NetDataPeerBrTracker` is renamed to `NetDataBrTracker` to reflect
that it can now track all Border Routers, not just peers.

A new `Filter` enum is introduced with `kAllBorderRouters` and
`kExcludeThisDevice` options. This allows callers to specify whether
to include the current device in the list of Border Routers.

The `CountPeerBrs()` and `GetNext()` methods are updated to
`CountBrs()` and `GetNext()` respectively, and now accept a `Filter`
parameter.

This change provides more flexibility to the `NetDataBrTracker` and
makes the code more reusable. The unit tests are also updated to
clean up resources to avoid heap allocation leaks at the end of
tests.
2025-09-29 18:05:55 -07:00
Abtin Keshavarzian 14373d5543 [heap] introduce Move() and unify TakeFrom() for move semantics (#11972)
This change enhances the move semantics for heap-allocated container
classes (`Array`, `Data`, and `String`) by introducing a consistent
pattern.

A new `Move()` method is added to `Heap::Array`, `Heap::Data`, and
`Heap::String`. This method returns an rvalue reference to the object,
making the intent to transfer ownership explicit at the call site.

The existing `TakeFrom()` methods are updated to accept an rvalue
reference and now include a check to prevent self-assignment, which
improves robustness.

For consistency, `Heap::Data::SetFrom(Data&&)` and
`Heap::String::Set(String&&)` are renamed to `TakeFrom()`.

All call sites are updated to use the new `foo.TakeFrom(bar.Move())`
pattern, replacing the more verbose and less clear
`static_cast<...&&>(bar)`.

Unit tests are updated to validate the new `TakeFrom()` and `Move()`
semantics, including tests for self-assignment and moving from a
null (empty) container
2025-09-29 18:04:56 -07:00
Abtin Keshavarzian fb6fa2002a [br-tracker] initialize aMinAge to uint32_t::kMax (#11963)
In `NetDataPeerBrTracker::CountPeerBrs()` method, the `aMinAge`
output parameter is a `uint32_t` but it was incorrectly
initialized to `NumericLimits<uint16_t>::kMax`.

This change corrects the initialization to use the
`NumericLimits<uint32_t>::kMax` to ensure the minimum age
calculation functions correctly over the full 32-bit range.
2025-09-24 18:32:18 -07:00
Abtin Keshavarzian a5c36a685a [br-tracker] move iteration logic out of RoutingManager::Iterator (#11962)
This change moves the logic for iterating over the `NetDataPeerBrTracker`
entries from `RoutingManager::RxRaTracker::Iterator` directly into the
`NetDataPeerBrTracker::GetNext()` method.

This decouples the `NetDataPeerBrTracker` from the `RoutingManager`'s
iterator implementation, allowing the removal of `RoutingManager` as a
friend class of `NetDataPeerBrTracker`.

This commit also includes smaller enhancements and changes to the
`RoutingManager::RxRaTracker::Iterator`:
- `Iterator::EntryType` is renamed to `PrefixType` for clarity.
- `Iterator::AdvanceToNextEntry()` is renamed to
  `AdvanceToNextPrefixEntry()`.
2025-09-24 16:42:24 -07:00
Abtin Keshavarzian 38781d43c9 [border-router] decouple NetDataPeerBrTracker from RoutingManager (#11960)
Moves the nested `RoutingManager::NetDataPeerBrTracker` class into its
own standalone class `BorderRouter::NetDataPeerBrTracker` in new
files `br_tracker.cpp` and `br_tracker.hpp`.

`NetDataPeerBrTracker` is now instantiated as a member of `Instance`
and is no longer owned by `RoutingManager`.

There is no logical/behavioral change in the `NetDataPeerBrTracker`
functionality.

Public C APIs `otBorderRoutingGetNextPeerBrEntry()` and
`otBorderRoutingCountPeerBrs()` are updated to get and use the
`NetDataPeerBrTracker` component.
2025-09-24 08:33:15 -07:00
Abtin Keshavarzian 27932f2006 [net] move slaac module from utils to net (#11955)
This commit moves the `SlaacAddress` module from `src/core/utils`
to `src/core/net`.

This change also updates the namespace from `ot::Utils` to
`ot::Ip6` and updates all includes and usages throughout the
codebase.

The `SlaacAddress` module was originally placed in `core/utils`
as SLAAC management was historically handled by the platform.
Now that the OpenThread stack manages SLAAC directly, this logic
is better placed under `core/net`.
2025-09-22 19:29:01 -07:00
rretanubun 35256c5aae [cli] add LQ In to the neighbor table output (#11927)
This allows a node to asses its LinkQuality In to its neighbors.
Similar to what is already available via router info.
Useful when not all its neighbors are routers.
2025-09-22 11:23:39 -07:00
dependabot[bot] d67c9bb606 github-actions: bump step-security/harden-runner from 2.13.0 to 2.13.1 (#11957)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.13.0 to 2.13.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/ec9f2d5744a09debf3a187a3f4f675c53b671911...f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.13.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-09-22 10:17:56 -07:00
Yakun Xu 466fdb87fa [debug] check NDEBUG for OT_ASSERT (#11929)
This commit verifies NDEBUG is not defined when OT_ASSERT is enabled and
is delegated to assert().
2025-09-19 17:52:38 -07:00
Tom Rebbert da61dc7eba [mle] avoid overwriting parent candidate during child ID request phase (#11953) 2025-09-19 15:35:26 -07:00
Abtin Keshavarzian 02af421a42 [nat64] introduce eviction mechanism for stale mappings (#11949)
Previously, when the translator ran out of IPv4 addresses or mapping
pool entries, any new NAT64 translation attempt would fail until
earlier entries reached their expiration time. The default expiration
time is long (7200 seconds / 2 hours).

This commit introduces a mechanism to evict existing "stale" mappings
(old but not yet expired) to make room for new ones.

This is handled by the new `EvictStaleMapping()` method, which is
called from `AllocateIp4Address()` and `AllocateMapping()` when
resources are full. A mapping is only eligible for eviction after a
minimum idle period (`kMinEvictTimeout`) which is set to 2 minutes
(matching `UDP_MIN` in RFC 6146).

The eviction logic prioritizes mappings based on protocol usage and
last use time. The preference for eviction, from most to least
preferred, is:

1. ICMP-only mappings
2. UDP (and possibly ICMP) mappings
3. TCP (and possibly other) mappings

If two mappings are in the same category, the one that has been
idle for the longest time is evicted.

This commit also adds a detailed `TestNat64Evict` test case to
validate the eviction logic and priority.
2025-09-19 14:39:56 -07:00
Li Cao 60dca7fbce [ncp] add netif state property change (#11950)
This commit makes NCP send notification to the host when the netif
state changes.

At the beginning we use ThreadHost API to start the thread network on
OTBR NCP which explicitly sends spinel property set command to the NCP
and get response. So the host side can get the latest state of netif
in the response. However if we use the cli command (`ifconfig up`) to
start the thread network, we need the NCP to send a notification to
the host that netif state changes.

I have verified that with the change, the host can receive the update
if we issue `ifconfig up` command.
2025-09-19 14:35:37 -07:00
Yakun Xu 3b3dd203be [utils] add a flag to use std new (#11937)
The noexcept placement new is standard in c++11. This commit adds a
config OPENTHREAD_CONFIG_USE_STD_NEW to allow using <new>. The default
behavior is still using OpenThread's own placement new implementation.
2025-09-18 14:50:15 -07:00
Abtin Keshavarzian fbc123940e [routing-manager] track all valid PIOs with on-link (L) flag (#11925)
Removes the `IsValidOnLinkPrefix()` helper functions which required a PIO
to have both the on-link (`L`) flag and either the autonomous address
configuration (`A`) or DHCPv6-PD preferred (`P`) flag to be considered
valid.

The `RxRaTracker` is updated to track any received valid PIO as long as
the on-link (`L`) flag is set, regardless of the `A` or `P` flags.

The `OnLinkPrefix` class is updated to store the state of the `A` and
`P` flags from the PIO. These flags are now checked within
`OnLinkPrefix::IsFavoredOver()` to determine if a prefix is eligible
to be a "favored" on-link prefix, but their absence no longer prevents
the prefix from being tracked.

This change ensures that the routing manager is aware of all non-ULA
on-link prefixes (even those with only the L flag set), which correctly
informs the decision to publish a default route.

This commit also:
- Updates `PrefixInfoOption` in `nd6.hpp` to use a `Flags` typedef and
  named constants instead of bitmasks.
- Updates `LogPrefixInfoOption` to log the state of L, A, and P flags.
- Adds a new unit test, `TestNonUlaPioWithOnlyOnLinkFlag`, to verify
  the new behavior.
2025-09-17 16:06:29 -07:00
Abtin Keshavarzian d27527ce54 [trel] distinguish between user and stack TREL enable requests (#11944)
This change updates the TREL interface enable logic to depend on two
requesters: the user (via `otTrelSetEnabled` API or CLI) and the
stack (internal, e.g., when the Thread protocol is running).

The TREL interface is now considered enabled only when both the user
and the stack have requested to enable it. By default, the user
preference is 'enabled', allowing the stack to control the state.

A key behavior change is that a user's request to disable TREL is now
persistent. If the user explicitly disables TREL, it will remain
disabled even if the stack stops and restarts (e.g., `ifconfig down`
then `ifconfig up`). The user must explicitly re-enable the TREL
(calling `otTrelSetEnabled(true)`) to allow TREL to operate again.

This is implemented by `Trel::Interface::SetEnabled()` method now
taking a `Requester` enum (`kRequesterUser` or `kRequesterStack`) as
input and tracking `mUserEnabled` and `mStackEnabled` flags
separately.

This commit also updates API/CLI documentation and adds a new test
(`TestTrelUserDisableRenable`) to verify this new behavior.
2025-09-17 11:23:31 -07:00
Jonathan Hui 2b85b0160f [fuzz] add CLI test (#11946) 2025-09-16 16:34:50 -07:00
Zhangwx f19beb2fda [history-tracker] enable tracking indirect tx (#11892)
The current history tracker only records direct transmissions, but
indirect transmissions are also required for debugging. This commit
adds support for tracking indirect transmissions.
2025-09-16 11:00:09 -07:00
BCo14 32d0995f89 [config] fix configs for reference device (#11913)
- OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
- OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS
2025-09-16 07:45:04 -07:00
Yakun Xu f4ff07ea07 [toranj] support default network key for debug (#11935)
This commit adds an environment for toranj script so that we can specify
a default network key for local debugging.
2025-09-15 20:17:44 -07:00
Yakun Xu ac7fbb4f86 [toranj] fix syntax warning in cli.py (#11931)
This commit fixes the syntax error by declaring the regex pattern as raw
string.

```
SyntaxWarning: invalid escape sequence '\d'
```
2025-09-15 16:59:01 -07:00
dependabot[bot] 4d4deabe8f github-actions: bump github/codeql-action from 3.30.1 to 3.30.3 (#11939)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.30.1 to 3.30.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/f1f6e5f6af878fb37288ce1c627459e94dbf7d01...192325c86100d080feab897ff886c34abd4c83a3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.30.3
  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-09-15 12:11:58 -07:00
Abtin Keshavarzian 9e26d0b149 [radio] avoid using zero-initializer lists for Mac types (#11921)
This change updates `Radio::Init()` to avoid passing
zero-initialized temporary objects of `Mac::ExtAddress` and
`Mac::KeyMaterial` types.

Instead, it declares local variables and passes them to the setter
methods. This improves code readability and makes the intent more
explicit.
2025-09-15 11:36:06 -07:00
Abtin Keshavarzian 242e10fb86 [mle] allow detached MTD to attach via stale announce (#11928)
This commit updates the logic in MLE `HandleAnnounce()` for processing
a received Announce message with an older (stale) timestamp.

Previously, only an Announce with a newer timestamp would be
considered for processing and announce attach (trying to attach using
the channel and/or PANID from the received announce). Also, any
device receiving a stale Announce with an older timestamp would send
its own Announce back to inform the sender.

This change updates the behavior regarding the processing of stale
Announce messages:
- A router-eligible FTD still sends an Announce back to help inform
  the other device.
- A detached MTD will now process the Announce (wait for a short delay
  before trying to attach to the older Dataset). This is useful when
  an MTD child device has a newer Dataset but the routers it can hear
  are still on a previous, older Dataset.
- An attached MTD now ignores the stale Announce. Since an MTD cannot
  become a router to help the device with the older Dataset join the
  new Dataset, sending an Announce back from the MTD would be
  pointless.

This commit also introduces a test to verify this exact scenario.
2025-09-15 11:34:34 -07:00
Abtin Keshavarzian f60b00695e [mle] fix implementation of IsMinimalEndDevice() (#11926)
A Minimal End Device (MED) is defined by the spec as an MTD whose
receiver is enabled all the time.

This commit fixes the implementation of `IsMinimalEndDevice()` to
match this definition. The previous implementation of this method
would incorrectly accept any MTD config (including SED or MED).

Within the core modules, `IsMinimalEndDevice()` is only used in
`MeshForwarder::UpdateIp6Route()`. This commit updates the logic
in this method to differentiate between an FTD (calling
`UpdateIp6RouteFtd`()) and an MTD (forwarding to parent) by
checking `IsFullThreadDevice()` instead of the previous check
against `IsMinimalEndDevice()` (which was effectively checking
MTD).

This commit also adds a new unit test, `TestDeviceMode()`, to
validate all configurations of `DeviceMode` (SED, MED, FTD) and
verify the behavior of `IsMinimalEndDevice()`.
2025-09-15 11:31:43 -07:00
Abtin Keshavarzian eba5bdc434 [nat64] use host ID tracking for IPv4 address allocation (#11909)
This change modifies the NAT64 translator to dynamically allocate IPv4
addresses by tracking a range of host IDs within the configured CIDR.
This approach replaces the pre-allocated `mIp4AddressPool`, making it
more memory-efficient by avoiding the storage of an entire address
array.

The translator now maintains `mMinHostId` and `mMaxHostId` derived
from the configured CIDR. When allocating an IPv4 address for a new
mapping:

- If `PORT_TRANSLATION_ENABLE` is enabled, addresses are assigned
  sequentially by cycling through the host ID range. Mappings can
  share an IPv4 address as they are distinguished by translated port
  numbers.

- If `PORT_TRANSLATION_ENABLE` is disabled, a 1-to-1 address mapping
  is used. The translator cycles through host IDs to find an unused
  IPv4 address. If all addresses are allocated, it attempts to free
  expired mappings before failing.

A new test case, `TestNat64CidrAddressReuse`, is added to validate the
address allocation and reuse logic. The test ensures that all
available addresses from a CIDR are used, new requests fail when the
pool is exhausted, and addresses are correctly reused after mappings
expire. It is run against multiple CIDR sizes (`/32`, `/31`, `/30`,
and `/27`) to verify behavior across various configurations.
2025-09-12 21:05:31 -07:00
Zhanglong Xia d5935a34f3 [meshcop] wraps HandleMbedtlsExportKeys() with MBEDTLS_SSL_EXPORT_KEYS (#11922)
The definition of the function `HandleMbedtlsExportKeys()` is wrapped
by the macro `MBEDTLS_SSL_EXPORT_KEYS`, but the implementation of the
function `HandleMbedtlsExportKeys()` is not wrapped by the macro
`MBEDTLS_SSL_EXPORT_KEYS`. Which causes `out-of-line definition` compiling errors.

This commit wraps the implementation of the function `HandleMbedtlsExportKeys()`
and the code that calls it with the macro `MBEDTLS_SSL_EXPORT_KEYS`.
2025-09-12 20:59:11 -07:00
Zhanglong Xia 19898c72a0 [api] add API to test whether the IPv6 address is a link local unicast address (#11902) 2025-09-12 20:42:14 -07:00
Li Cao bddd77d803 [ncp] add ephemeral key function in ncp (#11910)
The commit adds new spinel properties for ephemeral key feature:
* SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_STATE, for the NCP to update
  the ePSKc state to the host
* SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_ENABLE, for the host to
  enable/disable the ePSKc feature
* SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_ACTIVATE, for the host to
  start the ePSKc mode
* SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_DEACTIVATE, for the host to
  stop the ePSKc mode

The commit adds the NCP properties handler in NCP and also adds some
unit tests for the handlers.
2025-09-12 14:33:28 -07:00
Yakun Xu 48835fd143 [test] split size report jobs (#11918)
This commit split the size report workflow into two jobs of different
permissions.
2025-09-10 23:23:50 -07:00
Abtin Keshavarzian ddbcaa6aee [nat64] simplify state management (#11908)
This change simplifies the state management logic in the NAT64
translator by removing the `mEnabled` boolean flag. The `mState` enum
is now the single source of truth for the translator's operational
status.

A new `SetState()` method centralizes the actions performed when
transitioning to a new state, such as logging, signaling notifiers,
and clearing active mappings. The `IsEnabled()` helper is introduced
to check if the current state is not `kStateDisabled`.

Consequently, functions like `SetEnabled()` and `UpdateState()` are
updated to use the new `SetState()` function, making state
transitions more explicit and maintainable.
2025-09-10 21:21:51 -07:00
Damian Królik 07a278fb29 [link-metrics] make union packed to fix warning (#11920)
Clang warns that mMetricsValue is less aligned that its
union type. Make the union packed to fix this.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2025-09-10 10:42:51 -07:00
Yakun Xu e1d8a05c29 [udp] allow binding to multicast address (#11901)
This commit allows binding to multicast address, which means the socket
would only accept frames targeting to a particular multicast address.
This prevents other datagrams destined to the same port being delivered
to this socket.

Note that binding to a multicast address doesn't automatically subscribe
to the multicast group.
2025-09-10 08:51:27 -07:00
Zhanglong Xia 9491dccf42 [posix] include openthread/instance.h in src/posix/platform/settings.hpp (#11916) 2025-09-09 09:43:20 -07:00
Esko Dijk 3431162a09 [tcat] improved debug info format using hexadecimal + ASCII dump (#11881)
This improves debuggability of TCAT client and server, by using one
unified format (hex + ASCII) to show transmitted and received TCAT
data within the TLS session, as well as showing size of the encrypted
(TLS) data. For encrypted data, only size is now shown to avoid
clutter.  Showing the hex + ASCII dump allows devs/testers to visually
read TCAT TLVs from screen and identify how all TCAT commands are
processed by the Thread device.
2025-09-09 09:11:05 -07:00
Zhanglong Xia db7f037f73 [p2p] add unlink API to tear down the P2P link (#11904) 2025-09-08 14:15:09 -07:00
dependabot[bot] d7d26f10b1 github-actions: bump github/codeql-action from 3.29.2 to 3.30.1 (#11912)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.2 to 3.30.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/181d5eefc20863364f96762470ba6f862bdef56b...f1f6e5f6af878fb37288ce1c627459e94dbf7d01)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.30.1
  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-09-08 11:53:11 -07:00
Abtin Keshavarzian 0485be36a4 [nat64] replace Translator::Result with Error (#11898)
This change replaces the `Translator::Result` enum with the standard
`Error` type to report the outcome of a translation attempt. This
simplifies the implementation and aligns it with the rest of the
codebase.

The mapping from the old `Result` to the new `Error` is as follows:
- `kForward` is replaced by `kErrorNone`
- `kDrop` is replaced by `kErrorDrop`
- `kNotTranslated` is replaced by `kErrorAbort`

The `kErrorAbort` return value signals to the caller that no
translation was performed, and it can proceed with normal processing
of the message.

Additionally, the translation methods are renamed for better clarity.
2025-09-05 13:27:53 -07:00
Jonathan Hui da9babdc66 [multipan] fix unit test (#11900) 2025-09-05 13:25:18 -07:00
Abtin Keshavarzian df7ebc3dcc [core] replace anonymous enums with constexpr (#11899)
This commit replaces anonymous `enum`s used for defining constants
with `static constexpr` variables across various modules.
2025-09-04 19:48:09 -07:00
Abtin Keshavarzian e8c637fcf8 [netdiag] introduce types for diagnostic TLV data structures (#11897)
This commit introduces new types `otNetworkDiagData`,
`otNetworkDiagIp6AddrList`, and `otNetworkDiagChildTable` to
represent common data structures within Network Diagnostic TLVs.

These new types replace the previous anonymous structs within the
`otNetworkDiagTlv` union, improving code structure and readability.
The `mNetworkData`, `mIp6AddrList`, `mChildTable`, and
`mChannelPages` fields now use these named types.
2025-09-04 19:46:40 -07:00
Abtin Keshavarzian 5ac9ccfaed [nat64] ensure translator is active before translation (#11894)
This change adds an explicit check for `mState == kStateActive` at the
beginning of the translation functions.

This single check replaces individual validations for a valid IPv4
CIDR and NAT64 prefix. This simplifies the entry logic and fixes a
bug where the `Translator` could continue performing translations
even after it was explicitly disabled via `SetEnabled(false)`.

Additionally, this change fixes a bug in `TranslateToIp6()` where an
IPv4 message would be incorrectly marked as `kForward` when no IPv4
CIDR was configured (`mIp4Cidr.mLength == 0`). The correct behavior
is to drop the packet, so the result is now set to `kDrop`.
2025-09-04 10:53:44 -07:00
Abtin Keshavarzian 2421ba9a98 [nat64] rename GetIp6Prefix to GetNat64Prefix (#11896)
This change renames `GetIp6Prefix()` to `GetNat64Prefix()` to more
accurately reflect its purpose and to harmonize its name with the
existing `SetNat64Prefix()` and `ClearNat64Prefix()` methods.

The related getter methods in the header and implementation files are
also reordered for better organization.
2025-09-03 22:30:29 -07:00
Abtin Keshavarzian d952ad9085 [bit-utils] add CountMatchingBits utility function (#11893)
This change introduces a new utility function `CountMatchingBits()` to
calculate the number of matching leading bits between two byte
arrays.

This new fn replaces the now-removed `Ip6::Prefix::MatchLength()`.
The previous implementation was specific to the `Ip6::Prefix`
class. The new generic function is placed in `common/bit_utils` and
is used to update `Ip6::Prefix`, `Ip6::Address`, `Ip4::Cidr`, and
`PrefixTlv`.

A new unit test `test_bit_utils` is added with comprehensive tests for
the new function. The existing tests for `CountBitsInMask` are also
moved into this new test file.
2025-09-03 22:29:15 -07:00
Abtin Keshavarzian 6849b541e9 [common] move bit-related macros to bit_utils.hpp (#11890)
This change moves the `kBitsPerByte` constant and the `BitSizeOf()`
and `BytesForBitSize()` macros from `numeric_limits.hpp` to the
more specialized `bit_utils.hpp` header.

This consolidation places common bit-utility definitions into a more
appropriate, dedicated header, improving code organization and
logical grouping. Headers that relied on these definitions are
updated accordingly.
2025-09-03 22:28:18 -07:00
Abtin Keshavarzian ca8b29859d [routing-manager] track and expose addresses used on infra-if (#11891)
This commit introduces a mechanism within the `RoutingManager` to
track the IPv6 addresses used by the Border Router itself on the
infrastructure interface, particularly when sending Router
Advertisements. This provides visibility for debugging and
monitoring purposes.

A new data structure, `otBorderRoutingIfAddrEntry`, is added to
represent an address and the time elapsed since it was last used as
the source of an RA.

The tracked addresses can be retrieved using the new public API
`otBorderRoutingGetNextIfAddrEntry` or CLI command `br ifaddrs`.
2025-09-03 13:54:17 -07:00
Zhanglong Xia 4cb0de4233 [p2p] add initial peer-to-peer support (#11494)
This commit implements a minimum P2P which only supports
sending/receiving wake-up frames and establishing P2P links between
rx-on-when-idle devices.
2025-09-02 10:12:13 -07:00
Jonathan Hui 6657de95b8 [mesh-forwarder] always set direct transmission for MPL messages (#11887) 2025-09-02 08:06:48 -07:00
Abtin Keshavarzian fcfe442082 [nat64] update Mapping::ToString() to include translated ports (#11886)
When `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` is enabled,
multiple `Mapping` entries can exist for the same IPv6 and IPv4
addresses, differing only by their protocol ports.

To distinguish between these entries in logs and diagnostics, this
change updates `Mapping::ToString()` to include the source and
translated port numbers in the generated string output.
2025-09-02 08:05:22 -07:00
Abtin Keshavarzian aeba105a6f [common] introduce bit_utils.hpp for bit manipulation (#11884)
This commit introduces a new header file, `common/bit_utils.hpp`, to
consolidate bit manipulation utility functions.

These functions were previously located in `common/num_utils.hpp`.
Moving them to a dedicated file improves code organization and
clarity by separating them from general numerical utilities. All
files that used these functions have been updated to include the new
header.
2025-09-02 08:04:28 -07:00
Abtin Keshavarzian 51df484ac8 [nexus] add test for nat64 translator (#11882)
This commit introduces a new Nexus test to validate the functionality
of the NAT64 translator.

The test is divided into two main parts:
- `TestNat64StateChanges`: Verifies the state management of the
  translator. It checks that the translator transitions correctly
  between `kStateDisabled`, `kStateNotRunning`, and `kStateActive`
  when the feature is enabled/disabled or when the IPv4 CIDR and
  NAT64 prefix are configured or cleared. This test also confirms
  that state change notifications are properly signaled.
- `TestNat64Mapping`: Validates the address mapping and translation
  logic. It ensures that address mappings are correctly created for
  new IPv6-to-IPv4 traffic, reused for subsequent packets from the
  same IPv6 source, and eventually expire and are removed after a
  period of inactivity. It also verifies that the mapping table is
  cleared when the configured IPv4 CIDR is changed.
2025-09-02 07:58:17 -07:00
Zhanglong Xia 8b6b2b4056 [cli] fix typo in csl timeout docs (#11889) 2025-09-02 07:47:45 -07:00
Abtin Keshavarzian 4d1ae8552a [message] improve scoping of Buffer constants (#11885)
This commit moves two global constants, `kBufferSize` and
`kNumBuffers`, into their respective class scopes to improve
encapsulation and avoid potential name conflicts.

The `kBufferSize` constant is moved into the `Buffer` class as
`Buffer::kSize`. As `kBufferSize` is a generic and commonly used
name, this change prevents potential symbol collisions.

Similarly, the `kNumBuffers` constant is moved into the `MessagePool`
class, as it is exclusively used within that class.

All usages of these constants have been updated throughout the
codebase to reflect their new names.
2025-08-29 18:21:04 -07:00
Abtin Keshavarzian 269268fbf6 [time] introduce common ExpirationChecker class (#11883)
This commit introduces a new common helper class `ExpirationChecker`.

This class is designed to be used as a "matcher" for finding expired
entries in collections like `LinkedList` or `Array`. It encapsulates
a "now" time and provides an `IsExpired()` method to check if a given
time has passed.

This change consolidates duplicated private similar structs that
previously existed in `RoutingManager`, `Mdns`, and
`SrpAdvertisingProxy`, updating all users to the new common
implementation. This simplifies the code by removing redundancy.
2025-08-29 18:20:13 -07:00
Abtin Keshavarzian 83272e7eae [nat64] use OwningList to manage active mappings (#11878)
This change updates the management of active NAT64 mappings to use an
`OwningList`.

To support this, the `Mapping` struct now inherits from
`InstanceLocatorInit` and includes a new `Free()` method. This method
encapsulates the logic for releasing the associated IPv4 address and
the `Mapping` entry back to their corresponding pools.

This new design simplifies the `Translator` class by removing the
redundant `ReleaseMapping()`, `ReleaseMappings()`, and
`ReleaseExpiredMappings()` methods. All mapping cleanup operations
are now handled by the `OwningList` class (which invokes
`Mapping::Free()` on entries as they are removed).
2025-08-29 17:30:00 -07:00
Lucien Zürcher c007599107 [coap] add otCoapSetResponseFallback to process unmatched responses (#11583)
Adding two extensions:
1. Add an api function to configure a response fallback callback with
`otCoapSetResponseFallback`.
2. Enable fire and forget for NON requests, supporting requests which
do not expect a response.
2025-08-29 13:21:32 -07:00
Abtin Keshavarzian 853bbd1f43 [common] enforce correct CRTP usage for mix-in classes (#11880)
The mix-in helper classes like `Clearable<T>`, `Equatable<T>`, and
`Unequatable<T>` are intended for CRTP style inheritance, where `T`
is the derived class itself. A mistaken inheritance, such as `class
Foo : public Clearable<Bar>`, can compile successfully but lead to
subtle bugs.

This change enforces the correct CRTP usage at compile time. By making
the constructors of these helper classes `private` and declaring the
derived template class `T` as a `friend`, any incorrect inheritance
will now result in a build failure. This approach correctly detects
such a mistake, even if `Foo` and `Bar` happen to be `friend`s of
each other.

Additionally, `Equatable<T>` is updated to provide both `operator==`
and `operator!=`, removing its dependency on `Unequatable<T>`. This
change allows us to apply the `private` constructor enforcement to
`Equatable<T>` as well.
2025-08-29 12:58:45 -07:00
Abtin Keshavarzian 33d4f08385 [nat64] simplify SendMessage() using OwnedPtr (#11877)
This commit simplifies the implementation of `SendMessage()` by
changing its parameter from a `Message` reference to an `OwnedPtr`.

The `OwnedPtr` now manages the lifetime of the message, ensuring it is
always freed, whether the translation and send operation succeed or
fail. This change removes the need for a manual tracking flag and an
explicit `Free()` call in the error path, resulting in cleaner and
more robust code.
2025-08-29 12:49:48 -07:00
Abtin Keshavarzian 064bd3b79e [nat64] improve unit tests for Nat64::Translator (#11869)
This change enhances the unit tests for the NAT64 `Translator` to
improve readability. The key improvements include:

- Replaced raw hex dumps of packets with new helper functions that
  parse and log IPv4/IPv6 headers in a human-readable format.
- Simplified the counter tests and validation of the
  `ProtocolCounters`.
- Reworked the main test case functions, `Verify6To4()` and
  `Verify4To6()`, to leverage the new logging and verification
  helpers for better output.
2025-08-28 21:50:44 -07:00
Abtin Keshavarzian 8bfc8cba77 [ipv4] fix Cidr::Clear() (#11879)
The `Cidr` class was incorrectly inheriting from `Clearable<Address>`
instead of `Clearable<Cidr>`. This oversight meant that calling
`Clear()` on a `Cidr` object would not clear its `mLength` member,
only the `mAddress` field. This change corrects the template
parameter for the `Clearable` base class to `Cidr`, ensuring the
entire object is properly zeroed out.

This bug could cause issues in the NAT64 translator. When a user calls
`otNat64ClearIp4Cidr()` to disable translation, the underlying
`mIp4Cidr.Clear()` method would fail to clear the CIDR length. The
`Nat64::Translator` would check `mIp4Cidr.mLength > 0` in its
`UpdateState()` method to determine if a valid CIDR is configured.
Because `mLength` was not cleared, this check would pass incorrectly,
causing NAT64 translation to continue with an invalid,
partially-cleared CIDR instead of stopping as expected.
2025-08-28 19:10:42 -07:00
Abtin Keshavarzian fd7746b1e1 [core] harmonize access to MLE component using Get<Mle::Mle>() (#11874)
This change updates multiple modules to consistently use
`Get<Mle::Mle>()` for accessing the MLE component, removing the need
for local `Mle::Mle &mle` references.

This approach aligns with the common `Get<Module>()` access pattern
used across the codebase, improving consistency.
2025-08-28 14:29:48 -07:00
Abtin Keshavarzian 75bb4d018f [nat64] ensure to extend mapping lifetime on reuse (#11866)
Previously, a NAT64 mapping's lifetime was only extended upon its
initial allocation. This meant that if an existing mapping was found
and reused, its expiration timer would not be refreshed, potentially
leading to its premature removal.

This change moves the `mapping->Touch()` call from `AllocateMapping()` to
`TranslateFromIp6()`. This ensures that a mapping's lifetime is
extended every time it is used for translation, whether it is newly
allocated or an existing one being reused.
2025-08-28 10:43:04 -07:00
Abtin Keshavarzian 579d693295 [mle] simplify logic for multicast address registration (#11872)
This change introduces `ShouldRegisterMulticastAddrsWithParent()` to
consolidate the logic for determining when a child should register
its multicast addresses with its parent, thereby avoiding repeated
code.

The criteria for registration remain the same: a child registers its
multicast addresses if it is a Sleepy End Device (SED), or if it is a
Minimal End Device (MED) and its parent is running Thread 1.2 or a
later version.
2025-08-28 08:35:15 -07:00
Abtin Keshavarzian c192351e20 [nat64] prevent IPv4 addr sharing when port translation is disabled (#11865)
The logic for sharing an IPv4 address, intended for scenarios with a
small address pool (CIDR prefix > /28), was incorrectly being applied
even when port translation was disabled.

When `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` is disabled,
each mapping requires a unique IPv4 address. The previous
implementation would incorrectly reuse the same address from the
pool.

This commit makes the address sharing logic conditional on the
`OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` configuration. When
disabled, the translator now correctly allocates a unique IPv4
address for each mapping and returns it to the pool upon release.
2025-08-28 08:33:59 -07:00
Abtin Keshavarzian 54195e0ecf [nat64] improve AddressMappingIterator & expiration time calculation (#11855)
This commit improves the NAT64 address mapping iterator to ensure the
remaining lifetime for all mapping entries is reported consistently.

The iterator now internally stores a timestamp upon initialization.
This timestamp is then used as a common reference to calculate the
remaining lifetime for each `otNat64AddressMapping` entry, ensuring
consistent values throughout a single iteration.

The public C APIs remain unchanged, while the underlying implementation
and the `otNat64AddressMappingIterator` struct are updated.
2025-08-28 08:33:37 -07:00
Abtin Keshavarzian 370e822b31 [mle] improve logging for address solicit and router upgrade (#11871)
This change introduces `RouterUpgradeReasonToString()` to provide
human-readable strings for router upgrade reasons, which is used to
enhance logging in `BecomeRouter()` and `ProcessAddressSolicit()`.

These additions provide clearer insight into why a device is
attempting to become a router, aiding in debugging and network
analysis.
2025-08-28 07:49:53 -07:00
Abtin Keshavarzian b4365d3986 [nat64] optimize Translator::Mapping memory usage (#11873)
This commit places the `mSrcPortOrId` and `mTranslatedPortOrId`
members of the `Translator::Mapping` struct under the
`OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` build-time flag.

This optimization reduces the memory footprint of each `Mapping` entry
and the `mMappingPool` when the NAT64 port translation feature is
disabled.
2025-08-28 07:38:58 -07:00
Abtin Keshavarzian 388f734b64 [nat64] simplify mapping lookup and Touch() method (#11864)
This change streamlines NAT64 mapping management by removing the
`FindMapping()` and `FindOrAllocateMapping()` helper methods.

Following recent simplifications, such as adding new `Matches()`
flavors, the logic within these `Find` methods became much
simpler. Their functionality is now incorporated directly into
`TranslateToIp6()` and `TranslateFromIp6()`, respectively.

Additionally, the `Mapping::Touch()` method is simplified to no longer
require the current time as an argument. It now retrieves the time
internally.
2025-08-26 21:08:30 -07:00
dependabot[bot] bdbdcecb77 github-actions: bump docker/metadata-action from 5.7.0 to 5.8.0 (#11867)
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5.7.0 to 5.8.0.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](https://github.com/docker/metadata-action/compare/902fa8ec7d6ecbf8d84d538b9b233a880e428804...c1e51972afc2121e065aed6d45c65596fe445f3f)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: 5.8.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-08-26 20:15:12 -07:00
Abtin Keshavarzian d2d2f0092f [ipv4] smaller improvements in Address, Cidr, and Header (#11863)
This commit introduces several cleanups and smaller improvements to
the IPv4 types.

- Optimizes `Cidr::ToString(StringWriter&)` by writing the address
  directly to the provided writer, avoiding the allocation of a
  temporary `String` object.
- Moves the IPv4 header field offset constants from the public
  `ip4_types.hpp` header into the unit test file, as this was their
  only place of use. This cleans up the `Ip4::Header` public API.
- Replaces hardcoded values for address and string sizes with the
  corresponding `OT_IP4_*` definitions for consistency.
- Corrects the format specifier in `Address::ToString()` from `%d` to
  `%u` to properly print unsigned octet values.
2025-08-26 19:52:33 -07:00
Abtin Keshavarzian 7bb1ed0a7f [history-tracker] add DHCPv6 PD state and prefix history (#11848)
This change introduces a new history list to record the DHCPv6 Prefix
Delegation (PD) state and the delegated prefix.

The recorded history can be iterated using the new API
`otHistoryTrackerIterateDhcp6PdHistory()` and viewed from the CLI
using the new `history dhcp6pd` command.
2025-08-26 16:14:46 -07:00
Abtin Keshavarzian 819313474e [mdns] add test for truncated query eviction (#11857)
This commit adds a test case to `TestMultiPacket` to validate the
correct eviction of pending truncated queries.

The test scenario sends the same truncated query multiple times,
followed by a query containing a matching known answer. It then
verifies that no response is sent, confirming that the initial
pending queries were successfully evicted from the message queue.
This validates the fix from #11854.
2025-08-26 11:03:14 -07:00
Abtin Keshavarzian e0b6bbeccd [nat64] use IP headers for Mapping::Matches (#11856)
This change updates the `Mapping::Matches` methods to accept
`Ip4::Headers` and `Ip6::Headers` objects instead of separate IP
address and port arguments.

This simplifies the callers `FindOrAllocateMapping` and `FindMapping`
by encapsulating the conditional logic for port translation within
the `Mapping::Matches` methods. This allows for a single, unified
`FindMatching` method on the active mappings list.
2025-08-26 10:36:11 -07:00
dependabot[bot] cc44220c85 github-actions: bump actions/checkout from 4.2.2 to 5.0.0 (#11858)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/11bd71901bbe5b1630ceea73d27597364c9af683...08c6903cd8c0fde910a37f88322edcfb5dd907a8)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-26 07:54:01 -07:00
Abtin Keshavarzian 01bce95ba2 [mdns] handle allocation failure and fix use-after-release (#11854)
This commit changes the `RxMsgEntry` allocation check from `OT_ASSERT`
to `VerifyOrExit`. This ensures that a heap allocation failure for a
multi-packet RX message results in the message being gracefully
dropped, allowing network operation to continue instead of
asserting.

Additionally, `AddNew()` now removes any existing multi-packet message
entries from the same sender before attempting to allocate a new
`RxMsgEntry`. This helps to reclaim resources and prevent stale
entries.

This change also fixes a use-after-release bug by ensuring
that the `aRxMessagePtr` (an `OwnedPtr`) is not accessed after its
ownership is transferred by the `newEntry->Add(aRxMessagePtr)`
call.
2025-08-25 16:09:46 -07:00
Abtin Keshavarzian 9deea80b1a [nat64] simplify and enhance handling of counters (#11850)
This commit simplifies and enhances the NAT64 translator's counter
implementation.

- The `mProtocolCounters` and `mErrorCounters` are explicitly cleared
  in the `Translator` constructor, ensuring they are properly
  zero-initialized.
- The `ErrorCounters` C++ wrapper class is removed, and the counters
  are now updated directly based on `DropReason`.
- The `ProtocolCounters::Count*Packet()` methods are updated to accept
  `Ip6::Headers` and `Ip4::Headers` inputs directly, which simplifies
  the call sites.
- Private helper methods, `Update6To4()` and `Update4To6()`, are
  introduced in `ProtocolCounters` to reduce code duplication when
  incrementing packet and byte counts.
2025-08-25 14:39:57 -07:00
Abtin Keshavarzian 25b8e769d4 [nat64] introduce helpers for getting port or ICMP ID (#11849)
This commit introduces two new `static` helper methods,
`GetSourcePortOrIcmp6Id()` and `GetDestinationPortOrIcmp4Id()`, to
the `Translator` class. This eliminates repeated similar code and
improves overall readability.
2025-08-25 14:35:59 -07:00
dependabot[bot] 9d31ae5f2b github-actions: bump ossf/scorecard-action from 2.4.1 to 2.4.2 (#11853)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.1 to 2.4.2.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/f49aabe0b5af0936a0987cfb85d86b75731b0186...05b42c624433fc40578a4040d5cf5e36ddca8cde)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-version: 2.4.2
  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-08-25 12:17:49 -07:00
Abtin Keshavarzian dd893ce001 [history-tracker] record AIL router history (#11827)
This commit enhances the `HistoryTracker` to record information about
routers discovered on the Adjacent Infrastructure Link (AIL).

This feature is applicable when the device operates as a Border
Router, providing a mechanism to monitor the history of changes to
the discovered AIL routers for debugging and network analysis.

The history tracker records events when an AIL router is added,
removed, or when its tracked information changes. The recorded
information includes:
- The IPv6 address of the router
- Default router status and its preference
- RA flags: 'M' (Managed Addr), 'O' (Other), 'S' (SNAC Router)
- Operational information:
  - Whether the router is a local entity (on same device)
  - Reachability status
  - Whether it is a peer Border Router on the same Thread mesh
- The favored advertised on-link prefix by this router (if any)

A new public API, `otHistoryTrackerIterateAilRoutersHistory()`, is
added to iterate over the recorded AIL router history. A
corresponding CLI command, `history ailrouters`, is also included to
display this information.
2025-08-22 17:15:02 -07:00
Abtin Keshavarzian 2c697309b6 [nat64-translator] enhance and harmonize code style (#11847)
This commit updates the `Translator` class to improve code style,
readability, and consistency with the OpenThread coding conventions.
This is a pure refactoring commit with no intended logic changes. Key
changes include:

- Renamed types and variables for brevity (e.g., `AddressMapping` to
  `Mapping`).
- Renamed members within the `Mapping` struct for clarity(e.g., `mIp4`
  to `mIp4Address`).
- Standardized local variable names (e.g., `err` to `error`).
- Added `const` to methods that do not modify the class state.
- Improved and reformatted Doxygen and inline comments.
2025-08-22 14:31:39 -07:00
Abtin Keshavarzian afb52ba3a7 [mle] group Attacher method definitions in mle.cpp (#11841)
This commit improves the organization of `mle.cpp` by grouping all
`Attacher` method definitions together.

When the `Attacher` class was introduced in #11835, its method
definitions were intentionally kept in their previous order to
minimize the `git diff` for easier review. This resulted in the
`Attacher` methods being interleaved with other `Mle` methods.

This commit acts as a follow-up to rearrange the file and group all
`Attacher` methods into a dedicated section for better readability
and organization.

No logic changes are included in this commit.
2025-08-22 14:31:13 -07:00
Abtin Keshavarzian 46e3c15cd7 [toranj] add --log-level option to build.sh (#11840)
This change introduces a `--log-level` option to the `build.sh`
script, allowing the `OPENTHREAD_CONFIG_LOG_LEVEL` to be specified at
build time.

The supported log levels are `NONE`, `CRIT`, `WARN`, `NOTE`, `INFO`,
and `DEBG`. The default level is set to `INFO`.

The CI workflow is updated to test builds with all the supported log
levels.
2025-08-22 14:30:39 -07:00
Abtin Keshavarzian b6f1252bd8 [netdata] enhance FindContext() methods and Lowpan::Context (#11836)
This commit enhances the `FindContext()` methods and converts the
`Lowpan::Context` struct into a class.

The `FindContext()` methods are updated as follows:
- Renamed to `FindContextForAddress()` and `FindContextForId()` to
  more accurately reflect their function.
- The return type is changed from `Error` to `void`. Success is now
  indicated by checking the `IsValid()` state of the output `Context`
  object (matching how `Lowpan` class uses the `Context`). This
  change simplifies the callers and harmonizes the context check
  across different modules.

The `Lowpan::Context` struct is converted into a class, encapsulating
its members by making them private and introducing public getters.
2025-08-22 14:30:14 -07:00
Esko Dijk 7b59c810d9 [cli] clarify and improve TCAT CLI README, including links to relevant ID types (#11832) 2025-08-22 13:05:00 -07:00
Jonathan Hui 05d1eb07e0 [mpl] use RLOC as IPv6 source address (#11843)
This helps reduce header overhead.
2025-08-22 11:40:59 -07:00
Abtin Keshavarzian 3f1069e110 [test] enable NAT64 translator unit tests (#11845)
This commit makes several updates to enable and fix NAT64 unit test

- Enables the NAT64 translator in `toranj` test configs, ensuring
  that the `test_nat64` unit test is now covered by the GitHub
  Actions CI (under the `toranj` workflow).
- Enable `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` for the POSIX
  `toranj` build while disabling it for the simulation build, ensuring
  both configurations are built and covered by CI.
- Fixes the `test_nat64` unit test by removing an incorrect
  "mapping pool exhausted" step. This step is now invalid as the pool
  size is configured to a much larger value (254) via
  `OPENTHREAD_CONFIG_NAT64_MAX_MAPPINGS`.
2025-08-22 11:17:48 -07:00
Abtin Keshavarzian 258f467250 [wakeup-tx-scheduler] fix potential integer conversion warnings (#11842)
This commit resolves compiler warnings/errors related to potential
integer overflows and unsafe narrowing conversions.

- The type of `mTxRequestAheadTimeUs` is changed from `uint16_t` to
  `uint32_t` to avoid potential overflow when calculating the TX
  time.
- A `ClampToUint16()` utility is now used before setting the
  rendezvous time. This safely converts the calculated
  `rendezvousTimeUs` to a 16-bit integer, preventing a narrowing
  conversion warning.
2025-08-22 11:16:58 -07:00
Abtin Keshavarzian c5f66c9e02 [routing-manager] add Publish()/Unpublish() in Nat64PrefixManager (#11838)
This commit introduces `Publish()` and `Unpublish()` private helper
methods in `Nat64PrefixManager` to encapsulate and centralize the
logic for managing the published NAT64 prefix in the Network Data.

- `Publish(aPrefix, aPreference)` adds the given prefix to the Network
  Data. It handles removing any previously published prefix if the
  new prefix or preference differs.
- `Unpublish()` removes the currently published NAT64 prefix from the
  Network Data, if one exists.

These new helpers simplify the logic within the `Evaluate()` and
`Stop()` methods, reduce code duplication, and improve overall
clarity.
2025-08-21 13:52:57 -07:00
Abtin Keshavarzian e4f6008a57 [mesh-forwarder] fix log level build issue (#11839)
This commit fixes a build failure that occurs when the log level is
set to `NOTE`.

A previous change (#11507) updated some `MeshForwarder` logging
methods from the `NOTE` to `INFO` level (e.g., `LogFrame()`).
However, these methods remained grouped with `NOTE`-level methods
under a single `OT_SHOULD_LOG_AT(OT_LOG_LEVEL_NOTE)` preprocessor
guard.

This mismatch caused a build failure when `OT_LOG_LEVEL_NOTE` was
enabled (unused parameter warnings).

To resolve this, this commit separates the logging methods into their
respective `OT_SHOULD_LOG_AT()` guards based on their actual log
level (`INFO` or `NOTE`).
2025-08-21 13:50:29 -07:00
Abtin Keshavarzian f25b2db42b [network-data] align FindPreferredNat64Prefix() method name (#11837)
This commit renames `GetPreferredNat64Prefix()` to
`FindPreferredNat64Prefix()`.

The new name better aligns with the method's behavior, as it searches
for a preferred NAT64 prefix in the Network Data and can return
`kErrorNotFound`. This change also harmonizes the method name with
other similar `Find...()` methods in the `NetworkData` class.
2025-08-21 13:39:29 -07:00
Abtin Keshavarzian 64e285beef [mle] introduce Attacher class (#11835)
This commit introduces a new `Mle::Attacher` class to encapsulate all
logic and state related to the device attach process.

This change moves the attach state machine, parent candidate
management, attach timer, and message handling for Parent Request,
Parent Response, Child ID Request, and Child ID Response from `Mle`
into the new nested `Attacher` class.

This refactoring improves code organization and modularity by
separating the attach logic from the main `Mle` class.
2025-08-21 07:36:32 -07:00
Abtin Keshavarzian 968dbb2a04 [message] check for potential integer overflows (#11834)
This commit adds checks to prevent potential integer overflow issues
within the `Message` class.

Previously, calculations involving message offset and length, such as
`offset + length`, assumed the caller would provide values within a
safe range. However, in some edge cases where larger values are
given, this addition could wrap around. This could lead to incorrect
behavior, potential memory corruption, or assertion failures.

To address this, this change introduces a new generic utility
function, `CanAddSafely()`, to detect unsigned integer addition
overflows. This check is now applied in the following `Message`
methods to validate lengths and offsets before performing
arithmetic:

- `AppendBytes()`: Returns an error if `offset + length` overflows.
- `AppendBytesFromMessage()`: Returns an error on overflow.
- `GetFirstChunk()`: Safely clamps the read length to the available
  message length.
- `WriteBytes()`: Asserts if `offset + length` overflows.

Unit tests for the new `CanAddSafely()` utility are included, covering
`uint8_t` and `uint16_t` cases.
2025-08-20 22:22:39 -07:00
Jonathan Hui 364bbf5e49 Revert "[message] check for potential integer overflows (#11831)" (#11833)
This reverts commit f056d0062f.
2025-08-20 14:22:02 -07:00
Abtin Keshavarzian f056d0062f [message] check for potential integer overflows (#11831)
This commit adds checks to prevent potential integer overflow issues
within the `Message` class.

Previously, calculations involving message offset and length, such as
`offset + length`, assumed the caller would provide values within a
safe range. However, in some edge cases where larger values are
given, this addition could wrap around. This could lead to incorrect
behavior, potential memory corruption, or assertion failures.

To address this, this change introduces a new generic utility
function, `CanAddSafely()`, to detect unsigned integer addition
overflows. This check is now applied in the following `Message`
methods to validate lengths and offsets before performing
arithmetic:

- `AppendBytes()`: Returns an error if `offset + length` overflows.
- `AppendBytesFromMessage()`: Returns an error on overflow.
- `GetFirstChunk()`: Safely clamps the read length to the available
  message length.
- `WriteBytes()`: Asserts if `offset + length` overflows.

Unit tests for the new `CanAddSafely()` utility are included, covering
`uint8_t` and `uint16_t` cases.
2025-08-20 14:15:01 -07:00
Abtin Keshavarzian 8b1f217ef6 [toolchain] suppress gcc string operation warning (#11810)
Introduces macros to suppress a known false-positive GCC warning
"-Wstringop-overflow=0" which can be triggered when manipulating
network data.

The `AddHasRoute()`, `AddBorderRouter()`, and `AddServer()` methods
shift and update the network data bytes, which may involve inserting
or updating a sub-TLV within an existing TLV. This can trigger a
"writing x byte into a region of size 0" error on some GCC
toolchains.

This change adds the `OT_SUPPRESS_GCC_STRING_OP_BEGIN` and
`OT_SUPPRESS_GCC_STRING_OP_END` macros to silence this specific
warning within these code blocks.
2025-08-20 13:15:03 -07:00
Abtin Keshavarzian 3c8049ad65 [netdata] use bit manipulation helpers for NetworkDataTlv (#11810)
This change updates the `NetworkDataTlv` class to use common bit
manipulation helper functions (`ReadBits`, `WriteBits`, `SetBit`,
`GetBit`, `ClearBit`).

This change replaces the manual bit masking and shifting for accessing
the `Type` value and the `Stable` flag with calls to the new helpers.
The member variable `mType` is also renamed to `mTypeAndStableFlag` to
more accurately reflect its contents.
2025-08-20 13:15:03 -07:00
Abtin Keshavarzian c0fd3de68d [netdiag] ignore duplicate TLVs in Diag Get request (#11830)
This commit ensures that the Network Diagnostic server correctly
handles duplicate TLV types within a "Diagnostic Get" request.

Previously, if the `TypeList` TLV in a request contained duplicate
type entries, the server would process each one, leading to redundant
diagnostic TLVs being appended to the response message.

This is now fixed by using a `BitSet` to track the TLV types that have
already been processed from the request. If a duplicate type is
encountered, it is skipped, ensuring that each requested diagnostic
TLV is added to the response only once. This logic is applied to both
the standard and TCAT-specific request handling paths.
2025-08-20 13:09:36 -07:00
Tom Rebbert f3efd14e96 [mle] improve Graceful Detach for Routers (#11805)
Cause FTD children to detach if their parent router was removed from
the route TLV.
2025-08-18 12:27:48 -07:00
dependabot[bot] 2a719180aa github-actions: bump step-security/harden-runner from 2.12.0 to 2.13.0 (#11826)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.0 to 2.13.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/0634a2670c59f64b4a01f0f96f84700a4088b9f0...ec9f2d5744a09debf3a187a3f4f675c53b671911)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.13.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-08-18 11:14:24 -07:00
Abtin Keshavarzian 50edbc8d48 [mle] simplify address solicit handling (#11822)
This commit introduces a new `AddrSolicitInfo` struct to encapsulate
all parameters related to an Address Solicit request and its
processing outcome.

The processing of a TMF Address Solicit is broken down into two new
methods:
- `AddrSolicitInfo::ParseFrom()`: Handles parsing the incoming CoAP
  message.
- `ProcessAddressSolicit()`: Contains the logic for deciding whether
  to grant a router ID based on the parsed request.

This change separates parsing from processing logic, improving code
structure and readability without any functional changes.
2025-08-18 11:00:44 -07:00
Abtin Keshavarzian ca72e8d64a [mle] add Aloc16 helper class (#11818)
This commit introduces the `Mle::Aloc16` helper class to encapsulate
constants and helper methods related to Anycast Locators (ALOC16).

The new class provides static helpers for:
- Checking if a given ALOC16 has a specific purpose (e.g., Service,
  DHCPv6 Agent, Commissioner, Primary BBR).
- Converting between an ALOC16 and its related service, context, or
  session ID.

All existing code is updated to use the new helper methods. This
improves code readability and centralizes ALOC16 management.
2025-08-18 11:00:11 -07:00
Abtin Keshavarzian 12e0a7daa1 [mle] add methods for leader and partition ID selection (#11820)
This commit extracts the logic for selecting a leader ID and a
partition ID out of the `BecomeLeader()` method into two new private
helper methods: `SelectLeaderId()` and `SelectPartitionId()`.

This is a pure refactoring that does not alter behavior. It improves
the readability and maintainability of the `BecomeLeader()` method by
simplifying its implementation.
2025-08-18 10:56:15 -07:00
Abtin Keshavarzian a1dec571fd [num-utils] change IsValueInRange() return type to bool (#11821)
This change corrects the return type of the `IsValueInRange()`
template function to `bool`
2025-08-18 10:42:40 -07:00
Abtin Keshavarzian 9911440505 [mesh-forwarder] introduce MessageFramer to consolidate frame prep logic (#11817)
This change introduces a new `MessageFramer` class to encapsulate the
logic for preparing MAC data frames.

This change improves code modularity and separation of concerns by
isolating the frame preparation logic (MAC headers, mesh headers,
6LoWPAN compression, and fragmentation) from the message forwarding
responsibilities of `MeshForwarder`.

Classes such as `MeshForwarder`, `IndirectSender`, and
`DataPollSender` are updated to use the new `MessageFramer` class.
2025-08-18 10:41:01 -07:00
Abtin Keshavarzian ca372b8e99 [ip6] update MPL option processing and validation (#11816)
This commit enhances MPL option processing and validation.

Previously, the MPL option was processed immediately upon being found,
and multiple MPL options in the same message were accepted. This
could allow a malformed IPv6 message to be buffered for MPL
re-transmission multiple times with different seed IDs.

This change ensures the code first iterates through and validates all
included options within a Hop-by-Hop extension header, enforcing that
at most one MPL option is present before processing.

This is implemented by splitting `Mpl::ProcessOption()` into
`ReadAndValidateOption()` and a new version of `ProcessOption()` that
acts on a pre-validated `MplOption`.
2025-08-18 10:39:39 -07:00
Abtin Keshavarzian 9755d90b49 [cli] fix the documentation on how age is formatted (#11819) 2025-08-18 10:17:36 -07:00
dependabot[bot] 8c90b72b21 github-actions: bump docker/login-action from 3.4.0 to 3.5.0 (#11824)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/74a5d142397b4f367a81961eba4e8cd7edddf772...184bdaa0721073962dff0199f1fb9940f07167d1)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.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-08-18 08:20:20 -07:00
Abtin Keshavarzian 2d19b13aaf [history-tracker] add support for tracking favored on-link prefix (#11807)
This commit adds support to `HistoryTracker` to record the history of
favored on-link prefixes on the AIL.

It introduces the `otHistoryTrackerFavoredOnLinkPrefix` structure and
a new API, `otHistoryTrackerIterateFavoredOnLinkPrefixHistory()`, to
access the recorded data. The new CLI command `history onlinkprefix`
is added to display the tracked history, showing the prefix, its age,
and whether it is local to the Border Router.
2025-08-15 11:03:31 -07:00
Abtin Keshavarzian a3cd859502 [netdata] move service ALOC management from MLE module (#11815)
This change moves the service ALOC management logic from the `Mle`
module to `NetworkData::Service::Manager`.

This change simplifies the code by consolidating responsibilities.
Since the `NetworkData::Service` module manages service entries in
the Network Data, it is the logical owner for managing the associated
service ALOCs.
2025-08-13 19:07:59 -07:00
Abtin Keshavarzian 562a3d8c73 [cli] document mdns verboselogging command (#11809)
This commit adds documentation for the new `mdns verboselogging` CLI
command.
2025-08-13 10:38:19 -07:00
Abtin Keshavarzian a1ad5d23ef [netdata] reorder methods under NetworkData::Service (#11814)
This commit reorders method implementations in the source file
`network_data_service.cpp` to group them within their respective
`Iterator` and `Manager` class sections.

In PR #11680, the `Iterator` class was enhanced to be a separate class
from `Manager`. The method definitions in the `.cpp` file were kept
in their original order at that time to simplify the review by
keeping the `git diff` smaller.

Separator comments are also added to both the `.cpp` and `.hpp` files
to improve code structure and readability.

No functional changes are introduced.
2025-08-13 10:22:42 -07:00
Abtin Keshavarzian ed95672bc0 [netdata] use Mle constants in RemoveTemporaryData() methods (#11813)
This commit replaces hardcoded magic numbers for RLOC addresses with
their corresponding named constants from the `Mle` namespace.

- The DHCP Agent RLOC is now set using `Mle::kAloc16DhcpAgentStart`.
- The invalid RLOC address `0xfffe` is replaced by `Mle::kInvalidRloc16`.

This change improves code readability and maintainability. Redundant
comments were also removed.
2025-08-13 10:17:55 -07:00
Abtin Keshavarzian b89d05c5fc [netdata] unify GetNext...() methods into a single template (#11812)
This change updates the `NetworkData` iteration methods to reduce
redundant code and simplify their use.

Previously, separate methods were defined to iterate over different
types of network data entries (e.g., `GetNextOnMeshPrefix()`,
`GetNextExternalRoute()`). This change unifies these into a single
template method, `NetworkData::GetNext<EntryType>()`. A similar
change is applied to unify the corresponding `Contains...()`
methods into a single template.
2025-08-13 10:15:24 -07:00
Jonathan Hui 19b5bfedbf [script] fix typo in license header (#11811) 2025-08-12 18:19:41 -07:00
Abtin Keshavarzian 188fd690f5 [netdiag] use enum for IsLastFlag in AnswerTlv (#11808)
This commit replaces the boolean `aIsLast` parameter in the
`AnswerTlv::Init()` method with an `enum IsLastFlag`.

This change improves the readability and type-safety of the code when
specifying whether an answer is the last one in a network diagnostic
query.
2025-08-12 12:57:40 -07:00
Abtin Keshavarzian 184c4ca9ed [mle] ignore parent and child-update requests on parent when detaching (#11806)
This change ensures that a parent device in the process of detaching
from the network ignores incoming "Parent Request" and "Child Update
Request" messages.

A new `Detacher::IsDetaching()` method is added to check for this
state. This prevents potential inefficiencies that could arise if
these requests were responded during the detachment procedure.
2025-08-12 12:13:19 -07:00
Li Cao 318006e4da [format] standardize clang-format to 19.1.7 (#11797)
Since llvm-19, if we use package manager to install it, the minor
versions could be different. This commit standardizes the version on
linux to 19.1.7. This version is the same as the one installed by
homebrew.
2025-08-12 11:20:30 -07:00
Thomas 09214764ec [otci] fix parsing of dns_resolve4 and csl get/set methods (#11786)
fix parsing of

* dns_resolve4 returns a synthesized ipv6 address, but parsing expected an ipv4 address

fix csl methods

* add support for getting csl uncertainty/accuracy
* add support for setting the csl channel
* remove the non existing get_csl_period

renames variables/arguments that had a python builtin name
2025-08-12 11:14:05 -07:00
Jake Swensen 3ec7f23c5d [cmake] add OT_BORDER_ROUTING_MULTI_AIL_DETECTION build option (#11800)
Allow command line control over enabling/disabling the multi-ail
detection feature.
2025-08-12 11:03:26 -07:00
Abtin Keshavarzian 736808828d [mdns] add verbose logging (#11793)
This commit introduces a verbose logging feature in the mDNS module to
aid in development and debugging by providing detailed logs of mDNS
traffic.

The feature is enabled at build-time via the config option
`OPENTHREAD_CONFIG_MULTICAST_DNS_VERBOSE_LOGGING_ENABLE`
(mapping to the `OT_MDNS_VERBOSE` CMake option). When enabled,
logging can be controlled at run-time using the new
`otMdnsSetVerboseLoggingEnabled()` API and the corresponding
`mdns verboselogging` CLI command.

The initial state on startup can be configured using
`OPENTHREAD_CONFIG_MULTICAST_DNS_DEFAULT_VERBOSE_LOGGING_STATE`
(mapping to the `OT_MDNS_VERBOSE_STATE` CMake option).

When active, this feature logs the content of every sent and received
mDNS message, including the header, questions, and all resource
records. The logs are emitted at the `OT_LOG_LEVEL_NONE` level to
ensure they are always captured, regardless of the active log level
configuration.
2025-08-11 16:14:49 -07:00
Abtin Keshavarzian 4fb1a5da74 [cli] add mdns command guide (#11788)
Adds a new `README_MDNS.md` file to provide a comprehensive guide for
the `mdns` CLI command.

The guide includes:
- A quick start section with examples.
- A full list of all available sub-commands.
- Detailed explanation and usage examples for each sub-command.
2025-08-11 16:13:34 -07:00
Zhanglong Xia afcbe5b056 [child] remove duplicated OPENTHREAD_FTDs (#11803) 2025-08-11 12:20:06 -07:00
Abtin Keshavarzian 343e10dafe [mle] use PrevRoleRestorer for child update challenge (#11801)
This commit updates the challenge/response mechanism used when a
detached device sends a "Child Update Request" to restore its role as
a child.

Previously, this process shared the `mParentRequestChallenge` with the
parent search mechanism. This logic is now consolidated within the
`PrevRoleRestorer` class, which now manages the generation and
tracking of the `TxChallenge` used in "Child Update Request".

This change simplifies the `Mle` class design and makes the child role
restoration logic separate from the parent search and attach process.
This separation allows for future enhancements where a device may run
both mechanisms in parallel.
2025-08-11 12:18:25 -07:00
Jonathan Hui 2bc7712f57 [fuzz] add fuzzer for otPlatTrelHandleReceived (#11779) 2025-08-08 22:54:35 -07:00
Abtin Keshavarzian b09b791683 [history-tracker] track favored OMR prefix on a border router (#11775)
This commit adds support for tracking the history of the favored OMR
prefix on a border router. A new public API and the corresponding
`history omrprefix` CLI command are added to retrieve the recorded
history.

A new `otHistoryTrackerFavoredOmrPrefix` type is introduced to
represent an entry in the history. Each entry includes the OMR
prefix, its preference, and a boolean flag `mIsLocal` indicating
whether the prefix is the same as the one maintained locally by the
border router. The local OMR prefix can be based on either a randomly
generated ULA or a prefix delegated via DHCPv6-PD.
2025-08-08 22:54:09 -07:00
Abtin Keshavarzian e5d3f9e9c0 [crypto] allow null buffer in AesCcm::Payload() (#11799)
This commit updates `AesCcm::Payload()` to support a `nullptr` for the
output buffer. When decrypting, the `aPlainText` can be null, and
when encrypting, `aCipherText` can be null.

This change is useful when the caller only needs the authentication
tag and does not require the actual decrypted or encrypted payload,
thus avoiding the need to provide a temporary output buffer.

This is leveraged to simplify the MAC frame processing under fuzzing
build (`OPENTHREAD_FUZZ_FUZZER_BUILD`), removing a large
stack-allocated buffer (`kFuzzMaxFrameSize`).
2025-08-08 10:38:01 -07:00
Jason Zhang 5e04b4e261 [cmake] fix SRP server fast start mode option typo (#11798)
fix misspelled `OT_SRP_SERVER_FAST_START_MODE` build option
2025-08-08 10:36:55 -07:00
Abtin Keshavarzian 696c70994c [routing-manager] update tracking of favored on-link prefix (#11780)
This change enhances the favored on-link prefix selection logic within
the `RoutingManager::OnLinkPrefixManager`.

It introduces two new prefix state variables:
- `mAilPrefix`: Tracks the on-link prefix discovered from Router
  Advertisements received on the Adjacent Infrastructure Link
  (AIL). This renames the previous `mFavoredDiscoveredPrefix`.
- `mFavoredPrefix`: Tracks the final selected favored prefix, which
  can be either the local prefix or the `mAilPrefix`.

The setters `SetAilPrefix()` and `SetFavoredPrefix()` are added to
manage these state changes and provide additional logging.
2025-08-07 18:09:14 -07:00
Abtin Keshavarzian ed422b5a32 [mac] increase fuzz buffer size to support TREL (#11794)
The temporary buffer used in `RxFrame::ProcessReceiveAesCcm` under
fuzzing build is increased to 1280 bytes. This change allows for
fuzzing of larger TREL frames. A new constant `kFuzzMaxFrameSize` is
introduced for this purpose.
2025-08-07 18:08:12 -07:00
Marius Preda 08efcdaef9 [trel] fix compilation issue when otPlatTrelNotifyPeerSocketAddressDifference is not defined (#11784)
When using OPENTHREAD_CONFIG_TREL_MANAGE_DNSSD_ENABLE the TREL peer
discovery platform code is not needed anymore.
Added otPlatTrelNotifyPeerSocketAddressDifference under the same
logic as the rest of the TREL platform API that is not used
when OPENTHREAD_CONFIG_TREL_MANAGE_DNSSD_ENABLE is true.

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-08-07 08:19:44 -07:00
Abtin Keshavarzian e76db3af61 [mac] enhance command ID validation and parsing for 2015-spec frames (#11787)
The treatment of the Command ID field in a MAC command frame is
dependent on the IEEE 802.15.4 version. In the 2015 specification,
it is part of the encrypted payload, while in earlier versions, it
is part of the unencrypted MAC header. The `FindPayloadIndex()`
method correctly accounts for both cases.

This commit enhances the frame parsing and validation logic to account
for this difference.
- `ValidatePsdu()` is updated to ensure the frame is long enough to
  contain the Command ID when validating a 2015-version frame.
- `GetCommandId()` is updated to validate the presence of the Command
  ID field before access, fixing a potential out-of-bounds read.
- A new `IsMacCommand()` helper method is introduced to improve code
  clarity and replace direct frame type checks.
2025-08-06 19:04:13 -07:00
Abtin Keshavarzian 7ab5c5c042 [mle] simplify ThreadStatusTlv handling (#11782)
The Status TLV is used in several TMF messages (Address Solicit, DUA
Registration, MLR), and the meaning of its value is
context-dependent.

This commit refactors the TLV definitions by moving the status enums
from the generic `ThreadStatusTlv` class into the modules where they
are used.

The main changes are:
- The Address Solicit status is split into two more specific enums:
  - `RouterUpgradeReason` for Address Solicit requests.
  - `AddrSolicitResponse` for Address Solicit responses.
- `MlrStatus` and `DuaStatus` enums are moved to `mlr` and `dua`
  modules respectively.
- `ThreadStatusTlv` is simplified to a `typedef`.

This change improves code clarity, modularity, and type safety by
ensuring that status codes are defined and used within their proper
context.
2025-08-06 19:02:01 -07:00
Li Cao 8dadae2ea1 [format] upgrade clang-format to 19 (#11783)
We just updated the version from 14 to 16. But very unfortunately
clang-format-16 was just deprecated recently. So this time we update
the version to the latest available one. There are newer releases than
19 (like 20) but as I tested, sudo apt-get install -y clang-format-19
can work while 20 doesn't work.

misc-include-cleaner in clang-tidy-19 exerts a very strict check which
requires to directly include all headers for every symbols in the
source file. However in our current code we intentionally use some
indirect include. So this commit disables misc-include-cleaner.
2025-08-06 10:49:52 -07:00
Jonathan Hui 956e1a0c7d [fuzz] add fuzzer for otIp6Send (#11790) 2025-08-05 19:55:50 -07:00
Jonathan Hui dba483ac69 [tcp] skip checksum validation during fuzz tests (#11789) 2025-08-05 15:51:25 -07:00
Abtin Keshavarzian a9a9d84061 [trel] fix possible use-after-free in HandleTxtResult() (#11781)
This change fixes a potential use-after-free issue in the
`PeerDiscoverer::HandleTxtResult()` method.

When processing a TXT record, the corresponding `Peer` object could be
removed if it was identified as the device itself. However, a
subsequent call to `UpdatePeerState()` would still use the dangling
reference to the removed `Peer` object.

The fix merges the logic from the now-removed `ProcessPeerTxtData()`
method directly into `HandleTxtResult()`. After a `Peer` is removed,
the local `peer` pointer is set to `nullptr`, and the call to
`UpdatePeerState()` is guarded by a null check to prevent using
the invalid pointer.
2025-08-04 16:56:11 -07:00
dependabot[bot] 063dbc36d7 github-actions: bump umbrelladocs/action-linkspector from 1.3.4 to 1.3.7 (#11776)
Bumps [umbrelladocs/action-linkspector](https://github.com/umbrelladocs/action-linkspector) from 1.3.4 to 1.3.7.
- [Release notes](https://github.com/umbrelladocs/action-linkspector/releases)
- [Commits](https://github.com/umbrelladocs/action-linkspector/compare/a0567ce1c7c13de4a2358587492ed43cab5d0102...874d01cae9fd488e3077b08952093235bd626977)

---
updated-dependencies:
- dependency-name: umbrelladocs/action-linkspector
  dependency-version: 1.3.7
  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-08-04 10:33:54 -07:00
Jonathan Hui 31adbd0edc [fuzz] add fuzzer for otPlatInfraIfRecvIcmp6Nd (#11773) 2025-08-02 10:23:58 -07:00
Abtin Keshavarzian 0cf1ee09eb [mle] simplify WillBecomeRouterSoon for clarity (#11768)
This commit renames `IsExpectedToBecomeRouterSoon()` to
`WillBecomeRouterSoon()` to better reflect its behavior.

The implementation is simplified by using the `VerifyOrExit` pattern
instead of a single complex boolean expression, which improves code
readability.
2025-08-01 11:10:52 -07:00
Jonathan Hui 9cd5a2d93e [fuzz] add fuzzer for otPlatMdnsHandleReceive (#11772) 2025-07-31 13:28:23 -07:00
Yakun Xu 590c56e238 [config] include logging.h (#11766)
This commit includes `<openthread/platform/logging.h>` because
it uses `OT_LOG_LEVEL_CRIT`.
2025-07-30 17:05:58 -07:00
Abtin Keshavarzian 8bd5d73f9d [mesh-diag] add API to configure response timeout (#11753)
This change introduces new APIs to allow configuration of the response
timeout for mesh diagnostic queries. A corresponding CLI command
`meshdiag responsetimeout` is also added to get or set the timeout
value.

When set, the new response timeout is used for subsequent queries and
does not affect any that are ongoing. The timeout value is clamped
between 50 milliseconds and 10 minutes to ensure it stays within a
reasonable range.
2025-07-30 15:53:08 -07:00
Abtin Keshavarzian e93d281288 [history-tracker] move HistoryTracker to its own namespace (#11756)
This commit refactors `Utils::HistoryTracker` by moving it into its
own dedicated `ot::HistoryTracker` namespace for better code
organization.

The main implementation class is renamed from `HistoryTracker` to
`Local`, making the new class `ot::HistoryTracker::Local`. This
allows additional components (like server and client) to be defined
within the `HistoryTracker` namespace.

Nested types, such as `Iterator`, are now direct members of the new
`HistoryTracker` namespace.
2025-07-30 14:15:47 -07:00
arnulfrupp bb5585d412 [tcat] add tcat implementations and bug fixes (#11402)
Commit adds check if commissioning is possible and if the tcat device is already commissioned.
Adds advertisement update on disconnected and role change.
Fixes key handling for key references.
Fixes the authorization processing.
Implements recent changes of the application TLVs.
2025-07-30 12:27:10 -07:00
Abtin Keshavarzian 6c55d53a50 [mle] move child ID allocation logic to ChildTable (#11764)
This commit moves the child ID allocation logic from `Mle` to
`ChildTable`.

A new `AllocateNewChildRloc16()` method is added to `ChildTable` to
contain the allocation logic, and the `mNextChildId` counter is moved
to `ChildTable`. `Mle` is updated to use this new method.

This refactoring improves code encapsulation by making the
`ChildTable` responsible for managing all aspects of the children it
contains, including ID allocation.
2025-07-29 17:03:02 -07:00
Abtin Keshavarzian 72ee935dec [netdiag] fix incorrect bitmask for AnswerTlv index (#11762)
The `kIndexMask` within `AnswerTlv` was incorrectly defined as `0x7f`,
which only covers the lower 7 bits of the `mFlagsIndex` field. This
would improperly truncate the message index value.

This change corrects the mask to `0x7fff`, which properly utilizes the
lower 15 bits for the index, while the most significant bit remains
reserved for the `kIsLastFlag`.
2025-07-29 17:02:11 -07:00
Li Cao 34bb0e4ab1 [test] remove the node type rcp-ncp (#11752)
The type `rcp-ncp` was meant to run nodes of NCP on posix. But we
don't have NCP on posix anymore. So this can be removed.
2025-07-28 11:20:43 -07:00
Abtin Keshavarzian fcfee4ec7a [mle] introduce PrevRoleRestorer to manage role restoration (#11731)
This commit introduces `Mle::PrevRoleRestorer` to consolidate the
logic for restoring a device's previous role (child or router/leader)
after an MLE restart.

This new class replaces and encapsulates the functionality from the
now-removed `RouterRoleRestorer` class and `RestorePrevRole()` method.

`PrevRoleRestorer` manages its own timer and retransmission logic. It
handles sending Child Update Requests to restore a child role, or
multicast Link Requests to restore a router/leader role. It also adds
a small random delay before the first transmission attempt to avoid
synchronized transmissions when multiple devices restart at once.

This change simplifies the `Mle` class by centralizing all role
restoration logic into a single component, making future enhancements
to this process easier.
2025-07-23 18:46:11 -07:00
Jonathan Hui 382c4c44c4 [dns] add missing include (#11748) 2025-07-22 13:35:36 -07:00
Abtin Keshavarzian 44046b7b68 [history-tracker] add Network Data DNS/SRP address entry tracking (#11685)
This commit introduces a new feature in `HistoryTracker` to track
Network Data DNS/SRP unicast/anycast address entries. This new
functionality records when different Border Routers add or remove
these entries in the Network Data. This change also introduces new
public APIs and CLI command `history dnssrpaddr` to expose this
information.
2025-07-22 11:00:43 -07:00
Abtin Keshavarzian f73d64e611 [settings] change save/delete methods to return void (#11735)
This commit simplifies the `Settings` API by modifying all "Save"
and "Delete" methods to return `void` instead of `Error`.

Settings operations are required for a Thread device to function, so a
failure to save or delete from non-volatile storage should be treated
as a critical error. Previously, the code effectively ignored these
errors using `IgnoreError()`. This change instead treats any such
failure as a critical error, triggering an assert within the
`Settings` module.

The key changes include:
- `Settings::Save<T>()`, `Delete<T>()`, `DeleteAllChildInfo()`, and
  similar methods now return `void`.
- Internal `Settings` methods use `SuccessOrAssert()` to assert on
  errors.
- The responsibility for asserting on `kErrorNotImplemented` is moved
  to the `SettingsDriver` layer.

This update simplifies the caller logic by removing the need for
`IgnoreError()` at many call sites. Consequently, several methods
that primarily wrapped `Settings` calls, such as `Mle::Store()` and
`BorderAgent::SetId()`, have also been updated to return `void`.
2025-07-21 22:46:19 -07:00
Abtin Keshavarzian c9ee6d0576 [dns-client] increase default response timeout to 7 seconds (#11741)
This commit increases the default DNS response timeout config,
`OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT`, to 7000
milliseconds.

The default value of 7000 is selected to be longer than the
six-second wait time for queries resolved by the Discovery Proxy
(per RFC 8766, Section 5.6, first bullet).
2025-07-21 22:44:26 -07:00
Jonathan Hui 6a6afd8da4 [posix] call FinalizeMulticastRouterSock() in TearDown() (#11742) 2025-07-21 22:20:07 -07:00
Abtin Keshavarzian 4ded380722 [discover-scanner] use TxCallback to handle discovery request tx done (#11736)
This commit updates the handling of discovery request transmission
completion by using a `TxCallback`.

Previously, `MeshForwarder` contained special-case logic to identify a
discovery request message and would then explicitly call into
`DiscoverScanner::HandleDiscoveryRequestFrameTxDone()`.

This is changed so that `DiscoverScanner` now registers a `TxCallback`
directly on the discovery request message itself.
2025-07-18 08:56:13 -07:00
Abtin Keshavarzian 3019d3c6c4 [mle] reorganize Detacher methods (#11734)
This commit moves the `Detacher::Detach()` method implementation to
group it with other `Detacher` method definitions.

When the `Detacher` class was added in PR #11723, its methods were
intentionally kept in their original locations to keep the `git diff`
smaller and easier to review.

This is a pure code-move refactoring to improve code organization and
has no functional changes.
2025-07-16 15:23:27 -07:00
Abtin Keshavarzian 86590870d3 [mle] introduce GenerateRandomDelay() helper (#11729)
This commit introduces `GenerateRandomDelay()`, to simplify the
logic for generating a random delay up to a given max delay.
This is then used through `Mle` class.
2025-07-16 15:22:47 -07:00
Abtin Keshavarzian 8c4d537696 [posix] implement Posix::Dhcp6PdSocket for otPlatInfraIfDhcp6Pd* (#11607)
This commit implements `ot::Posix::Dhcp6PdSocket`, which provides the
`otPlatInfraIfDhcp6PdClient*` socket-like APIs for use by the core
`Dhcp6PdClient` module.

The `Posix::Dhcp6PdSocket` is a sub-component of `Posix::InfraNetif`.
2025-07-16 15:09:06 -07:00
Abtin Keshavarzian 5219147160 [trel] ignore mDNS service removal for peer table update (#11692)
This commit modifies TREL to disregard mDNS (DNS-SD) service removal
events when updating the peer table. Since mDNS peer removal signals
can be unreliable, this change prevents such signals from causing a
peer's removal. Instead, a peer entry is retained as long as TREL
packets and acks are successfully exchanged, moving towards the goal
of eliminating TREL's dependency on mDNS for peer discovery and
tracking.

This commit also introduces a new mechanism to track the last
interaction time with each peer. This information is used to evict
the least recently used entry when the peer table gets full and to
remove inactive peers after a long expiration period (7.5 min)
passes.

The `test_trel` Nexus test is updated to validate these new
behaviors.
2025-07-16 14:53:41 -07:00
Abtin Keshavarzian 23e54f680d [mle] refactor previous router/leader role restoration (#11728)
This commit updates `RestorePrevRole()` to directly start the
`RouterRoleRestorer` instead of calling `BecomeRouter()`.

Consequently, `BecomeRouter()` is simplified by removing the logic for
handling the `kRoleDetached` state. The method now focuses on the
child-to-router transition by sending an Address Solicit message, and
its initial role validation is made more explicit.

This change ensures the logic for restoring a previous router/leader
role is separate from the child-to-router transition logic.
2025-07-16 10:31:16 -07:00
Yakun Xu 5108ccdcf5 [size-report] correct the checkout ref (#11732)
The commit corrects the checkout ref to pull/<number>/merge, which is
the ref after merging and should be used for size checking.
2025-07-16 10:07:24 -07:00
Yakun Xu 2f1183f387 [git-tool] do not use GITHUB_TOKEN (#11730)
This commit stops using GITHUB_TOKEN in git-tool for better security.
2025-07-16 07:11:17 -07:00
Abtin Keshavarzian 6e1a6ff190 [mle] add Mle::Detacher class to manage graceful detach process (#11723)
This commit introduces a new `Mle::Detacher` class to encapsulate all
state and logic for the graceful detach process. By managing its own
internal state, timer, and completion callback, the `Detacher` class
centralizes the detach logic, improving code clarity and
maintainability.
2025-07-15 14:09:40 -07:00
Abtin Keshavarzian dbfc0cd94b [mle] register Message::TxCallback when sending "Child ID Req" (#11720)
This commit updates the mechanism for notifying the transmit
completion of a Child ID Request message.

Instead of `MeshForwarder` checking the message type and calling into
`Mle` upon transmit completion, `Mle::SendChildIdRequest()` now
registers a `TxCallback` directly on the message.

This change simplifies `MeshForwarder` by removing the need for it to
be aware of specific `Mle` message types.
2025-07-15 14:08:25 -07:00
Abtin Keshavarzian 5f623944b2 [mle] fix int conversion when setting TLV length (#11727)
This commit resolves a potential unsafe integer conversion warning by
explicitly casting the size of the status sub-TLV to `uint8_t` before
setting the length of the main TLV in
`SendLinkMetricsManagementResponse`.

Additionally, this change enables MLE_LINK_METRICS_SUBJECT_ENABLE`
feature in the `toranj` test configuration, allowing this feature to
be covered under its builds.
2025-07-15 12:18:53 -07:00
Yakun Xu d4734df8bb [size-report] checkout pull request head (#11724) 2025-07-15 10:48:46 -07:00
Abtin Keshavarzian e72e68a05e [mle] simplify requesting shorter Child ID Request msg (#11719)
This commit inlines `RequestShorterChildIdRequest()`  into its only
call site within `HandleChildIdRequestTxDone()`.
2025-07-15 08:04:46 -07:00
Yakun Xu 1803a957e2 [srp-server] skip looking for conflicts on host of the same key (#11716) 2025-07-15 07:46:07 -07:00
Abtin Keshavarzian 79d833ba3a [mle] avoid scheduling RetxTracker timer when disabled (#11721)
This commit adds a check in `RetxTracker::ScheduleTimer()` to ensure
the timer is not scheduled if MLE operations are disabled.

This change improves safety by handling an edge case during the
graceful detach process. In this scenario, a child sends a "Child
Update Request" with a zero timeout and, upon receiving a response,
immediately stops MLE. The added check prevents the retransmission
timer from being incorrectly scheduled after MLE has been stopped.
2025-07-15 07:41:36 -07:00
Abtin Keshavarzian f262475a49 [ip6] refactor Filter::Accept to Filter::Apply and return Error (#11714)
This commit refactors the IPv6 filter by renaming `Filter::Accept()`
to `Filter::Apply()` and changing its return type from `bool` to
`Error`.

The new method now returns `kErrorNone` for an accepted message and
`kErrorDrop` for a message that should be dropped. This change
improves clarity and aligns the filter's logic with the common
`SuccessOrExit` error handling pattern used throughout the codebase.
2025-07-15 07:39:50 -07:00
Abtin Keshavarzian bc4e3cdaa6 [check-size] use pull_request_target event to trigger post report (#11722)
This commit changes the workflow trigger event from `pull_request` to
`pull_request_target` so to match the event type that triggers the
`check-size` workflow.
2025-07-14 20:45:58 -07:00
Yakun Xu f4e239e651 [size-report] migrate to GitHub Actions (#11681) 2025-07-14 16:01:32 -07:00
Yakun Xu 579d834e0d [dnssd] limit TTL of Discovery Proxy result (#11687)
This commit limits the TTL of Discovery Proxy result according to RFC
8766 Section 5.5.1 and 5.6.
2025-07-14 16:00:26 -07:00
Abtin Keshavarzian 26f23ad635 [core] fix implicit integer conversion warnings (#11709)
This commit enables the `-Wimplicit-int-conversion` compiler flag for
`ftd`, `mtd`, and `radio` to improve code quality by detecting
potential data loss from implicit type conversions. This is enabled
when clang toolchain is used.

All resulting warnings have been addressed by either:
- Changing variable, parameter, or return types to ensure consistency
  and prevent overflows.
- Adding explicit `static_cast` where the type conversion is intended
  and safe.
2025-07-14 13:06:27 -07:00
Li Cao 02e73a0586 [format] enable simplify demorgan option (#11715) 2025-07-14 10:30:45 -07:00
Abtin Keshavarzian 5944b5e983 [mle] simplify HandleParentRequest (#11705)
This commit simplifies the `HandleParentRequest()`.

- The logic for detecting duplicate Parent Requests is made more
  readable by introducing the `kParentRequestDuplicateTimeout`
  constant.
- To reduce unnecessary log noise, checks like `IsRouterEligible()`
  or `!IsDetached()` no longer set and return an error. This
  prevents logging failure messages for conditions that are not
  actual errors.
- Verbose comments are removed in favor of self-documenting code.
2025-07-14 10:20:48 -07:00
Abtin Keshavarzian 8c9dd22d2c [mle] use uint32_t for delay parameter in DelayedSender (#11708)
This commit changes the `aDelay` parameter type in
`Mle::DelayedSender` methods from `uint16_t` to `uint32_t`.

This update supports specifying message transmission delays longer
than the previous 65-second limit and avoids potential implicit
integer downcasting.
2025-07-14 10:17:40 -07:00
dependabot[bot] 296034c25e github-actions: bump github/codeql-action from 3.28.19 to 3.29.2 (#11718)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/fca7ace96b7d713c7035871441bd52efbe39e27e...181d5eefc20863364f96762470ba6f862bdef56b)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.2
  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-07-14 10:00:48 -07:00
Yang Song e9b05b45a5 [nd6] correct comment for (#11717) 2025-07-14 08:19:38 -07:00
Zhanglong Xia 6bbcec9445 [diag] add a method IsFrameLengthValid() to check the frame length (#11712) 2025-07-14 08:18:59 -07:00
Jonathan Hui 9f88ca0288 [tests] explicitly disable border agent in test_publish_meshcop_service (#11713)
The `test_publish_meshcop_service` is updated to explicitly disable
the border agent before factory resetting `br`. This makes the
test more reliable by ensuring the MeshCoP service is unpublished.
2025-07-11 15:13:48 -07:00
Abtin Keshavarzian 23127fda98 [tests] explicitly enable/disable border agent in test_publish_meshcop_service (#11707)
The `test_publish_meshcop_service` is updated to explicitly disable
the border agent before stopping the `otbr-service`. This makes the
test more reliable by ensuring the MeshCoP service is unpublished
before stopping `otbr-service`.
2025-07-10 22:16:18 -07:00
Abtin Keshavarzian 406b1dee6e [instance] remove border agent disabling in Finalize (#11711)
This commit removes the explicit call to disable the `BorderAgent`
during instance finalization. This change prevents issues where the
call may trigger platform interactions that can fail due to the
platform layer being deinitialized before the `Finalize` is called.
2025-07-10 22:15:28 -07:00
Abtin Keshavarzian 72277d3ea3 [radio] fix clang-format (make-pretty) issue (#11710) 2025-07-10 20:50:28 -07:00
Li Cao 6c6e99ee7c [style] upgrade clang-format and clang-tidy from 14 to 16 (#11682) 2025-07-10 18:19:26 -07:00
Abtin Keshavarzian a9c2001bf1 [instance] improve shutdown sequence in Instance::Finalize() (#11706)
This commit enhances the instance shutdown sequence by explicitly
disabling the Border Agent in `Instance::Finalize()`.

Additionally, direct calls to the OpenThread C API, such as
`otThreadSetEnabled()`, are replaced with their corresponding C++
method calls, like `Get<Mle::Mle>().Stop()`.
2025-07-10 18:15:11 -07:00
Abtin Keshavarzian 8f67c5e72d [mle] refactor BecomeLeader to use enum for weight check (#11704)
This commit refactors the `Mle::BecomeLeader()` method to use a new
`LeaderWeightCheck` enum instead of a boolean parameter for checking
the leader weight.

The new enum, with values `kCheckLeaderWeight` and
`kIgnoreLeaderWeight`, makes the intent at the call sites more
explicit and improves code readability by avoiding the ambiguity of a
`true`/`false` flag. The functional behavior remains unchanged.
2025-07-10 18:13:45 -07:00
Abtin Keshavarzian 0d91ffc5ca [ip6] move Message::Ownership enum to Ip6 class (#11696)
This commit moves the `Message::Ownership` enum definition to the
`Ip6` class. This enum is exclusively used by the `Ip6` class to
determine whether to clone a message or take direct custody. This
model is not intended for use by other components. `OwnerPtr<>` is
the recommended approach for conveying ownership transfers.
2025-07-10 12:11:24 -07:00
Abtin Keshavarzian b0100b0268 [mle] simplify Reattach() implementation (#11695)
This commit simplifies the `Reattach()` method to improve readability.
The nested `if-else` statements are replaced with a `switch()` to
check `mReattachState`, and specific situations are handled with `if
(condition) { action; ExitNow(); }`.
2025-07-10 11:47:19 -07:00
Abtin Keshavarzian a01c9191c6 [test] relax mDNS query checks in border-router tests (#11698)
This commit relaxes the `border_router` test scripts that check mDNS
query results. The test will no longer fail if an expected record
does not appear in the additional section.

This change aligns with RFC 6763 section 12, which specifies that
additional records are recommended but not required. Particularly, a
TXT record is not recommended for an SRV query (section 12.2), and a
TXT query has no recommended additional records (section 12.3).

The test will now validate the additional record if it is present but
will not fail if it is absent.
2025-07-10 08:49:06 -07:00
Abtin Keshavarzian d2d644d470 [mdns] change SetEnabled() to be idempotent (#11690)
This commit changes the `SetEnabled()` API to return `kErrorNone` when
the component is already in the requested state (enabled or
disabled). Previously, the method would return `kErrorAlready` in
this scenario. Making this API idempotent simplifies caller logic, as
they no longer need to handle the `kErrorAlready` case.
2025-07-09 13:16:37 -07:00
kderda 852e5ac04b [diag] add diag sweep command (#11650)
This change introduces a new `diag sweep` command that iterates over
all channels and transmits a frame of a given length.
2025-07-09 10:52:06 -07:00
Zhanglong Xia 4764e6e714 [diag] deprecate otPlatDiagRadioTransmitDone() and otPlatDiagRadioReceiveDone() (#11615)
The radio platform API otPlatDiagRadioTransmitDone() and
otPlatDiagRadioReceiveDone() are the same with the API
otPlatRadioTxDone() and otPlatRadioReceiveDone(). This commit removes
the API otPlatDiagRadioTransmitDone() and otPlatDiagRadioReceiveDone()
to let the MAC layer and the diag module to use the same radio API to
send and receive 154 frames. So that the diag module could process the
ACK frame in the future.
2025-07-09 08:14:18 -07:00
Abtin Keshavarzian 87a919fd0a [mle] enhance role restoration logic in Start() (#11679)
This commit refactors `Mle::Start()` by moving the logic for restoring
the previous role into a new method, `RestorePrevRole()`.

This change simplifies the startup process and improves robustness by
adding more validation checks within `RestorePrevRole()`. The new
method ensures that the previously saved state information is
consistent before it is applied. For example, it verifies that
`mLastSavedRole` matches the saved RLOC16 and that parent information
is valid if the saved role was Child. These checks protect against
loading invalid settings and allow the device to start more quickly
by ignoring inconsistent state.
2025-07-08 22:50:40 -07:00
Abtin Keshavarzian 6e07db0898 [mdns] introduce auto-enable mode (#11669)
This commit introduces "auto-enable mode" in mDNS module. When this
mode is enabled, the mDNS module uses the same infrastructure network
interface as the Border Routing manager. The mDNS module is then
automatically enabled or disabled based on the operational state of
that interface. It is recommended to use the auto-enable mode on
Border Routers. New APIs and CLI commands are added to manage this
mode.

This commit also makes the if-index argument optional in `mdns enable`
CLI command. If an index is not provided, the command defaults to
using the Border Router's infrastructure interface. This help
simplify controlling the mDNS state in test scripts.
2025-07-08 17:03:17 -07:00
Abtin Keshavarzian 1bd98b7804 [netdata] enhance NetworkData::Service::Iterator (#11680)
This commit enhances the `NetworkData::Service::Iterator` class.
The `Iterator` is now a separate class from `Service::Manager`. It
provides `GetNextDnsSrpAnycastInfo()` & `GetNextDnsSrpUnicastInfo()`
methods, simplifying the code for iterating over these service
entries. The `Iterator` is also generalized to track a given
`NetworkData` instance, allowing it to iterate over service entries
on any `NetworkData` object, not just the Leader's.
2025-07-08 15:57:15 -07:00
Handa Wang a9b30754e4 [build] include necessary headers in spinel (#11683)
- Include `stdint.h` for `*int*_t` types. 
- Include `stddef.h` for `size_t` type.
2025-07-08 15:33:08 -07:00
Abtin Keshavarzian 85f0e8e0ac [energy-scan-server] use OwnedPtr to prevent memory leak (#11678)
This commit updates the `EnergyScanServer` to use an `OwnedPtr<>` for
its `mReportMessage` member.

This change ensures that the allocated report message is correctly
freed when the `otInstance` is destroyed, preventing a potential
memory leak.
2025-07-08 15:13:07 -07:00
Abtin Keshavarzian a2fb36cd0b [nexus] add mechanism to emulate node reset (#11662)
This commit adds a new mechanism to emulate a node reset on
`Nexus::Node`. This is realized by resetting all platform components
while ensuring the non-volatile `mSettings` remains unchanged, then
reinitializing the `ot::Instance` by invoking its constructor.

This is used to add a new `test_full_network_reset` test, which
emulates a full simultaneous reset of all nodes in a large network,
tracking how long it takes for the network to stabilize after the
reset event.
2025-07-08 15:10:30 -07:00
dependabot[bot] 64bc9f7ff6 github-actions: bump docker/setup-buildx-action from 3.10.0 to 3.11.1 (#11676)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.10.0 to 3.11.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2...e468171a9de216ec08956ac3ada2f0791b6bd435)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 3.11.1
  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-07-08 15:09:00 -07:00
Jonathan Hui 4781adaab8 [github-actions] remove use of Glitch from size check (#11684) 2025-07-08 13:43:25 -07:00
Abtin Keshavarzian 567c00217b [routing-manager] new API to get infrastructure interface info (#11667)
This commit introduces `otBorderRoutingGetInfraIfInfo()` to get the
interface index and running state of the configured infrastructure
interface. A corresponding CLI command is also added to retrieve this
information.
2025-07-07 13:08:51 -07:00
Abtin Keshavarzian cef5ec9c2d [mle] introduce RetxTracker to manage retransmissions (#11632)
This commit introduces `Mle::RetxTracker`, a new nested class that
encapsulates the state and logic for managing MLE message
retransmissions. It specifically handles retx of Child Update and
Data Request messages sent from a child to its parent, as well as the
periodic keep-alive Child Update tx from an rx-on-when-idle child.
This change centralizes all retransmission logic within
`RetxTracker`, replacing direct state manipulation and leading to a
cleaner, more modular design.

This change also includes the following improvements and fixes:

- The retransmission timeout (`kUnicastRetxDelay`) now includes a
  small random jitter.
- Fixes the logic for tracking the number of transmission attempts,
  ensuring the child detaches after `kMaxAttempts` (4) are reached.
  The previous code would incorrectly try one additional time
  (5 attempts).
- Tracks the transmission time of Data Requests and Child Updates
  separately. This ensures that periodic keep-alive Child Updates are
  sent at the correct time, even after a recent Data Request
  transmission.
- The `RetxTracker` is designed to be extensible for managing
  retransmissions of other message types in the future.
2025-07-02 17:48:53 -07:00
Abtin Keshavarzian 5856987084 [nexus] ensure platform components are initialized first (#11661)
This commit updates the `Nexus::Node` to initialize platform-specific
components first. This is achieved by defining them in a `Platform`
struct, which is inherited before `ot::Instance`.

This change ensures all platform components are ready and can be
safely used from the `Instance` constructor and any of its
sub-components.
2025-07-02 17:37:34 -07:00
Abtin Keshavarzian 309511c6b8 [mdns] make test_mdns more robust (#11668)
This commit updates the wait time in the `test_mdns` unit test to
handle a rare timing failure.

When a truncated message is sent, mDNS is expected to wait for a
random delay of at least 400ms. The test previously waited exactly
400ms before checking for emitted messages, leading to rare failures
if the random delay was precisely 400ms.

This change reduces the test's wait time to 399ms, ensuring it
correctly verifies that no message is emitted during the initial
delay period and making the test more robust.
2025-07-02 17:36:27 -07:00
Handa Wang 6e9fb76647 [nat64] schedule evaluation of policy when Nat64PrefixManager::Discover() fails (#11654)
Previously we were relying on the platform to call
`otPlatInfraIfDiscoverNat64PrefixDone` to trigger the evaluation of
NAT64 prefix. Since
https://github.com/openthread/openthread/pull/11481, we're no longer
doing proactive DNS-based prefix discoveries and it never calls the
callback `otPlatInfraIfDiscoverNat64PrefixDone`.

That means NAT64 evaluation can only happen when
`RoutingManager::EvaluateRoutingPolicy` is triggered, which can cause
a at most 3-minute delay (`kRaBeaconInterval`), between enabling NAT64
feature and the feature starts to work.

This commit triggers the evaluation of routing policy when
`Nat64PrefixManager::Discover()` fails to ensure the feature starts to
work on time.
2025-07-02 12:19:05 -07:00
Zhanglong Xia 63a083b523 [posix] fix the compile errors of src/posix/platform/alarm.cpp (#11658)
The definition of sMicroTimer and sRealTimeSignal are wrapped by the
__linux__, OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE and
!OPENTHREAD_POSIX_VIRTUAL_TIME.  But the code using these two
variables is not completely wrapped by these three macros. It causes
the compile errors in some conditions.

This commit wraps all the code that uses these two variables with
these three macros.
2025-07-02 12:17:55 -07:00
Abtin Keshavarzian 1ec9bce267 [mle] ignore Child Update Request when detached (#11656)
This commit updates `Mle` to ensure that a device ignores a
received "Child Update Request" message if it is currently detached.
This prevents the device from sending a "Child Update Response" in
this state. This behavior is particularly important when a device is
trying to restore its previous role as a router or leader.
2025-07-02 10:25:42 -07:00
Jonathan Hui e47122e5bb [tests] simplify check for mdns enable/disable output (#11664) 2025-07-01 22:10:00 -07:00
Jonathan Hui 68d603ef42 [tests] add support for enable/disable OT mdns (#11660) 2025-07-01 11:48:55 -07:00
Abtin Keshavarzian ef0e7bb858 [posix] add helpers in Mainloop to update Context (#11652)
This commit introduces new `Mainloop` helper functions. These helpers
can be used to update or check the read, write, and error file
descriptor sets (`fd_set`) or the timeout value within a
`Mainloop::Context`.
2025-06-30 21:38:45 -07:00
Abtin Keshavarzian cb90930632 [mdns] improve local host address logging (#11651)
This commit refines the logging of local host address events in the
`Mdns` module.

Address update events signaled from the platform layer are now logged
at the `Debug` level instead of `Info`. This avoids excessive logging
from platform implementations that use periodic polling for address
monitoring.

Instead, after the events are processed, an `Info` level log is now
generated only if the address list has changed. This new log
specifies which addresses were added or removed. Additionally, the
format for IPv4 addresses (tracked as IPv4-mapped IPv6 addresses) is
updated to use the standard dotted-decimal notation, making the logs
easier to read.
2025-06-30 14:41:10 -07:00
Abtin Keshavarzian 6f434cea61 [posix] add netlink-based address monitoring to MdnsSocket (#11645)
This commit adds a netlink-based address monitoring strategy,
`OT_POSIX_MDNS_ADDR_MONITOR_NETLINK`, to `Posix::MdnsSocket`. This is
provided as an alternative to the periodic poll-based approach
introduced in PR #11641.

With this model, `MdnsSocket` reports the initial list of IPv4/IPv6
addresses on the infrastructure network interface. It then uses a
`NETLINK_ROUTE` socket to listen for `RTM_NEWADDR` and `RTM_DELADDR`
events, signaling any subsequent address changes to the mDNS module.
2025-06-30 14:40:45 -07:00
Abtin Keshavarzian a495a2284b [otns] make various enhancements to Otns (#11643)
This commit contains various enhancements to the `Otns` class:

- Makes `Otns` methods non-static. This aligns their use with the
  clang-tidy `readability-static-accessed-through-instance` check,
  which disallows accessing static methods through an instance.
- Updates the `make-pretty` script to enable OTNS and include it in
  `clang-tidy` checks.
- Adds a stub implementation of `otPlatOtnsStatus()` in the simulation
  and fake platforms. This allows the OTNS feature to be enabled in
  `make-pretty` builds and covered by GitHub Action CI checks.
- Simplifies the `EmitStatus` methods to use the `String` class for
  constructing the status string.
- Adds a new helper method to construct the CoAP status string,
  removing duplicated code.
2025-06-30 14:39:30 -07:00
dependabot[bot] 0093b9caf5 github-actions: bump actions/upload-artifact from 4.6.1 to 4.6.2 (#11655)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.1 to 4.6.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1...ea165f8d65b6e75b540449e92b4886f43607fa02)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 4.6.2
  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-06-30 09:21:10 -07:00
Yakun Xu 38cfb2fddc [cert-test] support parsing multiple keys (#11618) 2025-06-30 08:48:40 -07:00
Jonathan Hui 516a95fca9 [toranj] remove duplicate define (#11644) 2025-06-27 11:46:09 -07:00
Abtin Keshavarzian e06a5bbb11 [posix] implement address monitoring in MdnsSocket (#11641)
This commit introduces an initial implementation in `Posix::MdnsSocket`
to monitor and report all IPv4 and IPv6 addresses assigned to the
infrastructure network interface. This mechanism is used by OpenThread's
native mDNS module and was added in PRs #11353 and #11394.

A new configuration, `OPENTHREAD_POSIX_CONFIG_MDNS_ADDR_MONITOR`, is
added to select the monitoring strategy. This commit implements the
`OT_POSIX_MDNS_ADDR_MONITOR_PERIODIC` approach, where `getifaddrs()`
is used to enumerate addresses periodically. The polling interval
is configured by `OPENTHREAD_POSIX_CONFIG_MDNS_ADDR_MONITOR_PERIOD`.

Note that the OpenThread mDNS module itself tracks the list of
reported addresses and will only take action when there is a change
from what was previously announced. This allows the platform to
simply report the full list of current addresses at each interval.
2025-06-26 13:41:44 -07:00
Jason Zhang 02da4ce5c6 [cli] fix command format in netdata README (#11642)
This commit fixes formatting issues in the netdata CLI README files to
improve clarity and correctness of the documentation.

The changes include:
- Adding the '>' prompt character to CLI command examples where it was
  missing.
- Specifying 'bash' as the language for code blocks to enable proper
  syntax highlighting.
- Remove an extra colon
2025-06-26 08:36:18 -07:00
Jonathan Hui f390da0c94 [tests] fix spelling errors (#11640) 2025-06-25 17:07:30 -07:00
Abtin Keshavarzian b794b28614 [posix] reorder declarations in MdnsSocket (#11639)
This commit rearranges the method and member variable declarations in
the `Posix::MdnsSocket` class to follow the recommended order, i.e.,
methods before member variables.
2025-06-25 16:48:53 -07:00
Abtin Keshavarzian 5b2bcee271 [srp-client] enhance single service mode (#11634)
This commit enhances the `Srp::Client` "single service mode". This
mode is enabled when a prepared SRP update message exceeds the IPv6
MTU size. In this mode, the client registers its services one by one,
with each SRP update containing only a single service.

The implementation is simplified by changing the `mSingleServiceMode`
flag from a persistent member variable of the `Client` class to a
field within the `MsgInfo` struct, making its scope
message-specific.

State transitions are now correctly applied to host and service
entries when operating in single service mode. This, in turn, helps
ensure that SRP message transaction IDs are managed correctly: the
same ID is used for retries of an unchanged service, while a new ID
is used if the service information has changed.

Finally, a new test case, `TestSrpClientSingleServiceMode`, is added
to `test_srp_server` to cover this behavior and its associated retry
logic in detail.
2025-06-25 16:45:49 -07:00
Abtin Keshavarzian c55098af5e [message] change queues to use non-circular linked list (#11630)
This commit updates the `MessageQueue` and `PriorityQueue`
implementations to use non-circular doubly linked lists instead of
the previous circular ones. Using a non-circular list requires the
queue to track the head element, but it simplifies common operations
like getting the head and iterating over the messages.

Particularly, `Message::GetNext()` now simply returns the `mNext`
pointer. Previously, `Message` had to store a pointer to its `mQueue`
within its `Metadata` to identify the tail of the queue and stop the
iteration correctly.

This commit also updates the unit tests. In particular,
`test_priority_queue` is significantly enhanced to cover many
scenarios, such as multiple messages with the same priority, and
messages with different priorities being added and removed in various
orders.
2025-06-25 13:03:43 -07:00
Yakun Xu 5d1d380012 [style] include include cleaner (#11635) 2025-06-25 12:22:05 -07:00
Abtin Keshavarzian 3aab10a8fb [srp-client] update message ID assignment model (#11592)
This commit updates the SRP client message ID assignment model.
Message IDs are now selected randomly, ensuring they differ from the
last ID used. The same message ID is reused when a message is
retried.

This replaces the earlier design where all messages, including
retries, used sequential message IDs.

The unit test is also updated to validate the new behavior.
2025-06-24 12:10:45 -07:00
Abtin Keshavarzian 84295be3f8 [message] add TxCallback to track transmission outcome (#11614)
This commit introduces new public APIs to register a `TxCallback` on a
message to be notified of its transmission outcome.

The callback is invoked with an error code indicating the transmission
status of the IPv6 message to an immediate neighbor (a one-hop
transmission). It does not indicate that the message was received by
its final, multi-hop destination.

For a unicast IPv6 message, a success (`OT_ERROR_NONE`) indicates that
the message, including all its corresponding fragments if applicable,
was successfully delivered to the immediate neighbor and a MAC layer
acknowledgment was received for all fragments. This is reported
regardless of whether the message is sent using direct or indirect
transmission (e.g., to a sleepy child via CSL or a data poll).

For a multicast message, an `OT_ERROR_NONE` status indicates that the
message and all its fragments were successfully broadcast. Note that
no MAC-level acknowledgment is required for a broadcast frame
transmission.
2025-06-24 09:37:15 -07:00
Abtin Keshavarzian 093d2a8427 [dhcp6-pd-client] initialize msgType to fix compiler warning (#11631)
This commit updates `SendMessage()` to initialize the `msgType`
variable before the `switch` statement.

This change addresses a compiler warning for a possibly uninitialized
variable, flagged by `-Werror=maybe-uninitialized`.

Note that the situation where `mState` would be an undefined value is
not technically possible in the current logic. However, the compiler
cannot guarantee this and therefore generates a warning. Initializing
the variable upfront resolves this issue.
2025-06-24 09:30:08 -07:00
Abtin Keshavarzian c6f3f1ff31 [message] disallow SetPriority() on enqueued messages in PriorityQueue (#11624)
This commit modifies `Message::SetPriority()` to prevent changing a
message's priority after it has been enqueued in a `PriorityQueue`.
Attempting to do so will now return `kErrorInvalidState`.

The functionality for altering the priority of an already-enqueued
message is not currently used or required. Should this behavior
become necessary in the future, the recommended approach is to
explicitly dequeue the message first, then change its priority, and
finally re-add it to the queue. This makes the intended behavior
clearer and more explicit within the code.

This commit also updates the `test_priority_queue` unit test to
reflect this change.
2025-06-23 13:15:53 -07:00
dependabot[bot] 7617b602b6 github-actions: bump actions/setup-python from 5.5.0 to 5.6.0 (#11626)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.5.0 to 5.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/8d9ed9ac5c53483de85588cdf95a591a75ab9f55...a26af69be951a213d495a4c3e4e4022e16d87065)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.6.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-06-23 08:13:50 -07:00
Abtin Keshavarzian 984b3cb1c8 [mle] remove kReattachStart from ReattachState enum (#11609)
This commit simplifies the code by removing the `kReattachStart` state
from the `ReattachState` enumeration. This enum is used after MLE
`Start()` to track whether to attempt to attach using a persisted
Active or Pending Dataset.

Previously, `kReattachStart` was a transitory state set in `Start()`
and then changed in the `Attach()` method to either `kReattachActive`
 or `kReattachStop`, based on whether the device had a saved Active
 Dataset.

This change simplifies the code by determining the state directly in
`Mle::Start()`, which allows for the removal of the now unnecessary
`kReattachStart` case.
2025-06-23 07:50:14 -07:00
Abtin Keshavarzian c221dae3e4 [test] ensure v1_2_test_backbone_router_service.py uses correct seqno (#11621)
This commit ensures `v1_2_test_backbone_router_service.py` uses the
correct logic for checking the next seq number.
2025-06-23 07:39:48 -07:00
Abtin Keshavarzian f90d50b220 [dhcp6] implement DHCPv6 Prefix Delegation (PD) client (#11584)
This commit introduces the `Dhcp6PdClient` class, which implements
DHCPv6 Prefix Delegation (PD) client functionality. It integrates
with `BorderRouter::RoutingManager` and its `PdPrefixManager`
sub-component. The CMake `OT_BORDER_ROUTING_DHCP6_PD_CLIENT` mapped
to `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` config
enables this feature.

Previously, the platform layer was expected to implement client
functionality, acquiring and providing the delegated prefix(es) to
the OT stack using `otPlatBorderRouter*` callbacks. This approach
continues to be supported. The `Dhcp6PdClient` feature adds native
support for this functionality in the OpenThread core.

The `Dhcp6PdClient` implementation follows RFC 8415, focusing on
prefix delegation and all required behaviors. The client follows the
standard four-message Solicit/Advertise/Request/Reply exchange to
obtain a delegated prefix, followed by a two-message Renew/Reply or
Rebind/Reply exchange to extend the lifetime of the delegated prefix.
When the prefix is no longer needed, a two-message Release/Reply
exchange ends its lease. The current client implementation does not
support the optional "Reconfigure Accept" mechanism.

A set of `otPlatInfraIfDhcp6PdClient*` platform APIs are also
introduced for use by the `Dhcp6PdClient`. These APIs are used to
enable or disable listening for DHCPv6 messages and to handle sending
and receiving them on the standard client and server UDP ports
(546 and 547), effectively acting as a UDP socket.

This commit also includes a comprehensive unit test covering various
aspects of `Dhcp6PdClient`, including common behaviors and many
specific edge cases.
2025-06-20 19:35:44 -07:00
Abtin Keshavarzian faadc5baed [message] remove MessagePool from the Message::Metadata (#11616)
This commit simplifies the `Message::Metadata` so that it no longer
tracks the `MessagePool`. Instead the `Message` now tracks the
`ot::Instance` it is associated with and acts as a `GetProvider`,
allowing access to any component within `Instance`, including
the `MessagePool`.
2025-06-20 19:21:30 -07:00
Abtin Keshavarzian 6d0618fc78 [routing-manager] enhance peer BR count tracking and signaling (#11594)
This commit enhances how changes in the number of reachable peer
Border Routers (BRs) are tracked and signaled. This tracking is
handled by `RxRaTracker` and utilized by the `MultiAilDetector` to
determine if BRs are connected to different AILs.

The `RxRaTracker::DecisionFactors` class now includes and tracks
`mReachablePeerBrCount`. This value is updated in the `Evaluate()`
method, which is invoked upon any change to the internal state
tracked by `RxRaTracker` (e.g., changes in discovered prefixes or
routers). This ensures that any change in the number of peer BRs is
promptly detected and signaled to other sub-components, allowing them
to update their state or take necessary actions.
2025-06-18 23:17:41 +09:00
Handa Wang e99a523726 [routing-manager] remove duplicate logging of RA header (#11604) 2025-06-18 23:10:42 +09:00
Yakun Xu 41320dc809 [license] fix typo (#11608) 2025-06-18 23:09:47 +09:00
dependabot[bot] c11e0f4659 github-actions: bump codecov/codecov-action from 5.4.2 to 5.4.3 (#11597)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/ad3126e916f78f00edff4ed0317cf185271ccc2d...18283e04ce6e62d37312384ff67231eb8fd56d24)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.3
  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-06-17 21:32:17 +09:00
Yakun Xu 48407719cd [crypto] avoid directly include config/crypto.h (#11603)
This commit avoids directly including `config/crypto.h` which breaks
configuration in project headers.
2025-06-17 21:06:48 +09:00
Yakun Xu a640f85db8 [posix] reliable transport for virtual time (#10984)
This commit changes the virtual time event transport from UDP to
SEQPACKET unix socket to ensure events are delivered successfully.
2025-06-17 21:05:24 +09:00
Yakun Xu b945928d72 [gn] move gn build into etc (#11577) 2025-06-17 14:21:37 +09:00
xusiyu 3dd19d9123 [trel] fix a format error of log (#11586)
According to precedents in other parts of the OpenThread source code,
a 32-bit unsigned integer should be printed using `%lu` instead of
`%u`.
2025-06-17 13:48:17 +09:00
Abtin Keshavarzian 3fd719063f [posix] fix MdnsSocket iteration over message queue (#11599)
This commit updates how `MdnsSocket::SendQueuedMessages()` iterates
over the message queue. The iteration is changed to get the next
message before processing the current one. This is necessary because
the current message may be dequeued and freed within the loop, which
would invalidate the pointer to the next message.
2025-06-17 13:47:05 +09:00
Abtin Keshavarzian aab0c29793 [mle] move AnnounceHandler methods together (#11598)
This commit moves the `Mle::AnnounceHandler` methods to be located
together in the same section.

The `AnnounceHandler` sub-component was added in a previous commit,
but its methods were intentionally left in their original locations
to keep the `git diff` small and easy to review. This change simply
relocates the methods to their proper place and includes no logical
modifications.
2025-06-17 13:46:29 +09:00
Abtin Keshavarzian 00e4e42c57 [cli] fix output of fractional part of ping average round-trip time (#11587)
This commit addresses an issue where the fractional part of the ping
average round-trip time (RTT) was not consistently formatted.
Previously, it used ".%u" with `(avgRoundTripTime % 1000)` which
could omit leading zeros for fractional values. It now uses ".%03u"
to ensure three digits are always displayed, padding with leading
zeros when necessary.
2025-06-17 13:45:49 +09:00
Rongli Sun 8a19434b8a [routing-manager] enhance MultiAilDetector (#11589)
This commit counts only reachable peer BRs for quick multi-AIL detection
when peer BR moves to a different infrastructure link.
2025-06-12 22:03:48 +09:00
Jason Zhang baf13fc994 [posix] fix region configuration loading order (#11585)
Fix the initialization order in ProcessRadioUrl() to ensure that
configuration files are loaded before region settings are applied.

Previously, the region code was set before configuration files
(product-config-file and factory-config-file) were processed. This
caused region-specific settings such as target power to be applied
from stale configuration data rather than the newly loaded
configuration file.

The fix reorders the parameter processing sequence:
1. Basic radio parameters (fem-lnagain, cca-threshold)
2. Configuration file loading (product-config-file, factory-config-file)
3. Region setting (region)
4. Other parameters (bus-latency, max-power-table, coex settings)

This ensures that when a region is set, it will use the correct
configuration data from the newly loaded files, allowing region-specific
power settings and other parameters to be properly refreshed.

Change-Id: Idcf16d194eea65d3efe3ae380d6fa90e71bd5499
2025-06-11 06:38:06 +09:00
Yakun Xu 6b03321cb2 [style] apply IWYU to public headers (#11580)
It would be easier to use OpenThread public headers if they are
self-contained and follows the IWYU style guide. This commit fixes some
style issues to make the public headers self-contained and IWYU. The
existing pretty check is also extended to verify the OpenThread public
headers are self-contained and follows IWYU.
2025-06-11 06:37:41 +09:00
Yakun Xu c8714060ea [test] stabilize Cert_5_1_05_RouterAddressTimeout (#11564)
With the router restoration, longer delay is expected. This commit
defines the router restoration delay and apply it on the unstable test
case Cert_5_1_05_RouterAddressTimeout.
2025-06-10 22:09:33 +09:00
dependabot[bot] b0e7b14963 github-actions: bump github/codeql-action from 3.28.18 to 3.28.19 (#11581)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.18...fca7ace96b7d713c7035871441bd52efbe39e27e)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.19
  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-06-10 06:34:22 +09:00
Abtin Keshavarzian cbb04be4a6 [routing-manager] use consistent Dhcp6Pd term & update unit test (#11579)
This commit renames DHCPv6-PD related types and methods in
`RoutingManager` to consistently use the `Dhcp6Pd` term.

This commit also updates the related unit test in
`test_routing_manager`. The test is renamed to `TestDhcp6Pd()`, and
the code style is updated to align with other test cases in the same
file. No changes are made to the actual test steps or what is covered
by the test itself. The method for reporting PD prefixes to the
OpenThread stack is modified within the unit test. Instead of using
`otPlat` APIs, `RoutingManager` methods are now directly invoked.
This helps make the unit tests independent of the configuration,
allowing for more flexible models where platform-provided APIs may
not be provided (e.g., DHCPv6 client as part of OpenThread code).
2025-06-10 06:24:23 +09:00
Yakun Xu 6191d3b139 [otci] support reliable transport (#11575)
This commit adds reliable transport in OTCI and switch the OTCI tests to
use the reliable simulation transport.
2025-06-06 09:11:34 -07:00
Li Cao 7d64173fd3 [history-tracker] add missing UpdateAgedEntries() method to EntryList (#11576)
Adds missing method `UpdateAgedEntries` for the template
specialization of `EntryList` when size is 0.
2025-06-06 09:08:47 -07:00
Yakun Xu 1662ca8001 [simulation] add reliable virtual time transport (#11029)
This commit adds a reliable transport based on SEQPACKET unix socket to
simulation platform and use this for tests on simulation platform.
2025-06-04 23:32:25 -07:00
Abtin Keshavarzian a1de12fd49 [dhcp6] introduce Option::Iterator class (#11574)
This commit adds the `Option::Iterator` class for searching for and
iterating over DHCPv6 options with a specific code within a message.
The iteration can cover the entire message or be constrained to a
given `OffsetRange`.

The `Option::Iterator` is used to simplify the `Dhcp6::Client` and
`Dhcp6.Server` implementations, particularly when iterating over
`IaAddressOption`s within an `IaNaOption`.
2025-06-04 23:30:42 -07:00
Lucien Zürcher 4b43f6de76 [coap] match only token for multicast and anycast (#11570) (#11571) 2025-06-04 17:20:01 -07:00
Yakun Xu 5201231daa [test] fix warning of escape in regex string (#11566) 2025-06-04 13:35:36 -07:00
Jonathan Hui 206698702d [fuzz] load only value enum values (#11573) 2025-06-04 13:25:32 -07:00
Jonathan Hui 5c8351b43d [github-actions] update fuzz workflow to latest recommended (#11563) 2025-06-04 11:21:26 -07:00
Jonathan Hui 45fc50cb2e [fuzz] allow border router services to start (#11561) 2025-06-04 11:19:35 -07:00
Yakun Xu a1e170cb94 [routing-manager] fix typo (#11568) 2025-06-04 07:32:53 -07:00
Abtin Keshavarzian 7533b1d93a [secure-transport] add ~SecureTransport() destructor (#11562)
This commit adds a destructor for `SecureTransport` that closes the
socket, and disconnects and removes any tracked sessions.

Removing the sessions ensures that the `SecureSession` instances and
any data allocated within them are properly freed. This handles the
case where the `otInstance` itself is destroyed, ensuring that all
heap-allocated items are cleaned up correctly to prevent memory
leaks.
2025-06-03 22:34:22 -07:00
Yakun Xu 2ae5522bed [style] avoid deprecated setDaemon (#11565) 2025-06-03 22:33:17 -07:00
Abtin Keshavarzian e4ac7162eb [mle] introduce AnnounceHandler class (#11558)
This commit introduces the `AnnounceHandler` class within `Mle` to
encapsulate logic for handling Announce messages. This change
simplifies the `Mle` module and makes the code easier to read and
follow.

The `AnnounceHandler` class handles received Announce messages with a
newer timestamp and different channel and/or PAN ID. It can delay
processing to collect and handle subsequent Announce messages.

It also manages starting the "announce attach" process, where the device
attempts to attach using the parameters from a processed Announce
message.
- If the attach is successful, this class sends an Announce on the old
  channel to inform other devices. This is done immediately after
  attaching as a MTD child or after a router transition attempt
  completes (on FTD).
- If the attach fails, the class ensures the channel and PAN ID are
  restored to their original values.

In particular, the new `AnnounceHandler` uses its own `Timer` to delay
the start of an announce attach. Previously, the `AttachTimer` was
repurposed for this, in addition to its use for attach state
management.
2025-06-03 13:33:49 -07:00
Abtin Keshavarzian 18c731764a [dhcp6] enhance DUID parsing and generation (#11559)
This commit updates and enhances the parsing and generation of the
DHCPv6 DUID in Client/Server Identifier Options.

DHCPv6 DUIDs can be specified in a variety of ways, and clients and
servers must treat them as opaque values that are compared for
equality. This change adds an `Eui64Duid` type to represent a DHCPv6
DUID based on the EUI-64 Link-Layer address format (DUID-LL).

A set of common helper methods are added to parse, match, and append
the DUID in a Client or Server Identifier option:
- `ReadDuid()`: Reads the raw DUID as a blob of data.
- `ReadAsEui64Duid()`: Reads a DUID, validating that it follows the
  DUID-LL format, and parses the EUI-64 address.
- `MatchesEui64Duid()`: Reads a DUID and checks that it matches a
  given EUI-64 address.
- `AppendWithEui64Duid()`: Appends a Client/Server ID option with a
  DUI using the DUID-LL format.

This commit also introduces `Option::AppendOption()` which appends a
DHCPv6 Option with a given code and data to a message.

These methods are then used to simplify the `Dhcp6::Server` and
`Dhcp6::Client` code.
2025-06-03 10:46:48 -07:00
Jonathan Hui 4e52d8eb7c [nexus] add missing case in ConnectEventToString() (#11560) 2025-06-03 10:43:57 -07:00
Esko Dijk 1804273276 [posix] set sin6_scope_id / ipi6_ifindex for all transmits to link-local (#11555)
This will avoid the problem that scope id or ifindex remains 0 for a
link-local transmission. If 0, the OS cannot decide which network
interface to use based on address alone.
2025-06-03 09:22:41 -07:00
Esko Dijk 151cf324bc [tcp][posix] ensure struct fields are initialized (#11552)
This aims to fix some instances in core/tcp6 and posix/udp where the
complete struct was not initialized. In otPlatUdpJoinMulticastGroup
and otPlatUdpLeaveMulticastGroup an explicit redundant setting to '0'
is added just for clarity for people reading the code.
2025-06-03 08:24:09 -07:00
Tony Zhou 5050bec030 [cli] add "dataset active|pending -ns" support (#11518)
This CLI command argument "-ns" prints out the dataset fields and
redact the sensitive values, including the network key and PSKc
fields.
2025-06-03 08:20:49 -07:00
Li Cao ea3a3da0ee [border-agent] add epskc journey statistics (#11530)
This commit adds some new statistics for ePSKc to show the time
duration of various sub process during the credential sharing.

A Nexus unit test is added to verify the stats are counted correctly.

A few small points to be noted:
* The `StopReason` which was used internally in `EphemeralKeyManager`
  is renamed as `DeactivationReason`, defined as public and is mapped
  to the public enum `otHistoryTrackerEpskcDeactivationReason`.
* The original reason `Timeout` is renamed to `SessionTimeout` to
  indicate this is a timeout of the secure session. This is to
  differentiate with the epskc mode timeout.
* A new reason `EpskcTimeout` to indicate the timeout is due to epskc
  mode timeout.
2025-06-02 22:23:07 -07:00
Jonathan Hui f9be8f76ee [fuzz] enable border router services (#11557)
- Border Routing Manager
- DHCPv6 PD
- NAT64
- SRP Server
- TCP
2025-06-02 15:58:25 -07:00
Yang Song 7fb682f928 [posix] fix misleading log message in DNS resolver (#11545)
The log message "No domain name servers found in %s, default to
127.0.0.1" is misleading because the code does not actually default to
127.0.0.1 if no nameservers are found.

This commit updates the log message to accurately reflect the
behavior.
2025-06-02 15:22:17 -07:00
Abtin Keshavarzian eb8a926037 [routing-manager] simplify PD prefix processing (#11554)
This commit simplifies the processing of PD prefixes provided by the
platform to `PdPrefixManager`. The platform can report DHCPv6 PD
prefixes in two ways: through a Router Advertisement (RA) message
containing Prefix Information Options (PIOs) or by providing a PD
prefix directly.

Previously, these two paths were processed in a single method, which
made the code harder to read and follow. This commit refactors the
logic to separate these two paths while using common helper methods.

This change introduces `EvaluateCandidatePrefix()`, which evaluates a
single candidate prefix and tracks the most favored one. After all
candidates are evaluated, `ApplyFavoredPrefix()` is called to apply
the most favored prefix and update the current PD prefix if
necessary.
2025-06-02 12:55:02 -07:00
Abtin Keshavarzian 02b8b2cda6 [dhcp6] add helper methods for option parsing and generation (#11551)
This commit introduces new helper methods for DHCPv6 Option parsing
and generation.

- It adds `Option::FindOption()` to search and parse the first DHCPv6
  option with a given code within a specified range of a `Message`.
- It also adds `Option::UpdateOptionLengthInMessage()`, which updates
  the Option length in a message based on the number of  bytes
  appended, simplifying the appending of variable-length options
  (e.g., `IaNaOption`, which can contain multiple sub-options).
- Additionally, `StatusCodeOption::ReadStatusFrom()` is added to read
  the status code from a Status Code Option in a specified range
  within a `Message`. The absence of a Status Code option implies
  success.
- Helper methods to search for and append `RapidCommitOption` are also
  included.

These new helper methods are then used by `Dhcp6::Server` and
`Dhcp6::Client`, simplifying the code, particularly for processing
options in received DHCPv6 messages.

This commit also adds a new `test-036-dhcp-prefix-netdata.py` test to
validate the publishing of prefixes with the DHCP flag in Network
Data and the behavior of the DHCPv6 client and server.
2025-06-02 12:51:48 -07:00
Abtin Keshavarzian c2de9f646a [trel] manage mDNS/DNSSD and peer discovery in core (#11528)
This commit enhances the TREL module to manage mDNS/DNSSD service
registration and peer discovery (browse and resolving for TREL
services). This feature can be controlled through
`OPENTHREAD_CONFIG_TREL_MANAGE_DNSSD_ENABLE` (and/or the CMake option
`OT_TREL_MANAGE_DNSSD`).

When enabled, TREL will utilize the `Dnssd` module, which provides
mDNS-related APIs. This can be tied to OpenThread's native mDNS
implementation or to `otPlatDnssd` (i.e., provided by the platform
layer).

This commit also adds support for the TREL platform in the `Nexus`
test framework and uses this to add a detailed `test_trel` case. This
test covers basic TREL peer discovery and operation, along with
specific scenarios such as peer removal delay, delayed mDNS start,
TREL service name conflict resolution, host address changes, and
supporting multiple services on the same host (while unlikely in
actual deployments, this can be useful for testing and simulation
where a single machine may act as multiple Thread nodes, thus
advertising multiple TREL services from the same hostname. This is
explicitly supported by the implementation and covered in the
tests).
2025-06-02 12:45:39 -07:00
Yang Song c020f86230 [posix] DNS resolver to handle link-local server address (#11548)
When `sendto` is used with a Link-Local IPv6 destination, the index of
the outgoing network interface must be included.
2025-06-02 11:09:27 -07:00
Abtin Keshavarzian a7a45b0913 [secure-transport] add ~SecureSession(void) destructor (#11553)
This commit adds a destructor for `SecureSession` which ensures the
freeing of any mbedTls allocated items. This addresses memory leaks
detected by fuzzer tests when `otInstance` is destroyed, though this
situation is unlikely in typical OpenThread stack integrations.
2025-06-02 10:07:08 -07:00
dependabot[bot] 634605f940 github-actions: bump docker/build-push-action from 6.17.0 to 6.18.0 (#11556)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.17.0 to 6.18.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/1dc73863535b631f98b2378be8619f83b136f4a0...263435318d21b8e681c14492fe198d362a7d2c83)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 6.18.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-06-02 08:56:19 -07:00
Abtin Keshavarzian de0739239b [message] add destructors for MessageQueue and PriorityQueue (#11550)
This commit adds destructors for `MessageQueue` and `PriorityQueue`.
This ensures that allocated `Message` instances in different queues
are freed when the `ot::Instance` is destroyed.
2025-05-30 14:06:26 -07:00
Abtin Keshavarzian 2bc5eec091 [notifier] streamline event delivery to core modules (#11546)
This commit updates the `Notifier` to directly signal events to
`BackboneRouter::Leader`, `Dhcp6::Server`, `Dhcp6::Client`, and
`NeighborDiscovery::Agent`. These classes were previously notified
indirectly through `Mle::HandleNotifierEvent()`.
2025-05-30 14:04:33 -07:00
Jonathan Hui cbe3654ce7 [fuzz] avoid undefined enum values (#11549) 2025-05-30 11:18:22 -07:00
Jason Zhang 16d9b2ad2a [posix] add runtime configuration file path support (#11514)
This commit enhances the POSIX platform configuration system to support
dynamic configuration file paths at runtime instead of only build-time paths.

ConfigFile class:
- Replace const char* mFilePath with char mFilePath[kFilePathMaxSize] to allow
  dynamic path updates after construction
- Add SetFilePath() and GetFilePath() methods
- Update constructor to use SetFilePath() with proper bounds checking

Configuration class:
- Add SetFactoryConfigFile() and SetProductConfigFile() methods to update
  factory and product config file paths

Radio URL parameter support:
- Add support for 'product-config-file' parameter in radio URL
- Add support for 'factory-config-file' parameter in radio URL
2025-05-29 21:52:07 -07:00
Abtin Keshavarzian 3a31754ee5 [dhcp6] style fixes and minor enhancements (#11543)
This commit contains style fixes and smaller enhancements in
DHCP6-related definitions and types. Mainly, the DHCP6 `Option`
sub-classes are renamed to include the `Option` suffix
(e.g., `IaAddressOption`), harmonizing the naming style with `Tlv`
and other `Option` classes (e.g., `Nd6` or `Dns` options).
2025-05-29 19:58:40 -07:00
Abtin Keshavarzian 976c2bc4a6 [trel] explicitly request trel ack for broadcast tx to known neighbors (#11537)
This commit modifies the TREL module to explicitly request TREL acknowledgements
for broadcast transmissions directed to known neighbors. This ensures quicker
discovery of when a TREL peer is no longer available.
2025-05-29 19:00:22 -07:00
Jonathan Hui 6d40977782 [fuzz] migrate fuzz framework to nexus platform (#11538) 2025-05-28 18:32:04 -07:00
Abtin Keshavarzian 1798f3b61c [dhcp6-client] remove undefined method declaration (#11539)
This commit removes an undefined method declaration in `Dhcp6::Client`
and inlines a simple method used for prefix checks.
2025-05-28 18:13:10 -07:00
Abtin Keshavarzian 0216b59fe1 [nexus] add support for otPlatMdns APIs simulation (#11529)
This commit updates `Nexus` simulation platform to implement and
emulate `otPlatMdns` APIs. This allows Nexus test cases to be
written which require and use the OpenThread's native mDNS.

This commit also enhances `test_border_agent` to validate that the
Border Agent's registered `_meshcop._udp` can be queried and
resolved (using mDNS) from other devices.
2025-05-28 18:03:39 -07:00
Jonathan Hui 7cbfb8edc9 [error] cast aError to size_t (#11533) 2025-05-27 21:31:01 -07:00
Jonathan Hui a2f783e6d5 [mac] avoid logging frame that has not been validated (#11532) 2025-05-27 21:30:41 -07:00
Rongli Sun 8c70c780c8 [log] suppress NOTE level logs to avoid log spam in user build (#11507) 2025-05-26 17:07:29 -07:00
Jonathan Hui fb4ca09759 [docker] remove android-trusty (#11525) 2025-05-26 17:03:38 -07:00
dependabot[bot] d8d862f8e5 github-actions: bump actions/setup-go from 5.4.0 to 5.5.0 (#11531)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/0aaccfd150d50ccaeb58ebd88d36e91967a5f35b...d35c59abb061a4a6fb18e82ac0862c26744d6ab5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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-05-26 17:03:23 -07:00
Jason Zhang de8974aca4 [docs] add guide on using python venv for cp-caps test (#11520)
Added comprehensive Python virtual environment setup guide to the
cp-caps README.md file.

This includes detailed sections for creation, activation, dependency
installation, and deactivation of virtual environments to help users
properly set up their testing environment and avoid package conflicts.
2025-05-23 09:52:38 -07:00
Abtin Keshavarzian 02390412cf [type-traits] add IsUint<Type> and IsInt<Type> (#11513)
This commit adds `TypeTraits::IsUint<Type>` and `IsInt<Type>` to
determine (at compile time) whether a given `Type` is an unsigned or
signed integer type (8, 16, 32, or 64 bit length). These help
simplify `static_assert()` checks in template methods that work
with integer types.
2025-05-22 19:31:32 -07:00
Abtin Keshavarzian f560c35fab [test] relax checks in test_publish_meshcop_service (#11526)
This commit updates `test_publish_meshcop_service` to relax the checks
when verifying mDNS browse response. Specifically, after `br1` is factory
reset, the Border Agent and other functions are not given the chance
to stop properly and remove previously registered mDNS entries. This
can result in stale entries remaining in the mDNS cache, leading to
more service entries appearing in `browse` results. This commit
relaxes the check from `assertEqual` to `assertGreaterEqual`,
allowing the test to pass when additional entries are observed.
2025-05-22 19:17:23 -07:00
Jonathan Hui 9c482336ba [posix] add conditional around SIGRTMIN (#11524) 2025-05-22 15:55:03 -07:00
Jonathan Hui 5e68d3d8ce [docs] remove unmaintained badges from README (#11523) 2025-05-22 14:14:41 -07:00
Jonathan Hui 3b0f5a96d2 [github-actions] bump go version to 1.23 (#11521) 2025-05-21 10:26:07 -07:00
Jason Zhang 8dec719a57 [gitignore] add python virtual env folder (#11515) 2025-05-21 07:14:41 -07:00
Abtin Keshavarzian 4071e328fe [dnssd-server] support SOA and NS query (#11413)
This commit updates the DNS-SD server to support responding to SOA and
NS record queries (including `ANY` record type queries) for the
default service domain. The recommended values for SOA record data
from RFC-8766 section 6.1 are used. The server name included in
SOA/NS answers is derived from the Extended Address of the device,
ensuring it remains fixed and consistent over reboots as long as the
device's Extended Address stays the same.

A new detailed test case is added in the `test_dns_client` unit test
to cover all the newly added behavior.
2025-05-20 18:33:14 -07:00
dependabot[bot] 901d2d3bec github-actions: bump github/codeql-action from 3.27.9 to 3.28.18 (#11512)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.9 to 3.28.18.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/df409f7d9260372bd5f19e5b04e83cb3c43714ae...ff0a06e83cb2de871e5a09832bc6a81e7276941f)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.28.18
  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-05-20 18:32:26 -07:00
Jonathan Hui 412596c990 [examples] define OPENTHREAD_FTD and OPENTHREAD_MTD (#11516) 2025-05-20 14:59:24 -07:00
Yang Song 1f54a868cf [dns] signal an error immediately when no upstream DNS server available (#11480)
Currently, if the platform has no upstream DNS server configured,
upstream DNS query will eventually time out. This can lead to delays
in responding to the DNS client.

The new otPlatDnsIsUpstreamQueryAvailable API provides a mechanism for
the platform to proactively signal the unavailability of upstream DNS.
2025-05-20 14:50:18 -07:00
Abtin Keshavarzian 4f692464d5 [trel] implement delayed peer removal in PeerTable (#11511)
This commit updates `Trel::Peer` and `PeerTable` to allow scheduling a
`Peer` for removal from the table after a given delay. This enables
smoother peer removal, especially for transient issues, by avoiding
abrupt disconnections.

To implement this, a `State` has been added to the `Peer` class,
tracking whether a peer is in `kStateValid` or `kStateRemoving`. If a
peer scheduled for removal is discovered again, it will be re-added
and marked as valid. Logging is also updated to show these new state
transitions. Additionally, `EvictPeer()` is updated to prioritize
evicting peers already scheduled for removal.

To ensure consistent API behavior, peers that are scheduled for
removal are skipped when iterating over the peer table using
`otTrelGetNextPeer()` or `otTrelGetNumberOfPeers()`.
2025-05-20 11:53:55 -07:00
Esko Dijk 526fcf548a [dns] update comments DNS-types to match IANA (#11489)
This adds comments to DNS types, to ensure that official names from
the IANA DNS parameters registry can be found in the OT source code
when starting to search from that starting point. This will make
development and code analysis easier for those not familiar with OT,
or coming from the DNS world. The IANA names (which may deviate from
RFC names) are from: https://www.iana.org/assignments/dns-parameters
2025-05-19 12:49:16 -07:00
Abtin Keshavarzian ca3df1f057 [dnssd] echo all questions in the response on NameError (#11510)
This commit updates the DNSSD server/resolver to ensure it includes
the questions in the response message when the returned RCODE is
`NameError` (NXDOMAIN). It also clears the question count and any
partially appended content if there is a failure to append all
questions (when `kResponseServerFailure` (SERVFAIL) is returned).

It also adds a test case in `test_dns_client` to resolve a
non-existent name and validate the included questions.
2025-05-19 12:09:12 -07:00
Zhanglong Xia 55d657187b [cli] add cli commands to show CSL accuracy and uncertainty (#11490) 2025-05-19 10:47:19 -07:00
Zhanglong Xia 44dadd5f45 [common] add integer bits operation templates (#11478) 2025-05-16 22:30:02 -07:00
Yakun Xu 36cd82c62f [utils] fix clang-tidy false alarm in VerifyOrExit (#11500)
Previously, the `VerifyOrExit()` macro's condition caused clang-tidy to
issue issue false positives regarding "boolean readability," suggesting
simplifications via De Morgan's Theorem. This occurred because the macro
wrapped the entire condition and then checked its negative.

This commit refactors the macro to evaluate the condition directly, which:

1. Eliminates the erroneous clang-tidy warnings.
2. Potentially enhances CPU branch prediction performance, as the
   condition is more likely to evaluate to true.
2025-05-16 22:29:16 -07:00
jrhodie fb0446f53b [docs] update description syntax for proper rendering (#11502) 2025-05-15 11:08:46 -07:00
Jason Zhang afd44695f5 [docs] add DeepWiki badge link (#11503)
Add a badge to repo's README file to enable weekly auto refresh in
https://deepwiki.com/openthread/openthread
2025-05-15 10:09:24 -07:00
Abtin Keshavarzian ee642bf005 [border-agent] add 'rv' key to MeshCoP TXT data (#11504)
This commit updates `BorderAgent::PrepareServiceTxtData()` to include
the "rv" key. This key represents the version of the TXT record
format. Per the Thread specification, it must be set to "1". Values
other than "1" are reserved for the future and MUST NOT be used.

This commit also updates `test_border_agent` to validate this key.
2025-05-15 10:06:07 -07:00
Jonathan Hui 18f9891db7 [github-actions] pin dependencies (#11506) 2025-05-15 09:55:05 -07:00
Handa Wang 3e8e11e345 [doc] remove offline state from CLI README (#11501) 2025-05-14 23:40:49 -07:00
Handa Wang 9ff0f8834e [meshcop] fix the build when Border Agent ID is disabled (#11498) 2025-05-14 21:48:30 -07:00
Yang Song 078c6f1dc5 [posix] update dns Resolver to attempt all servers before reporting failure (#11495)
This commit addresses a defect in the Resolver::Query function where
it would error out if the attempt to send a DNS query to any single
configured server failed. This could lead to query failures even if
other DNS servers were available and operational.
2025-05-14 07:54:54 -07:00
Abtin Keshavarzian 718a27e8f2 [trel] introduce TxtData and TxtDataEncoder in PeerDiscoverer (#11496)
This commit introduces `TxtData` and `TxtDataEncoder` as nested types
in `Trel::PeerDiscoverer`. These classes handle the decoding and
encoding of TXT data for the TREL service, separating this TXT
data-related logic from the rest of the code. This helps simplify the
code and enables future extensions, allowing the TXT data logic to be
used irrespective of how services are registered or discovered.
2025-05-13 21:49:00 -07:00
Abtin Keshavarzian 6961ad183a [trel] introduce Trel::PeerDiscoverer class (#11493)
This commit introduces `PeerDiscoverer` as a class responsible for
TREL peer discovery, separating this logic from `Trel::Interface`.
The new class currently handles the preparation of TXT data, calling
the platform API to register the TREL service, and handling callbacks
from the platform layer with newly discovered or updated peer
information.

This separation helps with TREL module organization and enables future
extensions, such as performing discovery using the native OpenThread
mDNS module or the platform-specific DNS-SD (`otPlatDnssd`) module,
in addition to the existing approach where discovery is delegated to
the platform layer.
2025-05-13 17:56:59 -07:00
Abtin Keshavarzian 8244bc7fad [border-agent] new API to set vendor-specific extra TXT data (#11487)
This commit introduces a new API to allow setting vendor-specific
extra TXT data to be included when the Border Agent advertises its
mDNS `_meshcop._udp` service.

The provided vendor TXT data is appended as given to the TXT data
generated by the Border Agent and included in the `_meshcop._udp`
mDNS service advertisement.

This vendor TXT data can be set at any time, regardless of the Border
Agent's state. Any change from a previously set value will trigger an
update of the registered mDNS service to advertise the new TXT data.

This commit also updates `test_border_agent` by generalizing and
simplifying the validation of the Border Agent's `_meshcop._udp`
service TXT data. The tests are also expanded to validate the
complete registered service TXT data, including the newly added
support for vendor-specific extra TXT data.
2025-05-13 17:56:36 -07:00
Handa Wang 7b1fdbf65f [posix] make the link-local route's metric configurable (#11486)
This commit allows to configure the link-local route's metric via
macro on Linux. By using a larger metric, we can prevent host
processes from accidentally sending traffic to Thread network
interface.

For example, when the mDNS daemon on the BR wants to respond to a `QU`
mDNS question, it will send the mDNS response to a link-local
address. In a multi-network environment, it could wrongly go to the
Thread network interface if the socket is not explicitly bound to the
desired interface.
2025-05-12 20:11:39 -07:00
Abtin Keshavarzian c3823f648f [trel] add PeerTable using OwningList and allow heap use (#11484)
This commit introduces `PeerTable` as a separate class to track TREL
peers, separating this logic from `Trel::Interface`. The peer table
uses `OwningList`, ensuring that `Peer` entries are properly freed
upon removal.

The logic for allocating a new peer is simplified, including the
mechanism to evict a peer to make room for a new one.

This commit also adds a new configuration option to allow TREL to use
heap-allocated `Peer` entries instead of a `Pool<Peer>` with a fixed
size. The `Peer` class now has a `Free()` method to ensure `Peer`
instances are properly freed, regardless of whether they are heap or
pool allocated. This, combined with the use of `OwningList`,
simplifies memory management.

To cover all configurations, `toranj` build configurations for the
POSIX platform are configured to disallow TREL heap usage, while
`toranj` configurations for the simulation platform enable it.
2025-05-12 14:48:50 -07:00
dependabot[bot] adf306c9f5 github-actions: bump codecov/codecov-action from 5.4.0 to 5.4.2 (#11488)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/0565863a31f2c772f9f0395002a31e3f06189574...ad3126e916f78f00edff4ed0317cf185271ccc2d)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: 5.4.2
  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-05-12 09:19:04 -07:00
Abtin Keshavarzian 293b41c808 [border-agent] manage mDNS MeshCoP service registrations (#11455)
This commit updates `BorderAgent` modules to directly manage the
registration of mDNS MeshCoP services. Previously, this was the
responsibility of the platform or higher-level code. This behavior is
enabled using `OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_ENABLE`
configuration option.

When enabled, the `BorderAgent` module itself will register the
`_meshcop._udp` service name with properly formatted TXT data. As the
state changes, the service registration is updated accordingly.

If the ephemeral key feature is enabled and used, the `BorderAgent`
will also manage the registration of the `_meshcop-e._udp` service.

The implementation allows the service instance name to be configured
in different ways. The Thread specification recommends using a
user-friendly name, such as "<VendorName> <ProductName>". The
name can be set using a newly added configuration option, or
alternatively, using a newly added public API for projects where the
name needs to be set at run-time after device initialization.

This commit also updates `test_border_agent`, validating all the
newly added behaviors related to MeshCoP service registrations.
2025-05-08 20:39:54 -07:00
Jonathan Hui 65098ebcc1 [dua] suppress warning logs on normal behaviors (#11483)
In `PerformNextRegistration()`, there are many reasons why no
registration message will be sent. For example, device is not attached
or there are no DUAs to register.

This commit suppresses warn-level log messages when no registration
message is expected and normal behavior.
2025-05-08 20:38:50 -07:00
Jonathan Hui 90a84f6ee8 [posix] remove libanl (#11482) 2025-05-08 13:24:22 -07:00
Abtin Keshavarzian 4df9a5b9c2 [trel] refactor Peer class and enhance PeerInfo parsing (#11477)
This commit contains smaller changes related to the TREL `Peer` class
and the parsing of TXT data within the `PeerInfo` class.

The `Peer` class definition is now moved into its own `trel_peer.hpp`
and `trel_peer.cpp` header and source files, separating it from the
`Trel::Interface` class. Additionally, the `Log()` method within the
`Peer` class has been enhanced (now using an `Action` enum).

The `PeerInfo` class remains a nested class of `Interface` and now
provides a `ParseTxtData()` method to parse the included TXT data
entries.
2025-05-08 10:49:49 -07:00
Jonathan Hui be879f198d [nat64] remove support for ipv4only.arpa (#11481)
Thread Specification is transitioning from RFC 7050 to RFC 8781 for
discovering the NAT64 prefix. This commit removes RFC 7050 behavior.
2025-05-08 10:45:43 -07:00
Abtin Keshavarzian ec2b0d4873 [trel] use LinkedList for TREL peer tracking (#11476)
This commit updates the internal data structure used for tracking TREL
peers. Peer tracking now uses a `LinkedList` of `Peer` objects
allocated from a pre-allocated `Pool<Peer>`, instead of using a
fixed-size `Array<Peer>`.

This change allows for future enhancements, such as using
heap-allocated `Peer` entries and/or extending the `Peer` object to
track additional (dynamically allocated) information.
2025-05-07 13:10:13 -07:00
Abtin Keshavarzian 2591b58f3c [trel] relax parsing of TXT data entries to allow extra bytes (#11470)
This commit relaxes the parsing of TREL TXT data entries to allow
extra bytes to be present at the end of a value.

Currently, these extra bytes are simply ignored. This change provides
safer forward compatibility, allowing for future additions to the
format of the TXT data entries.
2025-05-06 10:06:44 -07:00
Abtin Keshavarzian 19203d3287 [dns] add common TxtDataEncoder (#11469)
This commit moves and enhances the `TxtDataEncoder` class, relocating
it to the common `dns_types.hpp` header file.

The new `TxtDataEncoder` provides helper methods to append TXT entries
with a variety of value types, including `NameData`, C-strings, or an
unsigned integer (in big-endian format). This enhanced encoder is
then used by the `BorderAgent` when preparing MeshCoP TXT data and
also by the TREL module.
2025-05-05 18:57:27 -07:00
dependabot[bot] c2316488e3 github-actions: bump step-security/harden-runner from 2.11.1 to 2.12.0 (#11468)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.11.1 to 2.12.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/c6295a65d1254861815972266d5933fd6e532bdf...0634a2670c59f64b4a01f0f96f84700a4088b9f0)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.12.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-05-05 09:16:30 -07:00
Abtin Keshavarzian 262551ff64 [udp] relax SocketHandle::Matches() for host interface (#11465)
This commit relaxes the `SocketHandle::Matches()` method to allow a
socket associated with `kNetifUnspecified` to match when
`IsHostInterface()` is set. This is in addition to the existing
behavior of matching a backbone socket under the same condition.
2025-05-05 09:07:35 -07:00
Abtin Keshavarzian bf2e2417ed [border-agent] simplify State Bitmap preparation (#11463)
This commit simplifies the preparation of the State Bitmap, which is
included in the Border Agent's TXT data using the `sb` key.

Specifically, constants for field values are now directly used to
construct the `uint32_t` bitmap, making the process more
straightforward.

Additionally, relevant constants are converted to use `static
constexpr`, avoiding the use of unnamed `enum` definitions.
2025-05-01 14:02:54 -07:00
Abtin Keshavarzian ae940e6df8 [border-agent] update "ConnectionMode" in state bitmap when stopped (#11462)
This commit updates how the "ConnectionMode" field is set in the
Border Agent State Bitmap, which is advertised as the value of the
`sb` TXT key. In particular, when the Border Agent service is stopped
and therefore not accepting any connections, the value of this field
is now set to `kConnectionModeDisabled` to indicate this.

This commit also updates and enhances `test_border_agent` to validate
the State Bitmap entry in the TXT data, covering cases where the
device role changes or ePSKc support is enabled/disabled.
2025-04-30 07:45:21 -07:00
Abtin Keshavarzian d56222a8db [border-agent] add API to enable/disable Border Agent service (#11458)
This commit adds a new API to allow the Border Agent service to be
enabled or disabled. By default, the Border Agent service is enabled
when the `OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE` feature is used.
This new API allows the user to explicitly control its state. This
can be useful in scenarios such as:
- The user code wishes to delay the start of the Border Agent service
  (and its mDNS advertisement of the `_meshcop._udp` service on the
  infrastructure link). This allows time to prepare or determine
  vendor-specific TXT data entries for inclusion.
- Unit tests or test scripts might disable the Border Agent service to
  prevent it from interfering with specific test steps. For example,
  tests validating mDNS or DNS-SD functionality may disable the
  Border Agent to prevent its registration of the MeshCoP service.

This commit also adds a corresponding CLI command for the new API and
updates `test_border_agent` to validate this functionality.
2025-04-30 07:38:07 -07:00
Abtin Keshavarzian 9e9522aaac [mdns] allow service registration for local host (#11450)
This commit updates the mDNS service registration to allow services
for the local host. The `mHostName` field in an `otMdnsService`
structure can now be set to `NULL` to indicate that the service
if for the local host.

The `test_mdns` unit test is also updated to verify this new
functionality.
2025-04-29 14:07:16 -07:00
Abtin Keshavarzian 7a2e337493 [border-agent] signal TXT data change when Id is updated (#11457)
This commit updates the `BorderAgent` to ensure that if its `Id` is
changed using the `SetId()` method, any consequent changes to the
generated TXT data for the MeshCoP service are correctly signaled.
This signaling is performed using the "Service TXT Data changed
callback". This commit also updates `test_border_agent` to validate
this.
2025-04-29 08:56:18 -07:00
Abtin Keshavarzian 05c623454b [border-agent] shorten method and variable names (#11456)
This commit updates `BorderAgent` method and variable names to use
shorter forms where possible. Specifically, the term `MeshCoP` is
removed from many variable and method names, as the `BorderAgent`
class itself is already defined within the `MeshCoP` namespace.

This commit is purely a style and naming change and contains no
modification to the code logic.
2025-04-28 20:52:49 -07:00
Abtin Keshavarzian b3c4a7e583 [dnssd] support ANY record type queries (#11447)
This commit updates the DNS-SD `Server` implementation to support
queries for the `ANY` record type. This is supported whether a query
is resolved using the SRP server or the OpenThread native Discovery
Proxy.

When a query is resolved using the SRP server database, all known
records that match the query name and type are included in the
response (e.g., AAAA and KEY records for a hostname; SRV,  TXT and
KEY records for a service instance name; and PTR records for service
type or sub-type query names).

Note that unlike mDNS, where an `ANY` query is expected to elicit all
known matching records, in the case of a unicast DNS query for `ANY`,
the response is only required to contain at least one matching
record, not necessarily all of them. This will be the behavior when
the Discovery Proxy is used to resolve a unicast DNS `ANY` query
(i.e., once the first answer is received from the Discovery Proxy
(mDNS), a response is prepared and sent to the client).

The unit tests `test_dns_client` and `test_dnssd_discovery_proxy` are
updated to validate the new `ANY` query behavior.
2025-04-28 12:55:47 -07:00
Abtin Keshavarzian 6b5493c9f1 [mle] add safeguard for link request scheduling failures (#11442)
This commit adds a safeguard check in `Mle::HandleTimeTick()` to
protect against cases where scheduling or sending a Link Request
message to a new neighboring router fails. This can happen, for
example, if the device is temporarily out of message buffers.

This scenario is determined by checking if `router.IsStateLinkRequest()`
is true, there is no Link Request message scheduled to be sent to
this router, and the device is not waiting for a Link Accept
(`!router.IsWaitingForLinkAccept()`). In such a case, the neighbor is
removed using `RemoveNeighbor()`.
2025-04-28 09:38:14 -07:00
Abtin Keshavarzian d6c35621bb [dnssd] support RDATA translation in discovery proxy (#11437)
This commit adds implementation for RDATA translation in the
OpenThread native discovery proxy. Specifically, for certain record
types (like CNAME) where the record data includes one or more
embedded DNS names, this translation applies. If the embedded DNS
name in RDATA uses the local mDNS domain (`local.`), it is replaced
with the corresponding domain name for the Thread mesh network
(`default.service.arpa.`). Otherwise, the name is included unchanged
in the record data.

A new method, `AppendTranslatedRecordDataTo()`, is added to perform
this translation. It utilizes the `DataRecipe` table, similar to
`DecompressRecordData()`, to parse the record data and update the
embedded DNS names as needed.

The `test_dnssd_discovery_proxy` unit test is updated to cover the new
record data translation behavior.
2025-04-28 09:37:40 -07:00
Abtin Keshavarzian 819938d05d [core] move ThreadLinkInfo to its own header and source files (#11444)
This commit refactors the `ThreadLinkInfo` definition by moving it
into its own dedicated header (`thread_link_info.hpp`) and source
(`.cpp`) files. Previously, this definition was part of
`mesh_forwarder.hpp`.

This change simplifies the overall code structure. It also allows the
new `thread_link_info.hpp` header to be included by other modules,
such as `message.hpp`, thereby avoiding the need for forward
declarations.
2025-04-25 14:10:05 -07:00
Abtin Keshavarzian 49352a10c5 [dnssd] introduce AppendServiceRecords() helper (#11443)
This commit introduces a template helper `AppendServiceRecords()`
designed to append service-related records (SRV, TXT, and host
AAAA addresses) to the appropriate sections within a DNS `Response`
message.

This helper simplifies the codebase by removing repeated patterns.
These patterns occur when resolving queries using either SRP service
data or `ServiceInstanceInfo` retrieved from the platform (when the
platform implements discovery proxy function).
2025-04-24 18:24:09 -07:00
Abtin Keshavarzian d9710c6ecb [dnssd] smaller enhancements in Server (#11439)
This commit contains a few smaller enhancements in the DNS-SD server
implementation:
- `ShouldForwardToUpstream()` now checks the `mEnableUpstreamQuery`.
- The `ResolveByUpstream()` method now handles its own error logging.
- Comments are added/updated to improve code readability.
2025-04-24 14:12:41 -07:00
Abtin Keshavarzian 3e7528e4e9 [dns-client] use DecompressRecordData() for broader record type support (#11412)
This commit updates the DNS client to use `DecompressRecordData()`
helper method when processing `QueryRecord()` responses for
arbitrary record types.

This enables decompression of embedded DNS names within the received
record data for a wider range of record types. In particular, name
decompression is now supported for PTR, CNAME, DNAME, NS, SRV, SOA,
MX, RP, AFSDB, RT, PX, KX, and NSEC records.
2025-04-23 16:40:56 -07:00
Abtin Keshavarzian b0176443cc [cli] update CLI DNS callbacks to output error for long/invalid names (#11436)
This commit updates the DNS callbacks `HandleDnsBrowseResponse()`,
`HandleDnsServiceResponse()`, `HandleDnsRecordResponse()`, etc.,
to output an error if the query name is invalid or too long.

This change replaces previous `IgnoreError()` calls with specific
error handling code for these cases. This should help address CLI
Fuzzer test failures where long or invalid names might be generated
as CLI input.
2025-04-23 13:23:55 -07:00
Abtin Keshavarzian 20aefc2215 [dnssd] support generic record queries via discovery proxy and SRP (#11357)
This commit enhances the OpenThread DNSSD name server/resolver and its
native Discovery Proxy to support queries for arbitrary record
types.

To enable this, a new set of `otPlatDnssd` APIs are introduced for
generic `RecordQuerier`. These APIs mirror the existing APIs in the
OpenThread native mDNS module, allowing direct use of the native mDNS
implementation.

The discovery proxy implementation is updated to start and stop the
mDNS `RecordQuerier` when receiving a query for an arbitrary record
type, passing the first response record back to the client.

The unit tests `test_dnssd_discovery_proxy` and `test_dns_client`
are updated to cover all the newly added behaviors in discovery proxy.
2025-04-23 12:14:05 -07:00
Jonathan Hui 4be7e8baa2 [tests] allow service bind9 stop to fail (#11438) 2025-04-23 10:05:30 -07:00
Jonathan Hui ffb8e4d7c8 [docs] use NULL in place of nullptr (#11435) 2025-04-23 08:19:27 -07:00
Yaoxing Shan 424de28a2f [tcp] send RST and clear send buffer on abort (#11269)
This commit corrects the timing of Transmission Control Block (TCB)
re-initialization to ensure proper RST packet sending during TCP
connection aborts and to prevent potential issues due to incomplete
TCB cleanup.
2025-04-22 15:07:45 -07:00
Abtin Keshavarzian 283edc0bd5 [routing-manager] introduce MultiAilDetector (#11400)
This commit introduces the `MultiAilDetector` feature within the
`RoutingManager`. This feature detects whether Border Routers(BRs) on
the Thread mesh might be connected to different Adjacent
Infrastructure Links (AILs).

The feature can be enabled using the configuration option
`OPENTHREAD_CONFIG_BORDER_ROUTING_MULTI_AIL_DETECTION_ENABLE`.

The detection mechanism operates as follows: The Routing Manager
monitors the number of peer BRs listed in the Thread Network Data and
compares this with the number of peer BRs discovered by processing
received Router Advertisements (RAs) on its local AIL.

If the count derived from Network Data consistently exceeds the count
derived from RAs for a detection period of 5 minutes, the detector
concludes that BRs are likely connected to different AILs. This
triggers a detection state change, and a registered callback is
invoked. To clear this state, a shorter window of 1 minute is used.

Public APIs and corresponding CLI commands have been added to allow
checking the current detection state and registering a callback for
state change notifications.

This commit also includes test coverage for the newly added feature.
2025-04-22 13:44:12 -07:00
Jonathan Hui 16bafadb59 [rcp] change default baud rate to 460800 (#11432) 2025-04-22 13:27:55 -07:00
Abtin Keshavarzian 08a8767fcd [posix] move SocketWithCloseExec() helper to common utils.hpp (#11427) 2025-04-22 07:43:07 -07:00
Thomas f42af4e2ee [otci] add support for IPv4, vendor commands, networkdiagnostics (#11397)
With Thread 1.4 the cli application not can also (dns) resolve
IPv4 addresses. This commit adds the same support in otci

* dns_resolve4

Implements support for vendor operations in otci get/set

* vendor_name
* vendor_model
* vendor_sw_version

Implements network diagnostic commands

* get
* reset
* non_preferred_channels

Various other (small changes)"

* allow setting read timeout on serial connections
* allow replacing read routine filter
* expose latest thread versions in the public module api
* expand the definition of dns_get_config
* replaces mgmtget/mgmtset with the correct mgmtgetcommand and mgmtsetcommand
* replaces addressmode with the correct addrmode
* adds an `ignore_result` option to `execute_command`
* adds a missing `diag` command
* removes some unexisting getters
2025-04-21 14:49:58 -07:00
Abtin Keshavarzian 2e73358f9d [dns] introduce DecompressRecordData() and use it in mDNS (#11408)
This commit updates the mDNS `RecordQuerier` to handle record types
where the RDATA contains one or more potentially compressed DNS
names. For these types, the reported record data is now decompressed
to include the full DNS names. This enhancement applies to the
following record types: NS, CNAME, SOA, PTR, MX, RP, AFSDB, RT, PX,
SRV, KX, DNAME, and NSEC.

To achieve this, a helper `ResourceRecord::DecompressRecordData()`
method is introduced. This method uses a "recipe" formula specific
to each supported record type. The recipe defines the number of
prefix bytes before the first embedded name, the number of DNS
names, and the minimum number of suffix bytes after the names. A
common implementation then uses this recipe to parse and decompress
the RDATA. This approach makes the implementation flexible and allows
for easier addition of new record types and formats in the future.

Unit test `test_dns` is updated to validate the newly added method.
2025-04-21 14:29:09 -07:00
Abtin Keshavarzian 7536e3c73b [posix] enhance config header file (#11426)
This commit enhances the `openthread-posix-config.h` header by:

- Moving configurations defined in other headers
  (`platform-posix.h`) into this common header.
- Making sure the section containing guard checks for removed or
  renamed POSIX configurations is at the end of the header file.
2025-04-21 13:28:56 -07:00
dependabot[bot] 8d40aa3462 github-actions: bump actions/setup-go from 5.1.0 to 5.4.0 (#11430)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.1.0 to 5.4.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed...0aaccfd150d50ccaeb58ebd88d36e91967a5f35b)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 5.4.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-21 09:26:10 -07:00
Abtin Keshavarzian 0c1dfa0796 [mle] refactor MleRouter and Mle classes into a single Mle class (#11411)
This commit refactors the `Mle` modules and combines the `MleRouter`
and `Mle` classes into a single `Mle` class which now handles both
FTD and MTD functionalities.

The `MleRouter` and `Mle` classes were originally intended as
sub-classes, where the base class `Mle` would provide MTD and common
behaviors, and `MleRouter` would implement FTD-specific behaviors.
However, over the years and as new features were implemented, these
two classes became more intertwined, and the `Mle` class began to
include many FTD-related functions and interactions with `MleRouter`
private variables and methods.

This commit simplifies the code by combining the two into a single
class. The previous `mle_router.cpp` file is also renamed to
`mle_ftd.cpp` to indicate that it implements FTD-specific MLE
behaviors.
2025-04-18 14:28:47 -07:00
Abtin Keshavarzian f70749d21d [mdns] add API to get the list of local host IP addresses (#11404)
This commit introduces an API to iterate over the local host IPv6 and
IPv4 addresses known to the OpenThread mDNS module.

The platform layer is responsible for monitoring and reporting all
host IPv4 and IPv6 addresses to the OpenThread mDNS module, which
then tracks the full address list
(see `otPlatMdnsHandleHostAddressEvent()`). The newly added function
allows iteration through this tracked list, primarily intended for
information and debugging purposes.

This commit also adds a CLI command to utilize the new API.
Additionally, the `test_mdns` unit test has been updated to validate
the functionality of the newly added API.
2025-04-18 12:11:16 -07:00
Abtin Keshavarzian 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
Abtin Keshavarzian 3efe1c2c41 [mesh-forwarder] update and simplify Counters tracking (#11419) 2025-04-17 11:39:03 -06:00
Abtin Keshavarzian 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
Li Cao e1407fbab6 [border-agent] fix meshcop service omr entry (#11415) 2025-04-17 09:11:37 -06:00
Maciej Baczmański 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
arnulfrupp 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
dependabot[bot] 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](https://github.com/actions/setup-python/compare/42375524e23c412d93fb67b49958b491fce71c38...8d9ed9ac5c53483de85588cdf95a591a75ab9f55)

---
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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
dependabot[bot] 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](https://github.com/step-security/harden-runner/compare/4d991eb9b905ef189e4c376166672c3f2f230481...c6295a65d1254861815972266d5933fd6e532bdf)

---
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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Jonathan Hui 37b417a3ee [test] update OTBR Dockerfile path (#11390) 2025-04-02 10:14:33 -07:00
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Jonathan Hui caa1222e2a [github-actions] add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to mbedtls-2 build (#11383) 2025-04-01 09:37:32 -07:00
Kangping 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
dependabot[bot] 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](https://github.com/docker/login-action/compare/9780b0c442fbb1117ed29e0efdff1e18412f7567...74a5d142397b4f367a81961eba4e8cd7edddf772)

---
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
Abtin Keshavarzian 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
tanyanquan 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
Abtin Keshavarzian 4f11483aa6 [cli] simplify simple commands using Process{Get/Set}() helpers (#11374) 2025-03-27 22:45:30 -07:00
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Zhanglong Xia 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Abtin Keshavarzian 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
Yang Song 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
Yakun Xu 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
seb-fae 7a258287f1 [instance] add otInstanceGetIndex() (#11197) 2025-03-24 10:04:38 -07:00
xusiyu 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
Kamil Kasperczyk 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
dependabot[bot] 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](https://github.com/docker/setup-buildx-action/compare/f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca...b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2)

---
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
Yakun Xu 8c23a588ca [script] install gtest and gmock (#11358) 2025-03-24 08:29:53 -07:00
Yang Song 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
Yang Song 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
Li Cao 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
Thomas 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
Abtin Keshavarzian 21ba5bbea8 [coap] ensure correct retransmission timer scheduling (#11348)
This commit introduces `CoapBase::ScheduleRetransmissionTimer()`, a
new method that calculates the next retransmission timer fire time
based on all queued messages in `mPendingRequests` and then
schedules (starts or stops) the timer.

This method is now used whenever `mPendingRequests` is updated (a new
message is added or an existing message is removed). It is also used
in `HandleRetransmissionTimer()`, the timer's callback. This change
centralizes timer scheduling, simplifying the logic.

This also addresses an issue in the existing code where
`HandleRetransmissionTimer()` iterated over `mPendingRequests` to
determine expired messages and calculate the next fire time. However,
finalizing an expired message could trigger its `ResponseHandler`
callback, from which the caller may start or abort CoAP message tx
and  modify `mPendingRequests` and reschedule the timer, leading to
incorrect fire time calculations (`NextFireTime` can be incorrect
which would then improperly re-schedules the timer, stop it or
schedule it to a later time).

With this change, `HandleRetransmissionTimer()` first finalizes
expired messages (potentially invoking callbacks) and then calls
`ScheduleRetransmissionTimer()` to calculate the next fire time
based on the updated `mPendingRequests`, ensuring accurate timer
scheduling.
2025-03-18 14:22:17 -05:00
dependabot[bot] d095eb3869 github-actions: bump actions/upload-artifact from 4.6.0 to 4.6.1 (#11345)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08...4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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-03-17 09:15:05 -05:00
Handa Wang 6ed39e657b [posix] add an option to disable resolv.conf on initialization (#11343)
On Android we didn't have a chance to disable reading from
`resolv.conf` at initialization of `Resolver`. This caused a logging
line at critical level which could be confusing.
2025-03-17 09:08:44 -05:00
Abtin Keshavarzian c8fa6e3b8f [mdns] introduce RecordQuerier for continuous record queries (#11288)
This commit enhances the native mDNS implementation by adding
`RecordQuerier`, which enables continuous queries for arbitrary
record types and query names. The `RecordQuerier` follows a pattern
similar to service/address browsers and resolvers, allowing multiple
queriers to be started for the same record type and name (provided
they use different callbacks).

Record results are cached, and the cache correctly handles and reports
when new records are added or removed (either explicitly or due to
timeouts), including when the "cache-flush" flag is used in a
response.

Public OpenThread APIs and corresponding CLI commands are added for
`RecordQuerier` functionality.

The `test_mdns` unit test is updated with a detailed test case
covering the newly added `RecordQuerier` functions.
2025-03-13 10:38:28 -07:00
Yang Song a7dbd9b46d [posix] update Posix::Resolver to support IPv6 addresses for servers. (#11325)
This commit enhances the DNS resolver (`resolver.cpp`) to support IPv6
addresses in upstream DNS server configurations, allowing for greater
flexibility and compatibility in IPv6-enabled environments.
2025-03-13 08:36:10 -07:00
Cristian Bulacu 7f2828657a [secure-transport] Add option to specify NetifIdentifier (#11338)
This commit aims to add the possibility to specify a netif identifier for
SecureTransport::Open method. This method has now a default parameter,
kNetifUnspecified, if no argument is explicitly passed by the user.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-03-13 08:31:48 -07:00
Zhangwx 4c0af02513 [mesh-forwarder] fix ip6 route selection for the deprecated OMR addresses (#11332) 2025-03-12 22:52:57 -07:00
Zhanglong Xia 1f37da29e5 [csl] update CSL parameters only when necessary (#11312)
The current MLE and MAC layers will trigger a call to "SubMac::UpdateCsl()"
when the CSL state or CSL parameters change. This will bring a lot of
unnecessary interface call overhead when we make RCP support CSL receiver
in the future.

This PR refactors the code so that the MLE and MAC layers only trigger a
call to `UpdateCsl` when a valid state or parameter change occurs.
2025-03-12 22:27:49 -07:00
Abtin Keshavarzian 68543b0faf [routing-manager] process RDNSS options and track addresses (#11328)
This commit introduces a mechanism in `RoutingManager` to parse and
process Recursive DNS Server (RDNSS) options within received Router
Advertisement (RA) messages. The list of discovered RDNSS addresses
is tracked (per router) by `RoutingManager`, applying the advertised
lifetime to properly age the discovered entries.

This commit adds a new public API to retrieve the list of tracked
RDNSS addresses, along with a callback mechanism where OpenThread
users can register to be notified of changes to the RDNSS list. This
callback is invoked when any of the following changes occur:

- A new RDNSS address is advertised by a router.
- A previously discovered address is removed due to the router
  advertising it with a zero lifetime.
- A previously discovered address has aged out (its lifetime expired
  without being re-advertised).
- `RoutingManager` determines that the router advertising the address
  is now unreachable, resulting in the removal of all its associated
  entries.

This commit also adds corresponding CLI commands for the new API.

Furthermore, `test_routing_manager` is updated to include a test case
covering all the newly added behaviors in detail.
2025-03-12 11:06:16 -07:00
Abtin Keshavarzian b953ed1dfa [csl] use mPanChannel as default CSL channel (#11336)
This commit updates the CSL channel selection logic. When a CSL
channel is not explicitly set, the code now uses the tracked
`mPanChannel` (the current Thread PAN channel) instead of
`mRadioChannel` (the current channel the radio is listening on). This
ensures that the CSL channel aligns with the Thread PAN channel, even
when the radio temporarily switches to other channels, such as during
an MLE discover scan.
2025-03-12 11:04:16 -07:00
Abtin Keshavarzian d30b1ae6fb [mesh-forwarder] handle route lookup errors in UpdateIp6RouteFtd() (#11335)
This commit modifies `UpdateIp6RouteFtd()` to handle errors returned
by `NetworkData::Leader::RouteLookup()`, ensuring that messages are
dropped appropriately when a route lookup fails. It also initializes
`mMeshDest` to an invalid RLOC16 at the beginning of the method.
2025-03-12 10:59:00 -07:00
Yakun Xu 9e7b57d7fb [joiner] keep discovering when UDP port is bad (#11337)
This commit fixes the issue that the joiner starts joining process
immediately when an invalid Joiner UDP Port is encountered. This issue
was introduced by #9445 which attempts to ignore joiner routers having
an invalid Joiner UDP Port.
2025-03-12 10:36:54 -07:00
Abtin Keshavarzian 7d488bcf24 [csl] use correct time basis for CSL sample time (#11314)
This commit updates how the CSL sample time is tracked in `SubMac`,
ensuring that it is tracked using both radio time based on
`otPlatRadioGetNow()` and the local time (`TimeMicro::GetNow()`).
These two time sources may not necessarily be the same.

This change addresses the issue where the same time value was used for
both scheduling `mCslTimer` (which should be based on local time) and
for calls to the radio APIs (which should use radio time).
2025-03-10 17:17:12 -07:00
Jonathan Hui 255db173b7 [github-actions] remove avahi + TREL test (#11333) 2025-03-10 15:25:31 -07:00
dependabot[bot] 9f9d0a5a33 github-actions: bump step-security/harden-runner from 2.10.2 to 2.11.0 (#11331)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.2 to 2.11.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/0080882f6c36860b6ba35c610c98ce87d4e2f26f...4d991eb9b905ef189e4c376166672c3f2f230481)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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-10 09:20:51 -07:00
Kangping 1dd7f11ae7 [srp-server] fix fast-start mode disruption when device role changes (#11330)
When in fast-start mode, the SRP server will be disabled and then
immediately enabled again if the device transfers from Child to Router.
This commit fixes this issue by also matching the MLE-ID with the SRP
server address in the Network Data.
2025-03-10 08:54:38 -07:00
Jonathan Hui 555454c973 [cli] add validation of targetpower channel (#11326) 2025-03-05 18:14:13 -08:00
Zhanglong Xia a470e8bf0d [cli] add targetpower command support (#11321) 2025-03-04 21:47:45 -08:00
Abtin Keshavarzian b1ca77aae9 [srp-server] allow disabling "Fast Start Mode" via auto-enable (#11319)
This commit updates the `Srp::Server` so that Fast Start Mode can be
disabled by a call to `otSrpServerSetAutoEnableMode()`, in addition
to the existing method of calling `otSrpServerSetEnabled()`.

The `test_srp_server` unit test is updated to validate this new
behavior.
2025-03-04 15:18:37 -08:00
Jonathan Hui eb15a56a91 [github-actions] update runner from ubuntu-20.04 to ubuntu-24.04 (#11324) 2025-03-04 12:30:51 -08:00
Li Cao b321bf1f64 [border-agent] fix meshcop service update issue (#11320)
This commit fixes an issue in BorderAgent when handling Notifier
events.

If the events contain 'Epskc' and BA is not running, then the meshcop
service update will be skipped.
2025-03-04 08:04:08 -08:00
Zhanglong Xia 829f65f35b [csl] refactor the csl receiver (#11302)
This commit refactors the `sub_mac_csl_receiver.cpp` to handle
`ReceiveAt()` and `Sleep() or Receive()` operations in different
functions to simplify the code logic.
2025-03-03 18:23:32 -08:00
Yakun Xu ab7a874b2a [csl] enable cca for CSL transmission (#11027)
This commit enables CCA for CSL transmission. CCA is expected for CSL
transmissions. The platform layer may skip CCA if mCsmaCaEnabled is not
set. This commit ensures mCsmaCaEnabled is correctly delivered to the
platform layer.
2025-03-03 11:18:21 -08:00
Li Cao 75c8aed8f6 [border-agent] change meshcop service TXT value after enabling/disabling Epskc (#11310)
This commit posts a MeshCoP service changed task after Epskc feature
is enabled/disabled.

After Epskc feature is enabled/disabled, the `EpskcSupported` bit in
the statebitmap in MeshCoP Txt value should change accordingly.
2025-03-03 11:17:22 -08:00
Kangping 6866acc9a6 [srp-server] fix typo in otSrpServerIsFastStartModeEnabled (#11316)
Rename otSrpServerIsFastStartmodeEnabled to
otSrpServerIsFastStartModeEnabled
2025-03-03 09:36:24 -08:00
dependabot[bot] 859b559dcc github-actions: bump codecov/codecov-action from 5.3.1 to 5.4.0 (#11317)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3...0565863a31f2c772f9f0395002a31e3f06189574)

---
updated-dependencies:
- dependency-name: codecov/codecov-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-03 09:14:31 -08:00
Li Cao 2cc6d6c11f [ncp] add spinel properties for border agent (#11271)
This commit adds spinel properties for border agent MeshCoP service to
work under NCP.

* `SPINEL_PROP_BORDER_AGENT_MESHCOP_SERIVCE_STATE`: this simply
  conveys the MeshCoP service state, including `IsActive`, udp port
  and the encoded Txt values.

* `SPINEL_PROP_BORDER_AGENT_MESHCOP_SERIVCE_STATE_SUBSCRIPTION`: this
  notifies the NCP side to register the state change callback. Because
  we hope that the host side can have initial values. But if we
  register the state change callback in NCP's initialization, the
  callback will be invoked at a very early stage and send the values
  while the host isn't ready to receive the MeshCoP service values. So
  this property enables the host to decide when to receive the initial
  values.
2025-02-28 13:53:22 -08:00
Jason Zhang ab0fe1de98 [posix] fix GPIO interrupt pin error when SPI init (#11313) 2025-02-28 13:51:50 -08:00
Abtin Keshavarzian babbccd4c6 [srp-server] introduce "fast start mode" feature (#11305)
This commit adds "Fast Start Mode" feature for SRP server. This
feature is designed for scenarios where a device, often a mobile
device, needs to act as a provisional SRP server (e.g., functioning
as a temporary Border Router). The SRP server function is enabled
only if no other Border Routers are already providing the SRP
service within the Thread network. A common use case is a mobile
device joining a Thread network where it may be the first, or only,
BR. Importantly, Fast Start Mode allows the device to quickly start
its SRP server functionality upon joining the network, allowing other
Thread devices to quickly connect and register their services without
the typical delays associated with standard Border Router
initialization and SRP server startup (using NetData Publisher).
2025-02-28 13:49:30 -08:00
Abtin Keshavarzian 31f2897951 [csl] update CSL methods to use core MAC address types (#11306)
This commit updates `SubMac::UpdateCsl()` and related methods to use
the core types `Mac::ExtAddress` and `Mac::ShortAddress` instead of
C-style public/platform types. The extended address input is also
changed from a pointer to a reference.
2025-02-28 07:16:19 -08:00
Abtin Keshavarzian 6e0755bd1b [srp-server] add new otSrpServerAddressMode for faster start up (#11180)
This commit adds a new option in `otSrpServerAddressMode` as
`OT_SRP_SERVER_ADDRESS_MODE_UNICAST_FORCE_ADD`. This allows faster
SRP server start up by bypassing the Network Data publisher and
adding the "SRP/DNS unicast" entry directly to Network Data upon enabling
of the SRP server, regardless of how many other similar entries are
present.

This option is intended for testing and specific situations. A warning
is added to indicate that using this option will make the device
non-compliant with the Thread specification.

The unit test `test_srp_server` is updated with a new test case to
validate the new `AddressMode` and its related behavior.
2025-02-28 07:13:29 -08:00
Jason Zhang abadeadfbb [posix] introduce OT_EXIT_RCP_RESET_REQUIRED for platform reset requests (#11292)
This commit modifies the process exit behavior to introduce a new exit code
`OT_EXIT_RCP_RESET_REQUIRED`. This code signals that a hardware reset is required
by the POSIX platform, rather than being initiated directly by OpenThread itself.

This change is necessary to accommodate scenarios where the platform or a
separate stack (e.g., Wifi/BT) is responsible for managing hardware resets
of integrated chips (like Wifi/BT/Thread trinity chips). Previously, OpenThread
might have attempted to handle resets directly, which is not always appropriate
in these integrated environments.

This commit includes the following changes:
- Adds a new exit code: `OT_EXIT_RCP_RESET_REQUIRED` is now defined to indicate a
  platform-requested hardware reset.
- Makes reset parameters optional: The `gpio-reset-device` and `gpio-reset-line`
  parameters for reset functionality are now optional.
- process dies if gpio-reset-device is not given when TriggerReset().
2025-02-27 22:26:35 -08:00
Zhanglong Xia b5164cf836 [posix] remove the polling mode from spi interface (#11303)
The RCP should assert the interrupt pin to notify the SPI interface of
an impending data frame transfer to the host. This commit removes the
polling mode from the spi interface.
2025-02-26 19:53:37 -08:00
Li Cao 560940af20 [border agent] add OT API to get Border Agent MeshCoP Service TXT data (#11291)
This commit adds a new OT API `otBorderAgentGetMeshCoPServiceTxtData`
to get MeshCoP Service TXT data from OT core.

The intention is to facilitate the NCP property update for MeshCoP
Service TXT data. With the get API, NCP property update can use the
`ChangedPropsSet` way which is more robust.
2025-02-26 19:37:47 -08:00
Abtin Keshavarzian a67454f8cc [mle] update kAloc16ServiceEnd and add explicit ALOC16 range check (#11300)
This commit updates `kAloc16ServiceEnd` to `0xfc1f`, aligning it with
recent changes in the Thread specification. The range `0xfc10-0xfc1f`
is now used for service ALOC16 corresponding to the 16 service IDs,
and the range `0xfc20-0xfc2f` is reserved for future use.

It also updates the `NetworkData::Leader::AnycastLookup()` to
explicitly check a given `aAloc16` against the defined ALOC16 ranges.
This replaces the previous model, which assumed that ALOC16 ranges
followed each other sequentially. While this assumption held true
previously, the introduction of the reserved range disrupts this
pattern. The explicit range check ensures correct behavior regardless
of future changes, making it a safer and more robust approach.
2025-02-26 16:16:24 -08:00
Zhanglong Xia aaa929f6a6 [csl] call the CslSample in SubMac (#11301)
This commit moves the calling `CslSample()` logic from `Mac` to the
`SubMac`. It will make it easier for us to move CSL receiver to RCP in
the future.
2025-02-26 16:15:58 -08:00
Jason Zhang 0019f38839 [gtest] fix build error when building posix (#11289)
This commit fix build error when running "./script/cmake-build posix
-DOT_BUILD_GTEST=ON".
2025-02-25 22:28:58 -08:00
Li Cao 33a1f09569 [test] fix socat version to 1.7.4.4 (#11243)
This commit changes the installation of socat from using 'apt' to
manual installation.

We found the latest socat version 1.8.0.3 has an issue when running
with OTBR docker. To avoid the error caused by version and facilitate
local development, the commit provides a script to install socat of
version 1.7.4.4 and replaces the installation in CI and scripts..

We add the install script in openthread and ot-br-posix will use the
script in openthread to install socat.
2025-02-25 07:48:18 -08:00
Zhanglong Xia c8ed768bea [srp-server] fix typo in docs (#11294) 2025-02-25 07:46:41 -08:00
dependabot[bot] 6bc9309a85 github-actions: bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#11285)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.4.0 to 2.4.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/62b2cac7ed8198b15735ed49ab1e5cf35480ba46...f49aabe0b5af0936a0987cfb85d86b75731b0186)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  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-02-24 09:05:13 -08:00
Li Cao 0b0f371d34 [version] add thread version string (#11276)
This commit adds thread version string for the "tv" entry in border
agent MeshCoP TXT records.

The commit also replaces "1.3.1" with "1.4.0".
2025-02-24 09:00:55 -08:00
Abtin Keshavarzian 522f590fb6 [netdata] skip invalid TLVs in Network Data during iteration/search (#11283)
This commit enhances `NetworkData` modules to skip invalid TLVs during
iteration or search operations. Specifically, `NetworkDataTlv::Find
()` and `NetworkData::Iterate()` are updated. These two methods are
the primary methods used by all other methods for parsing or
searching for TLVs.

Generally, the leader validates TLVs before registration using
`NetworkData::Leader::Validate()`. However, this change improves
robustness by allowing receivers to also handle possible malformed
Network Data.

This commit also updates the `test_network_data` unit test to cover
the new behavior of skipping invalid TLVs.
2025-02-24 08:55:34 -08:00
Abtin Keshavarzian bc54d67ed8 [mle] clamp child timeout to min/max range (#11278)
This commit updates `SetTimeout()` to ensure the child timeout remains
within the minimum and maximum allowed values (per the specification,
the maximum value of 8 hours is used).

These limits are also enforced when the parent requests a different
timeout value in an MLE Child Update Response to the child's
request.
2025-02-21 21:48:34 -08:00
puddly e1adb71cf0 [channel-monitor] allow configuring startup behavior (#11164)
Allow the Channel Monitor feature to be compiled in but optionally be
disabled by default, allowing it to be started on-demand.
2025-02-21 13:38:45 -08:00
gytxxsy 165fdfd5d5 [border-agent] try getting coap dtls session from ephemeral key manager (#11270)
If the EphemeralKey Manager is enabled, when no active CoAP DTLS
session is found in the Border Agent's mDtlsTransport, it should
attempt to retrieve one managed by the EphemeralKey Manager.

This issue was discovered when using Thread devices, a Border Router ,
and `ot-commissioner` for commissioning with an ephemeral key. The
process is as follows:

Using `ot-commissioner` commit: `8fffd186b28809257bad73eab2459c97240fe535`
Using `openthread` commit: `36a8f71d0693bfb1407fc48444c4da6e7f2d32d6`

1. Using the ephemeral key, the BR and `ot-commissioner` established a
DTLS connection over the Wi-Fi link. This process worked as expected,
and the Border Agent successfully created `mCoapDtlsSession` in the
EphemeralKey Manager.

2. The `ot-commissioner` executed the command `joiner enableall
meshcop J01NU5` to allow joiners to connect.

3. When a Thread node attempted to join the network using `joiner
start J01NU5`, it failed.

The root cause was that when the `BorderAgent` received a CoAP message
from the Thread device and attempted to forward it to
`ot-commissioner` via `HandleTmf<kUriRelayRx>`, it could not find an
active CoAP DTLS session through
`FindActiveCommissionerSession`. Because the `mCoapDtlsSession` in the
EphemeralKey Manager was not managed by the Border Agent’s
`mDtlsTransport`.
2025-02-21 12:33:28 -08:00
Adam Labbe 6d0c1d4df1 [spinel] allow RCP reset if not multipan architecture (#11277)
This VerifyOrExit will prevent the RCP recovery process from resetting
the RCP. The comment highlights that given a multipan architecture, it
is not viable to reset the RCP once it is declared ready. In
non-multipan architectures, it is still viable and desirable to reset
the RCP as part of recovering it.

See https://github.com/orgs/openthread/discussions/11273
2025-02-21 12:00:18 -08:00
Jonathan Hui ed7db65f23 [docker] use "ENV key=value" format (#11266) 2025-02-19 19:18:42 -08:00
Yakun Xu 6fac4078b6 [test] cover src match handling (#11258)
This commit adds tests to cover the handling of Src Match entries,
including adding, removing and clearing of short addr entries and
extended addr entries.
2025-02-19 19:18:25 -08:00
Li Cao 36a8f71d06 [border-agent] add new apis for refactoring meshcop service publishing (#11215)
This commit adds a new OT API to set callback for border agent state
change: `otBorderAgentSetMeshCoPServiceChangedCallback`

`otBorderAgentStateChangedCallback` is invoked when the 'IsActive'
state of BorderAgent changes or the MeshCoP TXT data from Thread stack
changes. For example, the network name, the EXT PAN ID. This is used
to update the MeshCoP TXT data that will be published on the host and
notify the platform to start/stop the UDP Proxy.

After applying the UdpProxy design, the UDP port of published MeshCoP
service will be provided by the UdpProxy on the host (in ot-br-posix)
instead of OT core.
2025-02-18 13:33:16 -08:00
Abtin Keshavarzian a6432f7daa [routing-manager] simplify state management in PdPrefixManager (#11250)
This commit simplifies state tracking and updates within
`PdPrefixManager`. Previously, three boolean flags (`mEnabled`,
`mStarted`, and `mPaused`) and a `GetState()` method were used to
represent the state as a `Dhcp6PdState`.

This commit replaces the boolean flags with a single `mState`
variable of type `Dhcp6PdState`.  New `UpdateState()` and `SetState()`
methods handle all state transitions, ensuring PD prefix withdrawal
(OMR prefix removal from Network Data) and state change signaling.
2025-02-18 09:17:50 -08:00
dependabot[bot] 2c64402092 github-actions: bump docker/setup-buildx-action from 3.8.0 to 3.9.0 (#11259)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.8.0 to 3.9.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/6524bf65af31da8d45b59e8c27de4bd072b392f5...f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca)

---
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-02-18 08:38:26 -08:00
Zhanglong Xia aee0ba47e8 [cp-caps] use unittest to refactor the cp-caps test (#11213)
This commit refactors the cp-caps test as follows:
1. uses the unittest framework to refactor the cp-caps.
2. all tests are sorted alphabetically
3. all test names are changed to long names.
2025-02-18 08:28:06 -08:00
Abtin Keshavarzian d7f36da681 [test] relax BR tests that expect a single address on mDNS resolve (#11254)
This commit relaxes the tests that assume mDNS resolve would provide a
single IPv6 answer and explicitly check and require one address. This
behavior of the mDNS API is improved/changed in the `ot-br-posix`
implementation, allowing multiple addresses to be collected and
passed in the "resolved" callback.

 This commit updates the `_assert_dig_result_matches()` function to
 have an additional parameter, `allow_extra_answer`, which is then
 used in specific test steps.
2025-02-18 08:06:15 -08:00
Abtin Keshavarzian c583554263 [radio] fix ClearSrcMatchExtEntry() Extended Address byte order (#11257)
This commit addresses an issue introduced in #10892 where the Extended
Address byte order was not properly handled when calling
`otPlatRadio` APIs. OpenThread core uses big-endian encoding for
Extended Addresses, while the `otPlatRadio` APIs expect
little-endian, as per documented behavior.

PR #10892 refactored the byte-order reversal code from
`SourceMatchController` and `LinkRaw` into the `Radio` class. While
`Radio::AddSrcMatchExtEntry()` was updated properly to reverse the
byte order, `Radio::ClearSrcMatchExtEntry()` was not. This leads to
Extended MAC addresses not being properly removed from the source
match table, potentially causing issues with indirect transmission.
This commit resolves the issue.

It is strongly recommended to cherry-pick this fix into builds that
include #10892.
2025-02-14 12:53:40 -08:00
Abtin Keshavarzian 68312101ca [radio] clarify otPlatRadioReceiveAt() behavior (#11221)
This commit clarifies the documentation for `otPlatRadioReceiveAt()`
regarding its behavior when called multiple times after successfully
scheduling a reception window.  If a subsequent call occurs before
the start of the previous window, it MUST cancel the previous window
and effectively replace it. If the call occurs after the start of
the previously scheduled window, even if still within it, it MUST
NOT impact the ongoing reception.
2025-02-13 12:56:55 -08:00
Li Cao 3c7f387d45 [doc] instruct to build nexus test in a directory (#11234) 2025-02-13 12:56:31 -08:00
Abtin Keshavarzian ae76f12a3e [routing-manager] remove prefix change tracking in PdPrefixManager (#11246)
This commit simplifies the `PdPrefixManager` class by removing the
`currentPrefixUpdated` flag. The flag was used to track PD prefix
changes during prefix processing, solely to determine if a prefix was
deprecated. This deprecation check can be performed independently,
eliminating the need for the flag and simplifying the code.
2025-02-13 12:56:07 -08:00
Abtin Keshavarzian 5e822c1f3c [posix] set IPV6_ADDR_PREFERENCES on trel socket (#10953) 2025-02-13 12:54:12 -08:00
Jonathan Hui 29fbe83634 [docker] use latest recommendation for multi-arch build (#11252) 2025-02-13 12:39:09 -08:00
Abtin Keshavarzian 15a789267d [border-agent] support multiple parallel sessions (#11212)
This commit updates the `BorderAgent` implementation to support
multiple parallel sessions using PSKc. It adds new public OT APIs to
iterate over all sessions, along with related CLI commands. The nexus
`test_border_agent` is updated to cover multi-session behavior and
the new session iteration APIs.
2025-02-12 11:04:13 -08:00
Abtin Keshavarzian 1b9b73f2b7 [routing-manager] simplify PdPrefixManager::HasPrefix() (#11242)
This commit simplifies `PdPrefixManager::HasPrefix()` by simply
checking if `mPrefix` is empty (rather than `IsValidOmrPrefix()`).
A favored PD prefix is always validated before it is assigned to
`mPrefix`, and when the prefix is removed, `mPrefix` is cleared.
2025-02-12 11:02:40 -08:00
Abtin Keshavarzian 260193a30d [routing-manager] rename PrefixEntry to PdPrefix (#11241)
This commit renames `PrefixEntry` to `PdPrefix` within the
`PdPrefixManager` class. Associated variables are also updated,
improving readability.
2025-02-12 10:35:23 -08:00
Abtin Keshavarzian fd16f4569f [routing-manager] map otBorderRoutingDhcp6PdState to core type (#11240)
This commit updates `otBorderRoutingDhcp6PdState` to be properly
mapped using `DefineMapEnum()` to its related core-internal `enum`
definition. This avoids the use of `static_cast` for conversion and
ensures only associated `enum` types can be mapped to each other.
2025-02-12 10:33:14 -08:00
Abtin Keshavarzian aaddae1134 [routing-manager] use FavoredOmrPrefix::IsInfrastructureDerived() in PdPrefixManager (#11239)
This commit updates `PdPrefixManager::Evaluate()` to directly use the
helper method `FavoredOmrPrefix::IsInfrastructureDerived()` when
deciding to pause and change to `kDhcp6PdStateIdle`. This helps
improve code readability.
2025-02-12 10:32:52 -08:00
Handa Wang 95d90a0aa6 [tests] extend the waiting time in test_mdns_restart for SRP server to start (#11244)
Fixes the flakiness after enable the OpenThread Core Advertising Proxy.
2025-02-12 10:32:28 -08:00
Abtin Keshavarzian d1cb89cede [routing-manager] map otBorderRoutingDhcp6PdState to core type (#11240)
This commit updates `otBorderRoutingDhcp6PdState` to be properly
mapped using `DefineMapEnum()` to its related core-internal `enum`
definition. This avoids the use of `static_cast` for conversion and
ensures only associated `enum` types can be mapped to each other.
2025-02-12 10:29:49 -08:00
Abtin Keshavarzian eadf514084 [routing-manager] use FavoredOmrPrefix::IsInfrastructureDerived() in PdPrefixManager (#11239)
This commit updates `PdPrefixManager::Evaluate()` to directly use the
helper method `FavoredOmrPrefix::IsInfrastructureDerived()` when
deciding to pause and change to `kDhcp6PdStateIdle`. This helps
improve code readability.
2025-02-12 10:29:21 -08:00
Abtin Keshavarzian 05f16b63c7 [routing-manager] track and log favored OMR prefix changes (#11236)
This commit enhances the `OmrPrefixManager` to track and log changes
to the favored OMR prefix. The new log includes the old favored
prefix (if any) along with the new one, and provides additional
information such as its preference, whether it is a domain prefix, or
whether it matches the local OMR prefix. This replaces and enhances
the previous logs.

This new mechanism can also be used to signal (to other modules) when
the favored OMR prefix changes.
2025-02-12 10:28:27 -08:00
Zhanglong Xia c1c5db8f20 [utils] check whether mInfo.mTxInfo.mIeInfo is null before using it (#11238)
The simulation platform radio driver doesn't set the 'mInfo.mTxInfo.mIeInfo'
field of the ACK frame. And the function 'otMacFrameUpdateTimeIe()' directly
use the 'mInfo.mTxInfo.mIeInfo' field, this may cause the program crash.

This commit checks whether 'mInfo.mTxInfo.mIeInfo' is null before using it
and sets the 'mInfo.mTxInfo.mIeInfo' field of the ACK frame to null in
simulation platform.
2025-02-12 10:24:34 -08:00
Zhanglong Xia a516a86209 [tests] do not retry when failed to receive specified number of frames (#11229)
When running the command `diag receive 1 rlp`, the DUT may fail to
receive the frame, then the otci will try the command again and
again. These retries are useless, and they will take lots of time
before timeout.

This commit sets the number of retry to 0 before executing the
command, and restore the number of retry after the command is
executed. This commit also captures the timeout exception from the
adb_shell.
2025-02-12 10:23:37 -08:00
Zhanglong Xia 68a5ce3abe [diag] set mIsSecurityProcessed field before sending frames (#11235)
The radio driver will set the `mInfo.mTxInfo.mIsSecurityProcessed` field
to True after the radio driver encrypts the frame. Which causes subsequent
frames to be sent will not be encrypted.

This commit sets the `mInfo.mTxInfo.mIsSecurityProcessed` field before
sending each frame.
2025-02-11 14:14:27 -08:00
Jason Zhang f7080a9343 [otci] normalize ADB shell output for consistent line splitting (#11231)
This commit adds compatibility to support these kinds of devices, so
that the shell() function can always return expected split lines in
list.
2025-02-11 07:51:47 -08:00
Yakun Xu a2d65a1ad7 [wake-up] enable CCA for wake up frames (#11024)
This commit enables transmitting wake up frames with CCA enabled. A
build time configuration is added in case the coprocessor doesn't
support the newly added feature skipping CSMA/CA backoff only.
2025-02-10 12:37:40 -08:00
dependabot[bot] 8418995ff0 github-actions: bump actions/setup-python from 5.3.0 to 5.4.0 (#11232)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.3.0 to 5.4.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/0b93645e9fea7318ecaed2b359559ac225c90a2b...42375524e23c412d93fb67b49958b491fce71c38)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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-02-10 10:36:22 -08:00
Handa Wang fd2e06d413 [tests] deal with the No Such Record lines in the output of dns-sd (#11223)
When resolving a hostname, `dns-sd` may output a line saying `No Such
Record` with an all-zero address which should be discarded.
2025-02-07 11:04:43 -08:00
Handa Wang 3385437695 [tests] reduce waiting time in the test of registering 500 SRP services (#11222)
Previously there's a delay for every router (10 seconds) and child (3
seconds) for it to start. The serialized waiting times are
unnecessary. This commit removes such waitings to speed up the test
case. This is especially useful in the BR test
`test_srp_register_500_services_br.py` which uses non-virtual time.
2025-02-07 10:53:14 -08:00
Esko Dijk a0243fa01a [cli] add '-x' flag to tcp client to send hexadecimal data (#11218)
This adds the `-x` flag to the `tcp send` command so send specific
data defined by a hexadecimal string.  The purpose is to use this in
testing, for example to emulate HTTP GET requests.
2025-02-07 10:50:15 -08:00
Jonathan Hui 320b50538f [docker] use arm64 runner instead of qemu (#11220) 2025-02-07 09:24:14 -08:00
Abtin Keshavarzian 521f95f608 [border-agent] track ForwardContext and abort TMF txn on disconnect (#11216)
This commit updates the Border Agent so that the `CoapDtlsSession`
tracks the forwarded CoAP request and the allocated `ForwardContext`
to the leader using `Tmf::Agent` in a list.

If the CoAP session disconnects before the forwarded request finishes,
the pending transaction is explicitly aborted in the session's
`Cleanup()` method using `Tmf::Agent::AbortTransaction()`. This
ensures that the response handler, `HandleCoapResponse()`, is invoked
while the session remains valid.
2025-02-06 08:50:09 -08:00
Zhanglong Xia 64e0811355 [diag] do not allow running diag send and diag repeat concurrently (#11184)
The current diag module allows users running the 'diag send' and 'diag
repeat' concurrently. The command run later will change the settings
of the command run earlier, which will cause unexpected test results.

This commit does not allow running 'diag send' and 'diag repeat'
concurrently.
2025-02-05 11:03:29 -05:00
Abtin Keshavarzian 62cac82ad8 [mdns] update TxMessageHistory to use message length and CRCs (#11183)
This commit updates `TxMessageHistory` to track the message length
along with calculated CRC-16 and CRC-32 values of the message
content. This replaces the use of SHA256 hash, simplifying the code
and removing the dependency of the mDNS core module on the crypto
platform layer (and mbedtls).
2025-02-04 11:14:52 -05:00
Abtin Keshavarzian bdb394eb3b [border-agent] introduce BorderAgent::EphemeralKeyManager (#11166)
This commit introduces the `BorderAgent::EphemeralKeyManager` class,
which manages the use of the ephemeral key by the Border Agent.

The `EphemeralKeyManager` uses its own DTLS transport and CoAP secure
sessions. This allows the `EphemeralKeyManager` and the `BorderAgent`
service (which uses PSKc) to be enabled and used in parallel.
Previously, a single transport and session was shared between these
functions, requiring the normal BA service (with PSKc) to be stopped
before the ephemeral key could be used.

This is a fundamental change and improvement to the ephemeral key and
Border Agent functionality. Therefore some existing `otBorderAgent`
APIs need to be modified. For example, `otBorderAgentGetState()`,
which returned the Border Agent state to indicate whether there were
any active sessions, is no longer meaningful, as different
sessions/transports are now used for PSKc and ephemeral key, and
there can be multiple sessions. This commit intentionally renames and
changes the `otBorderAgent` public APIs, specifically all those
related to ephemeral key use, to highlight the fundamental change in
behavior. While this can cause backward incompatibility, it requires
app layer code that used the previous APIs to be updated to take into
account the new behavior.

This commit also updates `nexus/test_border_agent`, adding new tests
to validate the new behavior (e.g., BA service and ephemeral key
parallel sessions). It also includes and validates the Border Agent
counter updates under different scenarios (this enhances and replaces
`test_ephemeral_key_counters.py`).
2025-02-04 09:34:08 -05:00
dependabot[bot] c5458354da github-actions: bump codecov/codecov-action from 4.5.0 to 5.3.1 (#11210)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.5.0 to 5.3.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/e28ff129e5465c2c0dcc6f003fc735cb6ae0c673...13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-03 18:03:23 -05:00
Abtin Keshavarzian e5aaa57f26 [mle] introduce TxMessage::AppendAddressRegistrationEntry() (#11205)
This commit introduces `TxMessage::AppendAddressRegistrationEntry()`
which appends an address entry in an MLE Address Registration TLV.
The new helper method determines whether a given address can be
appended as a compressed (using a lowpan context ID) or as an
uncompressed entry. This simplifies the code by moving all checks
into a common method. It also adds an explicit check to ensure the
associated Context TLV has the "compress" flag set before using
the compressed format.
2025-01-31 10:33:46 -08:00
Abtin Keshavarzian 9c21165c14 [key-manager] clarify otPlatRadioSetMacKey() and add counter safeguard (#11201)
This commit clarifies the intended behavior of the radio platform API
`otPlatRadioSetMacKey()` by recommending that implementations also
clear the MAC frame counter value (tracked by the radio).

It also adds a safeguard for this in `KeyManager` by changing the
order of operations. The MAC frame counter is now reset before
updating the key sequence and MAC keys. A comment explains the
rationale behind this ordering. This is to avoid potential issue
where a large counter value may be used with the new MAC key which
could then hinder frame transmission for a long duration.
2025-01-29 08:35:51 -08:00
Xavier RAZAVET d31bcee812 [joiner] support a new EUI-64 at run time (#11200)
The otJoinerStart enables a mechanism for Thread
commissioning. The traditional Thread commissioning process uses
factory assigned EUI-64 of the device to derive the Joiner ID and
identify/filter a joiner (through steering data bloom filter).

But otJoinerStart does not allows users to have a new EUI-64 set
at run time.

On joiner side, when a new EUI-64 value is provided, the
Joiner code uses this new value to derive the Joiner ID and
identify/filter a joiner (through steering data bloom filter).

On commissioner side, users can use this new EUI-64 value.
2025-01-28 22:17:03 -08:00
Suvesh Pratapa a8632ace1b [config] define uptime feature for MTDs (#11192)
MTDs built out of the OpenThread stack fail 1.4 network diagnostics
test cases that track connection time and role time in MLE counter
TLVs. We can workaround manually defining UPTIME for MTDs, but it's
better to make it the default behavior.
2025-01-28 12:01:05 -08:00
dependabot[bot] ee2049fb48 github-actions: bump docker/setup-buildx-action from 3.7.1 to 3.8.0 (#11198)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.7.1 to 3.8.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/c47758b77c9736f4b2ef4073d4d51994fabfe349...6524bf65af31da8d45b59e8c27de4bd072b392f5)

---
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-01-27 22:29:46 -08:00
Abtin Keshavarzian 7a7d0c6cbd [common] update and enhance CRC calculation (#11182)
This commit updates and enhances the CRC module.

It updates the implementation to allow both CRC16 and CRC32
calculation with different polynomials. It adds new `Feed()` methods
to add bytes from a buffer or from a message into CRC computation. It
also adds a unit test to cover CRC calculation (both CRC16 and
CRC32).
2025-01-27 22:29:26 -08:00
Abtin Keshavarzian 27782ad164 [instance] group static variable declaration in Instance together (#11193) 2025-01-27 21:28:06 -08:00
Marius Preda c25120edc0 [cli] update default bind interface (#11187)
This commit updates the default CLI bind interface to be consistent with
the description. The default behavior should apply to all Thread nodes,
not just devices that define UDP platform layer. For Thread nodes that
only use the Open Thread Stack, netif type OT_NETIF_THREAD_HOST has no
meaning.

Support for OT_NETIF_THREAD_HOST has been kept using the -h option.

Updated the CLI bind command readme to make it clear when the netif
options are valid and what is the default behavior.

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-01-27 20:02:57 -08:00
Jonathan Hui 0f094dd266 [docker] fix multi-arch docker builds (#11199) 2025-01-27 19:57:19 -08:00
Abtin Keshavarzian 6694d5c275 [instance] define key-ref manager only under MTD or FTD builds (#11189) 2025-01-23 11:32:50 -08:00
Abtin Keshavarzian 648f1a982d [core] replace #if !OPENTHREAD_RADIO with explicit FTD or MTD check (#11190)
This commit replaces the `#if !OPENTHREAD_RADIO` checks with explicit
`#if OPENTHREAD_FTD || OPENTHREAD_MTD` checks.

The existing check relied on the assumption that exactly one of the
three options `FTD`, `MTD`, or `RADIO` will be set, and therefore
`#if !RADIO`  was used indirectly as a check for `FTD` or `MTD`. This
change improves clarity and allows for future addition of new
configurations (where this assumption may no longer hold true).
2025-01-23 09:48:55 -08:00
Abtin Keshavarzian e363faedee [mle] enhance neighbor aging & suppress Link Requests on FTD children (#10985)
This commit updates neighbor aging and recovery on FTD children. An
FTD child establishes links with neighboring routers to receive
multicast MPL (re)transmissions.

If the device is an FTD child and has more than `mChildRouterLinks`
neighbors, it uses a longer neighbor age (`kMaxNeighborAgeOnChild =
150s`) and removes the neighboring router upon expiration without
attempting to re-establish the link.

This differs from the existing behavior (which is still used when the
device is a router or an FTD child with `mChildRouterLinks` or fewer
neighbors), where a 100-second age is used, and the device attempts
to re-establish links upon expiration by sending Link Requests.

Link Requests from FTD children are suppressed when a neighboring
router becomes unavailable, and the child already has more than
`mChildRouterLinks` neighbors. This helps reduce unnecessary network
traffic on denser networks, especially when a router device is
powered off.
2025-01-22 15:52:55 -08:00
Zhanglong Xia 5d2d77e74e [cp-caps] test the mTxInfo of the radio frame (#11169) 2025-01-22 13:52:52 -08:00
Damian Królik f8a3e51db6 [diag] go back to sleep after transmission (#11181)
When "diag radio sleep" is followed by "diag send" or "diag
repeat", the radio switches to and stays in the receive mode
after a transmission. Normally, the MAC layer is responsible
for putting the radio back to sleep but the MAC layer is
bypassed when using the diag commands.

Make sure that the radio goes back to sleep after
a transmission when the sleep mode is on. This helps command
like "diag repeat" work more reliably as the transmission
is less likely to be interferred with the accidental frame
reception.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2025-01-22 13:48:53 -08:00
Marius Preda 436f1f0dd6 [nat64] add support for port translation (#11043)
This commit adds support for port translation in NAT64.  Currently the
translator only supports a direct mapping between an IPv4 and an IPv6
address requiring a large IPv4 pool to work effectively. This implies
the need for an additional NAT 4 to 4 translator as the border router
will only have one private IPv4 in the LAN.

This commit enhances the current functionality according to NAT64 RFC
and dynamic PAT mechanism. This is used by any home router to share a
public IPv4 address with a range of devices using private
addresses. The port translation ensures the source port or the ICMP
identifier is always unique in the mapping table allowing a reply
packet to be matched with the request using the destination port and
address. This functionality can be disabled at compile time.

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-01-22 11:41:14 -08:00
Marius Preda a21666e275 [tcp] redefine conflicting symbols (#11174)
This commit redefines tcplp symbols that conflict with LWIP's TCP implementation:
- tcp_input has been renamed tcplp_input
- tcp_output has be renamed tcplp_output
- tcp_close has been renamed tcp_close_tcb
- tcp_init was already removed but the prototype was still present and was deleted
- TCP_MSS and TCP6_MSS have been renamed to TCP_MAXSS and TCP6_MAXSS

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-01-22 10:59:24 -08:00
dependabot[bot] 0c3d2c2bde github-actions: bump actions/upload-artifact from 4.4.3 to 4.6.0 (#11176)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.3 to 4.6.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882...65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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-01-21 09:47:49 -08:00
Przemysław Bida 4d6def38a5 [tcat] implement extraction of active dataset and commissioner cert (#10991)
Commit adds implementation of:
	- 0x40 Tcat tlv extraction of active dataset,
	- 0x25 Tcat tlv extraction of commissioner certificate.

Includes also refactoring of `BleCommand` adds new method `process_response`.
This simplifies:
- `GetPskdHash`
- `GetRandomNumberChallenge`
2025-01-21 08:43:19 -08:00
Damian Królik 8c0363c79b [diag] correct usage of "diag frame" (#11179)
The example for the "diag frame" command uses an invalid
802.15.4 frame while not bypassing the header and security
processing with "-s" flag.
In such a case, it cannot be guaranteed that the underlying
platform will send such a frame if it can't parse the frame
IEs to check if any dynamic data is to be injected.

Switch to using a correct ACK frame.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2025-01-21 08:42:04 -08:00
Abtin Keshavarzian f6cee7950d [mle] track remaining Link Request attempts when re-establishing links (#11160)
This commit updates `Router` to track the number of remaining Link
Request attempts during link re-establishment (when no Advertisement
is received from a router, and the router is aged out). This helps
simplify the code managing link re-establishment.
2025-01-15 14:29:02 -08:00
Zhanglong Xia 09bdd1893e [cp-caps] compare the send and received frames (#11162)
The original code counts the number of received frames to check
whether the specified frame format is supported. It doesn't check
whether the sent and the received frames are the same. The test
results may have some deviation.

This commit compares the sent and received frame to check whether the
specified frame format is supported. This commit also add a case to
test the wake-up frame format.
2025-01-15 13:56:42 -08:00
Abtin Keshavarzian d39f791f6d [border-agent] remove unnecessary state checks in CoapDtlsSession methods (#11165)
This commit removes unnecessary Border Agent state checks in
`CoapDtlsSession` methods. When the Border Agent is stopped, the DTLS
transport is closed, and all associated sessions are cleared and
removed.
2025-01-15 13:54:36 -08:00
Abtin Keshavarzian 0e1c9a79a3 [style] use constexpr instead of anonymous enum for constants (#11161)
This commit updates a few remaining places where anonymous enums were
used to declare constants, replacing them with `static constexpr`.
2025-01-15 11:05:15 -08:00
Li Cao b8c4545656 [border-agent] add APIs to enable/disable ephemeral key feature (#11119)
This commit adds OT APIs to enable/disable the ephemeral key feature
and get IsEnabled state of it.

Currently a dbus method is provided to enable/disable the Ephemeral
Key feature and it is implemented with the module `BorderAgent` in
ot-br-posix. After we move the MeshCoP Service Publisher into OT core,
we won't use the `BorderAgent` module anymore. So we put the get/set
methods into OT core first. In addition, the MeshCoP service published
has a state bitmap which has a bit to indicate if Ephemeral Key
feature is supported. So we have to put this data into OT core.
2025-01-15 10:39:50 -08:00
Abtin Keshavarzian 84e80c6708 [link-quality] track "link quality out" in LinkQualityInfo (#11155)
This commit updates `LinkQualityInfo` to track the "link quality out,"
which is the link quality from the neighbor's perspective. This value
is currently tracked by the `Router` class. The existing methods in
`LinkQualityInfo` that return the "link quality in" are renamed to
use `LinkQualityIn` to clarify and distinguish them.

This change uses existing bits in `LinkQualityInfo`, freeing up bit
fields in the `Router` class to be used for other information.
2025-01-14 15:35:35 -08:00
Abtin Keshavarzian 1c7abb69e0 [border-agent] organize CoapDtlsSession method definitions (#11142)
This commit improves the organization of `border_agent.cpp` by
grouping the method definitions for `CoapDtlsSession` into a separate
section.

In PR #11131, many methods were moved into this class. To keep the
`git diff` smaller and easier to review, the methods were left in the
same order as previously defined. This resulted in the methods of
`CoapDtlsSession` and `BorderAgent` being mixed and interleaved.

This PR rearranges the methods and defines separate sections for each
class. This commit does not contain any code logic changes.
2025-01-14 11:23:01 -08:00
Zhanglong Xia 6dd795fc3f [spinel] save the radio spinel metrics to temporary settings (#11058)
The otRadioSpinelMetrics includes metrics that record the count of the
RCP timeout and the count of RCP reboot and so on. After these events
happen, the Thread stack will exits and the system will re-start the
Thread stack again. In this case, metrics of the otRadioSpinelMetrics
will be cleared and metrics values are awalys 0.

This commit adds a temporary settings to store the radio spinel metrics.
The temporary settings will clear all settings after the system reboots.
2025-01-14 07:56:11 -08:00
Abtin Keshavarzian d16d160e2c [border-agent] update CoapDtlsSession to handle session functionality (#11131)
This commit updates the `CoapDtlsSession` class in `BorderAgent` to
move all session-related functionality into this class. It now
handles its own state and uses its own `Timer`, ALOC, UDP receiver,
etc.

Many methods previously defined in `BorderAgent` are now defined in
`CoapDtlsSession`, ensuring each session can be processed
individually. The `ForwardContext`, which tracks forwarded TMF
commands, is also moved into `CoapDtlsSession` and updated to track
its associated session.

This change prepares `BorderAgent` to support multiple concurrent
sessions in future PRs.
2025-01-13 15:56:56 -08:00
Jonathan Hui 000ef41f5a [github-actions] add arm-gnu-toolchain-14.2rel1 (#11154) 2025-01-13 15:50:25 -08:00
Marius Preda f8a27c250c [ip-utils] extend and improve ip4/ip6 headers (#11151)
This commit adds a new class, Ip4::Headers that offers support for
managing an IPv4 header along with UDP/TCP/ICMP4 headers from a received
message/frame. This functionality is equivalent to the one already
present for IPv6.

Added GetId() and SetId() methods to ICMP4 class.

Improved the Ip6::Headers functionality:
- added SetSourcePort() method to allow easier translation of ports in NAT64.
- added GetIpLength() and GetIpHopLimit() methods.

Added SetSourcePort() and SetDestinationPort() methods for TCP.

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-01-13 10:20:06 -08:00
Zhanglong Xia 4b782d5b77 [cli] allow executing the factoryreset command when running sync commands (#11106)
When running the sync command, such as `diag radio receive 10000`, the cli
doesn't allow running other commands before the sync command returns. Which
causes that the sync command may be blocked for a very long time and users
can't do anything to terminate the sync command. This will also cause the
test script to fail to run the second case after running first case fails.

This commit allows the cli to execute the `factoryreset` command when running
the sync command.
2025-01-13 10:17:38 -08:00
Yakun Xu 7bd3abd67b [script] allow specify old commit for check-size (#11147) 2025-01-10 09:41:56 -08:00
Zhanglong Xia 0e16655211 [otci] add adb key support for adb interface (#11149)
This commit adds an option for users to set the adb key when connecting
devices via the adb interface.
2025-01-10 09:39:18 -08:00
seb-fae 3ae741f95e [instance] fix index computation in multi-instances context (#11099)
In multi instances context, the GetIdx function did not return the
correct instance index.
2025-01-09 15:11:39 -08:00
Maciej Baczmański d7a266856f [diag] handle errors of TransmitPacket() (#11076)
`TransmitPacket()` should return an error from platform Radio
implementation, as for example Radio can be in incorrect state.

If error occurs, increase `mSentErrorInvalidStatePackets` stat.

Add wrong state case to tests and fix `diag repeat stop` called
too lata.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-01-09 10:47:40 -08:00
Abtin Keshavarzian e7f8f75320 [mle] expedite recovery from temporary router link quality mismatch (#10906)
This commit adds a mechanism to expedite recovery from temporary
router link quality mismatches. If a received `RouteTlv` (from a
received Advertisement) indicates that the neighboring router claims
no link to us by setting its `GetLinkQualityOut()` towards us as `0`,
and our two-way link quality to this router is at least Link Quality
2, we schedule a unicast MLE Advertisement to be sent to this
neighbor. This advertisement is sent after a randomly selected delay
within a one-second window using `Mle::DelayedSender`.

This helps with link recovery on the neighboring router, which
otherwise may take longer due to reliance on the next trickle
timer-triggered Advertisement transmission, which can be up to 32
seconds later and, being multicast, may be missed.
2025-01-09 10:26:15 -08:00
Abtin Keshavarzian a877341b3b [mle] introduce "gradual router link establishment" on FTD children (#11025)
This commit introduces a "gradual router link establishment" mechanism
for FTD children. An FTD child device communicates through its parent
but can establish links with other neighboring routers to receive
multicast messages (forwarded MPL) from them, improving multicast
reliability.

An FTD child tries to establish links with the first
`ChildRouterLinks` routers quickly (sending an MLE Link Request to
initiate the link upon receiving advertisements from a neighboring
router). The `ChildRouterLinks` is configurable through an OT
configuration option (specifying the default value) and at run-time
using the `otThreadSetChildRouterLinks()` API.

After the first `ChildRouterLinks`, the "gradual router link
establishment" mechanism allows `kExtraChildRouterLinks` additional
router links to be established slowly over a longer time. Gradual
router link establishment uses the following conditions:

- The link quality to the router must be 2 or better.
- It is always skipped in the first 5 minutes
  (`kWaitDurationAfterAttach`) after the device attaches.
- The child randomly decides whether to perform/skip this (with a 5%
  probability).
- If the child decides to send a Link Request, a longer random delay
  window is used ([1.5-10] seconds).

Even in a dense network, if 500 FTD children receive the
advertisement, with a 5% selection probability, on average, 25 nodes
will try to send a Link Request randomly spread over a 1.5-10 second
window.

With a 5% probability, on average, it takes 20 trials (20 advertisement
receptions) for an FTD child to send a Link Request. Advertisements
are, on average, ~32 seconds apart, so a child will try to establish
a link in approximately 10 minutes (20 * 32 = 640 seconds).
2025-01-09 10:17:22 -08:00
Abtin Keshavarzian 5ddcb44a96 [nat64-translator] ensure expired mappings are released in timer callback (#11139)
This commit fixes the release of expired mappings by ensuring that
`ReleaseExpiredMappings()` is always called from the timer callback
`HandleMappingExpirerTimer()`, regardless of the logging level.
Previously, `ReleaseExpiredMappings()` was called as an input to
`LogInfo()`, which could become an empty macro (ignoring its input)
if info-level logs were disabled.
2025-01-08 21:00:09 -08:00
Abtin Keshavarzian 5447ab8527 [cli] simplify ProcessLine() implementation (#11140)
This commit simplifies the `Cli::ProcessLine()` implementation and
adds comments to improve readability and clarity.
2025-01-08 20:58:56 -08:00
Abtin Keshavarzian 2ae1ce5293 [secure-transport] support multiple sessions on the same transport (#11092)
This commit updates `SecureTransport` to support multiple
`SecureSession`s on the same transport. The transport tracks a list
of sessions that it owns and manages. Two new callbacks are
introduced:

- `AcceptCallback`: Used to accept a new connection request, providing
  the `SecureSession` instance to use (passing ownership of the
  session to the transport).
- `RemoveSessionCallback`: Signals that a session is removed,
  releasing ownership of the session.

`BorderAgent`, `Tmf::SecureAgent`, and `ApplicationCoapSecure` are
updated to adopt the new model.

This commit also updates the Nexus `test_dtls`, adding
`TestDtlsMultiSession` to validate multiple session support
behavior.
2025-01-08 13:43:05 -08:00
Zhanglong Xia 70d315af23 [diag] add diag send async command support (#11111)
The original `diag send` command is an asynchronous command. Users
must wait for a certain period of time and then run the `diag stats`
command to query how many packets have been sent to know whether all
packets have been sent. This is very inefficient, and it is not
convenient for scripts to process this command.

This commit changes the command `diag send` from an asynchronous
command to a synchronous command, and add the asynchronous command
`diag send async`.
2025-01-08 11:21:13 -08:00
Jakub Uliarczyk 9942b98a4a [tcat] add tlv command tree (#11077)
This commit adds 'tlv' command tree to the BBTC CLI.
The 'tlv' command has two subcommands: 'list' and 'send'.
The 'tlv list' prints available TLVs types that can be used in the 'send' subcommand.
The 'tlv send <TLV_TYPE> <TLV_PAYLOAD>' allows sending specific TLV with arbitrary payloads.

Example:
`tlv send a 1234`
Send ping TLV(0x0a) with payload '1234'

The 'tlv' command tree is to gain the ability to send the TLV with any payload at any time.
This feature allows to check the behavior of TCAT device against:
- receiving of unexpected TLV
- receiving of TLV with corrupted payload
- receiving of TLVs sent in custom order
2025-01-08 10:49:32 -08:00
Handa Wang 12a10cb056 [continuous-integration] print summary for thread-cert test cases (#11129)
Previously, it prints a line `PASS x FAIL y ...` when all the runs of
a test case complete. However, such messages could be hard to find
when multiple test runs fail so the messages are interspersed between
other logs.

This commit moves such messages to the end of the output. This makes
it easier to notice which test cases are failed. Also it will list the
failed iterations, which is useful when MULTIPLY > 1.
2025-01-08 10:46:21 -08:00
Li Cao 2ecf7f547d [gitignore] ignore nexus unit test binaries (#11134)
Ignore unit test binaries. For example, `tests/nexus/nexus_border_agent`.
2025-01-08 10:44:07 -08:00
Abtin Keshavarzian fc7249861c [tasklet] add Unpost() method (#11101)
This commit adds `Tasklet::Unpost()` to remove a tasklet from the
tasklet scheduler run queue if previously posted.

It also adds a detailed unit test, `test_tasklet`, covering various
uses of `Tasklet`, such as posting single or multiple tasks.,
re-posting a task from its own handler, Un-posting tasks in different
orders.
2025-01-08 10:43:11 -08:00
Yakun Xu dc4acf0346 [coap] use otError in C handlers (#11115)
This commit changes CoAP handlers to use otError in the function or
method definitions. This ensures the definitions are consistent with
the declaration in coap.h.
2025-01-07 15:48:38 -08:00
Abtin Keshavarzian f3dded43b6 [crypto-storage] add KeyRefManager to select KeyRef values (#11102)
This commit introduces `Crypto::Storage::KeyRefManager`, which manages
and selects the `KeyRef` values. `ot::Instance` now will have its own
`KeyRefManager`. Under `MULTIPLE_INSTANCE_ENABLE`, this allows
different `ot::Instance`s to use different `KeyRef` ranges by setting
an instance-specific offset. This offset is used when determining the
`KeyRef` numerical value for secure storage access.
2025-01-07 15:39:07 -08:00
Zhanglong Xia 3470934f74 [diag] remove redundant messages output by the diag module (#11118) 2025-01-06 21:36:57 -08:00
Yakun Xu b6a7f076c2 [script] enhance check-size for local use (#11116)
This simplifies doing local check by enhancing the script to accept
extra cmake options and specifying the commit to compare.

Example usage:

```bash
OT_SHA_OLD=e4a390f34 ./script/check-size nrf52840 -DOT_FULL_LOGS=ON
```
2025-01-06 16:20:04 -08:00
Abtin Keshavarzian 90e90bba71 [test] add test_border_agent to nexus test cases (#11110)
This commit adds `test_border_agent`, using the nexus framework, to
cover the functionality of `BorderAgent`. The test cases include:

- Border Agent initial state.
- Establishing a secure session to the Border Agent and
  disconnecting.
- Handling "Commissioner Petition" to accept a full commissioner.
- Handling "Commissioner Keep Alive" and timeouts.
- Ephemeral key use and its initial state.
- Establishing a connection with an ephemeral key and disconnecting.
- Ephemeral key timeout mechanism (with or without a session).
- Ephemeral key use stopping after the maximum number of failed
  connection attempts.
2025-01-06 15:54:08 -08:00
Jonathan Hui 90ced5637b [mesh-diag] fix typo didPorcess -> didProcess (#11126) 2025-01-06 13:44:58 -08:00
Abtin Keshavarzian e4fb743a85 [border-agent] track successful connection with ephemeral key (#11109)
This commit adds a new variable, `mDidConnectWithEphemeralKey`, which
tracks whether a successful secure session is established using the
ephemeral key. This variable is used in `HandleConnected()` to
determine whether to stop using the ephemeral key when the Border
Agent is notified that the secure session is disconnected.

This change ensures that ephemeral key use is not stopped after a
failed connection attempt, while still guaranteeing that an ephemeral
key can only be used once.

Without this fix, a failed connection attempt would immediately stop
the use of the ephemeral key. With this change, the intended
`kMaxEphemeralKeyConnectionAttempts` will be applied.
2025-01-06 13:27:26 -08:00
Yang Song 54f6c273ca [cli] make meshdiag cli as a separate module (#11105) 2025-01-06 10:19:39 -08:00
Ashish fdb8190f50 [ot-fct] fix access file from path defined in build parameter (#11080)
When configuration file defined in build parameter(command line argument),
ot-fct is wound't take into an account and accessed default path.

This commit fixes to access configuration file from path which is
defined from build command line parameter. Also, it fixes some
compilation issues while building from ot-br-posix.

Signed-off-by: ashish <ashish.vara@nxp.com>
2025-01-06 09:35:07 -08:00
Yakun Xu 93f6d619ef [wake-up] fix time wrap for wake-up frames (#11028)
This commit fixes the potential issue that mTxDelay becomes 0 around the
32-bit time wrapping.
2025-01-06 09:34:08 -08:00
Abtin Keshavarzian 336d70127d [thread-netif] do not close Tmf::SecureAgent on Down() (#11067)
This commit updates the code so that `Tmf::SecureAgent` is not closed
when the Thread network interface is brought down. The `SecureAgent`
is directly controlled and used by either the `BorderAgent` or
`Commissioner` during network operation, which should continue to
function even if the Thread network interface is offline. It may also
be used by the `Joiner`, but in that case, it will be closed by the
`Joiner` itself upon finishing the join attempt.
2025-01-06 09:19:49 -08:00
Zhanglong Xia 69b91f9e62 [otci] add diag radio related commands support (#11112) 2025-01-06 08:56:10 -08:00
Yakun Xu 10a0a65f71 [mle] fix warning of maybe-uninitialied tlvType (#11114) 2025-01-06 08:53:28 -08:00
Zhanglong Xia 173cb61379 [diag] count the number of packets that are sent succeed and failed (#11108)
When using the `diag frame -c xxxx` command to enable the CSMA-CA when
transmitting the frame, the command `diag send` won't output any message
the CCA failure happens. It is difficult for users to know whether
the CSMA-CA is actually effective via diag commands.

This commit counts the number of packets that are sent succeed and failed,
outputs the transmision failure reason and do not re-transmit the frame
after it fails to send.
2025-01-03 16:44:02 -08:00
Yakun Xu 0e7039599c [mle] remove redundant checks in otThreadBecomeRouter (#11107)
The MleRouter::BecomeRouter already checks the device role and the API
claims only return OT_ERROR_INVALID_STATE when the role is disabled.

This commit consolidates the device role check in
MleRouter::BecomeRouter.
2025-01-03 16:43:14 -08:00
Yakun Xu 18a5e18e69 [api] clarify CSMA/CA behavior in TxInfo (#11036)
This commit clarifies the expected behavior with CSMA/CA parameters in
TxInfo.
* non-zero mTxDelay or non-zero mTxDelayBaseTime or falsy
  mCsmaCaEnabled disables CSMA backoffs, thus ignores the
  mMaxCsmaBackoffs field.
* Zero mMaxCsmaBackoffs disables CSMA backoffs.
* CCA is solely controlled by mCsmaCaEnabled.
2025-01-03 16:39:42 -08:00
Abtin Keshavarzian 127baf4aa1 [border-agent] update interactions with native Commissioner (#11087)
This commit updates the interaction between `BorderAgent` and the
native `Commissioner`, removing the unnecessary mechanism to stop and
restart the Border Agent when the commissioner is enabled and
disabled.

This was previously required because both modules shared the same
underlying `Tmf::SecureAgent` and DTLS transport. This has been
changed recently so that `BorderAgent` uses its own DTLS transport
and sessions.
2025-01-03 16:31:22 -08:00
Abtin Keshavarzian 1024a1fdb9 [border-agent] use separate DTLS transport and CoAP secure session (#11085)
This commit updates `BorderAgent` to utilize its own DTLS `Transport`
and CoAP `SecureSession`, separating it from the shared
`Tmf::SecureAgent` used by `Commissioner` and `Joiner` modules. This
change enables future support for multiple sessions within
`BorderAgent`.
2024-12-27 16:53:29 -08:00
Abtin Keshavarzian 6bb4b7c98d [secure-transport] reorder method definitions in cpp file (#11082)
This commit improves the organization of `secure_transport.cpp` by
grouping method definitions for `SecureSession` and `SecureTransport`
into separate sections.

The recent PR #11046 introduced `SecureSession`, separating the
session and transport functionality. To keep the `git diff` smaller
and easier to review, the methods were left in the same order as
previously defined. This resulted in methods of `SecureSession` and
`SecureTransport` being mixed and interleaved. This PR rearranges the
methods and defines separate sections for each class. This commit
does not contain any code logic changes.
2024-12-27 16:49:33 -08:00
Abtin Keshavarzian 151444f7dd [dataset] validate Active/Pending Timestamp and Delay Timer TLVs (#11088)
This commit updates the `Dataset::IsTlvValid()` method to also
validate the Active/Pending Timestamp and Delay Timer TLVs, ensuring
they have the minimum required length. This ensures that a dataset
with invalid TLVs is correctly rejected when set on a device.
2024-12-26 16:19:40 -08:00
Abtin Keshavarzian 1063090817 [border-agent] remove unused GetUdpProxyPort() method (#11086)
This commit removes the unused `GetUdpProxyPort()` method and the
related code tracking the proxy port in `BorderAgent`.
2024-12-26 12:41:34 -08:00
Abtin Keshavarzian 2e39577111 [coaps] introduce Coap::SecureSession along with Dtls::Transport (#11056)
This commit introduces the `Dtls::Transport` and `Dtls::Session`
classes, separating session-related functions from transport-related
behaviors. It also introduces the `Coap::SecureSession` class, which
handles CoAP processing over a DTLS session. This simplifies the code
by allowing `Coap::SecureSession` to inherit many of its methods from
`Dtls::Session`, avoiding repetition. It also separates CoAP-specific
message processing from transport-related functionality.

`Tmf::SecureAgent` and `ApplicationCoapSecure` are updated to act as
both a `Dtls::Transport` and a single `Coap::SecureSession`.
2024-12-26 12:40:08 -08:00
Abtin Keshavarzian 4c378f798d [netdata] add version number to DNS/SRP service entries (#10752)
This commit adds a version field (`uint8_t`) to DNS/SRP Anycast and
Unicast Service entries in `NetworkData::Service::Manager`.

For Unicast entries, the version the version field is placed after
the existing fields, specifically after the IPv6 address and port number fields.
For Anycast entries it is added as the in server data as part of the
Server TLV.

When processing Network Data service entries, the version field is
optional and if absent, version number zero is assumed.

The `NetworkData::Publisher` now considers entries with the same or
higher version number when deciding whether to add or remove its own
entry, preferring those with a higher version.

In SRP client, when `AutoStart` mode is used and if there are multiple
Unicast, Service entries, the client prefers the one with larger
version number.

When selecting an anycast entry, the existing rules regarding sequence
numbers are still used. If multiple entries with the same sequence
number exist, the client will assume the minimum version number among
all such entries.

This commit also updates the `test_network_data` unit test, validating
the new format and related methods.

`test_netdata_publisher.py` is also updated to check service entries
with different version numbers.
2024-12-23 18:59:06 -08:00
Abtin Keshavarzian 588e93cd15 [linked-list] allow use of Matches() with variable number of arguments (#11065)
This commit updates `LinkedList` and `OwningList` to enhance
`FindMatching()`, `RemoveMatching()`, and related methods to use
`Matches()` with a variable number of arguments. The implementation
uses a variadic template function and forwarding references.
2024-12-23 18:23:06 -08:00
Abtin Keshavarzian e9f45cb997 [border-agent] simplify HandleUdpReceive() (#11075)
This commit simplifies the `BorderAgent::HandleUdpReceive()` method:

- All local variables are defined at the top of the method.
- Tracks whether the UDP message was handled in the new local
  `didHandle` variable (avoiding the reuse of a specific error code
  to track this).
- Simplifies log messages.
2024-12-23 18:15:36 -08:00
Abtin Keshavarzian 143ebbfb7c [config] add guard checks for features that require DTLS/TLS support (#11068)
This commit adds guard checks for Border Agent, Commissioner, Joiner,
and CoAP Secure API features that use Secure Transport (DTLS/TLS) to
ensure `OPENTHREAD_CONFIG_SECURE_TRANSPORT_ENABLE` is enabled. It
also moves the deprecation check for the earlier DTLS configuration
to `openthread-core-config-check.h` to be consistent with other
removed/deprecated configurations.
2024-12-19 14:43:45 -08:00
Jonathan Hui 0c4b8d7733 [docs] update version to 1.4.0 (#11069) 2024-12-19 14:24:26 -08:00
Abtin Keshavarzian 7716f4b496 [meshcop] add LogCertMessage() (#11072)
This commit adds `LogCertMessage()` to generate a message dump log for
certification test. This function is used by both `Joiner` and
`Commissioner`, removing duplicate code.
2024-12-19 13:43:25 -08:00
Zhanglong Xia ef5e4f3e3d [diag] add diag radio receive filter command support (#11054)
The current diag module will count any packets received. This commit
adds the command `diag radio receive filter` to allow the diag module
receives only frames with the specified destination mac address.
2024-12-19 13:25:25 -08:00
Abtin Keshavarzian ff053df393 [border-agent] rearrange method definitions (#11071)
This commit rearranges the method definitions in the `BorderAgent`
class so that related methods are next to each other. This improves
code readability and organization. This commit contains no logic
changes.
2024-12-19 12:30:13 -08:00
Abtin Keshavarzian 89979bd39b [border-agent] return Counters as reference (#11070) 2024-12-19 12:29:29 -08:00
Jonathan Hui a71c1cee6c [github-actions] fix markdown-lint-check (#11074) 2024-12-19 10:00:53 -08:00
Abtin Keshavarzian d1147d62b9 [trel] detect and handle socket addr discrepancy for TREL peers (#10869)
This commit introduces a new mechanism for the TREL link to detect and
handle discrepancies between the IPv6 address and port used by a TREL
peer in a received TREL packet, and the information previously
reported by the platform layer (through DNS-SD discovery) for the
same peer.

Ideally, the platform underlying DNS-SD should detect changes to
advertised ports and addresses by peers. However, there are
situations where this is not detected reliably.

As a received frame over the TREL radio link is processed by the MAC
or MLE layers, if the frame passes receive security checks at either
layer (indicating it is a secure and authenticated/fresh frame from a
valid neighbor), the TREL peer socket address is automatically
updated from the received TREL packet info. This ensures the TREL
peer table is updated correctly if there are changes to TREL peer
addresses of valid Thread neighbors upon rx from such neighbor,
increasing the robustness of the TREL link.

This commit also introduces a new `otPlatTrel` platform API,
`otPlatTrelNotifyPeerSocketAddressDifference()`. The TREL
implementation now notifies the platform layer whenever it detects a
discrepancy in a TREL peer's socket address, regardless of whether
the peer table is automatically updated. This allows the platform
layer to take any appropriate action, such as restarting or
confirming DNS-SD service resolution query for the peer service
instance and/or address resolution query for its associated host
name.

This commit also adds a new test that validates the newly added
behavior, including the auto-update of peer table information and
notification of the platform through the new API, triggered by either
MLE or MAC messages over the TREL radio link.
2024-12-18 20:35:58 -08:00
Abtin Keshavarzian c34484d335 [linked-list] remove unused method & rename FindMatchingWithPrev() (#11057)
This commit contains the following changes to `LinkedList`:

- Removes the `FindMatching()` version that searches within a given
  sub-section of the list, as this method is no longer needed.
- Renames the method that finds a matching entry and also returns the
  `prev` entry in the list to `FindMatchingWithPrev()`. This
  distinguishes it from other `FindMatching()` overloads and
  clarifies its purpose. This method is often used when the caller
  wants to find the matching entry and later remove it from the list.
2024-12-18 15:43:32 -08:00
Abtin Keshavarzian 67c28900ce [secure-transport] simplify how Connect/Receive callbacks are set (#11050)
This commit updates and simplifies how `Connect` and `Receive`
callbacks are set on `SecureTransport` and `CoapSecure`. Instead of
using the `Open()` method to set these, they are now directly set
using the corresponding `SecureSession` methods. This commit also
harmonizes the method name for setting the "connect" callback,
ensuring the same name is used by different classes.
2024-12-18 15:42:19 -08:00
Maciej Baczmański 33c9e67a9e [diag] refactor command processing to remove redundant code (#11055)
All diagnostic commands (instead of `diag start`) should fail if
device is not in diagnostic mode. Previously it was verified by
each command's process method (with a missing check in
`ProcessEcho` and `ProcessGpio`). This commit moves the check
directly to `ProcessCmd` and cleans up redundant code.

Additionally clean the documentation and align the code as for
some commands `status 0x00` was added on success and for some not.

Move `AppendErrorResult()` to `ProcessCmd()` as well.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-12-18 13:52:33 -08:00
Abtin Keshavarzian 4e9d362b67 [secure-transport] introduce SecureSession class (#11046)
This commit introduces the `SecureSession` class to manage
session-related functionality, decoupling it from the
`SecureTransport` class. `SecureSession` provides method such as
`Connect()`, `Send()`, and `IsConnected()`, while `SecureTransport`
focuses on transport-level operations and common configuration
(e.g., setting PSK, cipher keys).

The `Dtls` and `Tls` subclasses now inherit from both
`SecureTransport` and `SecureSession`, effectively providing the same
methods as before and implementing a single DTLS/TLS session over a
socket.
2024-12-17 22:01:31 -08:00
Abtin Keshavarzian 35608703f7 [secure-transport] set app keys on config before SSL context setup (#11044)
This commit updates `Setup()`, which initializes and sets up
`mbedtls_ssl_config` and `mbedtls_ssl_context`. The call
`mExtension->SetApplicationSecureKeys()` (which updates the
`mbedtls_ssl_config`) is now called before `mbedtls_ssl_setup()`
associates the config with the `mbedtls_ssl_context`. This
follows the recommendation that the config structure is not
modified after `ssl_setup()` and while a session is active.
2024-12-16 10:19:50 -08:00
dependabot[bot] e583b42500 github-actions: bump github/codeql-action from 3.26.9 to 3.27.9 (#11053)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.9 to 3.27.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/461ef6c76dfe95d5c364de2f431ddbd31a417628...df409f7d9260372bd5f19e5b04e83cb3c43714ae)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2024-12-16 09:04:19 -08:00
Zhanglong Xia 81542cada9 [posix] move settings file related methods to a separate file (#11023)
This commit refactors the settings module to move the settings file
related methods to a seperate file, so that other modules could resue
the same code to save thier settings to another settings file.
2024-12-16 08:49:11 -08:00
Zhanglong Xia 971f05f760 [diag] add diag receive command to show received specified number of frames (#11039)
The `diag frame` command can set the frame to be sent. But developers
has no command to check if the received frame is the same as the sent
frame. This commit adds the command `diag receive [async] <number>
[lpr]` to show the detailed info of specified number of received
frames.
2024-12-13 15:31:51 -08:00
Yakun Xu 93ef72ad92 [mle] avoid link dead lock (#11030)
The current MLE Link Request handler would result in dead lock if two
routers sends Link Request to each other at very close time points, when
either node tracks the other node in LinkRequest state, so rejects the
request until timeout.

This commit changes the handler so that a node will accept the Link
Request even if the peer is in LinkRequest state.
2024-12-13 14:39:21 -08:00
Abtin Keshavarzian 9404feeac9 [mle] remove scheduled Link Request to a router if a link is established (#11045)
This commit adds a mechanism to remove any scheduled (delayed) Link
Request transmissions to a neighboring router when a link is
established with it.
2024-12-13 14:36:09 -08:00
Zhanglong Xia ea7676cd54 [mac_frame] process the key id mode 2 only when the wakeup coordinator is enabled (#11047)
The wakeup frame is sent from the wakeup coordinator rather than the
wakeup end device.  Current code processes the key id mode 2 only when
the device is the wakeup end device.  This commit corrects this issue.
2024-12-13 07:21:22 -08:00
brian-level 1e3c4d7d6d [radio] fix sub-ghz build wrt channel page index (#11033)
The .cpp file uses channel page2 for subghz channels, not page1, this fixes that.
2024-12-12 23:27:58 -08:00
yanquantan d539ad3226 [diag] set rx_when_idle mode when diag start/stop (#11035)
This commit fixes an issue related to #9554 where a new radio
capability is introduced: RX_ON_WHEN_IDLE.

In this commit, we set `rx_on_when_idle` to be true when calling `diag
start`, and false when calling `diag stop` for devices which support
`rx_on_when_idle`.

This fix ensures that packets can still be received if `diag` is used
after `ifconfig down`.
2024-12-12 22:11:02 -08:00
Przemysław Bida d83ddf7137 [diag] add new command to factory diags (#11001)
Commit adds new command to factory diag called `radio`.
	- `enable` for enabling the interface to default mode,
	- `disable` for disabling the interface
2024-12-12 20:28:52 -08:00
Zhanglong Xia 9fefeedb0d [mac-frame] process the security of the wakeup frame (#11003)
If the radio driver supports the `OT_RADIO_CAPS_TRANSMIT_SEC`, the
radio driver should process the security of the send frame. But the
current method `otMacFrameProcessTransmitSecurity()` doesn't process
the security of the wakeup frame. Which causes sent wakeup frame is not
encrypted.

This commit enables the method `otMacFrameProcessTransmitSecurity()`
to process the security of the wakeup frame.
2024-12-12 15:32:41 -08:00
Yakun Xu 871196689d [test] skip installing cmake 3.10.3 (#11040)
There is a standalone CMake version check, no need to use this version
in gcc specific build tests. This change should accelerate gcc build
check, as it takes 8.5 minutes to build cmake.
2024-12-12 15:29:56 -08:00
Abtin Keshavarzian c2d5265c68 [secure-transport] separate transport/socket and session states (#11022)
This commit updates how state is tracked in the `SecureTransport`
class. It directly tracks whether the transport/socket has been
opened or closed in a new member variable `mIsOpen`. The TLS/DTLS
session state is tracked separately in `mSessionState`. This
separation allows for future changes to support multiple sessions
using the same transport/socket.

This commit also simplifies the session states, adding "disconnected"
and "disconnecting" (replacing "close notify") states.
2024-12-11 11:47:56 -08:00
Zhanglong Xia c427043c5a [spinel] do not update the sent frame if the frame has been updated before sending (#10976)
When running the command `diag frame -s
fd874f68f1ca00efbe00adde5d4f4913e953845a154d4cbab10000000001820e390005009bb8ea011c58a065c39fbd`
and `diag send 20` to send the specified diag frame, we found that the
frame is modified by the RadioSpinel module. Which causes the diag
sent frames are not the same.

This commit checks whether the frame header has been updated before
sending, the RadioSpinel module won't update the frame header if the
frame header has been updated before sending. This commit also adds an
option `-u` to the `diag frame` command to specify the
`mInfo.mTxInfo.mIsHeaderUpdated` field of the diag sent frame.
2024-12-11 11:04:39 -08:00
Yakun Xu b92bd46b60 [api] correct typo of CallbackContext (#11034) 2024-12-10 21:58:47 -08:00
Zhanglong Xia 4f2eec909b [diag] add options -b, -C, -d and -r to the diag frame command (#11010) 2024-12-10 07:59:12 -08:00
Zhanglong Xia 124f0508cb [spinel] add an API to enable/disable the RCP restoration feature (#11011) 2024-12-10 07:42:29 -08:00
Abtin Keshavarzian fe7d34f9d8 [secure-transport] track server/client role in mIsServer (#11021)
This commit adds a local member variable `mIsServer` to the
`SecureTransport` class to track whether it is configured to act
as a server or client.
2024-12-09 18:38:23 -08:00
Zhanglong Xia b37b15b525 [diag] use CmdLineParser to parse numbers in diag commands (#11009) 2024-12-09 18:37:17 -08:00
Yakun Xu ca318d2936 [test] make test_diag less flaky (#11008)
This commit expects echo of diag commands to make sure the command is
received by the node when waiting for the expected output. This helps
make this test less flaky.
2024-12-09 14:43:00 -08:00
Yakun Xu d540fc7f43 [mac] skip backoff when MaxBackoffs is 0 (#11012)
This commit allows skip CSMA backoff but keep CCA enabled by respect the
Max Backoffs parameter in TxInfo.
2024-12-09 11:12:35 -08:00
Yakun Xu e314146a58 [mle] do not request link if not recognized (#11007)
If the new router is not in peer's route TLV, the link request would
be ignored, causing the link establishment stuck at the Link Request
stage until timeout when a new attempt could proceed. This commit adds
a check on the initiator to make sure the peer router's Route TLV
contains the initiator's router id before sending the link request,
otherwise it refrains from initiating the link establishment.
2024-12-09 11:11:49 -08:00
Abtin Keshavarzian fa9994a753 [secure-transport] fix Send() method to send entire message (#11004)
This commit simplifies and fixes the `Send()` method by sending the
entire `aMessage` content and removing the extra `aLength` input
parameter. In all calls, the input `aLength` was set to the message's
length. The previous implementation of `Send()` did not correctly
handle cases where the passed-in length was longer than the available
bytes in the given message.

This commit also updates the documentation of `Send()` to clarify the
behavior regarding the transfer of ownership of `aMessage`.

Additionally, this commit simplifies `CoapSecure` and `BleSecure`
where `Send()` is called.
2024-12-09 11:08:53 -08:00
Abtin Keshavarzian abed472119 [cli] update ba counters to use counter name lookup array (#11005)
This commit updates the `ba counters` CLI command to use a counter
name lookup array. This follows the same approach used in `Cli` for
other counters, such as MAC, MLE, IP, and BR counters.
2024-12-09 11:07:27 -08:00
dependabot[bot] ded7c3e09f github-actions: bump actions/setup-python from 5.2.0 to 5.3.0 (#11014)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/f677139bbe7f9c59b41e40162b753c062f5d49a3...0b93645e9fea7318ecaed2b359559ac225c90a2b)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2024-12-09 11:06:25 -08:00
Abtin Keshavarzian 101eac0bc1 [mle] add mechanism to track current attach duration (#10923)
This commit adds a new mechanism to track the current attach time
(the time duration since device was last attached to a Thread mesh).
This duration indicates how long the device has been connected,
regardless of its role(child, router, or leader).

A related public OT API and CLI command are also added. This
information can be used for debugging purposes and internally within
the OT core to wait for the device to stabilize before enabling
certain behaviors.
2024-12-09 10:19:11 -08:00
Abtin Keshavarzian 7b72e97782 [srp-server] use kNetifThreadInternal for UDP socket (#10992)
This commit updates `Srp::Server` to associate its UDP socket with
`kNetifThreadInternal`, ensuring that received messages are from the
internal Thread network interface (i.e., from devices within the
Thread mesh).
2024-12-05 18:53:24 -08:00
Abtin Keshavarzian 6bbb258023 [test] add test_dtls to nexus test cases (#10996)
This commit adds `test_dtls` using the nexus framework, which covers
basic functionality of `Dtls` (`SecureTransport). The test covers:

- Devices acting as DTLS server or client
- Establishing a DTLS session and data transfer
- `ConnectedHandler` events when the peer or local side disconnects
- Failed connection attempts (e.g., using an incorrect PSK)
- Setting max allowed attempts and auto-close behavior
2024-12-05 18:47:48 -08:00
Jonathan Hui 49657d4bb7 [docs] remove empty lines (#10999) 2024-12-05 14:34:58 -08:00
Jonathan Hui 881f557629 [ip6] filter received packets with loopback addrs (#10998) 2024-12-05 12:41:12 -08:00
Jonathan Hui ee2d7d5a3e [mle] exclude loopback from Address Registration TLV (#10997) 2024-12-05 10:49:27 -08:00
Abtin Keshavarzian 382eaea259 [secure-transport] update mbedtls timer to track finish time (#10993)
This commit updates how MbedTLS timers are handled, ensuring that both
intermediate and finish times are tracked in their own variables.
This decouples the intervals from the underlying `TimerMilli`
instance, allowing the same timer to be shared to support multiple
sessions later.
2024-12-05 09:54:20 -08:00
Abtin Keshavarzian a0f861d78e [secure-transport] refactor Setup() to separate component setup (#10987)
This commit updates the `Setup()` method to separate the preparation
of the `mbedtls_ssl_config`, `mbedtls_ssl_cookie_ctx`, and
`mbedtls_ssl_context` components. This allows for decoupling these
components later, for example, to support multiple sessions using the
same configuration.
2024-12-04 12:32:06 -08:00
gytxxsy bf34ecc704 [cli] fix the issue of overflow when calculating ping statistics (#10986)
Fix the overflow issue when `mTotalRoundTripTime` is very large.
2024-12-04 10:48:31 -08:00
Abtin Keshavarzian 89d2ccacfb [secure-transport] rearrange method definitions (#10978)
This commit rearranges the method definitions in the `SecureTransport`
source file to place the `SecureTransport::Extension` class methods
next to each other and after the `SecureTransport` methods.
2024-12-04 10:19:58 -08:00
Abtin Keshavarzian 53c02c6141 [secure-transport] introduce Extension class (#10978)
This commit updates `SecureTransport`. It introduces the `Extension`
class within `SecureTransport`, providing support for additional
cipher suites and related methods to configure the ciphers
(e.g., `SetPreSharedKey()`, `SetCertificate()`).

This class decouples this functionality from the common
`SecureTransport` object, allowing it to be added to any class.
Classes like `ApplicationCoapSecure` or `BleSecure` can inherit from
`Extension` to provide these methods. An `Extension` is then
associated with a `SecureTransport` (or any of its subclasses). This
approach ensures that only instances requiring extended cipher suite
support incur the associated memory cost and avoid repeated code.

This commit also introduces `Dtls`, `DtlsExtended`, and `Tls` as
subclasses of `SecureTransport` for easier use by other modules.
2024-12-04 10:19:58 -08:00
Yakun Xu f0d6007cc3 [style] converge some common utils (#10982)
This commit converges common utils in core and lib to avoid duplicate
code and conflicts caused by two common utils are included by some
units.
2024-12-04 08:39:44 -08:00
dependabot[bot] 2868c9ce6b github-actions: bump actions/download-artifact from 4.1.7 to 4.1.8 (#10981)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.7 to 4.1.8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/65a9edc5881444af0b9093a5e628f2fe47ea3b2e...fa0a91b85d4f404e444e00e005971372dc801d16)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  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>
2024-12-02 15:37:35 -08:00
Abtin Keshavarzian 5c8af41eb2 [indirect-sender] reset message timestamp on child mode change to non-sleepy (#10979)
This commit resets (to now) the timestamp of queued messages for a
previously sleepy child when the child mode changes to non-sleepy.
This ensures that delay-aware queue management is correctly applied
to these messages and avoids them being dropped immediately.
2024-12-02 15:21:36 -08:00
Abtin Keshavarzian 473af53155 [udp] add kNetifThreadInternal which disallows platform UDP use (#10965)
This commit introduces `kNetifThreadInternal` as a network interface
option for UDP sockets. Unlike other options, this disallows the use
of platform UDP for the socket, indicating that the socket should use
the OpenThread internal Thread network interface only.

This model replaces the previous approach where `ShouldUsePlatformUdp()`
would check the socket port against a set of port numbers used by
different modules (such as MLE, TMF, Joiner Router, etc) to determine
whether platform UDP APIs should be used. With the new model, each
module decides whether to associate its socket with the
`kNetifThreadInternal`.

This is a more flexible and extensible model, ensuring that sockets
that should not use the platform do not waste resources (they will
not be created or opened/closed on the platform). This also help
avoid edge cases where platform UDP operations may unintentionally
fail when the platform socket is not actually needed.
2024-11-28 08:58:19 -08:00
Suvesh Pratapa ae5b750d30 [cli] set mUseTls to false after de-initializing TCP session (#10977)
Avoid SSL context operations in TCP callbacks (for
eg. `HandleTcpDisconnected`) when the context could have already been
de-allocated after de-initialization.
2024-11-27 15:36:33 -08:00
Abtin Keshavarzian 64cf63ecb2 [test] fix address list comparison in spinel_prop_codec (#10954)
This commit updates how address lists are compared in the unit test
`spinel_prop_codec`, ensuring that the correct size based on the
array length is passed to `memcmp()`.
2024-11-27 07:33:11 -08:00
Abtin Keshavarzian 8dfacb514b [mac] add CalculateRadioBusTransferTime() helper method (#10966)
This commit adds `Mac::CalculateRadioBusTransferTime()`, which
calculates the radio bus transfer time (in microseconds) for a given
frame size based on `Radio::GetBusSpeed()` & `Radio::GetBusLatency()`.
This helper method is used in the `CslTxScheduler` and
`WakeupTxScheduler` classes to update frame request-ahead time.
2024-11-27 07:32:26 -08:00
Abtin Keshavarzian 88ab0174ec [secure-transport] use mbedtls_ssl_is_handshake_over() (#10973)
This commit updates how the handshake completion is checked on MBedTLS
version 3.0 or later. Instead of accessing the private `state`
variable, the `mbedtls_ssl_is_handshake_over()` function is used.
This follows the recommendation of the MbedTLS documentation to avoid
using the deprecated `mSsl->MBEDTLS_PRIVATE(state)` access on newer
versions.
2024-11-27 07:31:14 -08:00
Abtin Keshavarzian 65dd8bff66 [udp] update Socket::Open() to include NetifId (#10964)
This commit updates how the `NetifId` is set on a `Udp::Socket`. It is
now specified as a parameter in the `Open()` call instead of `Bind()`.

This change makes the socket more flexible by allowing the `NetifId`
to be known earlier (which can be used for future optimizations). It
also allows the desired `NetifId` to be set even when `Bind()` is not
explicitly called, such as when `Connect()` or `SendTo()` are used on
a socket that is not yet bound. Previously, `kNetifThread` was
assumed by default in these situations.

The public `otUdp` APIs are left unchanged to ensure backward
compatibility.
2024-11-26 11:18:53 -08:00
Abtin Keshavarzian d347dd51e7 [udp] remove extra ShouldUsePlatformUdp() checks (#10962)
This commit removes the `ShouldUsePlatformUdp()` call in
`Ip6::PassToHost()` and `Udp::HandleMessage()`.

`ShouldUsePlatformUdp(port)` checks whether the port is NOT one of the
port numbers used by the OT stack, such as the MLE port, TMF port,
border agent port, or joiner port. This check is already covered by
`Udp::IsPortInUse()`, which checks if there is a UDP socket bound to
the given port.

Applying such a filter in `Udp::HandleMessage()` seems to have been
added by mistake, as it blocks the use of UDP receivers, which should
be able to receive and process on any port, not just the ports where
we have a socket bound.
2024-11-26 11:18:17 -08:00
Abtin Keshavarzian d43cb0d1ea [csl] introduce CslNeighbor class (#10956)
This commit introduces `CslNeighbor`, a subclass of `Neighbor` that
also inherits from `IndirectSender::NeighborInfo` and
`CslTxScheduler::NeighborInfo` to manage indirect transmission and
CSL-specific information.

The `Child` class now inherits from `CslNeighbor`, inheriting all CSL
functionalities while adding extra child-specific information. The
newly added `CslNeighbor` allows extending CSL functionality to
devices in other roles, not just `Child` devices.

The `CslTxScheduler` class is updated to use `CslNeighbor` as well
(instead of `Child`), making it more general-purpose.

`IndirectSender`, its sub-components, and `Mac` are updated to enable
CSL on MTD builds when `OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE`
is enabled.

This restructuring provides a more flexible and scalable framework for
implementing enhanced CSL functionality on new device types.
2024-11-26 10:58:25 -08:00
Li Cao 147de7e4cb [ncp] fix get property handler of SRP SERVER (#10967)
This commit fixes the wrong implementation of the GetProperty handler
of `SPINEL_PROP_SRP_SERVER_ENABLED` and
`SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE`.

In GetProperty handlers only the body should be written. It doesn't
need to and shouldn't call `BeginFrame` and `EndFrame`. If using
`BeginFrame` here, it will get an error of INVALID_STATE.
2024-11-25 10:49:53 -08:00
Abtin Keshavarzian 4b9134d5e1 [mac] define Mac::kCslRequestAhead constant (#10963)
This commit defines the `Mac::kCslRequestAhead` constant, which
maps to `OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US`. This
constant is used within the core modules.
2024-11-25 09:27:39 -08:00
Yang Sun dd6cd98064 [trel] bind the socket to TREL interface (#10957) 2024-11-25 09:13:08 -08:00
dependabot[bot] 1816c1862d github-actions: bump step-security/harden-runner from 2.10.1 to 2.10.2 (#10968)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.10.1 to 2.10.2.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/91182cccc01eb5e619899d80e4e971d6181294a7...0080882f6c36860b6ba35c610c98ce87d4e2f26f)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-11-25 07:19:45 -08:00
Abtin Keshavarzian ada03e6159 [num-utils] add DivideAndRoundUp() helper (#10960)
This commit introduces the `DivideAndRoundUp()` method, which divides
two given unsigned integers and always rounds the result up.
2024-11-22 18:53:45 -08:00
Przemysław Bida ac11a91d32 [logging] align define guards on RegisterLogModule and LogAt. (#10958)
Commit aligns define guards on `LogAt` macto and `RegisterLogModule` to
match. Previuosly `OT_SHOULD_LOG` was getting default value set as
platform defined and log level was buy default set to none which caused
misalignment.
2024-11-22 18:05:46 -08:00
Abtin Keshavarzian 051d8cd3c4 [radio] refactor Radio::Statistics (#10961)
This commit refactors `Radio::Statistics` to be a nested type within
the `Radio` class. It is declared as a `friend` of `Radio` so that
its interaction with `Radio` can be defined as `private` methods.
2024-11-22 17:07:54 -08:00
Abtin Keshavarzian b29b6433d9 [radio] add GetBusSpeed() and GetBusLatency() methods (#10959)
This commit adds `GetBusSpeed()` and `GetBusLatency()` methods to the
`Radio` class, which map to the corresponding `otPlatRadio` platform
APIs.
2024-11-22 16:49:30 -08:00
Zhanglong Xia c44538e4df [simulation] enable the platform assert (#10952)
When the ot-rcp enters the assert state, the host crashes and exits.
But the ot-rcp still runs in the dead loop and becomes an orphan
process.

This commit enables the platform assert so that the ot-rcp can
automatically exit when entering the assert state.
2024-11-22 16:48:51 -08:00
Abtin Keshavarzian 35cc162dec [indirect-sender] remove callbacks to its sub-components (#10955)
This commit removes the `Callbacks` class defined for use between
`IndirectSender` and its underlying `DataPollHandler` and
`CslTxScheduler` components. This model was added earlier in #3952 to
make all interactions between these modules asynchronous
(callback-based). The objective was to move the handling of data
polls and indirect transmissions closer to the MAC layer and allow
`DataPollHandler` logic to be moved to RCP in an host and RCP
architecture. With the introduction of CSL, this approach is no
longer viable, but the callback style was still used. This commit
removes this and simplifies the code.
2024-11-22 07:09:21 -08:00
Yakun Xu 025d84ba1e [fuzz] expect no ACK if TX frame is invalid (#10951)
The Sequence Number Suppression field and AR can be both 1 in fuzz test,
in which case, the frame is not valid. And no ack should be expected.
This commit changes the expectation in this case.
2024-11-21 18:13:27 -08:00
Li Cao b617ba3b71 [spinel] fix spinel_prop_codec unit test (#10950)
This commit fixes an issue in spinel_prop_codec unit test.

We cannot use Spinel::Decoder::ReadUintPacked with a spinel_prop_key_t
type. This will cause build errors on arm platforms.
2024-11-21 11:00:13 -08:00
Jakub Uliarczyk 9ae7de563c [tcat] fix: use normalize_uuid_str() on BBTC_SERVICE_UUID (#10879)
This commit adds 'normalize_uuid_str()' in 'scan_tcat_devices()'.
It fixes an issue finding TCAT devices in newer versions of the 'bleak' module.
2024-11-21 09:04:28 -08:00
Zhanglong Xia 7f6723ffb3 [log] add build option OT_LOG_MAX_SIZE to set the max log string size (#10948) 2024-11-20 20:06:35 -08:00
gytxxsy d5d602267c [spinel] return no_buf error when src entry count exceeds the maximum (#10884) 2024-11-20 19:47:17 -08:00
Przemysław Bida efa6f9fbc6 [tcat] implementation of tcat disconnect command (#10859)
Implementation of tcat disconnect command in python client.
2024-11-20 19:46:19 -08:00
Przemysław Bida bfcfc3f2b8 [tcat] add TCAT advertisement parsing in client (#10863)
Commit adds TCAT advertisement pars and display during scan operation
perormed in python client.
2024-11-20 18:49:28 -08:00
Abtin Keshavarzian ac12984358 [mle] apply random delay when sending Link Request on advertisement reception (#10870)
This commit updates `DelayedSender` to allow scheduling of delayed MLE
Link Request messages. This is used to apply a random delay when
sending a Link Request after receiving an MLE Advertisement from a
neighbor.

Advertisement messages are multicast transmissions and can be received
by multiple nodes, potentially causing synchronized generation of
Link Requests. This change helps distribute the transmission time
over a random window (one second if the requester is a router, or
[1.5-3] seconds window if it is a child).

When a router timeout occurs (i.e., no advertisements are received
from a neighboring router for more than the maximum allowed age), the
device sends Link Requests to restore its link. This commit updates
this process to apply a random delay (over a one-second window) to
each Link Request transmission.

This aligns the implementation with the Thread specification and can
improve network behavior when a new router is added or abruptly
removed.
2024-11-20 18:12:40 -08:00
Li Cao f26e1bb852 [spinel] add spinel property codec (#10934)
This commit adds spinel_prop_codec module to lib/spinel to provide
encoding & decoding functions for complex spinel properties.

This commit moves the encoding of `SPINEL_PROP_DNSSD_HOST`,
`SPINEL_PROP_DNSSD_SERVICE` and `SPINEL_PROP_DNSSD_KEY_RECORD` from
NcpBase to the lib and adds the decoding functions. The background is
that I found the encoding & decoding of complex spinel properties are
error-prone. However the encoding and decoding of one property are
usually put in different places. For example, encoding is in
openthread ncp while decoding is in ot-br-posix ncp spinel. It's
difficult to debug the decoding in ot-br-posix and there is no unit
tests for the encoding & decoding.

This commit puts the encoding & decoding together and adds unit tests
to ensure they are correct.
2024-11-20 12:24:34 -08:00
Abtin Keshavarzian a7e058f56c [coap] add base class CoapSecureBase and ApplicationCoapSecure (#10945)
This commit refactors COAPS classes, renaming the `CoapSecure` class
as `CoapSecureBase`, which is the base class of `Tmf::SecureAgent`
and a newly added `ApplicationCoapSecure` class. This change
simplifies the code and class hierarchy and ensures that the
Application COAP secure related functions are only provided by
`ApplicationCoapSecure` and when the corresponding config feature
`OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE` is enabled.
2024-11-20 10:20:47 -08:00
Abtin Keshavarzian 76a0334090 [secure-transport] remove extra mbedtls_ssl_close_notify() calls (#10947)
This commit removes the calls to `mbedtls_ssl_close_notify()` in
`SecureTransport::Process()` when, based on `rval`, it is determined
that `Disconnect()` should be called, as the `Disconnect()` method
itself will call `mbedtls_ssl_close_notify()`.
2024-11-20 10:09:01 -08:00
Abtin Keshavarzian 563df7dd56 [secure-transport] reorder member variables to avoid alignment gaps (#10946)
This commit reorders the member variables in `SecureTransport`,
grouping booleans and variables of the same size closer to each other
to avoid alignment gaps and allow for better code optimization.
2024-11-20 10:08:31 -08:00
Zhanglong Xia 51169ac032 [simulation] log the exit code when the program exits (#10936)
Sometimes `ot-rcp` will exit without any exit information in the
log. It is hard for developers to know what happens on the `ot-rcp`
side when the `ot-rcp` exits abnormally. This commit calls functions
defined in `lib/platform/exit_code.h` to exit the program and log the
exit information.
2024-11-20 07:22:47 -08:00
Abtin Keshavarzian 8d39758563 [secure-transport] simplify Process() method (#10933)
This commit simplifies `SecureTransport::Process()`:
- The `mReceiveCallback` is invoked only after a successful `read()`
  Afterward, we `continue` back through the loop to check if it can
  read again.
- The `rval` checks are now combined into a single `switch()`
  statement to determine if the connection should be disconnected,
  reset, or if the process should wait, and then takes the proper
  action.
2024-11-19 08:57:30 -08:00
Abtin Keshavarzian 013bb3eee5 [secure-transport] smaller enhancements in SecureTransport (#10932)
This commit contains changes to `SecureTransport`:

- Inlines simple methods (`Disconnect()` and `GetUdpPort()`).
- Removes/refactors simpler methods, such as `Receive()` and
  `HandleSecureTransportSend()`, which are now directly moved into
  `HandleMbedtlsTransmit()` and `HandleReceive()`.
- Removes unused `SetClientId()` and inlines its implementation.
- Removes extra `LogDebug` line (can be tracked by logging `State`
  changes).
- Simplifies `HandleMbedtlsReceive()` and how data is read from
  `mReceiveMessage`.
- Uses a consistent style to refer to function pointers.
2024-11-19 08:56:21 -08:00
Abtin Keshavarzian a2ea648b39 [ip6] add MessageInfo::HasSamePeerAddrAndPort() (#10931)
This commit adds `Ip6::MessageInfo::HasSamePeerAddrAndPort()` which
checks if the peer address and port of two `MessageInfo` objects
match. This method is used in different modules (`Coap`, `Srp::Server`,
`SecureTransport`) to simplify the code.
2024-11-19 08:37:43 -08:00
Abtin Keshavarzian f48838f267 [neighbor] update and clean up property documentation (#10940)
This commit removes unnecessary documentation of private member
variables in the `Neighbor` class and updates `enum` based constant ,
replacing it with `static constexpr`.
2024-11-19 08:35:49 -08:00
Abtin Keshavarzian 9cd65f78a3 [mac-frame] set mCslPresent on TxFrame when CSL IE is added (#10939)
This commit ensures that the `mCslPresent` flag is set on `TxFrame`
when the CSL IE header is appended to the frame. This addresses an
issue introduced in #10692 where this flag can remain unset.
2024-11-19 08:27:21 -08:00
Damian Królik 10d8b68f23 [mac] wake-up frame sequence transmission (#10771)
If the Wake-up Coordinator role is enabled:
1. Add an API to attempt to attach a Wake-up End Device.  For now,
   this new API starts a wake-up frame sequence to the WED, but all
   the remaining MLE changes will be provided in the upcoming PRs.
2. Add "wakeup wake" shell command.

Note:
This commit enables testing the wake-up feature without the need to
make any changes in the radio layer by implementing the wake-up frame
scheduling in the core.

In real products with the Wake-up Coordinator capability, this should
likely be offloaded to the radio layer to assure a reliable wake-up
despite of the high rate of the wake-up frames.
2024-11-19 08:23:37 -08:00
Yakun Xu 9277bce08e [spinel] add SPINEL_PROP_MAC_RX_AT (#10921)
This commit adds receive at functionality for spinel for host to
schedule reception on RCP.
2024-11-18 08:53:55 -08:00
dependabot[bot] 0579a4d3af github-actions: bump actions/setup-go from 5.0.2 to 5.1.0 (#10935)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32...41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2024-11-18 08:50:23 -08:00
Li Cao 3702c88a76 [ncp] implement ncp dnssd update service and key record (#10909) 2024-11-14 18:34:17 -08:00
Abtin Keshavarzian 0551005887 [secure-transport] remove unused variables and methods (#10918)
This commit removes unused variables/methods from the `SecureTransport`
class. It also removes repeated code and implements other minor
enhancements.
2024-11-14 15:02:37 -08:00
Abtin Keshavarzian de746129e9 [mdns] implement response aggregation (#10881)
This commit implements response aggregation (RFC 6762 section 6.4) in
the mDNS module. If multiple responses are scheduled to be sent, each
delayed by a different interval, earlier responses are further
delayed to allow aggregation with other responses scheduled to go out
a little later.

Before preparing a response, we determine the next multicast
transmission time that is explicitly after the current time. This is
used for response aggregation. As the response is being prepared,
different entries can decide whether to extend their answer delay
duration if allowed (e.g., probe question answer delay cannot be
extended) and possible (not extending the delay beyond the maximum
allowed delay).

To realize this, the way we track the `AnswerTime` of records is
changed. It is now tracked by two variables: `mQueryRxTime`
(the receive time of the question triggering the answer) and
`mAnswerDelay`.

This commit also adds `TestResponseAggregation()` to the `test_mdns`
unit test to validate the response aggregation behavior.
2024-11-14 08:29:16 -08:00
Zhanglong Xia cc8f078586 [test] test whether the RCP supports tx/rx 154 frames of all formats (#10912)
This commit add a command `--frame-format` to the `cp-caps` to test
whether the RCP supports sending and receiving 802.15.4 frames of all
formats.
2024-11-13 10:46:53 -08:00
Abtin Keshavarzian 659b4272b7 [mle] simplify handling of Link Accept variants (#10919)
This commit renames and updates `HandleLinkAcceptVariant()` used to
handle an MLE "Link Accept" or "Link Accept And Request". The method
now takes the `MessageType` directly as an input parameter.
2024-11-13 08:35:22 -08:00
Abtin Keshavarzian 81f677b502 [secure-transport] simplify tracking of selected cipher suite (#10917)
This commit adds a new `CipherSuite` enum in `SecureTransport` to
track the selected cipher suite. This helps simplify the code. A
table is used to map the selected `mCipherSuite` to a constant array
of `MBEDTLS_TLS_*` values to configure mbedTLS module.
2024-11-13 08:33:54 -08:00
Abtin Keshavarzian c1935a7f27 [mle] track Link Accept timeout in Router entry (#10916)
This commit updates how the Link Accept response timeout is tracked.
It is now directly tracked in a `Router` entry using a new member
variable, `mLinkAcceptTimeout`, which stores the remaining timeout in
seconds. This value is decremented from `HandleTimeTick()` every
second.

This model replaces the previous approach, which indirectly used
`SetLastHeard()` for this purpose. The earlier method had
shortcomings; primarily, `SetLastHeard()` could be called again on
receiving a new advertisement, inadvertently pushing back the Link
Accept timeout. This model also became problematic when a random
delay was introduced before the transmission of Link Requests
(e.g., after receiving an advertisement).

This commit also enhances the process for restoring a link when a
router is aged (i.e., no advertisements are received from it). In the
new model, once the router age expires, Link Requests are sent every
time tick (every second) up to `kMaxTxCount = 3` attempts. The main
change is that after the last attempt, the code waits for the Link
Accept timeout (~3 seconds) before the router is removed.
2024-11-13 08:31:59 -08:00
Abtin Keshavarzian 50785a0fc9 [mac-frame] enhance comments regarding PAN ID compression behavior (#10914)
This commit adds an additional note next to the table from the
specification text regarding valid combinations of flags within an
encoded MAC header and the interpretation of the "PAN ID Compression"
flag.
2024-11-13 08:06:52 -08:00
Abtin Keshavarzian 79572ec965 [config] remove CONFIG_MLE_SEND_LINK_REQUEST_ON_ADV_TIMEOUT (#10915)
This commit removes the `CONFIG_MLE_SEND_LINK_REQUEST_ON_ADV_TIMEOUT`
configuration option.

The related behavior is now always enabled, meaning a device will
always send a Link Request when the advertisement timeout is reached
and the neighbor age threshold is met for a neighboring router.
2024-11-12 13:20:54 -08:00
Abtin Keshavarzian c13fcc62c8 [mle] implement periodic parent search mechanism on FED/REED (#10722)
This commit implements "Periodic Parent Search" mechanism for FED/REED
devices (FTD children). This enhances and builds upon
the existing parent search feature, which is mainly intended for
MTD children.

An FTD child receives and processes MLE Advertisements from
neighboring routers. The child uses this information to track the
one-way link quality to each router, which is later used to compare
and select potential new parents.

Every "parent search check interval", the FTD child checks to see if
it can select a better parent by evaluating all neighboring routers
based on their link quality information. A router is considered a
suitable parent candidate only if its average RSS exceeds the current
parent's RSS by a margin (`PARENT_SEARCH_RSS_MARGIN`).

Once a candidate is selected, the FTD child sends unicast MLE Parent
Requests to both the candidate and its current parent. This ensures
updated connectivity information is obtained from both before making
a decision. The same set of criteria used to compare candidates
during initial attach are applied during parent switch.

If the attach attempt to the selected candidate fails (e.g., the
router already has the maximum number of children it can support),
the FTD child ensures not to select the same router again until
a "reselect timeout" expires.

This commit also adds the `test-025-fed-parent-search.py test`, which
validates the newly added FTD parent search behavior, including the
mechanisms to attach to a selected router and the reselect timeout.
2024-11-11 10:59:36 -08:00
dependabot[bot] 6e1292d46e github-actions: bump docker/setup-buildx-action from 3.4.0 to 3.7.1 (#10911)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.4.0 to 3.7.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/4fd812986e6c8c2a69e18311145f9371337f27d4...c47758b77c9736f4b2ef4073d4d51994fabfe349)

---
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>
2024-11-11 08:15:34 -08:00
Abtin Keshavarzian bf6d74d098 [mle] use DelayedSender to delay & aggregate Child Update Requests (#10853)
This commit refines the Child Update Request mechanism within the MLE
module. The `DelayedSender` class is now used to schedule these
requests, enabling the aggregation of multiple updates into a single
transmission.

The previous implementation, which relied on
`mMessageTransmissionTimer` and a state variable, has been replaced
with the `DelayedSender` mechanism. This change aligns the Child
Update Request process with the scheduling of other MLE messages,
ensuring consistency.

Additionally, the `mMessageTransmissionTimer` is now exclusively
dedicated to retransmission handling, simplifying the logic and
improving code readability. The introduction of two boolean
variables, `mWaitingForChildUpdateResponse` and
`mWaitingForDataResponse`, further streamlines retransmission
handling by clearly tracking the waiting state for specific
responses.
2024-11-11 08:02:00 -08:00
Abtin Keshavarzian 169ac65e93 [mle] rename SendChildUpdateRequest/Response() methods (#10853)
This commit renames the `SendChildUpdateRequest/Response()`  methods
to distinguish between those sending (from a child) to its parent and
those sending (from a parent node) to a child. This improves the
readability of the code.
2024-11-11 08:02:00 -08:00
Abtin Keshavarzian 7f814539c6 [secure-transport] track key-exchange info in separate structs (#10902)
This commit introduces the `EcdheEcdsaInfo` and `PskInfo` structs,
which encapsulate all the tracked properties needed when the
corresponding key-exchange mechanism is used. This helps simplify the
code by keeping all code related to each feature within the same
block.
2024-11-10 20:06:57 -08:00
Abtin Keshavarzian 2dce461b25 [notifier] use Array to track external callbacks (#10907)
This commit simplifies `Notifier` by using `Array` to track
registered callbacks.
2024-11-10 20:05:24 -08:00
Zhanglong Xia 0fb1c22d24 [otci] add the parameter wakeup channel to the method create_dataset (#10898)
The parameters of the method dataset_set_buffer() has been updated, but the
method create_dataset() still use previous defination of dataset_set_buffer().
It causes the crash when calling the method create_dataset().
2024-11-07 10:24:15 +01:00
Li Cao d0998beca4 [ncp] implement ncp version of otPlatDnssdRegisterHost (#10893)
This commit implements ncp version of otPlatDnssdRegisterHost.
1. move the position of `SPINEL_PROP_DNSSD_STATE` in `spinel.h`
   because it was by mistake put within the range of
   `SPINEL_PROP_SRP_SERVER`. The value is unchanged.
2. A template method `DnssdUpdate` is added because the same process
   works also for DNSSD service and key record which will be added in
   following PRs.
2024-11-07 09:46:59 +01:00
Abtin Keshavarzian e43120d903 [coaps] use LinkSecurityMode to determine layer two security usage (#10899)
This commit updates the `CoapSecure`, `Tmf`, and `SecureTransport`
modules to use the `LinkSecurityMode` enum and its defined constants
to indicate whether or not layer two security should be used. This
replaces the use of boolean input parameters with `kWithLinkSecurity`
or `kNoLinkSecurity` constants, improving code readability.
2024-11-06 09:16:02 +01:00
Abtin Keshavarzian fa95df5d6d [secure-transport] use LogAt() in HandleMbedtlsDebug() method (#10900) 2024-11-06 09:14:20 +01:00
Abtin Keshavarzian 7169561e79 [mle] update DelayedSender to keep the tx schedule (#10846)
This commit updates how `Mle::DelayedSender` sends MLE messages after
a delay.

Previously, a delayed message was fully prepared and placed in a
queue, waiting for its delay duration to expire. In the new model, a
delayed message is prepared when the requested delay time expires and
the message transmission time is reached. The message is constructed
right before transmission. This ensures that the delayed message
includes the most up-to-date information and simplifies the methods
that prepare and send different types of MLE messages.

`DelayedSender` now keeps track of the message type and the
specific information required to construct the message later. For
example, for a delayed Parent Response to a Parent Request, the
extended address and the `RxChallenge` of the child are saved.

This new model makes it easier to implement the desired behavior when
similar messages are already scheduled to the same destination. For
example:
-   For Data Request, if one is already scheduled, a new request can
    be skipped, as the earlier Data Request will be valid.
-   For Parent Response, Link Accept, and Data Response, a new
    schedule request replaces an earlier one.
-   For Discovery Response, multiple schedules are allowed.
2024-11-05 21:26:44 +01:00
dependabot[bot] e6a6b9fa0f github-actions: bump actions/upload-artifact from 4.4.0 to 4.4.3 (#10895)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.0 to 4.4.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/50769540e7f4bd5e21e526ee35c689e35e0d6874...b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2024-11-05 08:49:57 +01:00
Abtin Keshavarzian 23c970ea4d [secure-transport] apply style fixes and renames (#10890)
This commit applies style fixes and renames in the `SecureTransport`
class, including using the `k` prefix for constants and removing
unused member variables.
2024-11-05 08:14:06 +01:00
Yakun Xu 548f6f48ac [radio] reverse extended address in radio layer (#10892)
This commit reverses the Extended Address in radio layer so that the
reversing can be shared by multiple callers.
2024-11-05 08:11:47 +01:00
Yang Sun b0984aff7a [trel] fix crash (#10894)
Started from #10872, platform trel stays un-initialized if no TREL URL is
passed in. `otPlatTrelEnable` asserted for `sInitialized`, and caused
crashes when `otPlatTrelEnable()` is called.

This commit changes the assertions to VerifyOrExit() to allow
otPlatTrelEnable calls when TREL is not initialized.
2024-11-04 16:05:55 +01:00
jrhodie 854e92a40a [docs] formatting fix (#10891) 2024-11-01 17:34:48 -07:00
Jonathan Hui 82eaf47b20 [github-actions] migrate ubuntu runners to 24.04 (#10795) 2024-11-01 11:27:24 -07:00
Li Cao 8b3e51276b [ncp] implement ncp version of otPlatDnssd (#10882)
This commit implements NCP based version of `otPlatDnssdGetState`.

A unit test is added to verify the implementation. This commit also
adjusts the unit test workflow to put the ncp unit tests into a
separate item. The direct reason for this commit is that `otPlatDnssd`
APIs haven't been implemented in `FakePlatform` and when
`OT_PLATFORM_DNSSD` is turned, the build failed. Let's first run NCP
unit tests separately and later try to merge the test items.
2024-11-01 11:26:36 -07:00
Abtin Keshavarzian d3d91634f4 [udp] track netif ID in socket and simplify handling of backbone sockets (#10858)
This commit updates `otUdpSocket` to track the associated network
interface identifier to which the socket is bound. This simplifies
the code for tracking backbone sockets, particularly how
`Udp::HandlePayload()` finds a matching socket.

Previously, backbone sockets were placed at the end of the `mSockets`
linked-list. The code tracked and updated a pointer to the entry
before the first backbone socket in the list. This commit removes the
need for this additional tracking and simplifies the implementation.
2024-10-31 09:51:52 -07:00
Yang Sun 0a6ccf4a79 [trel] add otSys API to init/deinit TREL (#10872)
The current TREL implementation uses TREL URL to pass in the TREL
interface at system start. This works for devices that have a fixed
interface for TREL.

There are devices that can dynamically switch infrastructure link, for
those devices it's possible that infra link changes from ethernet to
wifi and TREL should be re-configured on the new interface.
2024-10-31 09:33:47 -07:00
Handa Wang ee6fbbae05 [tests] fix test_upstream_dns.py (#10883)
There's a CI failure that the BR sends the query to 8.8.8.8 as the
upstream DNS server and responded to the DNS client. This is undesired
behavior. We want the BR to query our test DNS server instead.

The issue happened because 8.8.8.8 is already an entry in
`/etc/resolv.conf`. To avoid querying it, we should fully overwrite
the `/etc/resolv.conf` to ensure the BR queries the test DNS server.

There's another issue that `bind9` service was also running on the BR
node which taken over all incoming DNS queries. `bind9` should only
run on the upstream DNS server node. I'll try fix this in a more
generic way later.
2024-10-31 08:14:43 -07:00
Abtin Keshavarzian 444d1dd6bc [mle] implement alternate RLOC16 usage during role transition (#10006)
This commit introduces a mechanism for a device transitioning from
child to router role to keep receiving frames addressed to its
previous short address for a brief period.

A new radio platform API, `otPlatRadioSetAlternateShortAddress()`, is
introduced. This allows the OT stack to configure an alternate short
address. Radio platform support for this function is indicated by the
`OT_RADIO_CAPS_ALT_SHORT_ADDR` capability in `otPlatRadioGetCaps()`
The same function can be used with `OT_RADIO_INVALID_SHORT_ADDR`
(`0xfffe`) to clear a previously set alternate short address. Support
for the new API is implemented in RCP and `RadioSpinel`, ensuring
backward compatibility by dynamically checking supported radio
capabilities.

MLE code is updated to instruct the radio to use the old child RLOC16
as an alternate address upon role transition. The MLE layer will
automatically clear the alternate address after eight seconds, or if
other state/mode changes occur. This eight-second window ensures the
new router can transmit four MLE Advertisement messages.
2024-10-30 16:38:10 -07:00
Abtin Keshavarzian a5e1c91055 [mdns] simplify response and query preparation by passing Context (#10876)
This commit simplifies the process of preparing response and query
messages in the mDNS module. Instead of passing `TxMessage` and
`aNow` separately,  a reference to `EntryContext` or `CacheContext`
is now passed directly to `PrepareResponse()` and other related
methods.

This direct approach streamlines the code and facilitates the
potential inclusion of additional fields in `EntryContext` in the
future.
2024-10-30 13:12:58 -07:00
Li Cao 74cdd26085 [ncp] add empty implementation for dnssd platform APIs (#10877)
This commit adds empty implementation for a NCP based version of
otPlatDnssd APIs.

Like NCP version of otPlatInfraIf APIs, this commit adds a control
option to enable/disable the simulation platform version of
otPlatDnssd APIs to avoid conflict. By default, the simulation version
of implementation will still be turned on.
2024-10-30 13:10:30 -07:00
Abtin Keshavarzian 06d83fcca1 [border-agent] invoke ephemeral key callback on session connection (#10699)
This commit updates the Border Agent to invoke the ephemeral key
callback when a commissioner candidate successfully establishes a
secure session using the ephemeral key. This can be identified by
checking the state `otBorderAgentGetState()` and matching it with
`OT_BORDER_AGENT_STATE_ACTIVE`. This new signal can be used to stop
advertising the mDNS service "_meshcop-e._udp" earlier (since the
ephemeral key is one-time use).
2024-10-30 13:03:08 -07:00
Song GUO 382337f9b3 [nat64] clear NAT64 counters when allocating new mapping table item (#10871)
When allocating a new NAT64 mapping table item to a transaction, the
counters might be dirty, causing incorrect counter values in NAT64
mapping protocol counters.
2024-10-30 08:31:17 -07:00
Li Cao 090c777b32 [ncp] add ncp srp server properties (#10866)
This commit adds SrpServer control on NCP.
2024-10-29 15:26:56 -07:00
Handa Wang cb27207675 [nat64] add API otNat64ClearIp4Cidr (#10848)
This commit introduces a new API `otNat64ClearIp4Cidr` which is useful
when the in-use NAT64 CIDR is preempted and the platform fails to
allocate a new IPv4 CIDR. In such a (rare) case we'd better notify OT
that there isn't an available CIDR. `otNat64SetIp4Cidr` doesn't
support an 0-length CIDR as the input so we'll have to introduce this
new API.
2024-10-29 07:56:05 -07:00
Handa Wang d88b63d192 [posix] bind the resolver's UDP socket to the infra network interface (#10864)
This commit fixes an issue in DNS recursive resolver that it didn't
bind its socket to the infra network interface. This may cause the DNS
message to be sent on an unexpected network interface, depending on
the routing table of the platform.

This commit also updates the test case `test_upstream_dns.py` to make
the upstream DNS server run on a different node. Previously the
upstream DNS server ran on the same node as the BR which is a
limitation of this test case.
2024-10-29 07:54:55 -07:00
Yakun Xu 005c5cefc2 [mac] apply RxChannelAfterTxDone only if RxOnWhenIdle (#10826)
This commit updates the implementation to apply RxChannelAfterTxDone
only if RxOnWhenIdle.
2024-10-28 14:19:44 -07:00
dependabot[bot] fb3b26553b github-actions: bump actions/checkout from 4.2.1 to 4.2.2 (#10867)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871...11bd71901bbe5b1630ceea73d27597364c9af683)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2024-10-28 09:50:03 -07:00
Li Cao 8cb126ede8 [test] add implementation of otPlatRadioSetChannelTargetPower in FakePlatform (#10865) 2024-10-28 09:28:13 -07:00
Yakun Xu 788608335e [rcp] always support sleep-to-tx capability (#10856)
This commit declares sleep-to-tx capability on RCP side so that the host
doesn't need to issue Receive() before Transmit().
2024-10-24 11:44:42 +01:00
Abtin Keshavarzian 2935435261 [core] update enum checks to use compile-time static counter utility (#10852)
This commit updates the `static_assert` checks for `enum` values within
all core modules to use the recently added compile-time static counter
and its related helper utility macros.
2024-10-24 11:34:22 +01:00
Yakun Xu 6827344e08 [radio-spinel] separate RCP version check and caps check (#10860)
This commit separates RCP version check and capability check in
RadioSpinel so that the RCP caps is guaranteed to be initialized
correctly.
2024-10-23 14:12:24 +01:00
Yang Sun 5d0853c8c9 [border-agent] update docs for set and clear ephemeral key APIs (#10854)
The docs are updated to mention that users can use the
`otBorderAgentDisconnect()` API to forcely disconnect from commissioner
sessions.
2024-10-23 13:11:45 +01:00
Zhanglong Xia c519aa4534 [api] update descriptions of the radio platform power APIs (#10839)
Current radio platform defines three power related APIs:
`otPlatRadioSetTransmitPower()`, `otPlatRadioSetChannelMaxTransmitPower()`
and `otPlatRadioSetChannelTargetPower()`. However, the descriptions of
these APIs do not clearly define the relationship between them, which
causes a lot of confusion for radio platform developers.

https://github.com/orgs/openthread/discussions/10761
https://github.com/orgs/openthread/discussions/10611
https://github.com/orgs/openthread/discussions/9899

This commit updates the descriptions these APIs to clearly define
the relationship between these power APIs.
2024-10-21 22:50:49 +01:00
Thomas 5bd9de5f30 [examples] remove unneeded implementation otTaskletsSignalPending (#10849)
The implementation of `otTaskletsSignalPending` in
`examples/apps/<app>/main.c` is exactly the same as the weak
implementation in `tasklet_api.cpp`. No need to repeat it and blocking
other implementations of that function.
2024-10-21 13:51:19 +01:00
dependabot[bot] 8806dbc100 github-actions: bump step-security/harden-runner from 2.8.1 to 2.10.1 (#10855)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.8.1 to 2.10.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/v2.8.1...91182cccc01eb5e619899d80e4e971d6181294a7)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-10-21 11:46:38 +01:00
Li Cao 2bc8685060 [ncp] fix implementation of NCP get dataset tlvs (#10850)
This commit fixes the bug in NCP Get
`SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS` and
`SPINEL_PROP_THREAD_PENDING_DATASET_TLVS`.

There are cases where dataset doesn't exist and
`otDatasetGetActiveTlvs` returns `OT_ERROR_NOT_FOUND`. This will cause
that the NCP doesn't send any responses to the host. This commit lets
the implementation ignore the NOT_FOUND error and will encode empty
data in this case.
2024-10-21 09:16:18 +01:00
Yakun Xu a1474853d8 [style] simplify checking conditional enum values (#10843)
This commit adds a compile time utility to check that enum values are in
order, which eliminates calculating the actual value of conditional enum
values in source code.
2024-10-17 18:27:46 -07:00
Abtin Keshavarzian deb35b0c25 [routing-manager] check local on-link prefix in IsAddressOnLink() (#10836)
This commit adds `OnLinkPrefixManager::AddressMatchesLocalPrefix()`
method, which checks whether a given address matches the current
local on-link prefix only when the prefix is valid (being published,
advertised, or deprecated by the BR). This method is used in
`RxRaTracker::IsAddressOnLink()`, ensuring that the local prefix is
always explicitly checked. This makes the check more robust and
independent of whether `RxRaTracker` receives and tracks
self-generated RAs.
2024-10-17 12:59:38 -07:00
Yakun Xu b8070846cd [diag] support per-frame tx power (#10847) 2024-10-16 22:27:26 -07:00
GLegoupil 3a037f2d49 [srp-client] improve Client::Start error handling (#10834)
SRP Client close socket on connect error to avoid to fail the next time.
2024-10-16 13:30:58 -07:00
Li Cao a225ee9c08 [test] add missing platform APIs in FakePlatform (#10844)
This commit adds some missing platform API implementation for
FakePlatform.

These are added so that FakePlatform can be used to write unit tests
in ot-br-posix.

The commit also guards the microSecondTimer code in `FakePlatform`
with the marcro `OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE` because
`otPlatAlarmMicroFired` is only defined in OT timer.cpp when
`OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE` is true.

This commit also removes some parameter names in the fake
implementation to avoid unused warnings.
2024-10-16 11:47:27 -07:00
Abtin Keshavarzian 31f92b6a2e [mle] fix updating of mDataRequestState for Network Data (#10841)
This commit updates and fixes how the `mDataRequestState` variable,
which controls retransmissions of MLE Data Request messages, is
updated.

An MLE Data Request message can be sent for different purposes: either
to request updated Network Data or to retrieve a Link Metrics Report
from a neighbor/parent. The `mDataRequestState` retransmission
mechanism is used to handle retx of Data Requests for retrieving
Network Data. This commit ensures that the code that updates these
variables is moved to `SendDataRequestAfterDelay()` and
not in the common version, which can be used for both Network Data
and Link Metric Reports. This ensures these states are not
incorrectly updated when a Link Metrics Report is retrieved.
2024-10-16 11:29:42 -07:00
Mia Yang 230c155652 [test] add retain_active_session option for ePSKc deactivate API (#10829) 2024-10-16 11:28:13 -07:00
Cristian Bulacu 4cc1ffd174 [dns-client] Initialize mSendLink structure in Client constructor (#10840)
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2024-10-15 13:34:49 -07:00
Yakun Xu b0790b8ff0 [mac] skip CSMA backoff when disabled (#10838)
This commit updates SubMac to skip CSMA backoff when TX frame disables
it.
2024-10-15 11:20:39 -07:00
Jonathan Hui 0066d565af [github-actions] switch to using llvm install script (#10837) 2024-10-15 09:30:38 -07:00
Yakun Xu 944a25a5be [time-sync] correct the time sync base to radio time (#10825)
The network time offset is computed based on the coprocessor time
instead of the host time.
2024-10-15 09:17:11 -07:00
gytxxsy 328e247341 [spinel] allow registering callback to handle compatibility errors (#10724)
When the RCP capabilities check fails, a mechanism should be provided
to notify the user of the error instead of causing the program to
crash.

For example, the hardware reboot function provided in the Spinel
driver interface could be invoked. The specific hardware reboot
implementation is left to the user, such as performing an RCP update.
2024-10-15 09:16:14 -07:00
Abtin Keshavarzian 7ec2c31816 [mesh-forwarder] introduce FinalizeAndRemoveMessage() (#10830)
This commit adds a new helper method, `FinalizeAndRemoveMessage()`,
which finalizes all direct and indirect transmissions of a message
before removing it from the send queue. This helper is used by
`EvictMessage()` and `RemoveDataResponseMessages()`, simplifying
the code.
2024-10-14 15:16:28 -07:00
Eduardo Montoya ef8f1709cd [mac] enable wake-up frame periodic sniffing (#10762)
When `OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE` is enabled:

- APIs are available to configure and enable wake-up frames sniffing.
- `SubMac::HandleWedTimer` periodically schedules receive slots on
  wake-up channel.
- Wake-up frames are processed.
- Upon reception of a wake-up frame, WUL is stopped.
2024-10-14 13:11:37 -07:00
Abtin Keshavarzian 072e53740b [message] simplify accessing of indirect tx ChildMask bit-set (#10824)
This commit renames the `BitVector<>` class to `BitSet<>` and updates
its methods, introducing simpler methods such as `Add()`, `Remove()`,
and `IsEmpty()`. This aligns better with the intended use of this
class as a bit-set, e.g., as a `ChildMask` to track the set of
sleepy children to which a message is scheduled for indirect
transmission.

The `Message` class now provides the `GetIndirectTxChildMask()`
method, which returns a reference to the `ChildMask` bit-set.
2024-10-14 12:12:09 -07:00
Jonathan Hui 358b0a3e18 [github-actions] migrate markdown check to Linkspector (#10835) 2024-10-14 12:02:05 -07:00
Jakub Uliarczyk 68c78d357e [tcat] feat: extend dataset hex command (#10831)
This commit extends the 'dataset hex' command in the bbtc.py script by
allowing dataset TLVs to be set using a hex-encoded format.

Till now the 'dataset hex' command was only printing the
'ThreadDataset' object values in hex-encoded format, there was no
functionality to set the TLVs using hex-encoded format.

The 'dataset hex' command has been modified so the user can pass
dataset TLVs in hex-encoded format as an argument to this
command. This enables the script to set desired dataset TLVs in one
command, instead of calling dataset commands individually.

Example usage: 'dataset hex <hex-encoded TLVs>'
2024-10-14 11:06:16 -07:00
dependabot[bot] 8b51782586 github-actions: bump actions/checkout from 4.1.7 to 4.2.1 (#10832)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/692973e3d937129bcbf40652eb9f2f61becf3332...eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2024-10-14 10:01:29 -07:00
Jonathan Hui ff19e03afa [scripts] SC2317: command appears to be unreachable (#10821) 2024-10-11 20:45:56 -07:00
Jonathan Hui 987eaf5d2d [assert] fix set-but-unused warnings (#10823) 2024-10-11 18:16:05 -07:00
Abtin Keshavarzian 43a73a1cac [ip6] simplify applying of TMF UDP filter in Ip6::HandleDatagram() (#10822)
This commit simplifies the filter checks that drop TMF UDP messages
from untrusted origins. The `mTmfOriginFilterEnabled` flag is checked
first, and then the full UDP header is read from the message.
2024-10-11 18:05:23 -07:00
Abtin Keshavarzian 39ebb530c0 [radio] add Radio::GetNow() (#10785)
This commit adds the `GetNow()` method to the `Radio` class, which
maps to `otPlatRadioGetNow()`. This method is used within core
modules to avoid calling the `otPlat` API directly, aligning with the
practice for all other `otPlatRadio` APIs, which are called through
the defined `Radio` class methods.
2024-10-11 18:03:33 -07:00
Jonathan Hui f3715b4596 [check-size] SC2004: $/${} is unnecessary on arithmetic variables (#10820) 2024-10-11 13:38:40 -07:00
Jonathan Hui bd1ffd6501 [toranj] SC2086: double quote to prevent globbing and word splitting (#10819) 2024-10-11 13:38:29 -07:00
Jonathan Hui c379f1e767 [github-actions] remove clang-32 checks (#10818)
Build checks for 32-bit arch are covered by arm-gcc.
2024-10-11 13:38:15 -07:00
Abtin Keshavarzian 5b188dccb0 [mac-frame] update CalculateKeySourceSize() (#10815)
This commit updates the helper method in `Mac::Frame` that determines
the security header's "key source" field size based on the "Key ID
Mode":
- It is renamed to `CalculateKeySourceSize()` to align with other
  methods, such as `CalculateSecurityHeaderSize()` and
  `CalculateMicSize()`.
- It now takes `uint8_t aSecurityControl` as input to harmonize with
  other `Calculate` helpers.
2024-10-11 13:13:06 -07:00
Abtin Keshavarzian 8fddb4cdf7 [ip6] simplify Ip6::InsertMplOption() (#10814)
This commit refactors the `InsertMplOption()` method for improved
efficiency and readability. Cascading `if`/`else` blocks have been
eliminated by handling the simpler `IsMulticastLargerThanRealmLocal()`
case first. Redundant checks for multicast destination and scope
have been removed, as these conditions are already covered by
`IsRealmLocalMulticast()` and `IsMulticastLargerThanRealmLocal()`.
2024-10-11 13:11:49 -07:00
Abtin Keshavarzian ad29f8e886 [ip6] style changes and renames (#10813)
This commit contains minor enhancements to the `Ip6` class, including
variable and method renames (to use shorter names) and minor style
changes.
2024-10-11 13:10:05 -07:00
Abtin Keshavarzian d163dee2af [dns-client] enhance logic for following up with IPv4 address query (#10781)
This commit updates the `ReplaceWithIp4Query()` method, which
determines whether an unsuccessful IPv6 address query should be
followed up with an IPv4 query.

The logic is changed as follows:

- If the response code to the IPv6 query indicates success but the
  answer section is empty (meaning the name exists but has no IPv6
  address), or the response code indicates an error other than
  `NameError`, the query is replaced with an IPv4 address resolution
  query for the same name.
- If the server responds with `NameError` (RCode=3), indicating that
  the name doesn't exist, an IPv4 query is not attempted.

This replaces the previous behavior where a follow-up query was
attempted for any error response code.
2024-10-11 10:32:53 -07:00
Abtin Keshavarzian af2e10a7bf [mac-frame] add mCommandId to TxFrame::Info (#10697)
This commit updates `TxFrame::Info` to include `mCommandId`, used when
the frame type is `kTypeMacCmd`. This allows callers to specify the
Command ID when preparing a MAC Command `TxFrame`. With this change
`Frame::SetCommandId()` is no longer used or needed so it is
removed.
2024-10-11 10:32:16 -07:00
Abtin Keshavarzian 5673039686 [message] track the MLE command type in Message (#10809)
This commit adds a new field, `mMleCommand`, to `Message::Metadata` to
track the MLE command type of the message. Helper methods, such as
`IsMleCommand()`, are added to `Message` to get/set/check the MLE
command type.

This replaces the previous model where `Message::SubType` was used to
track a subset of MLE commands. It helps simplify the code and allow
us to track all MLE commands.
2024-10-11 10:30:35 -07:00
Zhangwx 87474bdc88 [routing-manager] append source link-layer option in ND6 message (#10647)
This commit introduces a platform API to get the InfraIf link-layer
address. And add the source link-layer address option to all ND6
messages generated from OpenThread.
2024-10-11 10:12:38 -07:00
Yakun Xu c4262af670 [test] verify behavior of RxChannelAfterTxDone (#10817)
This commit adds a test to verify RX channel is switched correctly after TX done.
2024-10-11 08:26:28 -07:00
Yakun Xu 2ea0155129 [radio] fix ACK frame counter with previous key (#10816)
This commit tracks the frame counter used for the previous key index and
use it for the ACK frame to a frame still using previous key index.
2024-10-11 08:24:51 -07:00
Jakub Uliarczyk ed14eb19bd [tcat] feat: add dataset clear command (#10812)
Added 'clear' command to the 'dataset' command tree. This allows to
remove all entries in the 'ThreadDataset' object used by the script to
store the dataset values.

The reason behind this feature is that in the current implementation
of the script, the 'ThreadDataset' object entries are always
initialized by 'initial_dataset' when running the script.

No command allows to clear/remove the particular entry, which makes
this script unable to send an active dataset to the target device
without specific dataset values(custom dataset).

To make this possible, the 'clear' command has been added to the
'dataset' command tree, which removes all entries from the
'ThreadDataset' object and, by using existing commands, sets the
desired entries in the 'ThreadDataset' object from scratch.

This enables the script to send custom active dataset values to the
target device.
2024-10-10 21:48:26 -07:00
Abtin Keshavarzian 19b2d6bbc4 [mle] simplify router/leader role restoration upon reset (#10798)
This commit introduces the `RouterRoleRestorer` class, nested within
`MleRouter`, to manage router/leader role restoration after an MLE
operation restart (e.g., a device reboot) by sending multicast Link
Requests. This class simplifies the code and centralizes role
restoration logic.

Specific changes:

- A new member variable `mLastSavedRole` is added to track the last
  attached role (saved in non-volatile memory). This is used by
  `RouterRoleRestorer` to determine the number of Link Request
  attempts. This variable replaces the previous `mWasLeader`, which
  was only updated after a reboot and would not account for role
  changes afterward.
- The `AttachTimer` is now used for role restoration instead of the
  retransmission timer, as role restoration always occurs while the
  device is detached and before any attach attempts.
- The `kLinkRequestTimeout` is used for the last attempt before
  considering restoration failure.
- The `mChallengeTimeout` mechanism is now removed (in earlier Thread
  specification versions, multicast Link Requests could be used while
  the device was attached, but this is no longer used or needed).
- `test-012-reset-recovery.py` is updated to validate the role
  restoration behavior. `test_detach` is also updated and fixed.
2024-10-10 21:47:34 -07:00
Yakun Xu 057b87fdd1 [spinel] parameters untouched on decoding error (#10810)
This commit updates the doc of spinel decoder that the parameters are
untouched on parsing error.
2024-10-10 21:46:44 -07:00
Song GUO b378c704d0 [routing-manager] fix for updating prefix without deprecating the old one (#10811)
In some cases, the platform may send the new prefix without
deprecating the existing prefix when renewing the prefix allocated by
PD.

The existing code will stop the timer, causing the prefix to be active
forever.

This commit fixes this issue.
2024-10-10 21:32:48 -07:00
Li Cao ee851d2a62 [ncp] add border routing InfraIf send ICMP6 ND (#10793) 2024-10-10 08:13:12 -07:00
Abtin Keshavarzian 2dbaaa5cfd [mac] simplify preparation of header IE entries (#10692)
This commit updates `TxFrame::Info` and `PrepareHeadersIn()` to
prepare header IE entries along with MAC and security headers. New
boolean fields in `TxFrame::Info` indicate whether CSL or Time IE
entries should be appended to the frame. This simplifies the code,
particularly `MeshForwarder::PrepareMacHeader()`, which now just sets
these flags on `TxFrame::Info`. It also allows for the removal of
`AppendHeaderIe<>()` and its related methods.

This commit also updates `GenerateWakeupFrame()` to use the new
model for appending `RendezvousTimeIe` and `ConnectionIe` fields.
2024-10-10 08:10:58 -07:00
Abtin Keshavarzian e7ca8b1aa1 [mle] simplify graceful detach mechanism and reuse mAttachTimer (#10800)
This commit updates the graceful detach mechanism in `Mle`. A boolean
`mDetachingGracefully` is added to track when the device is
performing a "graceful detach". The `mAttachTimer` is reused for
scheduling the detach delay, as any attach operation can be stopped
during detach, and the timer can be reused. This simplifies the code
and removes the need to use a specific timer for the graceful detach
process.
2024-10-10 08:07:48 -07:00
Abtin Keshavarzian 16d7c2a468 [indirect-sender] add HasQueuedMessageForSleepyChild() (#10806)
This commit adds new helper methods in `IndirectSender` to find a
queued message for transmission to a given sleepy child that also
satisfies a certain condition (using a general-purpose predicate
`MessageChecker` function pointer).

These helpers are then used in `IndirectSender` and `MleRouter` to
simplify the code, particularly in `SendChildUpdateRequest()`, where
sending multiple "Child Update Request" messages to a sleepy child
being restored (after a parent restart/reboot) should be avoided.
2024-10-10 08:05:01 -07:00
Abtin Keshavarzian 7d171b6f48 [message] reorder Metadata properties (#10807)
This commit reorders member variables in the `Buffer::Metadata`
struct, grouping booleans and `uint` bitfields of the same size to
avoid alignment gaps.
2024-10-10 08:00:17 -07:00
Yakun Xu ab5950cb54 [spinel] support per-frame TX power in coprocessor (#10804)
This commit passes the TX power from host to coprocessor. This commit
also adds a new fake platform for coprocessor to cover the changes in
RadioSpinel and NCP.
2024-10-10 07:51:13 -07:00
Abtin Keshavarzian 287dbfa251 [test] introduce Nexus test framework and platform (#10533)
This commit introduces a new test framework named Nexus. The
framework includes the Nexus platform implementation that emulates
platform behavior, allowing multiple nodes running the OpenThread
core stack to be simulated and interact with each other within the
same process.

Unlike the simulation platform, where nodes run in separate processes
and interact via POSIX sockets, Nexus nodes are simulated within a
single process. Nexus tests can interact directly with the C++ or C
OT core APIs, providing more control than the simulation platform's
CLI-based interactions. The flow of time in Nexus tests is directly
controlled by the test itself, allowing for quick time interval
advancement.

This model allows for faster and more scalable simulations, enabling
quick simulation of larger networks for longer durations.

This commit introduces the basic platform implementation, including:
- `nexus_alarm`, `nexus_radio`, and `nexus_settings` modules.
- Logging support, allowing logs to be distinguished per emulated
  node.
2024-10-09 14:27:54 -07:00
Jonathan Hui a79ca11642 [github-actions] use setup-python action (#10797) 2024-10-09 07:50:16 -07:00
Yakun Xu 8cb529be2a [test] add fake platform (#10594)
This commit adds a fake platform for unit/component tests. This platform
uses virtual time so it should be able to run fast.

Note that the fake platforms leverage C++ virtual methods to allow mocking.

This commit verifies setting active dataset triggers the active dataset
change event by the notifier.
2024-10-08 21:00:35 -07:00
Jonathan Hui f943729515 [github-actions] remove g++multilib where unused (#10799) 2024-10-08 20:59:25 -07:00
Song GUO 7971508587 [thread-cert] create internet directory for NAT64 and PD tests (#10794) 2024-10-08 20:22:55 -07:00
Abtin Keshavarzian 0e81aa1014 [mle] update SendParentResponse() to use Child & input (#10801)
This commit updates `SendParentResponse()` to accept `aChild` as a
`Child &` instead of a `Child *`, as it will always expect a valid
child object and won't handle a `nullptr` input.
2024-10-08 18:10:39 -07:00
Jonathan Hui ce57c5a969 [github-actions] simplify toranj-unittest (#10802) 2024-10-08 18:03:57 -07:00
Abtin Keshavarzian c027237676 [mle] simplify condition in Mle::BecomeDetached() (#10796)
This commit updates the skip condition in `BecomeDetached()` to use
positive boolean checks for improved readability. This condition
applies when the device is already detached and is about to start an
attach attempt.
2024-10-08 14:37:30 -07:00
Yang Sun be74a3c035 [border-agent] add api to disconnect from secure sessions (#10754) 2024-10-08 09:18:05 -07:00
Abtin Keshavarzian a8bf8e7095 [routing-manager] update valid on-link prefix (PIO) condition (#10791)
This commit updates `RoutingManager::IsValidOnLinkPrefix()`, which
checks whether a received PIO is a suitable on-link prefix. The
updated check requires the `L` (on-link) flag to be set, along with
either the `A` (autonomous address-configuration) flag or the `P`
(DHCPv6-PD preferred) flag. This aligns the implementation with the
latest SNAC router draft.
2024-10-08 09:08:23 -07:00
dependabot[bot] 722b15059a github-actions: bump step-security/harden-runner from 2.9.1 to 2.10.1 (#10789)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.9.1 to 2.10.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde...91182cccc01eb5e619899d80e4e971d6181294a7)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-10-07 09:10:33 -07:00
Abtin Keshavarzian 181ede9404 [mle] reorder MleRouter class member variables (#10786)
This commit reorders member variables in the `MleRouter` class,
grouping booleans and `uint`s of the same size to avoid alignment
gaps. It also reorders some of the private method declarations and
adds sections for constants, nested types, methods, and variables.
2024-10-07 08:57:19 -07:00
Jakub Uliarczyk 52d3f49ffe [tcat] feat: add 'adapter' argument and use 'BLEDevice' for scanning (#10657)
Added '-a', '--adapter' arguments to the bbtc.py arguments
parser. This allows the selection of the HCI adapter for the scanning
procedure.

According to 'Bleak' documentation of the 'BleakClient'
class(https://bleak.readthedocs.io/en/latest/api/client.html#bleakclient-class),
it's better to use the 'BLEDevice' object in 'BleakClient' during the
object instantiation, therefore it has been changed for the scanning
2024-10-07 08:55:20 -07:00
Abtin Keshavarzian b8d2e5d63a [mac-frame] add DetermineFcfAddrType() helper (#10780)
This commit adds the `DetermineFcfAddrType()` helper function, which
determines the Frame Control Field (FCF) address type for a given
address. The result is bit-shifted based on whether the address is
the source or destination and whether the frame uses the general
format or is a multipurpose frame. This helper simplifies methods
that prepare MAC headers.
2024-10-04 10:57:45 -07:00
Thomas 678d137293 [secure-transport] only initialize mCookieCtx on the server (#10782)
`MBEDTLS_SSL_COOKIE_C` is only used on the server. There is no point
in initializing it on the client side.
2024-10-04 10:56:54 -07:00
Suvesh Pratapa 7810269ce5 [spinel] define a new spinel-specific configuration value for source match table size (#10778)
Avoids any confusion with `OPENTHREAD_CONFIG_MLE_MAX_CHILDREN`:

* `OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES` in
  `openthread-spinel-config.h` defines size of the local source match
  table used by RadioSpinel when
  `OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT` is used.
* For OpenThread, the default value of this config is
  `OPENTHREAD_CONFIG_MLE_MAX_CHILDREN`.
* Other protocols (in case of MultiPAN with spinel) can define
  whatever value they want for the size of the table using this
  config.
2024-10-04 10:14:19 -07:00
Abtin Keshavarzian 262b998c10 [mac-frame] remove unused Set{Src/Dst}{Addr/PanId}() methods (#10779)
Recent changes updated `Mac::Frame` to use `FrameBuilder` for
preparing frame headers. With the adoption of this model, the
previously defined `Set` methods for setting source/destination
address or PAN ID are no longer used or needed. This commit removes
them.
2024-10-03 15:57:44 -07:00
Abtin Keshavarzian f0cb5a3f22 [mac-frame] update GenerateWakeupFrame() to use FrameBuilder (#10774)
This commit updates `TxFrame::GenerateWakeupFrame()` to utilize the
`FrameBuilder` class for constructing frame header fields.

It also updates the `TestMacWakeupFrameGeneration()` unit test in
`test_mac_frame.cpp`:
- Uses source and destination address constants that are not reversible
  to validate that extended addresses are appended in the correct byte
  order.
- Includes minor style changes (renames constants and uses lowercase
  hexadecimal digits for consistency).
2024-10-03 06:46:04 -07:00
Przemysław Bida 213665cce0 [tcat] implementation of TCAT general class commands (#10700)
Commit introduces implementation of missing general class commands:
- PresentPskdHash
- PresentPskcHash
- PresentInstallCodeHash
- RequestRandomNumChallenge
- RequestPskdHash

Also include minor fixes in Tcat python client and refactoring of expect
tests for tcat.
2024-10-02 11:10:16 -07:00
Abtin Keshavarzian e120051e21 [toranj-config] explicitly enable OPENTHREAD_CONFIG_TLS_ENABLE (#10773)
This commit explicitly enables the `OPENTHREAD_CONFIG_TLS_ENABLE`
macro in `core-toranj-config.h`. This configuration is used to
generate a custom `openthread-mbedtls-config.h` using the `unifdef`
command in `mbedtls/CMakeLists.txt`. Some versions of `unifdef` do
not expand macros first and expect the macro to be defined as a
simple number. This change ensures the build is successful.
2024-10-02 07:45:36 -07:00
Abtin Keshavarzian 09698fae24 [mac-frame] add TxFrame::Info and simplify mac header preparation (#10689)
This commit simplifies the preparation of MAC and security frames. It
introduces a `TxFrame::Info` structure that provides information
about the frame, such as its type, version, source and destination
addresses, PAN IDs, security level, and key ID mode. A new method
`PrepareHeadersIn()` is added, which uses the `Info` structure to
construct the MAC address and security headers in a given `TxFrame`.

This approach replaces the earlier `Mac::Frame::InitMacHeader()` where
all the information was passed as a list of input arguments. The
`TxFrame::Info` approach simplifies the code and allows for future
extension to accommodate other parameters (e.g., Header IE entries).
2024-10-01 11:37:17 -07:00
Abtin Keshavarzian 3a28b7bbdf [message] introduce FooterData<DataType> class (#10760)
This commit adds the `Message::FooterData<>` template class, which
represents data (typically metadata) associated with a `Message` that
is appended to the end of the message. It can be read later from the
message, updated (re-written) in the message, or fully removed from
it.

The `FooterData` class provides common helper methods such as
`AppendTo()`, `ReadFrom()`, `UpdateIn()`, and `RemoveFrom()` in a
generic way. This helps simplify the various `Metadata` types defined
within the OT core modules, removing repeated definitions of similar
methods for each type.
2024-09-30 10:24:23 -07:00
dependabot[bot] 4434862f4c github-actions: bump github/codeql-action from 3.26.2 to 3.26.9 (#10769)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.26.2 to 3.26.9.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/429e1977040da7a23b6822b13c129cd1ba93dbb2...461ef6c76dfe95d5c364de2f431ddbd31a417628)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2024-09-30 09:28:04 -07:00
Abtin Keshavarzian d77f4ab4ac [nd6] add CONFIG_BORDER_ROUTING_ENABLE guard check (#10759)
This commit adds `CONFIG_BORDER_ROUTING_ENABLE` guard checks to
`nd6.hpp` and `nd6.cpp` source files, as the definitions in these
files are only used when the `BORDER_ROUTING` feature is enabled.
2024-09-30 09:26:12 -07:00
Rongli Sun 925a951d71 [border-agent] process Keep Alive messages only for active commissioner (#10750)
This commit updates how Keep Alive messages are handled by the Border
Agent. After establishing a secure session, a device has
`TIMEOUT_COMM_PET` (50 seconds) to take any action, including sending
a petition to become an Active Commissioner. This change ensures that
Keep Alive messages are ignored before a device becomes an Active
Commissioner, preventing candidates from extending their sessions.
Keep Alive messages are now processed only for Active Commissioners
(BA in `kStateAccepted` state), aligning the implementation with the
Thread specification.
2024-09-30 09:24:58 -07:00
Abtin Keshavarzian 6593d2c9fd [test] enhance test_dns_client to include addr resolution query (#10766)
This commit updates `test_dns_client` to validate independent address
resolution queries (in addition to the existing service resolution
tests). Specifically, it adds test cases for `ResolveIp4Address()`
and scenarios where the server responds with an error RCODE.
2024-09-30 09:09:54 -07:00
Abtin Keshavarzian 4c45ee8e0e [dns-client] fix handling of IPv4 resolve failure (#10766)
This commit fixes an issue in `Client::ReplaceWithIp4Query()` where an
IPv6 address resolution query failure could lead to an incorrect IPv4
query being sent. The incorrect query type was being checked in this
method, causing `ResolveIp4Address()` to keep sending queries.
2024-09-30 09:09:54 -07:00
Li Cao a6d607370c [ncp] add border routing InfraIf recv ICMP6 ND (#10755)
In this commit, a new spinel property
`SPINEL_PROP_INFRA_IF_RECV_ICMP6_ND` is added for the host to pass the
ICMP6 ND messages to the NCP.
2024-09-29 23:29:26 -07:00
Song GUO 7cd179e23a [routing-manager] stop PD if there is another prefix with higher preference in netdata (#10289)
This commit adds a new IDLE state to PdPrefixManager.

PdPrefixManager enters idle state when PD is enabled and there is
already a BR requesting PD prefix. When there are multiple BRs
publishing PD prefix at the same time, the one with lexcial smaller
prefix wins.
2024-09-29 23:27:30 -07:00
Yakun Xu 6e46e2e9f1 [rcp] apply receive channel after tx done (#10649)
This commit applies the RxChannelAfterTxDone in the tx done callbacks,
so that vendors doesn't have to implement in platform layer.
2024-09-27 09:11:46 -07:00
Yang Sun a9805ed93a [cli] add docs for trel counters (#10756) 2024-09-26 14:02:10 -07:00
Eduardo Montoya 596c5aa6a2 [dataset] add support for wake-up channel (#10736)
- Add Wake-up Channel TLV to the dataset.
- Add CLI support to handle the wake-up channel.
- Add MAC support for wake-up channel (to be used for sending
  and receiving wake-up frames).
2024-09-26 14:01:46 -07:00
Abtin Keshavarzian b42be4cff1 [mle] add DelayedSender class to manage delayed msg tx (#10733)
This commit introduces the `DelayedSender` nested class within `Mle`
to handle delayed MLE message transmissions, such as delayed
responses. Existing methods related to delayed message handling have
been refactored into this new class.
2024-09-25 10:52:56 -07:00
Abtin Keshavarzian 3913e0de61 [mle] enhance MTD child IPv6 address registration (#10743)
This commit improves how MTD children register their IPv6 addresses
with their parent. The `Slaac` class now tracks the Lowpan Context
ID (from Network Data) for each SLAAC address. If the Context ID
associated with an existing SLAAC address changes (due to Network
Data updates), the `Slaac` module notifies the `Mle` to schedule
a "Child Update Request" transmission (if the device is an MTD
child). This ensures that the MTD child re-registers its addresses,
resolving any previous registration failures caused by incorrect or
outdated context ID compression.

This commit also adds `test-035-context-id-change-addr-reg.py`
to validate the newly added behavior.
2024-09-25 10:28:53 -07:00
Esko Dijk 3a57996016 [mle] add Thread Domain Name TLV (59) to MLE Discovery Response (#10745)
This commit adds the Thread Domain Name TLV (59) to the MLE Discovery
Response message. The TLV is only included if not equal to
'DefaultDomain', as per Thread 1.4 spec Section 8.4.4.1.1.2.  Also,
the TLV is only included for Thread 1.4 or higher builds.  This is
because for Thread < 1.4 the inclusion of this TLV was only specified
for CCM devices. Thread 1.4 changed this: the TLV is now included if
the domain name is not equal to the default name "DefaultDomain"
specified in Section 5.22.

The purpose of including the domain name is to allow discovery of
Thread Networks that belong to the same domain that the Joiner is part
of. This is used by any commissioning methods where the Thread device
can roam e.g. CCM/CCM-light or other (future) methods.
2024-09-25 08:22:09 -07:00
Li Cao 2388bc2264 [ncp] extend border routing InfraIf setup for state synchronization (#10749)
The commit extends `SPINEL_PROP_INFRA_IF_SETUP` to
`SPINEL_PROP_INFRA_IF_STATE` so that it can be used to either do infra
if setup (trigger border routing starting on NCP) or synchronize infra
if state to the NCP (ON/OFF state, IP addresses).

The current implementation on NCP will compare the `InfraIfIndex`. If
the index is different the value on NCP, it will be regarded as an
initialization or change of InfraIf. Thus the border routing module
will be re-initialized.
2024-09-25 08:18:16 -07:00
Abtin Keshavarzian af2c77e171 [border-agent] update ephemeral key connection timeout handling (#10609)
This commit enhances how ephemeral key timeout is used. If the timeout
expires while a commissioner or commissioner candidate is connected,
the session will be terminated. The Border Agent (BA) will then stop
using the ephemeral key and revert to using PSKc.

The ephemeral key timeout timer starts when the ephemeral key is set
on the BA. During this timeout interval, the ephemeral key can be
used only once by an external commissioner to establish a secure
connection.
2024-09-24 15:26:12 -07:00
Jonathan Hui d669b2e964 [github-actions] migrate from macos-12 to macos-14 (#10751) 2024-09-24 14:49:30 -07:00
Abtin Keshavarzian 74645c0e6e [test] get the address of correct node in test script (#10744) 2024-09-24 11:30:47 -07:00
Jonathan Hui c182933979 [doxygen] remove empty line at end of block (#10748) 2024-09-24 09:51:34 -07:00
Zhanglong Xia c0b5a54e10 [test] add version command to cp-caps (#10734)
This commit adds a version command to cp-caps to get the current version.
And we release the current version of cp-caps as 0.1.0.
2024-09-24 08:05:04 -07:00
dependabot[bot] d015004a74 github-actions: bump actions/upload-artifact from 4.3.6 to 4.4.0 (#10746)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.6 to 4.4.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/834a144ee995460fba8ed112a2fc961b36a5ec5a...50769540e7f4bd5e21e526ee35c689e35e0d6874)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2024-09-23 09:25:06 -07:00
Damian Królik bc50521cfa [mac] multipurpose wake-up frame support (#10728)
1. Add OT_WAKEUP_COORDINATOR and OT_WAKEUP_END_DEVICE build
   options.
2. Add support for parsing and constructing 802.15.4
   Multipurpose frames.
3. Add support for parsing and constructing wake-up
   frames.
2024-09-23 09:02:15 -07:00
Li Cao b605bb993e [ncp] add border routing InfraIf setup (#10707) 2024-09-23 08:38:20 -07:00
Abtin Keshavarzian bd310dba95 [message] fix comments (#10731) 2024-09-20 07:29:36 -07:00
Abtin Keshavarzian 3074451618 [core] remove redundant namespace usage (#10730)
This commit removes redundant namespace qualifiers from two instances
within core modules, preventing potential build warnings with certain
toolchains.
2024-09-20 07:29:18 -07:00
Abtin Keshavarzian 944a246d1a [radio-platform] add extern "C" for weak otPlat definitions (#10740)
This commit adds the `extern "C"` specifier to all `OT_TOOL_WEAK`
`otPlat` definitions to ensure correct linkage when compiled with a
C++ compiler. It also explicitly includes `platform/time.h` in
`radio_platform.cpp`.
2024-09-19 13:01:02 -07:00
Abtin Keshavarzian 9f6921cf04 [core] optimize #include directives in core cpp files (#10717)
This commit removes unnecessary `#include` directives in core `cpp`
files that already include `instance.hpp`. The `instance.hpp` header
itself includes all necessary OT core headers and definitions as they
are contained within an `ot::Instance`.
2024-09-18 12:03:54 -07:00
Yakun Xu c6a4657178 [diag] add flag to enable CSMA/CA (#10723) 2024-09-18 11:20:11 -07:00
Bob MacDonald fa3509ebce [tcplp] fix an issue that occurs when using LTO and TCP is not enabled (#10726)
When building and linking with link time optimizations and TCP is
not enabled (OPENTHREAD_CONFIG_TCP_ENABLE = 0) the following error
occurs:

tcp_subr.c:96: undefined reference to tcplp_sys_get_ticks'

To address the problem we are removing the __attribute__((used))
annotation on the initialize_tcb function which will prevent the
function from being retained when no one references it.
2024-09-18 10:50:03 -07:00
Yakun Xu ba3bce2b62 [otci] update package info (#10706) 2024-09-18 08:11:02 -07:00
Abtin Keshavarzian f07bcc2bfe [mle] rename Mle::Handle{Command}() methods to indicate constraints (#10721)
This commit renames `Mle::Handle{Command}()` methods where different
overloads are provided (e.g. in `Mle` and `MleRouter`) based on
device role or being an FTD. The method names now explicitly mention
the constraints (e.g. `HandleChildUpdateRequestOnChild()` or
`HandleAdvertisementOnFtd()`). This change aims to improve code
readability, making it easier to determine the purpose of each
method.
2024-09-17 18:20:37 -07:00
Abtin Keshavarzian 62df7e9267 [message] clarify partial read behavior of Read() vs ReadByte() (#10719)
This commit updates and clarifies the behavior of `Message::ReadByte()`
and `Message::Read()` overloads regarding partial reads.

- `ReadByte()` will read the available bytes and return the actual
  number of bytes read if fewer bytes are available in the message
  than the requested read length. This behavior remains unchanged.
  The documentation is updated to emphasize this behavior.
- `Read()` methods return `kErrorParse` if the requested length cannot
  be read. This is the existing behavior which remains unchanged.
  Previously, `Read()` methods would still perform a partial read and
  populate the buffer/object with as many bytes that could be read,
  even in case of failure and returning `kErrorParse`. This behavior
  has been changed in this commit so the method will skip
  reading/copying bytes if the full length cannot be read. This
  aligns the documentation and behavior with how the `Read()` methods
  are used and intended to be used within the OT stack.
2024-09-17 14:06:27 -07:00
Abtin Keshavarzian 5070adbc29 [settings] simplify saving of Border Agent ID (#10701)
This commit simplifies how Border Agent ID is saved in non-volatile
`Settings` by utilizing generic methods designed for single-value
setting entries. As a result, `Settings::BorderAgentId` now only
needs to define the key and the associated entry value type. This
eliminates the need for `otBorderAgentId` to be defined as packed,
thereby simplifying this structure.
2024-09-17 14:06:06 -07:00
Abtin Keshavarzian f12dfaf531 [coap] ensure CoAP header and token length are validated (#10720)
This commit updates `Coap::Message::ParseHeader()` to perform two
crucial validations:
- It now checks if the message contains sufficient bytes to read the
  minimum 4-byte CoAP header.
- Afterwards, determines the CoAP token length from the read header,
  and then validates that the message has enough bytes to read the
  token.

These validations prevent the parsing and misinterpretation of a
malformed or incomplete CoAP message as a valid one,
2024-09-17 12:14:57 -07:00
Abtin Keshavarzian 4a57dd8e09 [include] fix #include style for public OT headers (#10710)
This commit updates `#include` of public OT headers to follow
the OT style guide and use brace (`<`) and (`>`) style.
2024-09-17 12:13:34 -07:00
Abtin Keshavarzian 94a6bfaae6 [mle] replace "FED" with "FTD child" when applicable (#10718)
This commit replaces uses of the term "FED" in comments and method
names with "FTD child" where the logic applies to any FTD child
(i.e., both FED and REED). This clarifies the behavior and aligns the
code with Thread specification terminology.
2024-09-17 10:39:03 -07:00
Przemysław Bida 75ffb48c57 [tcat] TCAT documentation cleanup. (#10681)
Commit adds documentation to tcat CLi commands, also removes incorrect
parameter form `otBleSecureTcatStart`.
2024-09-17 10:13:37 -07:00
Abtin Keshavarzian d60ec8811c [mesh-forwarder] use Array to track forwarded frame info (#10540)
This commit updates and simplifies the tracking of information
(message priority, drop status) for forwarded mesh-header fragmented
frames. This is used for consistent priority assignment to all
fragments of the same message and facilitates delay-aware queue
management, where dropping one fragment leads to dropping all
subsequent fragments of the same message.

The entry type is renamed to `FwdFrameInfo`, and an `Array` is used to
track the entries. Array helper methods such as `RemoveAllMatching()`
and `FindMatching()` help simplify the code. Since `Array` tracks the
current length, iterating over unused entries is avoided.
2024-09-16 14:58:45 -07:00
Abtin Keshavarzian 9d8fcfdb8b [mesh-forwarder] simplify logging messages (#10716)
This commit simplifies logging methods (e.g., `LogIp6Message()`) in
the `MeshForwarder` class:
- Log lines are prepared in a `String`, allowing new fields to be
  added conditionally. This simplifies the code and avoids complex
  `printf`-style formats for handling optional fields.
- New helper methods are added to prepare common labels in a log line
  (e.g., adding MAC address, adding security/error/priority fields).
- Logging IPv6 source/destination addresses is simplified by defining
  a new helper to log an address/port.
2024-09-16 14:55:50 -07:00
Abtin Keshavarzian 67b8f5c821 [routing-manager] set SNAC Router Flag in emitted RA (#10695)
This commit updates the `RouteingManager` to set the newly
allocated "SNAC Router Flag" (bit 6) in emitted RA messages from
Thread BR. The flag is also parsed and tracked in received RA
messages.

This replaces the previous model where an experimental flag bit
in "Flags Extension Option" indicated a "stub router". This commit
also removes the `STUB_ROUTER_FLAG_IN_EMITTED_RA_ENABLE` confg
(no longer optional/experimental) and renames `mStubRouterFlag` to
`mSnacRouterFlag`.
2024-09-16 13:33:32 -07:00
dependabot[bot] 5f74baa2ea github-actions: bump ossf/scorecard-action from 2.3.3 to 2.4.0 (#10714)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.3 to 2.4.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/dc50aa9510b46c811795eb24b2f1ba02a914e534...62b2cac7ed8198b15735ed49ab1e5cf35480ba46)

---
updated-dependencies:
- dependency-name: ossf/scorecard-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>
2024-09-16 10:18:58 -07:00
Yakun Xu d0f7699110 [radio] add tx timestamp (#10688)
This commit adds tx timestamp so that the pcap callback can get the time
when a frame was transmitted.
2024-09-16 10:13:25 -07:00
Abtin Keshavarzian 5ff30d7cef [core] move locator Get<Type> definitions to instance.hpp (#10711)
This commit moves the locator `GetProvider::Get<Type>()` and its
related `Timer` and `Tasklet` methods to `instance.hpp`. With this
change we can remove `locator_getters.hpp` header fully thus
simplifying the code.
2024-09-16 10:10:51 -07:00
Yakun Xu d7810fa04d [test] use ubuntu 22.04 for otci workflow (#10703)
This commit update the otci workflow to use ubuntu-22.04 because some
dependency fails to build on ubuntu-20.04.
2024-09-14 07:35:02 -07:00
Yang Sun 97a3f7648f [trel] add cli to get TREL UDP port (#10702)
The test software for certification currently uses the mDNS packets of
trel service responses to find out the trel port, and then use the port
number to determine which packets in a capture should be decoded as TREL
packets. However this may not be reliable since it depends on when the
capture starts. Added a cli to get trel port, so this can be used by
a THCI function.
2024-09-13 09:54:33 -07:00
Yakun Xu dccc5193af [radio] add a helper of SFD handler (#10670)
This commit adds a helper of SFD handler to deal with IEs and security
needs to be processed in SFD handler from ISR.
2024-09-12 23:02:07 -07:00
Tom Rebbert 2aeb8b833b [mle] prioritize equivalent pending dataset update over MLE announce (#10631)
Avoid processing announce messages with equivalent data that is stored
in a pending dataset update.
2024-09-11 07:27:37 -07:00
Jonathan Hui 2f51cababf [github-actions] migrate version 1.3 checks to 1.4 (#10694) 2024-09-11 07:25:32 -07:00
Yakun Xu c0690e78fc [build] set default Thread version to 1.4 (#10690)
This commit updates the default Thread version to 1.4, so that most
latest features will be enabled by default. This commit also explicitly
enable the epskc feature just like other features in the build script.
2024-09-10 13:39:38 -07:00
Marcin Kajor 07a1b7bd98 [mle] add API to configure the store frame counter ahead (#10576)
Currently the OPENTHREAD_CONFIG_STORE_FRAME_COUNTER_AHEAD
is hard-coded in the OT core, yet sometimes it is
desired to modify this value which requires
re-building of the OT libraries and forces
re-certification of the end product.

Implement `otThreadSetStoreFrameCounterAhead`
and `otThreadGetStoreFrameCounterAhead` to allow
API clients to configure the store frame counter
ahead parameter at run-time. This extension offloads
product makers from the need of re-certification
in case the store frame counter ahead must be tuned.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
2024-09-10 12:33:27 -07:00
Abtin Keshavarzian 7673194af6 [mac] move HeaderIe definitions into separate files (#10683)
This commit moves all `HeaderIe` related definitions from
`mac_frame.hpp/cpp` into newly added `mac_header_ie.hpp/cpp` source
files. This commit does not make any changes to the code.
2024-09-09 10:57:07 -07:00
dependabot[bot] 2283b799b0 github-actions: bump docker/login-action from 3.2.0 to 3.3.0 (#10687)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/0d4c9c5ea7693da7b068278f7b52bda2a190a446...9780b0c442fbb1117ed29e0efdff1e18412f7567)

---
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>
2024-09-09 10:22:34 -07:00
Yakun Xu bb5e9b791a [spinel] coorect description of STREAM_RAW (#10680)
This commit corrects the description of STREAM_RAW.

- timestamp should be type `X`.
- channel can be both RX and TX channel.
2024-09-06 13:18:25 -07:00
Yakun Xu a887530e0d [pcap] fix pcap callback for TX frames (#10678)
This commit fixes the pcap callback for TX frames:

* Report the tx frame on each tx started callback, so that
  retransmissions can be captured.
* Set the RSSI to be invalid for TX frames.
2024-09-06 12:21:03 -07:00
Esko Dijk 4459c54069 [tcat][ble] fixes to connection state mgmt and Disconnect cmd (#10619)
- Fixes to connection state management and handling of Disconnect
  command TLV
  - specifically, this now ensures that TCAT remains on (started)
    after a commissioner disconnects. Earlier, there was the problem
    that the 2nd commissioner couldn't connect anymore.
  - specifically, in ble_secure.cpp the check for if
    (mTcatAgent.IsEnabled()) is removed, since the err =
    mTcatAgent.Connected(mTls) will already check this and raise an
    error if not enabled. If not enabled, the Device is in a wrong
    state to handle TCAT Commissioner commands so now it closes the
    connection right away. That's better than to leave the
    Commissioner in limbo on the TLS connection. The Commissioner can
    now retry again and all will be well again.
- timeout of at most 10 seconds on UDP write operation in simulation
  mode (if longer, the TCAT device isn't reachable and the
  Commissioner now shows the error to the user.) Earlier, it got stuck
  forever.
- Corrects some copy/paste errors in API definitions in comments; adds
  comments where needed to explain.
  - adds whitespace at some places to align format with rest of code
- improved some of the --debug output for the UDP simulation mode of
  the TCAT Commissioner.
2024-09-05 19:59:39 -07:00
Handa Wang e63e9ce86b [posix] support specifying DNS server for resolver (#10663)
This commit adds 2 system APIs for resolver for integration on Android
platform.
- `otSysUpstreamDnsServerSetResolvConfEnabled` is for
  enabling/disabling retrieving the DNS servers from `resolve.conf`.
- `otSysUpstreamDnsSetServerList` for specifying the DNS servers on
  the infra link.
2024-09-05 15:12:56 -07:00
Przemyslaw Bida db6393251a [tcat] Add timeout while connecting over BLE. (#10597)
Adding timeout while handling ble connection establishement in TCAT.
2024-09-04 07:49:33 -07:00
Przemyslaw Bida 12cf1207d2 [tcat] Fix handling certificate path in tcat client. (#10597)
Commit fixes propagation of certificate path from `cert-path` option
to `scan` command.
2024-09-04 07:49:33 -07:00
Li Cao c36c0ed760 [ncp] add NCP based implementation (empty) of platform InfraIf APIs (#10638)
This implementation will be used on all platforms for NCP nodes
(simulation, any vendor platforms). However the simulation platform
already has a different implementation. To avoid conflicts, the commit
adds a control flag in simulation config so that we can choose whether
to enable the simulation implementation.
2024-09-04 07:48:59 -07:00
Handa Wang 01cb5b08cf [posix] decouple resolver.cpp from netif.cpp (#10662)
This commit introduces `platformResolver*` APIs so that `system.cpp`
can treat resolver as an independent module.

Reasons for this refactor:
- Simplify the integration on Android platform.
- The functionality of resolver is not related to the functionality of
  netif.
2024-09-03 13:47:07 -07:00
Yakun Xu 2493658d6a [config] disable uptime logging when multi-instance enabled (#10659)
This commit soften enabling log uptime in simulation and posix platform
so that it won't be enabled when multiple instance is also enabled.
2024-09-03 13:05:58 -07:00
Mason Tran 928074c538 [tests] add a expect test for coaps disconnect (#10655) 2024-09-03 11:08:08 -07:00
Zhanglong Xia aed9cd1a30 [csl] add Mac::Frame methods to process the CSL IE (#10651)
This commit provides unified methods for checking whether the CSL IE
is present and getting the CSL IE.
2024-09-03 10:36:45 -07:00
Handa Wang 5b33afd188 [docs] add the missing section for dns upstream command (#10665) 2024-09-03 10:34:08 -07:00
dependabot[bot] f908b5e315 github-actions: bump actions/setup-python from 5.1.1 to 5.2.0 (#10660)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.1 to 5.2.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/39cd14951b08e74b54015e9e001cdefcf80e669f...f677139bbe7f9c59b41e40162b753c062f5d49a3)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2024-09-03 07:57:42 -07:00
Handa Wang e19c775ce3 [doc] fix typos in comments (#10664)
Done by `script/code-spell` with some manual fixes.
2024-09-02 14:05:54 -07:00
Rongli Sun 98d1aed973 [border-agent] apply pskc if changed (#10641)
This commit applies new pskc into secure transport when it's changed
via active/pending dataset, without impacting existing secure session
if any or ephemeralkey mode if it's activated
2024-09-02 14:02:51 -07:00
Yang Sun d60aaab22e [dtls] notify kDisconnectedLocalClosed when disconnect locally (#10653) 2024-08-31 09:51:12 -07:00
Rongli Sun f9349c1486 [border-agent] not forward MGMT_GET/SET commands directly to leader (#10652)
This commit doesn't forward the MGMT*GET/SET commands directly to leader
any more, and enforces the use of UDP Proxy for Thread Management
Commands.
2024-08-29 14:13:39 -07:00
Suvesh Pratapa 45c5fe475b [posix] add radio URL parameter uart-init-deassert to deassert DTR and RTS on init when flow control is disabled (#10644)
This lets us preserve legacy behavior where `uart-flow-control` was
not required even with hardware flow control enabled.
2024-08-28 11:38:31 -07:00
Yakun Xu 3a525f3b57 [radio] otPlatRadioGetNow fallback to otPlatTimeGet (#10646)
This commit makes the default otPlatRadioGetNow implementation fallback
to to otPlatTimeGet so that the default one is a correct implementation
in single chip architecture.
2024-08-28 10:54:19 -07:00
Abtin Keshavarzian f91610f3f3 [mle] include Supervision TLV only from sleepy child (#10628)
This commit updates the code to include the Supervision Interval TLV
in MLE messages sent from a child only when the child mode indicates
it is sleepy (`!IsRxOnWhenIdle()`). The Network Diagnostic Child TLV
is also updated to use zero for the "Supervision Interval" field
when the child is not sleepy. The `test-023-mesh-diag.py` is updated
to validate this new behavior.

The parent node still tracks the received supervision interval from a
child in the `Child` entry. This parameter indicates the interval
that would be used if the child were to be supervised.
2024-08-28 08:06:01 -07:00
Yakun Xu 706013fa7b [git-tool] explicit disable rebase (#10645)
This commit adds `--no-rebase` to `git` command when applying
dependencies because recent git versions doesn't have a default rebase
strategy anymore.
2024-08-27 19:58:17 -07:00
Yakun Xu 95a4c338e0 [diag] support send security processed frames (#10640)
This commit extends the `diag frame` command by adding an argument `-s`
to indicate whether the frame has been encrypted or not, so that the
diag commands can be used to test frames having security processed in
the host.
2024-08-27 18:35:04 -07:00
Abtin Keshavarzian a30cbda8ae [mle] include Link Margin TLV in Child Update messages (#10626)
This commit adds code to include the Link Margin TLV in MLE Child
Update Request or Response messages sent by a parent to a child. This
allows the child to learn and update its "link quality out" to its
parent.

The change is designed to be backward compatible. Child devices
running older firmware will simply disregard this additional TLV.
When processing the message, the presence of the Link Margin TLV is
checked (it is optional).
2024-08-27 11:14:50 -07:00
Abtin Keshavarzian e3f0a7cc37 [radio-spinel] fix tracking of current MAC frame counter (#10635)
This commit fixes an issue in `RadioSpinel` related to the tracking of
the MAC frame counter used during RCP restoration. Previously,
`RadioSpinel` tracked the last seen counter on any secured
received/transmitted frame. However, the frame counter should only be
tracked for frames that use Key ID Mode 1 and where the included Key
ID in the frame matches the current Key ID being used. The `SubMac`
module also tracks the current MAC frame counter, and it does perform
Key ID Mode and Key ID checks.

This commit adds a new public API `otLinkGetFrameCounter()` to get the
current frame counter. This is used by `RadioSpinel` to get the frame
counter instead of having `RadioSpinel` track the frame counter
itself.
2024-08-27 11:13:32 -07:00
Jason Zhang 4465c9b57a [tests] optimize multi-ail test case to run three BRs on two infra link (#10637)
This commit:
1. update the topology to make 3 BRs running on 2 AILs;
2. specify the test name as `test_multi_backbone_infra`, which is
  focusing on verifying the multiple backbone framework works good
3. fix bug that previously pinging throught ethernet does not actually
   work.

For 3, previous `br1.ping(br2_infra_link_local, interface=br1_infra_link_local)`
actually send ping command via ot-ctl instead of the docker bash. The
new `br1.ping(br2_onlink_ula, backbone=True)` actually send a docker
bash command to ping another node via ethernet. Here we choose to use
onlink ULA address (9100::) instead of the link local address because
only "ping [link-local-addr]%eth0" (by specifying the zone index) can
work for link-local address, but this is not currently supported by
`LinuxHost.ping_ether()` method.
2024-08-27 09:41:55 -07:00
Abtin Keshavarzian 8f2ddf93c3 [thread-cert] relax TLV type checks in pktverify (#10627)
This commit modifies thread-cert scripts utilizing `pktverify` to
adopt a more flexible approach to TLV type checking. Specifically, it
replaces strict equality (`==`) or strict subset (`<`) checks with a
subset or equal check (`<=`) when verifying the presence of TLVs in a
message. This adjustment ensures that test scripts adhere to the
principle of ignoring extra or unknown TLVs, thereby future-proofing
them against potential protocol updates that might introduce new
TLVs.
2024-08-27 08:18:45 -07:00
Rongli Sun abb6934cdd [border-agent] directly respond to MGMT_COMMISSIONER_GET from non-active commissioner (#10632) 2024-08-26 20:31:46 -07:00
Yakun Xu 3c6b8a3dd2 [time] unify macros for time unit conversion (#10636)
This commit unifies macros used for time unit conversion so that we
don't need to define it on different components.
2024-08-26 20:26:31 -07:00
dependabot[bot] 5e34ab2eab github-actions: bump actions/upload-artifact from 4.3.1 to 4.3.6 (#10639)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.3.1 to 4.3.6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/5d5d22a31266ced268874388b861e4b58bb5c2f3...834a144ee995460fba8ed112a2fc961b36a5ec5a)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2024-08-26 08:54:10 -07:00
Abtin Keshavarzian 1c5ad3403d [core] replace strcmp() with StringMatch() (#10629)
This commit replaces the use of `strcmp()` with `StringMatch()`, which
is an OT-specific internal function for comparing strings. This
ensures consistent use of internal helper functions.
2024-08-23 10:26:35 -07:00
gabekassel 1a2d5f0458 [core] valgrind reported memory access bugs (#9833)
* posix: check for nlmsg error tlv attributes

if we couldn't set NETLINK_EXT_ACK, there's no extra nlmsg attributes in
the error. avoid UB and walking uninitialized memory by checking the
flag for those attributes. for us, this avoids segfaults and in one
instance, an infinite loop while walking the non-existant attributes.

Signed-off-by: Nick Owens <nick.owens@eero.com>

* posix: zero initialize sigaction struct before use

this removes a valgrind warning about use of uninitialized memory in a
syscall when backtrace is enabled.

Signed-off-by: Nick Owens <nick.owens@eero.com>

* key_manager: zero initialize otSecurityPolicy

valgrind reports that otSecurityPolicy is used uninitialized, so just
make it zero.

clear all bytes when setting to default

Signed-off-by: Nick Owens <nick.owens@eero.com>
2024-08-22 16:18:37 -07:00
Yang Sun 24e930654e [epskc] add API for ePSKc telemetry (#10608)
Adds API to get border agent counters which include counters for
ePSKc, PSKc and coap messages.
2024-08-21 23:02:44 -07:00
Abtin Keshavarzian e90792da0b [routing-manager] advertise deprecating RIO prefixes with low preference (#10625)
This commit updates `RoutingManager::RioAdvertiser` to advertise
deprecating prefixes with `NetworkData::kkRoutePreferenceLow`.
`test_routing_manager` is updated to validate this new behavior.
2024-08-21 19:30:56 -07:00
Abtin Keshavarzian 697adfd112 [netdata] centralize service/server TLV logic in Service::Manager (#10624)
This commit updates the `NetworkData::Service::Manager` class to
provide helper methods for adding and removing different service
types (DNS/SRP anycast or unicast services, backbone router
service).

With this change, the definitions of `ServiceData` and `ServerData`
formats for different service types are now `private` to the
`Service::Manager` class. This centralizes the logic for constructing
and parsing the service/server TLVs, making it easier to update and
add new fields to these formats in the future.
2024-08-21 19:25:10 -07:00
Przemysław Bida 8a0ea2b692 [tcat] implement new tcat General commands (#10526)
New General TLV's implemented:
- Get network name
- Get device id
- Get ext pan ID
- get provisioning URL
2024-08-21 19:21:10 -07:00
Abtin Keshavarzian afac808a81 [netdata] enhance GetNextDnsSrpAnycastInfo() to include RLOC16 (#10620)
This commit updates `Service::Manager::GetNextDnsSrpAnycastInfo()` to
iterate over Server sub-TLVs and include the RLOC16 of each entry in
the returned `Info` structure. The unit test `test_network_data` is
updated accordingly. This change simplifies the `Publisher` method
used for counting existing anycast entries in the Network Data.
2024-08-20 08:31:02 -07:00
Abtin Keshavarzian f127469f7d [routing-manager] check reachability & send ICMPv6 unreach err (#10548)
This commit introduces a mechanism  to check for reachability of
messages forwarded by the BR and send an ICMPv6 Destination
Unreachable error to the sender if needed.

Specifically, if the Border Router (BR) decides to forward an IPv6
message outside the AIL and the message's source address matches a
BR-generated ULA OMR prefix (with low preference), and the
destination is unreachable using this source address, then an ICMPv6
Destination Unreachable message is sent back to the sender.

For example, this situation can occur when a local,
non-infrastructure-derived ULA OMR prefix is published alongside a
`::/0` route (due to discovered PIO/RIO prefixes by the BR). A Thread
mesh device may try to reach addresses beyond the local AIL (e.g.,
the global internet) using the ULA OMR prefix, which would be
unreachable.

This feature is controlled by an OT config flag, enabled by default.
Alternatively, this functionality may be implemented within the
platform layer, in which case the configuration should be disabled.

This commit also adds a test case `test-504-br-icmp-unreach-err.py`
validating the newly added behavior.
2024-08-20 08:29:33 -07:00
Zhanglong Xia fb7b457ab2 [posix] update the max size of file path to PATH_MAX (#10622)
The length of the configuration file path may exceed the default
defined max length 255.

This commit changes the name from `kFileNameMaxSize` to
`kFilePathMaxSize` and sets its value to the PATH_MAX.
2024-08-19 11:24:59 -07:00
dependabot[bot] 4e053fe517 github-actions: bump github/codeql-action from 3.25.11 to 3.26.2 (#10623)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.11 to 3.26.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/b611370bb5703a7efb587f9d136a52ea24c5c38c...429e1977040da7a23b6822b13c129cd1ba93dbb2)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2024-08-19 08:51:55 -07:00
Esko Dijk e4558664a8 [coap] fixes in parameter name and in comments. (#10615) 2024-08-16 12:19:23 -07:00
Abtin Keshavarzian d0895415da [netdata] update GetNextDnsSrpUnicastInfo() to use Type (#10616)
This commit updates `Service::Manager::GetNextDnsSrpUnicastInfo()` to
accept a `DnsSrpUnicast::Type`, indicating the desired entry type
(either `kFromServiceData` or `kFromServerData`). This simplifies the
code, which previously iterated over all types and performed type
checks. Additionally, this change simplifies the `Publisher` methods
used for counting existing DNS/SRP unicast entries of different
types.
2024-08-16 10:27:14 -07:00
Abtin Keshavarzian 6209b0b855 [spinel] correct SPINEL_PROP_IPV6_ADDRESS_TABLE documentation (#10617)
This commit aligns the documentation in `spinel.h` with the
implementation for `SPINEL_PROP_IPV6_ADDRESS_TABLE` regarding the
order of valid/preferred lifetime fields.
2024-08-16 10:24:16 -07:00
Esko Dijk 88bc4e95e0 [cli] clarify docs - parameter use for dns config to change service mode only (#10614)
Also adds missing CLI outputs in examples.
2024-08-16 10:23:17 -07:00
Jason Zhang b5c57e6ad7 [thread-cert] wrap command br peers and br routers (#10613)
This commit adds functions to read peer BRs and routers on infra link by
wrapping the ot-ctl command `br peers` and `br routers`.

`test_multi_ail.py` is also updated to test the new added functions.
2024-08-16 07:23:53 -07:00
Jason Zhang 93e838102c [thread-cert] support to get link-local address of the infra interface (#10603)
This commit targets to support getting infra link-local address of a
OtbrNode in docker test, which is usefully for future test cases.

The test_multi_ail.py is also updated to test the new method added.
2024-08-15 07:35:18 -07:00
Jonathan Hui 54571af6a7 [github-actions] free up disk space for docker build (#10610) 2024-08-14 20:43:33 -07:00
Abtin Keshavarzian fd7284b0e9 [address-resolver] freshness timeout mechanism for cache entries (#10575)
This commit introduces a freshness timeout mechanism for address cache
entries which is used to decide when removing stale entries when the
associated RLOC16 is unreachable.

In `AddressResolver`, when resolving an EID from an existing cache
entry, if the target RLOC16 is unreachable, the entry is typically
considered stale and removed to allow a new address query to be sent.
This commit adds a mechanism to skip this removal step if the entry
has been recently updated, i.e., an `AddressNotify` has been received
for it and its `FreshnessTimeout` has not yet expired.

The `FreshnessTimeout` check prevents repeated address query
transmissions when mesh routes are not yet discovered (e.g., after
initial attach) or if there is a temporary link issue.
2024-08-14 12:58:04 -07:00
Abtin Keshavarzian 9fd6596e7b [dns-client] track limited query (one question) servers (#10403)
This commit updates `Dns::Client` to remember servers/resolvers that
are known to have trouble with multiple-question queries. This
information is learned from earlier interactions with the server.

When `ResolveService()` is requested, if the user explicitly
requests "optimize" service mode, the request is honored. Otherwise,
if "optimize" service mode is chosen from the default configuration
and the DNS server is known to have trouble with multiple-question
queries, "separate" service mode is used instead.

This commit also updates the `test_dns_client.cpp` unit test to
validate the newly added behavior.
2024-08-14 12:41:18 -07:00
Abtin Keshavarzian 1645880b8e [dsnsd-server] support handling of "A record" queries (#10364)
This commit adds support for responding to "A record" queries in the
DNS-SD server and discovery proxy.

If the query matches a host registered with the SRP server, the host's
IPv6 addresses are returned in the Additional Data section of the
response. If the query is resolved by the proxy, the `otPlatDnssd`
APIs are used to start/stop IPv4 address resolvers for the hostname
on the infrastructure network.

The `test_dnssd_discovery_proxy` unit test is updated to validate the
new functionality.
2024-08-14 12:40:48 -07:00
Jonathan Hui ec0b2991a8 [docker] add linux/arm64 to platforms (#10605) 2024-08-14 10:44:46 -07:00
sarveshkumarv3 8edc081fdc [spinel] make SendCommand public to allow calling without variable arguments (#10602)
Changed access of SendCommand to public to allow calling without
variable arguments. This is to address compilation error in
ot-br-posix repo NcpSpinel::ThreadErasePersistentInfo (while building
for OpenWrt v23.05.4 for a mips target)(error: 'args' may be used
uninitialized [-Werror=maybe-uninitialized])
2024-08-14 08:12:30 -07:00
Abtin Keshavarzian 5edc3673fd [routing-manager] fix typo in IsInitialPolicyEvaluationDone() (#10607) 2024-08-13 23:48:25 -07:00
dependabot[bot] 6e00d72c0e github-actions: bump step-security/harden-runner from 2.8.1 to 2.9.1 (#10598)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.8.1 to 2.9.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6...5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-08-13 22:28:19 -07:00
Mia Yang fa26102fe5 [test] verify ephemeral key settings and _meshcop-e (#10537) 2024-08-13 21:40:40 -07:00
Abtin Keshavarzian 3bcea2467b [ip6] style fixes and minor enhancements (#10560)
This commit contains minor enhancements in the `Ip6` class:

- Removes unnecessary `static_cast<uint8>()` use
- Combines repeated `case` statements
- Use shorter variable/type names.
- Style fixes.
2024-08-13 21:37:55 -07:00
Abtin Keshavarzian 943d2302a3 [thread] move OT_THREAD_VERSION_* constants to public header (#10599)
This commit moves the definition of `OT_THREAD_VERSION_*` constants
from the config header to the `openthread/thread.h` OT public header
file (where `otThreadGetVersion()` is declared). This allows other
projects integrating the OT stack to also see and use these
constants.
2024-08-13 15:43:45 -07:00
Jason Zhang 509596fe2c [test] fix potential backbone name conflict when running cert suite (#10596)
### Background

https://github.com/openthread/openthread/pull/10550 introduced a new
way to support multiple backbone nework in otbr docker test. Though it
works good while running a single test, a bug exists when running
cert-suite, which runs a batch of tests in parallel.

cert-suite allocates the name of the backbone interfaces dynamically
by setting env PORT_OFFSET for each test, so there is potentially
conflict exists if we hard code the `backbone_network` name in
TOPOLOGY. This PR is targeting to fix this potential naming conflict.

### Fix

We fix it by assigning a number for `backbone_network_id` in each BR
definition in TOPOLOGY, instead of setting a fixed `backbone network`
name. The final backbone network name is decided by both `PORT_OFFSET`
env and the number of `backbone_network` (in
`backbone{PORT_OFFSET}.{backbone_network}` format)

For example, if `PORT_OFFSET` is 0 and `backbone_network_id` is 1,
then backbone network name will be `backbone0.1`. For the tests that
only use one backbone network and the `backbone_network_id` is not
given, the backbone network name is by default
`backbone{PORT_OFFSET}.0`.

### New test case format
```
class NewTestCase(thread_cert.TestCase):
    ...
    BR = 1
    ...
    TOPOLOGY = {
        BR: {
            ...
            'is_otbr': True,
            'backbone_network_id': <backbone-id>,
            ...
        }
        ...
    }
    ...
```

`<backbone-id>` is any integer from 0, for each BR inside a single
test, if `<backbone-id>` is different, the BR use different backbone
interfaces; the same `<backbone-id>` inside a single test case means
the same backbone network interface.

`'backbone_network_id': <backbone-id>` is optional for single backbone
test cases, when it's not given while defining a otbr node, the
backbone is default as `backbone{PORT_OFFSET}.0`.

For developers, if you are defining a new test which has multiple
backbone interfaces, please ensure `backbone_network_id` is explicitly
defined in each BR, otherwize an error is reported.
2024-08-13 09:21:43 -07:00
Zhanglong Xia ddbc99b821 [radio] update the description of otPlatradioSetChannelTargetPower() (#10585)
This commit updates the descrition of the function
`otPlatRadioSetChannelTargetPower()` to make the function descrition
more accurate, and updates the implementation of the function based on
the latest description.
2024-08-12 22:25:05 -07:00
Zhanglong Xia df757ba0cf [test] test whether the RCP supports the Link Metrics (#10592)
This commit adds a test case to `cp-tests` to test whether the RCP
supports the Link Metrics.
2024-08-09 16:50:42 -06:00
Jason Zhang 28b6011433 [thread-cert] print elapsed time of each test when running cert suite (#10593)
This is helpful to know the exact time that each test take when running
bunch of tests in cert suite.
2024-08-09 14:55:36 -07:00
Jason Zhang 67717618b7 [test] support multiple backbone interfaces in otbr docker test (#10550)
In previous otbr docker tests, when creating docker containers, all the
containers(otbr nodes) are connected to the same docker network bridge `backbone0`
(when the env PORT_OFFSET is not set or set to 0), this means all the
otbr nodes are connected to the same infrastructures.

This commit adds support to enable user to config otbr instance
infrastructures seperately in `TOPOLOGY` when defining test cases, this
provides flexibility to run multi-ail related test cases.

The format to define backbone interface per node is:

```
class NewTestCase(thread_cert.TestCase):
    ...
    BR = 1
    ...
    TOPOLOGY = {
        BR: {
            ...
	    'is_otbr': True,
	    'backbone': <backbone-name>,
	    ...
	}
	...
    }
    ...
```

`'backbone': <backbone-name>` is optional, when it's not given when
defining a otbr node, the backbone is default as
`BACKBONE_DOCKER_NETWORK_NAME`. The `<backbone-name>` is suggested to be
defined as `backbone[0-9]` to make it more easy to read and understand.

This commit also adds test_multi_ail.py as an example test case to use
this new method, this test case checks the two otbr nodes are connected
to the different infra and are in the same Thread mesh network.
2024-08-08 07:44:26 -07:00
Jason Zhang 6635201aa1 [thread-cert] fix bug that docker network is not removed (#10590)
In some cases that `_do_packet_verification` is False (e.g. verify() is
not defined), the docker network is not correctly removed.

docker network interface should always be removed at the end of the test
if it was created at the begin of the test
2024-08-08 08:37:57 -06:00
Jason Zhang eb468b4e6d [gitignore] ignore files in ot_testing folder (#10591)
ot_testing/* are generated when running "script/test cert_suite"
2024-08-08 08:37:19 -06:00
Li Cao d034b5c850 [spinel] add spinel property to send mgmt set dataset in TLVs format (#10587)
This commit adds a new spinel property
`SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET_TLVS` to do network
migration operation on NCP.

The existing property `SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET`
cannot be used for two reasons:
1. It uses a structured format instead of raw TLVs format.
2. The set handler of `SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET`
   doesn't call `otDatasetSendMgmtPendingSet` with a callback. On NCP,
   we want to know the result of the MGMT_SET operation. (accepted,
   rejected or timeout)

This new property works similarly as
`SPINEL_PROP_NET_LEAVE_GRACEFULLY` added in
https://github.com/openthread/openthread/pull/10337

1. Host sets the property to NCP.
2. NCP will give an immediate response on the result of
   `otDatasetSendMgmtPendingSet`.
   - If succeeded, NCP will respond an empty property
     `SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET_TLVS`
   - If failed, NCP will respond a LAST_STATUS of the error info.
3. When the callback of `otDatasetSendMgmtPendingSet` is called, NCP
   will send a notification of
   `SPINEL_PROP_THREAD_MGMT_SET_PENDING_DATASET_TLVS` to the host to
   notify the result of the operation.
2024-08-07 21:43:22 -06:00
Zhanglong Xia cc16fc2d67 [otci] add link metrics commands to otci (#10580) 2024-08-07 21:08:33 -06:00
Abtin Keshavarzian 19dadd9c45 [srp-client] add KeyInfo type alias for KeyPair or KeyPairAsRef (#10579)
This commit introduces the `KeyInfo` type, which is a `typedef` to
either `KeyPair` or `KeyPairAsRef` depending on whether the feature
`KEY_REFERENCES_ENABLE` is enabled.

This simplifies the code, removes repeated code, and eliminates extra
`#if` checks when `KeyInfo` is used.
2024-08-06 08:56:26 -06:00
Mia Yang 634745dd72 [test] verify state bitmap when runtime enable/disable EphemeralKey mode (#10503)
Meshcop ePSKc mode supported bitmap check.
2024-08-06 08:54:02 -06:00
Jason Zhang 1d35e30e0e [thread-cert] output docker stdout/stderr only when VERBOSE is non-zero (#10574)
This commit supresses the docker output unless verbose mode is enabled,
which helps preventing unnecessary output from cluttering the console.

docker output is enabled when:
 * env VERBOSE is set to a non-zero value

docker output is suppressed (redirecting to /dev/null) when:
 * VERBOSE is not explicitly set in env, or
 * env VERBOSE is set to 0
2024-08-06 08:49:27 -06:00
Abtin Keshavarzian 10366cb3bf [srp-client] update MsgInfo to include mMessage (#10577)
This commit updates and renames the `Info` class to `MsgInfo`, which
now includes `mMessage` as an `OwnedPtr` to the message to be prepared.
This simplifies the code by encapsulating the `Message` and all its
associated data needed to prepare an SRP update message into one data
structure. This structure can be passed as a single input to
different methods preparing various SRP update components, instead of
as two separate inputs.  The OwnedPtr ensures automatic freeing of the
message upon any error.
2024-08-05 16:28:32 -06:00
dependabot[bot] 069ba71f5e github-actions: bump actions/setup-python from 5.1.0 to 5.1.1 (#10583)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/82c7e631bb3cdc910f68e0081d67478d79c6982d...39cd14951b08e74b54015e9e001cdefcf80e669f)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2024-08-05 16:18:36 -06:00
Handa Wang 05d6bd6eb3 [posix] allow custom implementation of otPlatInfraIfDiscoverNat64Prefix (#10566)
This commit moves the macro guard
`OPENTHREAD_POSIX_CONFIG_INFRA_IF_ENABLE` in the code so that it can
allow custom implementation of `otPlatInfraIfDiscoverNat64Prefix` when
`OPENTHREAD_POSIX_CONFIG_INFRA_IF_ENABLE` is disabled.

The use case is on Android platform. We'll not let `ot-daemon`
proactively discover the prefixes by DNS. Instead, System Server will
do the discovery of NAT64 prefix on AIL and it will notify `ot-daemon`
when the AIL NAT64 prefix is discovered/removed.
2024-08-05 16:17:11 -06:00
Zhanglong Xia 18365adcf5 [spinel] stop Spinel time sync when Thread satck is not running (#10573)
The radio_spinel periodically send Spinel command
SPINEL_PROP_RCP_TIMESTAMP to RCP to synchronize time between host
and RCP. Even if Thread stack is not running, it will periodically
wake up the Thread host.

This commit stops the time sync when the Thread stack is not running
to save host power.
2024-08-05 16:11:54 -06:00
Rongli Sun 91eef98f95 [border-agent] log enhancements (#10549)
This commit updates logs on secure session establishment and
commissioner for accuracy.
2024-08-05 16:10:36 -06:00
Li Cao 54d10720f6 [spinel] add spinel property to get/set dataset in raw TLVs (#10569)
This commit adds two new spinel properties:
`SPINEL_PROP_THREAD_ACTIVE_DATASET_TLVS` and
`SPINEL_PROP_THREAD_PENDING_DATASET_TLVS`, as well as the get/set
property handler on NCP side.

Currently we can only transport dataset through spinel with fixed
format. Using Tlvs allows us to append TLVs are not defined in the
current Thread Specification.
2024-08-05 16:09:52 -06:00
Zhanglong Xia c5ad131028 [cli] add the sync option to the linkmetrics cli commands (#10518)
The cli command `linkmetrics` only provides an asynchronous output
method. It is difficult for scripts to call the `ot-ctl` to capture
the results of asynchronous output.

This commit replaces the command `linkmetrics mgmt` and `linkmetrics
query` with commands `linkmetrics config` and `linkmetrics
request`. Both the commands `linkmetrics config` and `linkmetrics
request` are set to the `sync` mode by default, and an option `async`
is added to these commands to support `async` mode.
2024-08-02 13:37:18 -07:00
Yakun Xu e219fe92f1 [mac] support frames without sequence number (#10544)
This commit adds the capability to support frames without sequence
number.
2024-08-02 09:50:45 -07:00
Handa Wang 03113e8502 [nat64] enhancements for Translator::UpdateState (#10564)
This commit applies following enhancements to the
`Translator::UpdateState`:
- Remove the `aAlwaysNotify` parameter to simplify its logic.
- Fix an issue that `mState` may not be updated when setting a CIDR.
2024-08-01 08:33:19 -07:00
Zhanglong Xia fba922ebe2 [test] test the Thread network 1 hop throughput (#10552)
This commit adds a test case to the `cp-tests` to test the Thread network 1 hop
throughput.
2024-08-01 08:27:35 -07:00
Rongli Sun cbd35e34a7 [dua] resume registration when fails to become router (#10559) 2024-08-01 08:15:10 -07:00
Abtin Keshavarzian a759a4a09f [ip6] update PassToHost to use aReceive for applying RX filter (#10541)
This commit updates `PassToHost()`, removing the `aApplyFilter` input
and using `aReceive` to determine whether or not to apply the RX
filter. The filter serves multiple purposes:

- Ensure Thread control UDP traffic (e.g., MLE, TMF, etc.) is filtered
  out when delivering IPv6 datagrams to the host.
- Apply ICMPv6 echo requests filtering, based on the configured mode
  (whether the OT stack should respond to pings for specific address
  types or they should be passed to the next layer).
- Filter TCP traffic when the native OT TCP stack is used.

In all cases, the filter should be applied only if the IPv6 message is
supposed to be received by the device itself (i.e., the destination
matches the device's address), which is indicated by the `aReceive`
input.

The `aApplyFilter` input was previously set to `!forwardHost`,
indirectly assuming that `forwardHost` and `receive` would be
exclusive. While this remains true for unicast destinations, recent
changes updated the code so that all multicast traffic is forwarded
to the host regardless of whether it is also marked for `receive`.
This caused multicast MLE/TMF traffic to be passed to the host even
though it should be filtered. This issue is now addressed by this
change.

This commit also ensures that RX filter rules are consistently applied
to fragmented IPv6 messages. Previously, the filter would not apply
when fragmented IPv6 messages were passed to the host, but with this
change, the filter is applied when the message should be received by
the device.
2024-07-31 14:54:01 -07:00
Abtin Keshavarzian 6a8d4ea2a5 [ip6] avoid re-reading IPv6 header when updating BR counters (#10558)
This commit updates the code to avoid re-reading the IPv6 header when
updating BR-related counters in `Ip6::PassToHost()`.
2024-07-31 08:32:55 -07:00
Suvesh Pratapa 5493815126 [ncp] initialize diag output callback per instance in NcpBase (#10547)
This fixes a bug where diag get output callback was not set properly
if we used instance with iid > 1, leading to failure output.
2024-07-30 13:48:14 -07:00
Suvesh Pratapa 3c2d4487d8 [cmake] add option for OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE (#10545)
This makes it easier to configure this option for testing on OTBR/RCP.
2024-07-30 12:03:43 -07:00
Li Cao 82cee34a3f [api] fix dnssd platform API doc (#10556) 2024-07-30 11:01:46 -07:00
Abtin Keshavarzian 736bd18652 [ip6] remove UDP port check for messages with HostTrusted origin (#10546)
This commit removes the checks previously performed on messages with
the origin `HostTrusted` that are to be forwarded to the Thread mesh.
This origin is used for messages generated by the OpenThread stack
itself. These checks were unnecessarily restricting such messages
from using Thread Control UDP port numbers (like TMF, MLE, etc.).
The additional check `!IsLoopbackToHostAllowed()` (which is set to
`true` by default on such messages) bypassed the entire block,
preventing any functional impact.

Recent related changes (in #9437) added similar guard checks for
messages with `HostUntrusted` origins.
2024-07-30 10:54:21 -07:00
Abtin Keshavarzian c6da03c378 [ip6] simplify PassToHost() to directly use Ip6::Header (#10542)
This commit updates `PassToHost()` to directly use the `Ip6::Header`
and its `GetSource()` and `GetDestination()` methods when applying
filter rules. This replaces the previous model where a `MessageInfo`
was constructed from the received IPv6 header and passed to
`PassToHost()`. The previous model indirectly assumed that the
message was received, with the `MessageInfo` sock/peer addresses
mapped accordingly. However, `HandleDatagram()` can also process
messages originating from the device itself, where the notion of peer
and sock addresses would be reversed. Using `Ip6::Header` directly
makes the rules clearer and simplifies the logic of `PassToHost()`.

Additionally, this change simplifies the code by moving the
construction of `MessageInfo` to the `Receive()` method, where the
message is received.
2024-07-30 10:53:49 -07:00
Mia Yang 0df96d8dad [lib] add little endian methods in utils (#10534) 2024-07-30 10:43:54 -07:00
dependabot[bot] e913c7d235 github-actions: bump actions/setup-go from 5.0.1 to 5.0.2 (#10554)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/cdcb36043654635271a94b9a6d1392de5bb323a7...0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2024-07-29 10:41:43 -07:00
Zhanglong Xia 70969285f9 [otci] add iperf3 commands support to otci (#10519)
This commit adds the iperf3 commands to `otci` for testing Thread
network throughput.
2024-07-26 10:44:22 -07:00
Abtin Keshavarzian 2cc0798a97 [border-agent] directly respond to MGMT_GET from non-active commissioner (#10524)
This commit updates the `BorderAgent` to directly respond to
`MGMT_ACTIVE_GET` and `MGMT_PENDING_GET` requests from a non-active
commissioner. Requests from an active commissioner are still
forwarded to the leader. This aligns the implementation with Thread
1.4 requirements (ephemeral PSKc use case).

To achieve this, the following changes are made:

- New `State` values are added to distinguish between when a
  commissioner candidate is connected and when its petition to become
  the active commissioner is accepted. This determines whether the
  `MGMT_GET` request should be handled directly or forwarded to the
  leader.
- This state is tracked locally by `BorderAgent` instead of monitoring
  Network Data to determine whether an active commissioner exists.
  This ensures correct behavior even when Network Data updates are
  delayed.
- The `DatasetManager` is updated to provide `ProcessGetRequest()`
  to process an `MGMT_GET` request and prepare the response. This is
  then used by `DatasetManager` itself and `BorderAgent`.
2024-07-25 11:04:37 -07:00
Yakun Xu af18582b4e [test] set default paths of expect scripts (#10530)
This commit adds default paths for expect scripts to make it easier for
running expect scripts. With this change, we can run expect tests as
follows:

```bash
./script/cmake-build simulation
./script/cmake-build posix
./tests/scripts/expect/cli-ping.exp
OT_NODE_TYPE=rcp ./tests/scripts/expect/cli-ping.exp
```

This commit also updates an existing test to cover the change.
2024-07-24 06:50:17 -07:00
Zhanglong Xia d0fbfb8c76 [sub-mac] use relative time when starting CSL TX delay (#10525)
The original code uses the absolute time when staring the CSL TX delay
in `SubMac`. The timer is a `MicroTimer` and the absolute time comes
from the `mTxDelayBaseTime`. The `mTxDelayBaseTime` comes from the
radio time `otPlatRadioGetNow ()`, the time of `MicroTimer` should
come from `otPlatAlarmMicroGetNow()`. If the `MicroTimer` and the
radio are using different timer sources, it will cause the unexpected
issue.

This commit use the relative time when starting CSL TX delay to fix
this issue.
2024-07-22 09:56:54 -07:00
dependabot[bot] 625b18630c github-actions: bump docker/setup-buildx-action from 3.3.0 to 3.4.0 (#10531)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/d70bba72b1f3fd22344832f00baa16ece964efeb...4fd812986e6c8c2a69e18311145f9371337f27d4)

---
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>
2024-07-22 09:21:21 -07:00
Maciej Baczmański 4e3483c751 [low-power] enhance mCslFrameRequestAheadUs calculation for RCP (#10488)
Implement `otPlatRadioGetBusLatency` API, add optional
`bus-latency` argument to ot-daemon
and `diag radiospinel buslatency`diagnostic commands.

Add callback to notify that the bus latency has been updated
and update frame request ahead from runtime, by
recalculating the `mCslFrameRequestAheadUs` value.

Changes allow setting a bus latency while starting a new session
between host and RCP device. This way, one host can be connected
to different devices and vice versa, ensuring that the latency
will be added to `mCslFrameRequestAheadUs` calculations and CSL
tx requests will not be sent too late.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-07-19 21:39:32 -07:00
Zhanglong Xia 602167f94a [sub-mac] unify the timer usage (#10520)
The `SubMac` uses `MilliTimer` or `MicroTimer` based on the
configuration.  When the `SubMac` uses the timer, it has to
distinguish the type of the timer. This commit optimizes the code to
provide unified time related functions to `SubMac` to use time. This
commit doesn't change the code logic.
2024-07-18 10:36:29 -07:00
Handa Wang b73114c860 [continuous-integration] fix the path for uploading artifacts when the BR fails (#10521)
The OTBR testing artifacts used to be at the root directory but they
are now at `ot_testing/`.
2024-07-17 19:45:48 -07:00
Abtin Keshavarzian 6f30a3f913 [mle] update otThreadBecomeLeader() to allow leader take over (#9186)
This commit updates the `otThreadBecomeLeader()` API (and its related
core `MleRouter::BecomeLeader()` method) to allow an already attached
device to take over as leader, creating a new partition. For this to
work, the local leader weight (`otThreadGetLocalLeaderWeight()`) must
be greater than the weight of the current leader (which can be
retrieved using `otThreadGetLeaderWeight()`). If it is not, error code
`OT_ERROR_NOT_CAPABLE` is returned to indicate to the caller that they
need to adjust the local weight.

This commit also updates the related CLI command and adds a new test,
`test-032-leader-take-over.py`, to validate the newly added
mechanism.
2024-07-17 19:43:09 -07:00
Abtin Keshavarzian 171f94c307 [srp-client] defer SRP update on SLAAC address deprecation (#10505)
This commit updates SRP client's `AutoHostAddress` behavior to
defer SRP updates on SLAAC address deprecation events.

Under `AutoHostAddressMode`, all preferred addresses on Thread Netif,
excluding link-local and mesh-local addresses, are registered. If no
eligible address is available, then the ML-EID will be registered.

This commit adds a new mechanism where if a previously registered
address starts being deprecated (e.g., due to an OMR prefix removal
from Network Data), the SRP update is deferred. The client will
re-register after the deprecation time has elapsed and the address is
removed. In the meantime, if any other event triggers the client to
send an SRP update, the updated address list will be included in that
update.

This commit also updates `test_srp_auto_host_address` to validate the
newly added behavior.
2024-07-17 11:14:09 -07:00
Li Cao 6f52d78195 [radio] make host-rcp time sync be controlled by the posix platform (#10504)
This commit makes `CalcRcpTimeOffset` of `RadioSpinel` into a public
method and call it from system `Process` method instead of making it
default behavior of `RadioSpinel`. This is also to avoid `RadioSpinel`
has a fixed behavior which is decided by
`OPENTHREAD_CONFIG_THREAD_VERSION`.
2024-07-17 10:44:38 -07:00
Li Cao 0897b50a27 [spinel] fix little endian in lib (#10522) 2024-07-17 10:10:12 -07:00
Abtin Keshavarzian aba7aede14 [network-data] enhance route lookup for ALOC destination (#10509)
This commit updates `NetworkData::Leader` to enhance route lookup for
ALOC destinations. It contains the following changes:

- Adds `LookupRouteForServiceAloc()` to look up the route for a
  service ALOC. This method uses the common `CompareRouteEntries()`,
  which applies the same rules as in external route lookup.
- Adds `LookupRouteForAgentAloc()` to look up the route for DHCPv6 or
  ND agent ALOC.
- Adds `FindPrefixTlvForContextId()` to find a Prefix TLV matching a
  given Context ID (used in `GetContext()` and
  `LookupRouteForAgentAloc()`)
- Adds `LookupRouteIn()` to perform route lookup among all entries of
  a given `PrefixTlv` that match a given `EntryChecker` function
  (used for `DefaultRouteLookup()` or `LookupRouteForAgentAloc()`)
- Adds `test-031-service-aloc-route-lookup.py`.
2024-07-16 13:06:14 -07:00
Abtin Keshavarzian cf5637f3ca [mesh-forwarder] RemoveMessagesForChild() to use a predicate fn (#10514)
This commit updates `RemoveMessagesForChild()` to use a predicate
function to determine which messages should be removed. This replaces
the `Message::SubType` filtering and allows messages matching
multiple sub-types to be removed together.
2024-07-16 09:11:10 -07:00
Abtin Keshavarzian be6b198730 [mesh-forwarder] use RemoveMessageIfNoPendingTx() (#10513)
This commit replaces direct calls to `DequeueAndFree()` with
`RemoveMessageIfNoPendingTx()` in `EvictMessage()`, `HandleResolved()`,
and `RemoveDataResponseMessages()`. This promotes consistency in
message removal logic and eliminates the need to check if the removed
message is `mSendMessage`, as this is already handled by
`RemoveMessageIfNoPendingTx()`.
2024-07-16 08:57:49 -07:00
sarveshkumarv3 b301a4c43f [settings] reset the platform settings file descriptor once closed (#10512)
On platform settings deinit, the file descriptor is closed but the
variable is not reset, which can lead to calling close on a stale fd
leading to bad file descriptor error in case the API is invoked
multiple times.
2024-07-15 11:17:09 -07:00
Li Cao 6f2d8b6b22 [spinel] add get iid method (#10516)
This commit adds a method to get spinel interface Id in
`SpinelDriver`.

This is to enable the user class of `SpinelDriver` can compose the
spinel header itself.
2024-07-15 10:43:40 -07:00
dependabot[bot] 9b57797c0a github-actions: bump actions/checkout from 4.1.6 to 4.1.7 (#10517)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.6 to 4.1.7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/a5ac7e51b41094c92402da3b24376905380afc29...692973e3d937129bcbf40652eb9f2f61becf3332)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2024-07-15 10:26:28 -07:00
Li Cao 7887cc7574 [spinel] fix hints of missing radio caps (#10507) 2024-07-15 09:50:25 -07:00
Abtin Keshavarzian f331472b73 [routing-manager] track peer BRs and their age from Network Data (#10485)
This commit adds a new mechanism in `RoutingManager` to discover and
track peer BRs found in Network Data. The `NetDataPeerBrTracker`
class implements this functionality, tracking a list of peer BR
RLOC16s and their age (time since appearance in the Network Data).

This commit also implements public OT APIs to iterate over the peer BR
list or get the total count, along with corresponding CLI commands
(`br peers`), and a test case validating the behavior.
2024-07-15 09:49:08 -07:00
Li Cao b0790b3daa [spinel] fix cmake source list for spinel_helper.cpp (#10515) 2024-07-15 08:50:43 -07:00
Zhanglong Xia 20c9bcbc41 [test] test whether the RCP supports data poll (#10494)
This commit adds a test case to the `cp-tests` to test whether the RCP
supports data poll transmitter and receiver.
2024-07-12 08:59:28 -07:00
Li Cao f32c18bc08 [spinel] extract SpinelStatusToOtError method from RadioSpinel into a helper module (#10506)
This commit moves `RadioSpinel::SpinelStatusToOtError` to a seperate
header `spinel_header.hpp` so that this method can be used
externally. (For example, in `ot-br-posix`.
2024-07-11 16:00:55 -07:00
Abtin Keshavarzian 2d2e8cf80a [channel-manager] require CSL to enabled with CSL_CHANNEL_SELECT_ENABLE (#10266)
This commit requires `MAC_CSL_RECEIVER_ENABLE` to be enabled when
`CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE` is also enabled. This is
checked and enforced in the `channel_manager.hpp`, emitting an
`#error` if it fails. This simplifies the `#if` checks related to
this in the `ChannelManager` class and CLI module.
2024-07-11 14:16:26 -07:00
Zhanglong Xia fbb715baa7 [test] test whether the RCP support CSL transmitter (#10495)
This commit adds a test case to `cp-tests` to test whether the RCP
supports the CSL transmitter.
2024-07-11 10:37:15 -07:00
Dávid Fehér 77ca3c54d1 [cli] add support for CoAP URI queries in CLI requests (#10003)
New feature:

Added CoAP URI query processing functionality to CLI.

Solution:

URI string is checked for a '?' character. If found, the URI query
related part is moved to another string. Afterwards, the modified
`coapUri` string will contain only the path-related parts, and a
second string (`coapUriQuery`) will hold only the URI query related
parts. Then `coapUri` is passed to the original
`otCoapMessageAppendUriPathOptions()` method and `coapUriQuery` is
passed to a new method called `otCoapMessageAppendUriQueryOptions()`,
which - similarly to the other - splits the URI query part into more,
smaller pieces by the delimiter '&' and adds them as separate options
to the CoAP message making the request generated by this CLI function
RFC compliant.  If '?' is not found, everything is processed the old
way.
2024-07-11 09:34:02 -07:00
Li Cao 78ecafb0d7 [radio] move required radio caps from radio spinel into posix platform (#10502)
This commit moves the definition of the 'RequiredRadioCaps' from
`RadioSpinel` to posix `Radio` class. Because this definition depends
on `OPENTHREAD_CONFIG_THREAD_VERSION`. And we want to remove lib's
dependency on OT core. And lib as a tool should be able to decide what
caps to check at runtime.
2024-07-10 22:56:52 -07:00
Abtin Keshavarzian 4c84e4d642 [routing-manager] indicate peer BRs in discovered infra-if routers (#10448)
This commit updates the public API `otBorderRoutingGetNextRouterEntry`
and `otBorderRoutingRouterEntry` structure to indicate whether a
discovered router on an infrastructure link is likely a peer Thread
Border Router (BR) connected to the same Thread mesh. The related CLI
commands are also updated.

Additionally, this commit adds new tests to validate the discovery and
tracking of peer BRs.
2024-07-10 14:47:18 -07:00
Abtin Keshavarzian 32fe4c7cdd [dataset-manager] apply partial dataset config on channel set failure (#10490)
This commit updates `DatasetManager::ApplyConfiguration()` to apply
the rest of the parameters in the Dataset even if setting the channel
fails. The channel error is now logged as `LogCrit()`.
2024-07-10 10:21:17 -07:00
Yakun Xu b85d4eed71 [platform] add per-frame tx power capability (#10481)
This commit adds a new radio capability to indicates that the platform
supports specifying tx power per frame.
2024-07-10 10:20:01 -07:00
TimL cdbb9e5342 [posix] deassert DTR and RTS if flow control is disabled (#10454)
Many USB radio devices (particularly those based on TI CC2652) have
reset and bootloader activation directly connected to DTR/RTS lines.
These devices will fail to start, in the default state where both
DTR/RTS are asserted on connection.

This patch ensures flow control is disabled and both DTR and RTS are
deasserted on startup while configuring the terminal.
2024-07-10 10:11:38 -07:00
Abtin Keshavarzian 695e7a50a3 [network-data] refactor anycast dest lookup to NetworkData::Leader (#10493)
This commit refactors the code and methods responsible for looking up
anycast destination, moving them from the `MeshForwarder` class to
the more appropriate `NetworkData::Leader` class. This better aligns
the responsibilities of each module (e.g. `RouteLookup()` is provided
by `NetworkData::Leader). This is a pure refactor with no changes or
enhancements to the existing implementation.
2024-07-09 11:24:37 -07:00
Przemysław Bida bf5ddb908e [tcat] implementation of tcat Ping command (#10484)
Commit implements Tcat ping command `kTlvPing`.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-07-09 10:11:39 -07:00
Abtin Keshavarzian e4c50bc5df [cli] harmonize header include style (#10492)
This commit harmonizes header file include style in CLI source files.
Most `#include` statements do not have any `#if` guard checks before
them, but some do. This commit removes the extra `#if` guard checks.
For CLI sub-modules, the `cli_<module>.hpp` header itself will have
the proper `#if` guard checks.
2024-07-09 10:01:57 -07:00
Abtin Keshavarzian 8d4119c914 [routing-manager] track router age (#10453)
This commit adds a new mechanism in `RoutingManager` to track the
duration since a router is first discovered. This information is now
provided in `otBorderRoutingRouterEntry`, and the CLI `br routers`
command is updated to include this information for each router.

To enable tracking of longer durations, `Uptime` is used, which tracks
milliseconds since the start of `ot::Instance` as a `uint64_t` value.
`TimerMilli::GetNow()` is not suitable for this purpose because it
utilizes `uint32_t` intervals, which would limit the maximum
trackable time to roughly 49 days due to potential overflow.
2024-07-09 09:57:57 -07:00
Abtin Keshavarzian 821f2415e0 [test] harden test_srp_server (#10486)
This commit updates `test_srp_server` to wait longer after the start
of the SRP client before performing the test steps. This makes the
test more robust against random jitter which may be applied by the
client when registering.
2024-07-08 15:44:53 -07:00
Abtin Keshavarzian 91e5a798f8 [cli] simplify parsing dataset TLVs (#10476)
This commit adds the `ParseTlvs()` helper method in the `Cli::Dataset`
class, which parses TLVs (as hex strings) from an input argument.
This is used in multiple methods to simplify the code.

The `Process<Cmd("set")>()` method is updated to avoid extra
conversion and use of core-internal types.
2024-07-08 15:05:58 -07:00
Abtin Keshavarzian 9ac67520f2 [mesh-forwarder] track parsed IPv6 header in RxInfo (#10467)
This commit adds an `Ip6::Header` field to `RxInfo`, along with the
`ParseIp6Headers()` method to decompress and parse the IPv6 headers
from the received frame. `RxInfo` now tracks whether the headers have
been parsed before.

The IPv6 headers may be parsed from different code paths as the
received frame is processed. For example, `UpdateRoutes()`,
`GetFramePriority()`, and `CheckReachability()` may parse the IPv6
headers. By having `RxInfo` cache the parsed IPv6 headers,
duplicate parsing is avoided.
2024-07-08 15:04:37 -07:00
dependabot[bot] 528784caa5 github-actions: bump actions/setup-go from 5.0.0 to 5.0.1 (#10489)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/0c52d547c9bc32b1aa3301fd7a9cb496313a4491...cdcb36043654635271a94b9a6d1392de5bb323a7)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2024-07-08 15:01:28 -07:00
Zhanglong Xia b6d46327f4 [otci] add network management API to otci (#10482)
This commit adds high level Thread network management API
'create_dataset()', 'join()', 'leave()' and 'wait_for()' to otci.
2024-07-08 14:58:38 -07:00
Abtin Keshavarzian 4c0d8f2e59 [srp-client] apply short random jitter to lease renew time (#10473)
This commit updates `Srp::Client` to apply a short random jitter
(15 seconds) when calculating the lease renew time. The lease is
renewed close to its expiration, using a guard interval of 120
seconds (renewing 120 seconds before expiration). The jitter is added
to distribute client refreshes, in case many clients registered their
services around the same time.
2024-07-05 12:40:00 -07:00
Zhanglong Xia 71dd8a2d3a [test] add script to test which diag commands RCP supports (#10463)
This commit implements a test script tools/cp-caps/rcp_caps_test.py to
test which diag commands RCP supports using the DUT and reference
device.
2024-07-05 09:56:41 -07:00
Zhanglong Xia 686aab7589 [csl] move csl related functions to sub_mac_csl.cpp (#10477)
This commit moves csl receiver related functions to
sub_mac_csl_receiver.cpp to simply the sub_mac.cpp to improve the code
readability.

This commit is a pure refactoring and doesn't contain any logic or
code changes.
2024-07-05 09:54:20 -07:00
Rongli Sun fbdb4b6c8f [test] supplement state bitmap test (#10318) 2024-07-05 09:51:33 -07:00
Abtin Keshavarzian e72ef4354a [test] harden test_advertising_proxy (#10474)
This commit makes two changes in `test_advertising_proxy`:

- In the test step where the server is restarted, a longer wait time
  is used to account for the longer jitter interval used by SRP
  client in such a case.
- Due to the use of short lease time (10 seconds) in this test, the
  client will refresh the registered services quickly. Therefore, in
  `check_host_and_service()`, any of `Registered`, `ToRefresh`, or
  `Refreshing` states are accepted as indicating successful
  registration.
2024-07-05 09:49:03 -07:00
Abtin Keshavarzian 000f5fcb30 [meshcop] update ChannelMaskTlv to use OffsetRange (#10465)
This commit updates `ChannelMaskTlv` to use `OffsetRange` when
iterating over and parsing the list of entries contained in the TLV.
2024-07-03 16:39:04 -07:00
Abtin Keshavarzian c49cd72792 [mle] remove now undefined UpdateChildAddresses() (#10475)
This method was refactored in 25fe46d8dd (#8963) but its declaration
was not removed.
2024-07-03 16:38:15 -07:00
Abtin Keshavarzian e7837eb104 [mesh-forwarder] use RemoveMessageIfNoPendingTx() on direct tx fails (#10471)
This commit updates `PrepareNextDirectTransmission()` to use
`RemoveMessageIfNoPendingTx()` if a message cannot be prepared for
direct transmission. This ensures the message is not dequeued and
freed if it is also queued for indirect transmission.
2024-07-03 15:19:03 -07:00
Jonathan Hui be79db724d [routing-manager] add missing exit label (#10472) 2024-07-03 12:57:09 -07:00
Li Cao 5a9c768d44 [spinel] merge spinel config files (#10468)
This commit removes `spinel-config.h` and moves the configs to
`openthread-spinel-config.h` so that the definitions can also be
overridden by definitions in customized lib config file.
2024-07-03 11:23:00 -07:00
Abtin Keshavarzian 41ded02814 [routing-manager] add support for tracking peer BRs (#10445)
This commit adds a new feature to the `RoutingManager` to enable
tracking information about peer Thread Border Routers that are
connected to the same Thread network.

When enabled, the `RoutingManager` will maintain a record of
advertised RIO/PIO prefixes discovered from received Router
Advertisement (RA) messages of peer BRs. When disabled (the existing
behavior), such entries are not tracked.

When tracked, these entries are marked to be disregarded and are not
considered in any decision-making processes, such as selecting
favored on-link prefixes or determining routes to publish in the
Thread Network Data. They are primarily intended for debugging and
telemetry (information gathering) purposes.
2024-07-03 11:21:04 -07:00
Abtin Keshavarzian 5248408076 [ip6] use OffsetRange for parsing options in extension headers (#10466)
This commit updates `Ip6` and `Lowpan` to use `OffsetRange` when
iterating and parsing options in an HBH extension header. It also
simplifies the `RemoveMplOption()` method by adding an `Action` enum,
which determines how to remove the MPL option: whether to shrink the
HBH header, fully remove the HBH header (if it contains no other
options), or replace MPL option with padding.
2024-07-03 11:17:47 -07:00
Abtin Keshavarzian 408f3f205f [mesh-forwarder] add RxInfo::ToString() to simplify logging (#10462)
This commit adds `RxInfo::ToString()`, which generates a common log
string about an `RxInfo` using the "len:%d, src:%s, dst:%s, sec:%s"
format, providing frame length, source and destination addresses, and
whether link security is used. This is then used in different logging
methods, simplifying the code.
2024-07-03 11:15:55 -07:00
Abtin Keshavarzian 3701ce96dd [tlv] use OffsetRange and make ParsedInfo public (#10461)
This commit updates `Tlv` helper methods to use `OffsetRange` in their
implementation. It also makes the `Tlv::ParsedInfo` type public. This
struct represents information about a parsed TLV in a message,
including the TLV type, the `OffsetRange` for the full TLV, and the
`OffsetRange` where the TLV's value resides in the message. This
replaces and enhances the `ParseAndSkipTlv()` method.

The `ParsedInfo` provides two methods:

- `ParseFrom()`: Parses a TLV at a given offset or offset range.
- `FindIn()`: Searches for a given TLV type in a message.

These methods handle both extended and regular TLV formats, validating
that the parsed TLV is well-formed and fully contained within the
message and the given `OffsetRange`.

Modules that iterate over a sequence of TLVs in a message are updated
to use `ParsedInfo` and its methods, simplifying the code.
2024-07-03 11:15:28 -07:00
Yakun Xu aebecca964 [cmake] disable c extensions (#10460)
CMake by default enables c extensions. As a result, gnu99 is used
instead of c99. This commit explicitly disables c extensions.
2024-07-02 08:53:02 -07:00
Abtin Keshavarzian d87be657c6 [srp-client] enhance selection of TX jitter based on trigger reason (#10357)
This commit improves the `Srp::Client` mechanism for applying random
jitter delays before sending update messages to the server. It now
supports different jitter ranges based on specific triggers. Since
trigger events are often network-wide, potentially causing
simultaneous SRP re-registration from many nodes, longer jitter
intervals are used to distribute the resulting SRP update
transmissions and avoid congestion.

The following triggers are covered:

- Server switch: Client switching to a new server while already
  connected to a discovered server. This occurs when a new server
  entry appears in Network Data which is preferred over the current
  selection.

- Server restart: Client was previously connected to a server that
  disappeared from Network Data. Later, the same or a new server is
  discovered in Network Data.

- SLAAC address add or remove: This is generally triggered by updates
  to SLAAC prefixes in Network Data (e.g., OMR prefix changes).

- First registration after attach:

  - If the device is attaching to an established Thread mesh
    (e.g., after a reboot or initial pairing), the Network Data it
    receives should already include a server entry, leading to a
    quick server selection after attach. If server selection occurs
    within a short window, a shorter TX jitter is used, allowing the
    device to register quickly and become discoverable.

  - If server discovery takes longer, a longer TX jitter is used. This
    situation can indicate a server/BR starting up or a network-wide
    restart of many nodes (e.g., due to a power outage).

This commit introduces `TxJitter` class to manage the requested TX
jitter based on a trigger reason. It tracks the time of the event
that triggered a longer jitter request. If the update message is sent
immediately after the trigger event, the requested maximum jitter is
applied. However, if the update message is sent later, the maximum
jitter is adjusted proportionally to the time elapsed since the
trigger event. If the elapsed time exceeds the requested maximum
jitter interval, the default short jitter is applied to avoid
unnecessary registration delay.
2024-07-02 08:52:28 -07:00
Abtin Keshavarzian 6f12c8164e [mesh-forwarder] restore FrameData in GetForwardFramePriority() (#10459)
This commit updates `GetForwardFramePriority()` to save the original
`aRxInfo.mFrameData` before parsing the fragment header. The header
parsing may modify `mFrameData` to skip over the parsed portion. The
original `FrameData` is restored before returning, ensuring that
forwarded frames include the fragment header and eliminating the need
to create a copy of `aRxInfo`.
2024-07-01 19:20:07 -07:00
Li Cao 41b91a982b [spinel] allow custom config file for lib spinel (#10449) 2024-07-01 19:16:39 -07:00
Zhanglong Xia 2d3df2acee [posix] add rcp capability diag command to check the Spinel interface speed (#10443) 2024-07-01 19:16:10 -07:00
Abtin Keshavarzian a448bce915 [core] add OffsetRange class (#10436)
This commit introduces the `OffsetRange` class, which represents a
range of offsets within a `Message` or data buffer (i.e., a starting
offset and a length indicating the number of bytes in the range).

The class provides methods for common operations:

- Getting the start or end offset, or the remaining length.
- Checking if the range is empty or contains a certain number of
  bytes.
- Advancing the start offset by a given amount, ensuring it never goes
  beyond the end offset.
- Shrinking the range's length.

The new `OffsetRange` class simplifies methods that previously used
separate `aOffset` and `aLength` input parameters, improving code
readability and maintainability. It also facilitates reading and
processing content within a specified range.

For example, `Tlv::FindTlvValueOffsetRange()` now directly returns an
`OffsetRange` indicating the location of the TLV value. The `Message`
class is also updated with new `Read()` and `Append()` method variants
that accept `OffsetRange` arguments. These methods ensure that read
content is contained within the specified `OffsetRange`.
2024-07-01 19:15:17 -07:00
Przemysław Bida 6aa6f45606 [tcat] implement decommissioning in tcat_agent (#10415)
Commits adds handling of TCAT TLV 0x60 `kTlvDecommission`.
2024-07-01 19:14:53 -07:00
Abtin Keshavarzian 99b3ed4ca8 [mesh-forwarder] add RxInfo to encapsulate received frame info (#10451)
This commit introduces a new private struct `RxInfo` in the
`MeshForwarder` class, encapsulating information related to a
received frame during processing. The `RxInfo` struct contains
`FrameData` to track the received frame data bytes, `ThreadLinkInfo`,
and `Mac::Addresses`. This simplifies the code by allowing the
`RxInfo` to be passed to different methods instead of passing the
same information as separate parameters.
2024-07-01 13:05:03 -07:00
Zhanglong Xia 34484f4293 [otci] add diag commands support to otci (#10450) 2024-07-01 08:13:38 -07:00
Abtin Keshavarzian 7b9b396dd5 [routing-manager] add OnLinkPrefix::IsFavoredOver() (#10452)
This commit adds the `OnLinkPrefix::IsFavoredOver()` method to
determine if an on-link prefix is eligible to be considered as a
favored prefix, and if so, is favored over another prefix. A
numerically smaller prefix is considered favored.

Additionally, a new test case is added to `test_routing_manager` to
validate the selection of favored on-link prefixes, including the
the requirement of a minimum preferred lifetime of 1800 seconds
for a prefix to be considered eligible.
2024-07-01 08:12:42 -07:00
dependabot[bot] 356253efd6 github-actions: bump github/codeql-action from 3.25.3 to 3.25.11 (#10455)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.25.3 to 3.25.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/d39d31e687223d841ef683f52467bd88e9b21c14...b611370bb5703a7efb587f9d136a52ea24c5c38c)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2024-07-01 08:11:47 -07:00
Abtin Keshavarzian a0ba929e39 [mle] add RLOC16 related helper methods in Mle (#10440)
This commit introduces new helper methods in the `Mle` class:

- `HasRloc16()`: Checks if the device is using a given RLOC16.
- `MatchesRouterId()`: Checks if this device's RLOC16 matches a given
  Router ID.
- `HasMatchingRouterIdWith()`: Checks if this device's RLOC16 shares
  the same Router ID with a given RLOC16. This implies that the two
  devices are either directly related as parent and child or are
  children of the same parent within the Thread network.
- `ParentRloc16ForRloc16()` derives the router RLOC16 corresponding to
  the parent of a given (child) RLOC16.

These methods act as syntactic sugar, simplifying code and enhancing
readability.
2024-06-27 12:54:07 -04:00
jrhodie e10a92570f [srp] fix otSrpClientStart documentation (#10435) 2024-06-26 18:48:01 -07:00
Abtin Keshavarzian 7ca21a38f2 [tlv] ensure handling of extended TLVs when iterating over sub-TLVs (#10439)
This commit adds the `Tlv::ParseAndSkipTlv()` static method, which
parses a TLV (regular or extended) in a message at a given offset. It
validates that the TLV is fully contained within the message and
updates the offset to skip over the entire parsed TLV.

This helper method is used in various modules where manual iteration
over a sequence of TLVs is performed, specifically to skip over
extended TLVs. The following methods are updated to utilize this new
method and perform additional TLV checks:

- `DiscoverScanner::HandleDiscoveryResponse()`
- `MleRouter::HandleDiscoveryRequest()`
- `LinkMetrics::SubJect::AppendReport()`
- `LinkMetrics::Subject::HandleManagementRequest()`
- `LinkMetrics::Initiator::HandleReport()`
2024-06-26 21:37:01 -04:00
Abtin Keshavarzian f2ed3e9c0d [dns-client] switch to separate SRV/TXT queries on response timeout (#10444)
This commit updates `Dns::Client` so that when resolving a service
using `kServiceModeSrvTxtOptimize`, it switches to single-question
query mode and sends separate parallel SRV and TXT queries upon the
first response timeout. This is in addition to the existing behavior
of switching to separate queries upon receiving a response with an
error rcode from the server.

The `test_dns_client` unit test is also updated to validate this
scenario. New `TestMode` configurations are added to server to
control its behavior, allowing it to either reject multi-question
queries (by sending a "FormatError" rcode) or ignore them (sending
no response).
2024-06-26 21:35:30 -04:00
Zhanglong Xia 7252cadb5a [posix] skip 0x00 bytes at the start of the received SPI frame (#10442)
The SPI interface may receive the garbage bytes 0xff or 0x00 at the
start of the received SPI frame. This commit skips the 0x00 bytes
at the start of the received SPI frame.
2024-06-26 13:32:39 -04:00
Abtin Keshavarzian 975ffd72fc [meshcop] simplify appending and parsing of NetworkNameTlv (#10441)
This commit simplifies the appending and parsing of `NetworkNameTlv`
using `Append<StringTlvType>()` and `Read<StringTlvType>()` TLV
helper methods.
2024-06-26 11:52:55 -04:00
Abtin Keshavarzian 21b5764686 [child] add GetIp6Addresses() and simplify MLR state tracking (#10424)
This commit introduces several changes to the `Child` class for
managing registered IPv6 addresses by MTD children:

- A new method, `Child::GetIp6Addresses()`, is added, returning the
  `Array` of registered IPv6 address entries. This array includes all
  tracked child IPv6 addresses except for the mesh-local EID, which
  can be retrieved using `Child::GetMeshLocalIp6Address()`.
- The simplified model enables easy iteration over the address array
  using `Array` range-based `for` loops. With this change, the
  complex `AddressIterator` and `AddressIteratorBuilder` nested
  classes are removed, streamlining the code.
- MLR state tracking for child IPv6 address entries is simplified with
  the introduction of a new class, `Child::Ip6AddrEntry`,
  representing a registered IPv6 address entry. This class provides
  `GetMlrState()` and `SetMlrState()`, enforcing that the MLR state
  can only be set on a child IPv6 address entry.
2024-06-26 11:12:02 -04:00
Abtin Keshavarzian c8681ff8e4 [routing-manager] centralize RxRaTracker decision logic and signaling (#10389)
This commit enhances `RoutingManager::RxRaTracker`:

- A new private `Evaluate()` method centralizes logic for handling
  changes in tracked routers and advertised prefixes. It removes
  expired entries, determines decision factors used by other
  `RoutingManager` components, and schedules timers.

- A new class `DecisionFactors` is added to track factors used by
  `RoutingManager`, including the favored on-link prefix, presence of
  ULA/non-ULA prefixes, and M/O flags for mirroring in emitted RA
  messages.

- `Evaluate()` determines these factors and signals changes using
  `HandleRaPrefixTableChanged()` only when necessary, simplifying
  signaling and avoiding redundant calculations.
2024-06-26 11:03:23 -04:00
Zhanglong Xia 588dfae6f4 [posix] check the max number of RCP supported sleepy children (#10399)
This commit adds a diag command to rcp capbility diag module to check
the max number of RCP supported sleepy children.
2024-06-26 11:00:46 -04:00
Abtin Keshavarzian cc8f66c56f [core] use RLOC16-related constants and methods consistently across modules (#10434)
This commit aims to make the use of RLOC16-related constants and
methods consistent across different modules.

- It replaces `Mac::kShortAddrInvalid` with `Mle::kInvalidRloc16` to
  refer to an invalid RLOC16 value (note that these constants use the
  same value `0xfffe`).
- It uses `Get<Mle::Mle>().GetRloc16()` to retrieve the device's
  RLOC16 instead of `Get<Mac::Mac>().GetShortAddress()`.
- It updates `AddressResolver` to consistently use `uint16_t` for
  RLOC16 (instead of the `Mac::ShortAddress` typedef).
2024-06-25 16:09:35 -04:00
Abtin Keshavarzian dc69fb1ace [tcat-agent] use Dataset directly when setting Active Dataset (#10433)
This commit updates `HandleSetActiveOperationalDataset()` by removing
the extra conversion from `Dataset` to `Dataset::Tlvs` and directly
using the `Dataset` when saving the Active Operational Dataset.
2024-06-25 16:08:31 -04:00
Abtin Keshavarzian 7b779a3db1 [child] update MLR masks when removing registered IPv6 addresses (#10425)
This commit modifies `Child::RemoveIp6Address()` to update the
`mMlrToRegisterMask` and `mMlrToUnregisterMask` when a registered
child IPv6 address entry is removed from the list. These bit-vector
masks track the MLR state associated with the entry using its index
in the array. Since `Array::Remove()` replaces the deleted entry with
the last one in the array, the MLR masks are also updated to reflect
this change.
2024-06-25 16:08:16 -04:00
Zhanglong Xia ec69ad31f9 [posix] add rcp diag command to check RCP's radio and spinel capability flags (#10400) 2024-06-25 09:26:15 -04:00
Abtin Keshavarzian 7d619875d2 [mesh-forwarder] update forwarding messages to ALOC destination (#10419)
This commit updates how messages with an ALOC destination are
forwarded. If the chosen ALOC destination is a child, its parent is
used as the mesh destination unless the device itself is the parent.
Additionally, if the selected ALOC destination is a sleepy child of
the device, the parent node ensures to prepare the message for
indirect transmission. These changes ensure correct forwarding to ED
or SED devices when they register a service and want to receive
messages on their service ALOC.

This commit also adds a new test, `test-030-anycast-forwarding.py`,
which validates the forwarding to ALOC addresses on both ED and SED
devices.
2024-06-24 15:00:15 -04:00
Zhanglong Xia 8bd427b9c3 [spinel] log sent Spinel frames (#10429) 2024-06-24 10:07:47 -07:00
Stefan Agner 9232ead562 [posix] fix build with custom netif prefix route set (#10431)
This fixes a build error when the pre-processor define
OPENTHREAD_POSIX_CONFIG_NETIF_PREFIX_ROUTE_METRIC is set:

```
/usr/src/ot-br-posix/third_party/openthread/repo/src/posix/platform/netif.cpp:486:26: error: ‘kLinkLocalScope’ does not name a type
  486 |         static constexpr kLinkLocalScope = 2;
      |                          ^~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
```
2024-06-24 09:05:53 -04:00
Abtin Keshavarzian ea25f0954b [mesh-forwarder] move CheckReachability() to MeshForwarder (#10421)
This commit moves the `CheckReachability()` & `ResolveRoutingLoops()`
methods from the `MleRouter` class to the `MeshForwarder` class
now as `private` methods. This consolidates all `CheckReachability()`
overloads within the `MeshForwarder` class.
2024-06-24 08:43:17 -04:00
dependabot[bot] 35847e19af github-actions: bump step-security/harden-runner from 2.7.0 to 2.8.1 (#10432)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.7.0 to 2.8.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/63c24ba6bd7ba022e95695ff85de572c04a18142...17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-06-24 08:38:20 -04:00
Handa Wang 5d3764d1ea [doc] fix the broken link of meshdiag topology in CLI README (#10430) 2024-06-24 08:31:14 -04:00
Abtin Keshavarzian 336984b25a [mle] add IsRouterRloc16() and IsChildRloc16() (#10423)
This commit adds `IsRouterRloc16()` (replacing `IsActiveRouter()`),
which checks whether a given RLOC16 refers to a router and not
a child. The new name clarifies that it is only a check on the RLOC16
value and does not verify if the corresponding router ID is allocated
and active. This commit also adds `IsChildRloc16()`, which is similar
to `IsRouterRloc16()` and checks if the given RLOC16 is for a child.
This simplifies the code and improves readability.
2024-06-24 08:29:53 -04:00
Abtin Keshavarzian a9f34d944c [child] use Array<Ip6::Address> to track registered addresses (#10422)
This commit updates the `Child` class to use `Array<Ip6::Address>` to
track the list of IPv6 addresses registered by an MTD child,
simplifying the code.
2024-06-24 08:25:55 -04:00
Abtin Keshavarzian 8370a827a9 [mesh-forwarder] remove unused SetDiscoverParameters() method (#10420) 2024-06-24 08:00:09 -04:00
Abtin Keshavarzian 473fbcaba9 [child-table] add HasMinimalChild() and move logic from MleRouter (#10418)
This commit adds the `HasMinimalChild()` method to the `ChildTable`
class and moves the logic for checking if a device has an MTD child
with a given RLOC16 from the `MleRouter` class to `ChildTable`. This
aligns better with the `ChildTable` class's responsibility of
managing all children and providing methods to search and find child
entries in the table.
2024-06-21 11:26:13 -07:00
Abtin Keshavarzian 89b54dca2b [mle] remove GetNextHop() and directly use RouterTable method (#10417)
This commit removes the `MleRouter::GetNextHop()` method and instead
directly uses `RouterTable::GetNextHop()`. This improves consistency
across all modules.
2024-06-20 20:41:49 -07:00
Abtin Keshavarzian 1b87190509 [cli] output service ID when listing services in network data (#10408) 2024-06-20 20:12:16 -07:00
Abtin Keshavarzian 387831b697 [routing-manager] simplify RxRaTracker::HandleRouterTimer() (#10382)
This commit simplifies `RxRaTracker::HandleRouterTimer()`. When all NS
probes to a router fail and it is marked as unreachable,
`HandleRouterTimer()` now directly removes/deprecates its
route/on-link prefixes, replacing a separate method previously used
for this purpose.

Additionally, a new helper method, `ShouldCheckReachability()`, is
added to check if a reachability check (sending NS probes) is needed.
This check is performed only if the router is not already marked as
unreachable and is not the local device itself.
2024-06-20 20:11:27 -07:00
Zhanglong Xia 215c23f2a6 [diag] add diag output callback (#10354)
The length of diag output messages is limited by the diag buffer size.
Developers have to change the diag buffer size to allow diag module to
output long messages. If diag output messages become longer and
longer, developers have to keep changing the diag buffer size.

This commit adds an output callback to diag module to output diag
messages.  Then the length of diag output messages won't be limited by
the diag buffer size.
2024-06-19 20:27:35 -07:00
Abtin Keshavarzian 31e512ac7b [mle] replace Mle::GetNextHop() with GetParentRloc16() (#10407)
This commit removes the `Mle::GetNextHop()` method, which returned the
parent RLOC16 (when the parent state was valid) irrespective of a
given destination.

The `Mle::GetNextHop()` method was only used on MTD builds and from
`MeshForwarder::UpdateIp6Route()` method, where
`mle.GetNextHop(Mac::kShortAddrBroadcast)` served as an indirect way
to get the parent RLOC16. This is now replaced with a direct
`GetParentRloc16()` call, clarifying the intended purpose.

On FTD builds, the `MleRouter::GetNextHop()` is used instead of
`Mle::GetNextHop()`. The `MleRouter` method remains unchanged. Since
it would also return the parent's RLOC16 when the device is acting as
a child, using `GetParentRloc16()` covers this case as well.
2024-06-19 16:57:34 -07:00
Abtin Keshavarzian e581f07414 [ip6] add Ip6::Address::IsLinkLocalUnicastOrMulticast() (#10405)
This commit adds `IsLinkLocalUnicastOrMulticast()` to `Ip6::Address`
to indicate whether the address is either a link-local unicast or a
link-local multicast address.

The existing `IsLinkLocal()` is renamed to `IsLinkLocalUnicast()` to
clarify its purpose and align its name with `IsLinkLocalMulticast()`
and the new method.
2024-06-19 16:53:29 -07:00
Zhanglong Xia 3345af0780 [otci] fix the setDaemon() is deprecated warning (#10409)
The otci reports warning `DeprecationWarning: setDaemon() is
deprecated, set the daemon attribute instead`.  This commit updates
the otci to fix this warning.
2024-06-19 16:41:09 -07:00
Zhanglong Xia 4978e58e5c [otci] add ADB USB connection support for OTCI (#10406) 2024-06-19 16:40:17 -07:00
Zhanglong Xia 4e8f3c06c1 [posix] check whether the RCP support specified Spinel properties (#10387)
This commit calls RadioSpinel `Set()`, `Get()`, `Insert()` and `Remove()` functions
to check if the RCP supports specified Spinel properties.
2024-06-18 10:47:14 -07:00
Li Cao fc0646c6eb [simulation] fix tiny issue of infra if (#10402) 2024-06-18 10:38:59 -07:00
Esko Dijk a46786b0e8 [cli] udp bind doc update to clarify that multicast address cannot be used as argument (#10370) 2024-06-18 09:17:11 -07:00
Li Cao fad66e272a [posix] add OT sys API to get the spinel driver (#10393) 2024-06-18 08:30:35 -07:00
Abtin Keshavarzian 54afce92ab [udp] add template SocketIn class for easier socket usage (#10392)
This commit adds a new template `Udp::SocketIn<Owner, RxHandlerPtr>`,
which defines a UDP socket for use within a specified `Owner` class.
It includes a `HandleUdpReceive()` member method callback for
processing received messages. This model, similar to `TimerMilliIn`,
eliminates the need for each socket user to define boilerplate code
for providing a static member function that simply casts and calls
the member method. This is now handled by the template `SocketIn`
class. The `Udp::Socket::Open()` method is also modified to no longer
require the callback and context parameters.
2024-06-17 18:31:26 -07:00
Abtin Keshavarzian 4749aa2ae0 [routing-manager] add mIsReachable to otBorderRoutingRouterEntry (#10388)
This commit adds `mIsReachable` to the `otBorderRoutingRouterEntry`
structure to indicate whether a router is reachable. A router is
marked unreachable after it fails to respond to multiple Neighbor
Solicitation (NS) probes. Additionally, the `br` CLI commands are
updated to display this information.
2024-06-17 11:31:30 -07:00
Zhanglong Xia 0fac5dcf0b [child-supervision] remove unused method declarations (#10394) 2024-06-17 11:09:22 -07:00
dependabot[bot] 1837b64c21 github-actions: bump codecov/codecov-action from 4.3.1 to 4.5.0 (#10395)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.3.1 to 4.5.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/5ecb98a3c6b747ed38dc09f787459979aebb39be...e28ff129e5465c2c0dcc6f003fc735cb6ae0c673)

---
updated-dependencies:
- dependency-name: codecov/codecov-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>
2024-06-17 10:31:54 -07:00
Abtin Keshavarzian 5127e7e5c0 [mle] enhance RLOC and ALOC address generation (#10391)
This commit enhances the generation of RLOC and ALOC addresses in the
`Mle` class.

Methods retrieving RLOC/ALOC addresses no longer return an `Error` and
are now `void`. The previous check for a valid `GetRloc16()` value,
which returned `kErrorDetach` if unset, is removed because this
scenario only occurred before the device's initial attachment.
Post-attachment, the RLOC16 remains valid even if the device is
detached. This change simplifies the code since RLOC/ALOC address
retrieval happens after the initial attachment.

Additional enhancements include:

-   Changing the input parameter order in `GetCommissionerAloc()` to
    match `GetServiceAloc()`.
-   Using `Ip6::Address::SetToRoutingLocator()` to construct RLOC
    addresses, harmonizing address generation and improving code
    readability.
2024-06-17 09:23:43 -07:00
Konrad Derda 8a8a4d8e31 [netif] remove multicast promiscuous mode configuration (#10338)
Since 74c833b623 was introduced all IPv6
multicast packets are passed to the host. Previously used promiscuous
mode configuration is now unused. This commit removes the dead code and
corresponding elements as there is no use case for them at the moment
(and they can confuse a user).

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-06-14 10:08:44 -07:00
brian-level 282f54c2a6 [ip6] fix warning when logging enabled (#10375) 2024-06-14 10:07:24 -07:00
Abtin Keshavarzian 3315c44bb3 [mle] rename mesh local address methods to use Rloc and Eid (#10385)
This commit renames the methods for retrieving mesh local addresses to
`GetMeshLocalRloc()` and `GetMeshLocalEid()` (from `GetMeshLocal16()`
and `GetMeshLocal64()`, respectively) to align with the terminology
used in the Thread specification. Member and local variables are also
renamed accordingly.
2024-06-14 10:06:25 -07:00
Abtin Keshavarzian cba0f5ca2b [mle] use RouterIdMatch() to compare Router IDs of two RLOC16 values (#10384)
This commit updates the code to use `RouterIdMatch()` for comparing
the Router IDs of two given RLOC16 values. Additionally, it
simplifies the `IsMinimalChild()` method.
2024-06-14 10:05:40 -07:00
Abtin Keshavarzian 503bca022e [mle] add GetLeaderRloc16() helper method (#10383)
This commit adds the `Mle::GetLeaderRloc16()` method, which returns
the RLOC16 of the Leader. This simplifies code that previously used
`GetLeaderId()` followed by a conversion to RLOC16.
2024-06-14 10:04:45 -07:00
Abtin Keshavarzian 18e635d2ee [dataset] move secure storage methods to DatasetManager (#10381)
This commit refactors methods that save or read a specified Dataset
TLV in/from secure storage under `PLATFORM_KEY_REFERENCES`. These
methods are moved from the `Dataset` class to the `DatasetManager`
class, consolidating related functionality and aligning with the
responsibilities of each class. The `Dataset` class is focused on
appending/parsing TLVs, while the `DatasetManager` class is
responsible for managing and saving the Active and Pending Datasets.
2024-06-14 10:03:15 -07:00
Abtin Keshavarzian a98b60ef2e [udp] clear all properties in SocketHandle from Udp::Open() (#10380)
This commit modifies `Udp::Open()` to clear all properties of the
passed-in `aSocket` using the `Clear()` method. This replaces the
existing code, which only cleared the socket and peer address and
port numbers. This change ensures that `void *mHandle` member
variable in `otUdpSocket` is also set to `nullptr` before invoking
platform UDP `otPlatUdpSocket()`.
2024-06-14 10:00:58 -07:00
Abtin Keshavarzian 3b589b3e1f [routing-manager] add RxRaTracker::Router::IsReachable() (#10379)
This commit adds the `IsReachable()` helper method to `Router` class,
which checks whether a router is considered reachable. It replaces
the previous comparisons of `mNsProbeCount` in the code, improving
readability. Neighbor Solicitation (NS) messages are used to
determine reachability if the router has not been heard from for some
time.
2024-06-14 10:00:14 -07:00
Abtin Keshavarzian fb24bec873 [mle] add TxMessage::AppendLinkAndMleFrameCounterTlvs() (#10378)
This commit adds `AppendLinkAndMleFrameCounterTlvs()` to
`Mle::TxMessage` for appending both Link and MLE Frame Counter TLVs.
This mirrors the existing `RxMessage` method for reading these
counters.
2024-06-14 09:58:57 -07:00
Abtin Keshavarzian 69924eaa78 [cli] update service add command to allow empty server data (#10377) 2024-06-14 09:58:22 -07:00
Abtin Keshavarzian 6bc3b4de8a [mdns] use NextFireTime for scheduling timers (#10371) 2024-06-13 08:52:16 -07:00
Yakun Xu fa71a8afa3 [diag] specify sending frame (#10359)
This commit adds an extra command `diag frame` to specify the frame
used for `diag send` and `diag repeat`, so that we can use this
command to send arbitrary 802.15.4 frames.
2024-06-13 07:53:48 -07:00
Abtin Keshavarzian cb1220d79b [cli] fix unused retval warning on otPlatLogCrashDump() call (#10369) 2024-06-12 17:50:48 -07:00
Abtin Keshavarzian 4a0d6b7b64 [test] update key-increment test scripts to align with cert test (#10347)
This commit removes the option to set `key_switch_guardtime` when
constructing nodes and network topology in test scripts. The
following tests are updated to reflect this change:

- `Cert_5_8_02_KeyIncrement.py`
- `Cert_5_8_03_KeyIncrementRollOver.py`
- `Cert_6_6_01_KeyIncrement.py`
- `Cert_6_6_02_KeyIncrementRollOver.py`
2024-06-12 10:56:00 -07:00
Abtin Keshavarzian 9c1f1f3dfb [key-manager] update how the "Key Switch Guard Timer" is reset (#10347)
This commit updates the resetting of the Key Switch Guard Timer. It is
now reset under two conditions:

- The device itself triggers a key rotation and moves to the next key
  sequence after the rotation time has passed since the last switch.
- The device receives a MAC or MLE message with an incoming key index
  matching the next key index. Regarding MLE messages, this rule is
  applied regardless of the message being classified as Authoritative
  or Peer.
2024-06-12 10:56:00 -07:00
Handa Wang 185b0e18e7 [posix] improve the logging in netif (#10362)
This commit improves the logging of `posix/platform/netif.cpp` in
following ways:

- Fix the false warning log when OT stack adds a unicast address.
  1. When OT adds an address, it will add an address on host netif.
  2. Then it causes a netlink `RTM_NEWADDR` event.
  3. It assumes the newly added address is added by the host, so tries
     to add the unicast address to OT again by
     `otIp6AddUnicastAddress`.
  4. `otIp6AddUnicastAddress` returns 'invalid arguments' error so it
     will log `Failed to process event...`.

- Improve the logging of `AddRoute` and `DeleteRoute`. Previously they
  silently sent out the requests so we don't know what the allocated
  netlink sequence numbers were used for.
2024-06-12 08:26:53 -07:00
Maciej Baczmański 32f462ff34 [cmake] add option for OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US (#10361)
This makes it easier for vendors to tweak scheduling CSL
transmission request depending on minimum time to process it
(which for example might be higher for RCP architecture).

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-06-11 11:13:21 -07:00
Yakun Xu b2141a6822 [style] unify using member variable (#10360) 2024-06-11 09:09:07 -07:00
Abtin Keshavarzian fe0037e67a [mle] add Mle::RxMessage::ReadAndSetNetworkDataTlv() (#10358)
This commit adds `ReadAndSetNetworkDataTlv()` to `Mle::RxMessage` to
read the Network Data TLV from a received MLE message and set it in
`NetworkData::Leader`.
2024-06-11 08:45:11 -07:00
Abtin Keshavarzian 7ba7fb2eb6 [srp-client] use sequential message IDs & allow older response IDs (#10353)
This commit updates `Srp::Client` to use sequential message IDs,
replacing the previous model where message IDs were generated
randomly.

When processing responses from the server, older message IDs are
accepted as long as the corresponding older message was identical to
the latest one. This helps in situations where the server's response
may be delayed  (e.g., due to network congestion) and the client retry
mechanism is retransmitting the same update message.

This commit also adds a unit test `TestSrpClientDelayedResponse()`
to validate the new behavior.
2024-06-11 08:43:49 -07:00
Abtin Keshavarzian d9bb516f0d [routing-manager] schedule all timers in RxRaTracker together (#10343)
This commit adds `RxRaTracker::ScheduleAllTimers()`, which is called
whenever there is a change in tracked information about routers and
their advertised on-link or route prefixes. This method determines
the next router expiration time (to initiate NS probes), the next
prefix entry expiration, and the next stale time, then schedules all
the timers. This centralizes all timer calculations and simplifies
the code.
2024-06-11 08:39:58 -07:00
Abtin Keshavarzian 5dbbab175b [dnssd-server] implement DNS-SD discovery proxy functionality in core (#10050)
This commit implements a generic discovery proxy in the DNS-SD server.
It uses a set of newly added `otPlatDnssd` platform DNS-SD(mDNS) APIs
to start or stop browsers, SRV/TXT resolvers, and IPv6/IPv4 address
resolvers. These APIs closely match the native OpenThread mDNS
implementation.

OpenThread DNS-SD's existing `QueryCallback` mechanism, enabling
customized discovery proxy implementations, remains supported.

This commit includes a comprehensive unit test. This test validates
the discovery proxy's behavior, covering: standard use cases, request
timeout, s hared resolver/browser usage for multiple queries with the
same name, filtering of invalid addresses, and various edge cases.
2024-06-10 12:16:24 -07:00
dependabot[bot] a8f07b57cf github-actions: bump docker/login-action from 3.1.0 to 3.2.0 (#10356)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/e92390c5fb421da1463c202d546fed0ec5c39f20...0d4c9c5ea7693da7b068278f7b52bda2a190a446)

---
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>
2024-06-10 09:11:26 -07:00
Abtin Keshavarzian dd1e5f426d [mle] add Mle::RxMessage::ReadAndSave{Active/Pending}Dataset() (#10348)
This commit adds `ReadAndSave{Active/Pending}Dataset()` helper methods
to `Mle::RxMessage` to read the Active or Pending Dataset from a
received MLE message and save it in the corresponding
`DatasetManager`.

This commit also refactors the code for parsing the MLE TLVs, moving
it from `DatasetManager` to the `Mle` class for better alignment of
responsibilities.
2024-06-07 14:04:32 -07:00
Li Cao 22ee728ac7 [ncp] add property to instruct NCP to leave gracefully (#10337)
This commit adds a new property SPINEL_PROP_NET_LEAVE_GRACEFULLY. The
host can trigger otThreadDetachGracefully by setting this spinel
property. Hence a SetProperty handler is implemented for this
property. A GetProperty handler is also added for this property for a
property response.
2024-06-07 14:03:45 -07:00
Cristian Bulacu 9cc1cd9e58 [mdns] add support for legacy unicast response feature (#10053)
Signed-off-by: Cristib05 <cristian.bulacu@nxp.com>
2024-06-07 14:01:50 -07:00
Esko Dijk 3873c6fcd5 [tcat] add TCAT Commissioner / Device certs for Thread certification testing (#10211) 2024-06-06 11:27:44 -07:00
Przemysław Bida 398df8c408 [tcat] implement tcat advertisement (#9858)
Commit introduces implementation of TCAT advertisement over BLE
compliant with Thread 1.3.1 specification.
2024-06-06 11:26:59 -07:00
Li Cao cdeb02b035 [posix] extract co-processor init out of otSysInit (#10344)
This commit adds a new posix sys API `otSysInitCoprocessor` which only
initializes the platform spinel component. (Reset the co-processor and
get the type)

The intention is to let the app to get the co-processor type without
creating the otInstance. Currently only `otSysInit` can be called
which creates the otInstance. However in some cases, we don't want to
create the instance at the early stage.
2024-06-06 08:42:49 -07:00
Zhanglong Xia 89b42178ad [posix] add RCP capability diag module (#10335)
This commit adds a RCP capability diag module for verifying the RCP's
capability. This commit is an initial commit that only tested several
Spinel commands.
2024-06-06 08:40:47 -07:00
Abtin Keshavarzian d6eb56c319 [routing-manager] enhance TestPrefixStaleTime() (#10342)
This commit changes unit test `TestPrefixStaleTime()` so that a route
prefix is advertised with a lifetime of 800 seconds, which is longer
than the `kStaleTime` of 600 seconds. With this change, the entry
will not expire and become stale at the same time. This simultaneous
expiration could cause issues depending on the order of execution of
`mStaleTimer` and `mExpirationTimer`, which would be scheduled for
the same time. With this change, the entry will still be valid (due
to the lifetime of 800 seconds) when the stale timer fires after 600
seconds. This ensures that the test runs consistently and does not
depend on the order in which timer callbacks fire.
2024-06-05 10:53:36 -07:00
Abtin Keshavarzian 18f7bc32f1 [mle] add TxMessage::AppendActiveAndPendingTimestampTlvs() (#10341)
This commit adds `AppendActiveAndPendingTimestampTlvs()` helper
method, which appends both Active and Pending Timestamp TLVs to the
message. This helps simplify the code as the two TLVs are almost
always included together in different MLE messages.
2024-06-05 10:52:58 -07:00
Abtin Keshavarzian b77645458e [mle] add Mle::TxMessage::AppendDatasetTlv() (#10340)
This commit refactors the code for preparing and appending MLE TLVs,
moving it from `DatasetManager` to the `Mle` class for better
alignment of responsibilities.

It adds `TxMessage::AppendDatasetTlv()`, which appends an Active
or Pending Dataset (if present) to an MLE message following the
proper MLE TLV format. This includes removing the corresponding
`Timestamp` from the dataset, as MLE messages include timestamps
using their own MLE TLVs rather than within the dataset itself.
2024-06-05 10:52:29 -07:00
Abtin Keshavarzian b5b17ba396 [mle] allow appending pending timestamp TLV with zero seconds (#10327)
This commit removes the `GetSeconds() != 0` check in
`Mle::AppendPendingTimestampTlv()`. This allows `DatasetUpdater` to
use a Pending Timestamp with random ticks and a zero seconds value if
there is no pending Dataset.
2024-06-04 15:45:32 -07:00
Abtin Keshavarzian fcd3c5c4b7 [timestamp] add IsValid() and comparison operator overloads (#10325)
This commit enhances the handling of `Timestamp`.

Methods `SetToInvalid()` and `IsValid()` are added to the `Timestamp`
class. The value where all bytes are set to `0xff` is used to
represent an invalid `Timestamp`. This corresponds to max seconds,
max ticks with the authoritative (`U`) flag set.

This helps simplify `DatasetManager`, where we need to track local and
network Active/Pending timestamps, which may not be present. These
are now represented by setting the `Timestamp` to the invalid value
(replacing the earlier model where a `Timestamp` pointer was used
with `nullptr` representing an invalid timestamp).

This allows us to simplify the `Timestamp::Compare()` method, now
getting two `Timestamp &` instead of `Timestamp *`. With this, we can
also define comparison operator overloads to compare two `Timestamp`
objects, which helps make the code simpler and more readable.
2024-06-04 13:48:31 -07:00
Abtin Keshavarzian 5bb3667a49 [dataset] add WriteTimestamp() and RemoveTimestamp() (#10333)
This commit introduces new helper methods in the `Dataset` class to
write or remove a Timestamp TLV (Active or Pending) to/from the
Dataset. These are added alongside the existing `ReadTimestamp()`
method.
2024-06-04 13:47:51 -07:00
Abtin Keshavarzian 0d5f41dcc4 [mle] minor enhancements to HandleParentResponse() (#10331)
This commit contains minor enhancements to `HandleParentResponse()`:

- Variable name `linkMarginOut` is used for the Link Margin TLV value
  included in the response from the parent candidate. This is used to
  `SetLinkQualityOut()`.
- `twoWayLinkMargin` variable name is now used to show the two-way
  link margin.
- `IsBetterParent()` is updated to calculate the two-way link quality
  for the new parent candidate from the two-way link margin (instead
  of getting it as a parameter).
2024-06-04 13:04:53 -07:00
Abtin Keshavarzian d4ec3712d1 [mdns] add APIs to iterate over browsers and resolvers (#10140)
This commit adds APIs to iterate over mDNS browsers and resolvers,
along with related CLI commands. These are intended for testing. It
also introduces a build config `ENTRY_ITERATION_API_ENABLE` to
control whether the mDNS module provides mechanisms and public APIs
for entry iteration.
2024-06-04 13:04:15 -07:00
Konrad Derda d11d705d98 [ip6] do not report an error for disabled host loopback (#10339)
Currently, sending an IPv6 multicast destined packet encoded in
otMessage with the otIp6Send() function reports an error kErrorNoRoute
if "host loopback allowed" flag is disabled (despite of packet being
properly passed to Mesh Forwarder). This commit changes a flag checking
statement to return kErrorNone instead.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-06-04 13:03:22 -07:00
Abtin Keshavarzian d1506ab77b [routing-manager] update stale time constant to 10 minute (#10330)
This commit renames the entry stale time constant to `kStaleTime` and
sets it to 10 minutes (from 30 minutes). This change aligns the
`RoutingManager` with the recommended value in the latest stub router
RFC draft (`STALE_RA_TIME`).

The unit test `test_routing_manager` is also updated to reflect this
new constant.
2024-06-04 11:45:20 -07:00
Abtin Keshavarzian 791ee87880 [dataset-manager] enhance starting of Pending Dataset delay timer (#10334)
This commit updates and fixes how the Pending Dataset delay timer is
started. It is now started only after the timestamps are checked and
the local Pending Dataset is updated and saved to non-volatile
storage from the `LocalSave()` method.

In particular, we no longer start the delay timer from the `Save()`
method, which reads the `Dataset` from a received `Message`. This
is because we may receive a Pending Dataset with a timestamp that is
older than the currently saved local Pending Dataset. In this case,
the local Dataset is correctly not updated but without this change,
we could start the delay timer for the received stale Pending
Dataset.
2024-06-04 11:43:09 -07:00
Jonathan Hui 59e202cbdd [mbedtls] remove -Wno-unused-but-set-variable (#10336) 2024-06-04 10:05:58 -07:00
Li Cao ea61703252 [spinel] remove including openthread-core-config.h (#10322)
`openthread-spinel-config.h` is included by many modules like
`spinel_encoder`, `spinel_decoder`. To use these modules in external
projects, we need to remove the including of
`openthread-core-config.h`.
2024-06-03 23:06:23 -07:00
Łukasz Duda 70bad1df78 [mbedtls] enable MBEDTLS_OID_C when MBEDTLS_PK_PARSE_C is enabled (#10332)
This commit fixes mbedTLS config where MBEDTLS_OID_C is not set
together with MBEDTLS_PK_PARSE_C in some OpenThread configurations.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-06-03 18:46:32 -07:00
Abtin Keshavarzian b4ec4ce365 [mle] add ConnectivityTlv::IsSingleton() (#10329)
This is used to simplify `Mle::HandleParentResponse()`.
2024-06-03 18:25:54 -07:00
Abtin Keshavarzian e1918b31c3 [encoding] declare HostSwap() functions as constexpr (#10326)
This allows their use when defining constant values.
2024-06-03 14:22:04 -07:00
Abtin Keshavarzian 8fc67f3104 [meshcop] update Timestamp::AdvanceRandomTicks() (#10320)
This commit updates `Timestamp::AdvanceRandomTicks()` to ensure that
the seconds value is incremented only if the ticks value overflows.
2024-06-03 13:37:35 -07:00
dependabot[bot] b2f17f865d github-actions: bump actions/download-artifact from 4.1.4 to 4.1.7 (#10324)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.4 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/c850b930e6ba138125429b7e5c93fc707a7f8427...65a9edc5881444af0b9093a5e628f2fe47ea3b2e)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  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>
2024-06-03 10:42:50 -07:00
Abtin Keshavarzian 26b7416045 [routing-manager] fix and enhance prefix stale time calculation (#10317)
This commit updates the determination of stale times for discovered
on-link or route prefixes. The stale time is now calculated per
unique prefix. If multiple routers advertise the same on-link or
route prefix, the stale time for the prefix is set to the latest
among all corresponding entries.

This addresses an issue in the previous implementation where, for
on-link prefixes, the stale time was determined as the latest stale
time over all on-link entries, regardless of the actual prefixes. For
route prefixes, the earliest stale time was used, also disregarding
the possibility of multiple routers advertising the same prefix.

This commit also updates the `test_routing_manager` unit test to
validate the corrected stale time calculation.
2024-06-03 10:18:36 -07:00
Abtin Keshavarzian d95b44cda7 [mle] add helper methods to RxMessage (#10319)
This commit adds helper methods to `Mle::RxMessage` for reading and
processing specific TLVs:

- `ReadModeTlv()`: Reads the Mode TLV as a bit mask and converts it to
  a `DeviceMode`.
- `ReadVersionTlv()`: Reads the Version TLV and verifies that it is at
  least 1.1 (the minimum supported version).
- `ReadAndMatchResponseTlvWith(const TxChallenge &)`: Reads the
  Response TLV and matches it against a given challenge.
2024-05-31 12:23:36 -07:00
Abtin Keshavarzian 4951dee753 [routing-manager] update stale time calculation for local RA header (#10316)
This commit updates the calculation of stale time for a discovered
local RA header (to mirror), incorporating the default route lifetime
specified in the header when it is non-zero, in addition to the RA
stale time constant. This ensures proper behavior even if the RA
header default route lifetime is shorter than the RA stale time.

Additionally, this commit adds `CalculateExpirationTime()` to
determine the expiration time from a given update time and lifetime
duration in seconds. If the given lifetime exceeds the supported
range of `TimeMilli` (~24 days), it clamps the value to ensure time
calculations remain within the valid `TimeMilli` range.
2024-05-31 12:10:04 -07:00
Abtin Keshavarzian 7b08e9a9b1 [routing-manager] update and simplify RA beacon timing (#10309)
This commit updates constants in `RoutingManager`. Timing constants
are now consistently specified as an interval with an associated
jitter, where the actual interval is randomly selected within the
range `[interval - jitter, interval + jitter]`.

The initial transmission of three RAs with a short interval of 16
seconds (± 2 seconds jitter) remains unchanged. However, subsequent
RA transmissions now use a regular beacon interval of 3 minutes (± 15
seconds jitter), replacing the previous random interval selection
within `[200, 600]` seconds.

The selection of 3 minutes as the regular RA beacon interval aligns
the implementation with the latest stub router RFC draft's
`RA_BEACON_INTERVAL` default value.
2024-05-31 12:03:42 -07:00
Abtin Keshavarzian ca7dd8288b [mle] simplify signaling of DUA address change (#10296)
This commit simplifies how `ProcessAddressRegistrationTlv()` signals
DUA address changes. Signaling now occurs after all child addresses
are registered, using a new `SignalDuaAddressEvent()` method. This
method checks the old and new DUA addresses to determine the
appropriate event to signal.

Additionally, `Child::GetDomainUnicastAddress()` is updated to return
an `Error` and copy the DUA address into a provided `Ip6::Address`
reference.
2024-05-31 12:00:30 -07:00
Eduardo Montoya edad0f97ef [radio] update otPlatRadioSetRxOnWhenIdle documentation (#10307) 2024-05-30 14:13:12 -07:00
Abtin Keshavarzian d2e74dc705 [routing-manager] fix lifetime management of PD prefix (#10310)
This commit updates `PdPrefixManager` to use the newly added
`GetDeprecationTime()` method for managing the lifetime of a DHCPv6
PD prefix. This method calculates the deprecation time using the
prefix preferred lifetime directly, instead of relying on the RA
stale time constant  `GetStaleTime()`.

While the PD prefix may be determined by processing RA messages
received on the Thread interface, the RA stale time is not relevant
in this context. The RA stale time is only applicable to RA messages
received over infra-if. It specifies the time that can pass after the
last RA from a particular router on infra-if before assuming the
router might be unavailable and triggering Router Solicitation
(RS) messages.
2024-05-30 11:36:48 -07:00
Ashish bef804c6be [utils] add API to reset/clear linked list of enh-ack link metrics (#10294)
Enh-ack link metrics required to reset/clear when radio(RCP) is reset to
clear existing data. To support it, added API to reset/clear linked list
of enh-ack link metrics.

Signed-off-by: Ashishkumar Vara <ashish.vara@nxp.com>
2024-05-30 11:21:35 -07:00
Abtin Keshavarzian 8d38fc76af [dso] use NextFireTime (#10306)
Updates `Dns::Dso` class to use `NextFireTime`.
2024-05-30 11:19:43 -07:00
Abtin Keshavarzian 0b716730b0 [mdns] use NextFireTime class (#10304)
This commit updates the mDNS module to use the recently introduced
general-purpose `NextFireTime` class, replacing the module-specific
`TimerContext` class.
2024-05-30 11:19:03 -07:00
Abtin Keshavarzian 2841ca02d7 [dataset-updater] enhance DatasetUpdater (#10293)
This commit simplifies the `DatasetUpdater`:

- Restricts `DatasetUpdater::RequestUpdate()` to be used only when the
  device is fully configured and has a valid Active Dataset; otherwise,
  it returns `kErrorInvalidState`. This simplification allows for the
  removal of the timer (previously used to delay the update if no
  Active Dataset was present).
- Adds a check in `RequestUpdate()` to determine if the requested
  Dataset changes are already present in the current Active Dataset,
  returning `kErrorAlready` if so.
- Enhances `RequestUpdate()` to prepare and set the Pending Dataset
  immediately. It stores the requested Dataset as a sequence of TLVs
  and retains the Active and Pending Timestamp values for later use
  in determining update success or failure.
- Simplifies the code for checking Dataset changes and reporting
  update outcomes. A common `HandleDatasetChanged(Dataset::Type)`
  method is added, which can be used when the Active or Pending
  Dataset changes and performs the necessary checks, eliminating
  duplicate code.
2024-05-30 11:17:00 -07:00
Łukasz Duda 1336da4212 [mbedtls] optimize AES configuration (#10286)
This commit optimizes the configuration of AES encryption to be tailored
for OpenThread.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 12:07:57 -07:00
Łukasz Duda 27f1dbcfc1 [mbedtls] modify GitHub workflows to test MbedTLS v2.28.8 (#10286)
This commit adds a CI check for MbedTLS version 2.28.8, instead of
testing version 3, which is now enabled by default.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 12:07:57 -07:00
Łukasz Duda c96e3b9504 [mbedtls] migrate to MbedTLS v3.6.0 (#10286)
This commit updates the in-tree version of MbedTLS to v3.6.0.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 12:07:57 -07:00
Łukasz Duda 59b87d6d48 [fuzz] fix typo and enable SRP Advertising Proxy (#10300)
This commit fixes the typo and enables SRP_ADV_PROXY - also by turning
on the dependent components.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 09:18:17 -07:00
Łukasz Duda 6db2d5882d [cli] fix memory leak on TCP init failure (#10300)
This commit fixes potential memory leak for CLI TCP module.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 09:18:17 -07:00
dependabot[bot] 330b1759f1 github-actions: bump actions/checkout from 4.1.2 to 4.1.6 (#10299)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/9bb56186c3b09b4f86b1c65136769dd318469633...a5ac7e51b41094c92402da3b24376905380afc29)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2024-05-27 22:21:00 -07:00
Abtin Keshavarzian 10cff14788 [timer] add NextFireTime class (#10295)
This commit introduces `NextFireTime`, a helper object for tracking
the next fire time along with the current time. It provides an
`UpdateIfEarlier(Time)` method to update the tracked next fire time
with a new given time only if it is earlier.

The `NextFireTime` class simplifies a common code pattern used across
modules to determine the earliest fire time when scheduling a timer.
It also ensures that the next fire time is never set before the
current time, improving code safety.
2024-05-27 21:46:50 -07:00
Łukasz Duda ef10dec155 [mle] fix warning with storedCount (#10301)
This commit fixes the warning, when logs are disabled:

warning: variable "storedCount" set but not used
[-Wunused-but-set-variable]

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-27 21:40:29 -07:00
Abtin Keshavarzian a54f4c4850 [dataset] simplify IsSubsetOf() (#10292)
This commit adds a method `Dataset::IsSubsetOf()` to check whether one
dataset is a subset of another. A dataset is considered a subset if
all its TLVs, excluding Active/Pending Timestamp and Delay Timer
TLVs, are present in the other dataset with exactly matching values.

This new method simplifies `Dataset::Info::IsSubsetOf()`. The unit
test `test_dataset` is updated to validate the `IsSubsetOf()()`
method.
2024-05-24 20:18:37 -07:00
Abtin Keshavarzian 0abc8d7a0d [routing-manager] simplify how RxRaTracker handles local on-link prefix (#10291)
This commit introduces the following changes:

- Adds a new callback `HandleLocalOnLinkPrefixChanged()` for
  `OnLinkPrefixManager` to signal changes to the local on-link
  prefix (derived from the extended PAN ID).
- Modifies `RxRaTracker` to always ignore a PIO prefix matching the
  local on-link prefix, regardless of the current state of
  `OnLinkPrefixManager`. Such a PIO originates from another Thread
  border router connected to the same Thread network and is not used
  by `OnLinkPrefixManager` to decide whether it needs to advertise
  the local on-link prefix.
- Updates `RxRaTracker` to be notified when the local on-link prefix
  changes. In its `HandleLocalOnLinkPrefixChanged()`, it removes any
  prefixes in the table matching the new prefix.
2024-05-24 09:35:45 -07:00
Abtin Keshavarzian a46bdd938e [dataset-manager] simplify Restore() (#10290)
This commit simplifies the `Restore()` methods:

- A private overload `Restore(const Dataset&)` is added, taking the
  read `Dataset` as input to avoid duplicate reads.
- The public `Restore(void)` is updated to use the new private
  `Restore(const Dataset&)`.
- The `HandleDetach()` method is removed, and its use in the `Mle`
  class is replaced with `Restore()`.
2024-05-24 09:14:39 -07:00
gytxxsy e7535f7183 [mle] update router table after adding a new neighbor (#10288)
Use the `Route64 TLV` to update the router table after adding a new
neighbor in `HandleLinkAccept`.

With this change, when a router re-joins the network, it will restore
its nexthop table while processing the `link accept`, rather than
having to wait for an `mle advertisement`.
2024-05-23 07:41:35 -07:00
Zhanglong Xia 1b2ad3d837 [spinel] parse correct RcpMinHostApiVersion capability (#10285)
The RcpMinHostApiVersion capability should be parsed from
SPINEL_PROP_CAPS response using SPINEL_CAP_RCP_MIN_HOST_API_VERSION,
rather than using SPINEL_PROP_RCP_MIN_HOST_API_VERSION.
2024-05-23 07:15:02 -07:00
Abtin Keshavarzian a57d927b0a [string] add ParseDigit(), ParseHexDigit(), and other helper functions (#10282)
This commit adds a set of helper functions to parse a given digit or
hex digit character to its numeric value, or to check if a given
character is a digit, uppercase, or lowercase letter.
2024-05-22 14:37:22 -07:00
Abtin Keshavarzian 31ac6266fa [routing-manager] track whether a discovered router is local device (#10284)
This commit adds `mIsLocalDevice` in the `Router` class to track
whether it represents the local device (e.g., another software entity
on this device). This information is used to skip sending NS probes
to this router. Tracking this information directly in the `Router`
class is safer than checking the address using `mInfra.HasAddress()`,
as the addresses may have changed since the last RA was received.
This commit exposes this information through the public APIs and CLI
command, and updates `test_routing_manager` unit test to validate the
new flag.
2024-05-22 11:09:02 -07:00
Abtin Keshavarzian 0b503a0f7a [dataset] simplify Clear() methods (#10283)
- Update `DatasetManager::Clear()` to stop delay timer if it is
  Pending Dataset.
- Remove `PendingDatasetManager::ClearNetwork()` (use `Clear()`
  instead).
2024-05-22 11:07:22 -07:00
Abtin Keshavarzian f752153aaf [routing-manager] update and simplify decisions for processing PIO/RIO (#10281)
This commit updates how `RxRaTracker` decides whether to process
PIO/RIO from a received RA message:

- The checks are performed directly in related `Process()` methods,
  removing the `ShouldProcess()` methods.
- The check `Get<RoutingManager>().IsRunning()` is removed as it is
  already checked before processing the RA message.
- The check `IsValidOmrPrefix()` is removed for RIO route prefixes.
  Instead, all route prefixes are tracked, regardless of length
  (excluding link-local or multicast prefixes). With this change,
  there is no longer a need to specifically check and allow the
  default route.
2024-05-22 10:58:26 -07:00
Abtin Keshavarzian 8b04e9ca73 [dataset] move ApplyConfiguration() to DatasetManager (#10280)
This commit moves the implementation of `ApplyConfiguration()` from
the `Dataset` class to `DatasetManager`. This aligns better with the
responsibility of the `DatasetManager` class (managing the active and
pending dataset and being an `InstanceLocator`), keeping the
`Dataset` class focused on providing helper functions related to TLVs
in the Dataset: finding TLVs, reading TLV values, writing/updating
TLVs, etc.
2024-05-21 13:27:14 -07:00
Abtin Keshavarzian b01b262a5c [routing-manager] track and report last update time of routers (#10244)
This commit enhances the `DiscoveredPrefixTable::Router` class to
track the last time an ND6 message (RA or NS) was received from each
discovered router. This information is now available through the
`otBorderRoutingRouterEntry` and can be viewed using the `br routers`
CLI command.
2024-05-21 13:26:40 -07:00
Abtin Keshavarzian 3cb454030c [routing-manager] move decision to process PIO/RIO to RxRaTracker (#10270)
This commit moves functionality from `RoutingManager` to
`RxRaTracker`:

- The `ShouldProcessPrefix/RouteInfoOption()` methods, which decide
  whether to skip or process a PIO/RIO, are moved to `RxRaTracker`.
- `RxRaTracker` is directly notified on network data change, using its
  new `HandleNetDataChange()` method. This replaces
  `UpdateRxRaTrackerOnNetDataChange()`.
2024-05-21 13:25:49 -07:00
Li Cao 71bd98744c [posix] add spinel driver getter to allow external app to access (#10272) 2024-05-21 13:25:12 -07:00
Abtin Keshavarzian 153e2567cd [mdns] include additional records along with sub-type PTR answer (#10276)
This commit updates the native mDNS implementation to include
additional records (SRV, TXT, and AAAA for host) when answering
sub-type PTR (browse) queries, the same way it is included for base
PTR queries. The unit test `test_mdns` is also updated to verify and
expect this behavior accordingly.
2024-05-21 13:24:45 -07:00
Abtin Keshavarzian 6e595de659 [dataset-manager] track local dataset in DatasetManager (#10275)
This commit updates the `DatasetManager` to track information about
the local dataset, such as the local timestamp, update time, and
whether it is saved in non-volatile settings. This change effectively
merges the `DatasetLocal` logic into `DatasetManager`, allowing for
the removal of `DatasetLocal` and simplifying the code.
2024-05-21 13:23:55 -07:00
Ashish 0ce49fc532 [utils] fix build when OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=0 (#10260)
Issue: Disabling channel monitor feature on ot-daemon by setting
following flag "OT_CHANNEL_MONITOR = 0" a compilation error was
present.

Fix: Some pieces of code in OpenThread shall be under
OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE.

Signed-off-by: Ashishkumar Vara <ashish.vara@nxp.com>
2024-05-20 09:24:14 -07:00
dependabot[bot] 10ccec2604 github-actions: bump docker/setup-buildx-action from 3.2.0 to 3.3.0 (#10274)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/2b51285047da1547ffb1b2203d8be4c0af6b1f20...d70bba72b1f3fd22344832f00baa16ece964efeb)

---
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>
2024-05-20 09:04:57 -07:00
Abtin Keshavarzian e529303266 [dataset-manager] ensure mDelayTimer is stopped when no Pending Dataset (#10268) 2024-05-20 08:57:33 -07:00
Abtin Keshavarzian c1add348a6 [dataset-manager] combine protected and private sections (#10267)
This commit combines the `protected` and `private` sections of
`DatasetManager`, adding `ActiveDatasetManager` and
`PendingDatasetManager` as `friend`s. This simplifies the code and
aligns with the goal of having more functions handled by the
`DatasetManager` base class.
2024-05-20 08:56:43 -07:00
Abtin Keshavarzian e36c513ab7 [routing-manager] move handling of prefix stale timer to RxRaTracker (#10265)
This commit moves the scheduling and handling of the stale timer to
`RxRaTracker`. This aligns with the responsibility of this class
managing all discovered on-link/route prefixes and the locally
generated RA header to mirror.
2024-05-20 08:54:50 -07:00
Abtin Keshavarzian 42d567d089 [mdns] ensure callback is invoked when registering host with no address (#10264)
This commit updates the native mDNS implementation to ensure the
callback is invoked when a host is registered without any address
(effectively unregistering the host and removing any previously
registered addresses for the host-name).

The implementation ensures the callback is invoked after returning
from the `RegisterHost()` call (invoked from a posted tasklet), as
required by the mDNS API definitions.

Additionally, the `test_mdns` unit test is updated to cover
registering a host with no address for the first time or updating a
previous registration.
2024-05-20 08:54:16 -07:00
Jonathan Hui 6444157e37 [mbedtls] remove config workaround (#10263) 2024-05-17 21:02:46 -07:00
Abtin Keshavarzian 67a262713c [routing-manager] move tracking of local RA header to RxRaTracker (#10257)
This commit moves the tracking of the RA header of locally generated
RA messages from `TxRaInfo` to the `RxRaTracker` class. The tracked
RA header is used when `RoutingManager` sends an RA, ensuring
consistent RA headers across all RAs emitted from the device.

This aligns the logic by having `RxRaTracker` track all information
from received RAs and simplifies stale time calculations.
2024-05-17 15:57:47 -07:00
Abtin Keshavarzian 63442f7302 [dataset] move Read() overload implementations to DatasetManager (#10258)
This commit simplifies `DatasetLocal` by moving the different overload
implementations of `Read()` to `DatasetManager`. This aligns the code
so that overloads are provided by `DatasetManager` and `DatasetLocal`
provides one version of `Save()` or `Read()`. Unused/undefined
methods in `DatasetLocal` are also removed.
2024-05-17 09:33:23 -07:00
Abtin Keshavarzian 213aede48e [dataset] move Active Dataset replacement check in PendingDatasetManager (#10217)
This commit refactors the logic that determines whether to replace the
current Active Dataset with a Pending Dataset upon its delay timer
expiration.

Instead of performing the check within the more general-purpose
`DatasetManager::Save()` method, the logic is now moved directly
into `PendingDatasetManager::HandleDelayTimer()`. This change makes
the code more specific and prevents unintended checks in other
situations where `Save()` is used (e.g., when Active Dataset is
directly set).

The conditions remain the same: The Pending Dataset's Active
Timestamp must be newer, or the Pending Dataset must contain a
different network key.

This commit also adds `test-029-pending-dataset-key-change.py`
to validate the roll-back of Active Timestamp using Pending
Dataset.
2024-05-17 08:50:30 -07:00
Jonathan Hui ee1ae6c96c [tests] do not build unit tests in oss-fuzz (#10259) 2024-05-17 08:47:06 -07:00
Abtin Keshavarzian 0f9419f880 [routing-manager] rename DiscoveredPrefixTable to RxRaTracker (#10255)
This commit renames the `DiscoveredPrefixTable` to `RxRaTracker`. The
new name is shorter and emphasizes that this class is responsible for
processing received RA messages and tracks useful information about
the RA (routers and their advertised flags and prefixes).

It also renames `RaInfo` to `TxRaInfo` to clarify its role for
tracking information about emitted RAs.
2024-05-17 08:46:33 -07:00
Abtin Keshavarzian beb3cc1239 [mle] simplify HandleLeaderData() (#10248)
This commit updates `Mle::HandleLeaderData()`:

- Simplify the checks for presence of Active/Pending Dataset TLV.
- Introduce `saveActive/PendingDataset` boolean flags to track whether
  we should read and save the included Dataset from the received
  message. These replace and consolidate a group of other local
  variables.
- Restrict the `IsLeader()` checks to FTD builds
2024-05-17 08:45:31 -07:00
Li Cao be109137f3 [spinel] remove dependency on ot core (#10212)
This commit tries to eliminate the dependency of the lib directory on
OT core, especially for headers under lib directory.

Currently the headers and sources under lib directory uses a lot of OT
util functions and template classes. This is not preferred because it
will cause dependency issues if we leverage lib from another
project. For example, if we include headers under lib from
`ot-br-posix`, it won't be able to find the OT common headers. If we
add INCLUDE path of OT core common, that will bring a bigger issue:
There are many conflict headers. `ot-br-posix` also has headers as
'common/code_utils.hpp'.

This commit eliminates the dependency by copying required headers from
core/common to lib/utils directory (with some changes). All the util
functions are under namespace `ot::Lib::Utils`.

`OT_ASSERT` is simply replaced by `assert`. `assert` is already used
across the lib directory.

The commit also adds a config file only for the spinel module to avoid
including `openthread-core-config.h`.
2024-05-16 18:49:09 -07:00
Abtin Keshavarzian 1ab2919e6a [routing-manager] signal table change on M/O flag update of routers (#10250) 2024-05-16 18:20:45 -07:00
Abtin Keshavarzian 16ee66a6a5 [routing-manager] fix received NA message min length check (#10256) 2024-05-16 18:20:08 -07:00
Jonathan Hui 8c92497a7b [secure-transport] remove redundant null check (#10254) 2024-05-16 18:19:34 -07:00
Abtin Keshavarzian c8e2eb868b [mle] add helper method SetLeaderData(const LeaderData &) (#10245) 2024-05-16 13:42:09 -07:00
Abtin Keshavarzian f15dbd67fd [dataset] add ContainsAllTlvs() helper method (#10249)
This commit introduces the `ContainsAllTlvs()` method to `Dataset`,
which checks if a dataset contains all the specified TLVs. This new
method simplifies the implementation of `IsCommissioned()` and
`ContainsAllRequiredTlvsFor(Type)`
2024-05-16 13:19:10 -07:00
Li Cao 72f2df87ed [gitignore] do not ignore .cmake files (#10247) 2024-05-16 10:21:16 -07:00
Abtin Keshavarzian 848de78c60 [dataset] enforce successful Dataset saves in non-volatile (#10237)
This commit updates error handling when saving Active/Pending
Operational Datasets in non-volatile settings. Previously,
`kErrorNotImplemented` was permitted as a return value due to legacy
behavior. Since non-volatile storage is now a mandatory requirement
for Thread operation, we enforce successful saves by asserting on any
error encountered during this process. Methods returning error types
are updated, and some now return `void`.

The public APIs `otDatasetSetActive()` and `otDatasetSetPending()` are
affected by this change. They now always return `OT_ERROR_NONE` and
can essentially be treated as having a void return type. The `otError`
return type is maintained solely for backward compatibility.
2024-05-15 17:29:26 -07:00
Abtin Keshavarzian 0a4d6d34a8 [routing-manager] utilize Network::Leader::ContainsOmrPrefix() (#10240)
This commit optimizes `RoutingManager`:

- Replaces `RoutingManager::NetworkDataContainsOmrPrefix()` with
 `ContainsOmrPrefix()`.
- Simplifies `OmrPrefixManager::ShouldAdvertiseLocalAsRio()` by
  utilizing `ContainsOmrPrefix()`.
- Relocates `ContainsOmrPrefix()` to `network_data_leader.cpp` and
  removes its FTD-only restriction.
2024-05-15 14:05:09 -07:00
Abtin Keshavarzian 6724a0bd85 [gitignore] add more temp files to .gitignore (#10243) 2024-05-15 14:04:13 -07:00
Yakun Xu f97a01c40d [simulation] rename local host to local interface (#10241)
This commit renames command line argument --local-host to
--local-interface to reduce confusion as discussed in #10194.

This commit also add help message for local interface.
2024-05-15 11:04:37 -07:00
Li Cao 6f0b62ff39 [gitignore] ignore files genereated by running toranj unit tests (#10242) 2024-05-15 10:29:29 -07:00
Abtin Keshavarzian 4fe428d079 [network-data] optimize ContainsOmrPrefix() (#10239)
This commit simplifies the `Leader::ContainsOmrPrefix()` method by
eliminating the loop over sub-TLVs based on stable flag status. Since
OMR prefixes must be marked as stable, the search for a given OMR
prefix can be restricted to stable sub-TLV only.
2024-05-15 10:29:07 -07:00
Abtin Keshavarzian f66f095d4d [test] fix description for test-028-border-agent-ephemeral-key.py (#10238) 2024-05-15 10:28:20 -07:00
Li Cao 0cd21e6137 [posix] add return of co-processor type in otSysInit and allow posix plat run with NCP (#10220)
This commit lets posix `otSysInit` return the Co-processor type by
adding a field in `otPlatformConfig`. (This avoids breaking the
existing code that uses `otSysInit`.) Returning the Co-processor type
allows the app layer has the information and can do
initialization. For example, the dbus server.

The commit also allows `otSysInit` and `otSysDeinit` to be completed
when the co-processor type is NCP. This doesn't mean `ot-daemon` can
work with NCP now. But this is required by further developing NCP
support in `otbr-agent` because these two methods are required. The
native posix app (ot-daemon) will still exit when it detects a
co-processor other than RCP.

When the co-processor type is RCP, `otSysInit` and `otSysDeinit` work
as usual. When the type is NCP, only spinel manager will be
initialized and ot::Instance will not be created.
2024-05-15 10:27:22 -07:00
Abtin Keshavarzian 02acc480dd [routing-manager] ignore checksum in RA hash calculation (#10230)
This commit modifies the `CalculateHash()` method to use a zero
checksum value for RA (ICMPv6) header for both received and emitted
RA message. In prepared RA messages, the checksum is always set to
zero, and the platform layer is responsible for calculating and
updating it. For a received RA, while platforms typically zero out
the checksum after validation, this behavior isn't explicitly
required by `otPlatInfraIf` APIs. By ignoring the checksum(setting it
to zero) during hash calculation, this change ensures correct
calculation regardless of platform behavior.

This commit also updates `test_routing_manager` to intentionally
modify the checksum field in an emitted RA message before passing it
back to the OT stack. This validates the updated hash calculation
behavior.
2024-05-14 14:28:02 -07:00
Abtin Keshavarzian 83e2732bae [dataset] simplify dataset Save() methods (#10227)
This commit streamlines dataset-related helper methods:

- Renames all methods that save local dataset to `SaveLocal()` for
  consistency and to distinguish them from `Save()` methods, which
  set the partition's dataset and perform additional checks
  (e.g., ensuring the timestamp is ahead).
- Renames `SendSet()` to `SyncLocalWithLeader()` and passes `aDataset`
  as an input parameter to avoid redundant dataset reads.
- Removes the now unnecessary `HandleDatasetUpdated()` method, as its
  functionality can be inlined within `SaveLocal(const Dataset &)`.
- Consolidates additional dataset type-specific actions(e.g., starting
  a delay timer for Pending Dataset changes) into the base class
  `DatasetManager` methods `Save()` and `SaveLocal()`, simplifying
  the code and reducing redundancy.
- Modifies `DatasetLocal` to provide a single `Save()` method with a
  `const Dataset &` input. `DatasetManager` now handles conversions
  from various dataset representations (e.g., component-wise
  structures or TLV sequences).
2024-05-14 12:12:18 -07:00
Abtin Keshavarzian e27885ecb4 [routing-manager] track origin of received RA messages (#10229)
This commit adds `RouterAdvOrigin` enumeration to track the origin of
a received RA message, whether it is from another router on the
infrastructure, or self-generated by either the `RoutingManager`
module or another software entity running on the device.

This is used to exclude prefixes from self-generated `RoutingManager`
RAs in the prefix table and simplifies learning and adopting of RA
headers from other software entities on the same device.

The origin is now logged when a new RA is received for improved
debugging.

This commit also updates `test_routing_manager` to pass back any sent
RA messages to the OT stack. This validates the mechanism for
identifying self-generated RA messages.
2024-05-14 11:04:56 -07:00
Abtin Keshavarzian e47973a753 [routing-manager] add section comments (#10228)
This commit enhances the readability of the `RoutingManager` class
definition by adding comments to delineate different sections within
the code: Constants, typedefs, enumerations, nested classes and
structs, private methods, and variables.
2024-05-14 08:53:53 -07:00
Suvesh Pratapa a074684110 [clang-format] accept different patch versions of clang-format (#10042)
Homebrew installation of clang-format (satisfying >14.0 requirement)
outputs the following version string:
```
Homebrew clang-format version 14.0.6
```

This change fixes the following error while running make-pretty:
```
 *** ERROR: Homebrew clang-format version 14.0.6; clang-format 14.0 required
```
2024-05-14 08:42:54 -07:00
Abtin Keshavarzian f12785def6 [dataset] add support for handling MGMT_ACTIVE_REPLACE on leader (#10201) 2024-05-13 09:57:19 -07:00
Abtin Keshavarzian 68b8c88e18 [routing-manager] introduce RoutePrefix and OnLinkPrefix types (#10216)
This commit refactors and simplifies `RoutingManager`:

- Introduces `OnLinkPrefix` and `RoutePrefix` classes, both derived
  from a common base class `LifetimedPrefix` (representing a prefix
  and its valid lifetime).
- Replaces the originally dual-purpose `DiscoveredPrefixTable::Entry`
  (used for both route and on-link prefixes) with a new template
  `Entry<Type>`, specifically used with `OnLinkPrefix`, `RoutePrefix`,
  and also `Router`.
- Updates `Router` to maintain separate lists for on-link and route
  prefixes.
- Utilizes `OnLinkPrefix` in `PdPrefixManager` for tracking DHCPv6-PD
  prefixes.
2024-05-13 09:38:22 -07:00
Yakun Xu 39ce8117a5 [simulation] support simulating radio over IPv6 (#10194)
This commit adds support to simulate Thread radio over IPv6.

With this commit, a simulation will be simulated over either IPv6 or IPv4.
If it's simulated on IPv6, it communicates with other simulation nodes
in IPv6 group `ff02::116`. And if it's simulated on IPv4, it communicates
with other simulation nodes in IPv4 group `224.0.0.116`.

Note that simulating virtual time is not included in this commit.
2024-05-13 09:27:54 -07:00
dependabot[bot] 7cc636ccce github-actions: bump ossf/scorecard-action from 2.3.1 to 2.3.3 (#10225)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.3.1 to 2.3.3.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/0864cf19026789058feabb7e87baa5f140aac736...dc50aa9510b46c811795eb24b2f1ba02a914e534)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  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>
2024-05-13 09:24:48 -07:00
Dávid Fehér 1fceb225b3 [cli] add UDP socket openness check before sending with udp send (#10206)
Problem: Executing the `udp send` command in CLI without previously
opening the example udp socket results in an unhandled null-pointer
exception.

Solution: Before anything is processed in the
`UdpExample::Process<Cmd("send")>(Arg aArgs[])` method, the UDP socket
is checked whether it's open or not. If not, the method returns with
OT_ERROR_INVALID_STATE error avoiding the null-pointer exception.
2024-05-09 07:41:54 -07:00
Mason Tran 0b114821d9 [spinel] only request crash logs on RCP recovery if capable (#10213)
During RCP recovery, the Host does not check if the RCP supports
logging a crash dump. This causes RCP recovery to fail when the RCP is
built with `OPENTHREAD_CONFIG_PLATFORM_LOG_CRASH_DUMP_ENABLE =
0`. This bug was introduced in #10061

This commit will make the Host only request crash logs from the RCP if
the RCP supports it.
2024-05-09 07:39:19 -07:00
Abtin Keshavarzian 74573b5d3f [routing-manager] use OwningList for Router and Entry lists (#10214)
This change leverages `OwningList<>` to manage discovered routers and
prefix entries within `RoutingManager`. This ensures automatic
deallocation of these items, streamlining memory management. It works
independently of whether the items are heap-allocated or from a
`Pool`.
2024-05-08 19:53:25 -07:00
Abtin Keshavarzian 8e3f51da84 [dns] add checks for multi-label looped compressed DNS names (#10215)
This commit enhances `Dns::Name` to detect and handle cases where a
compressed DNS name contains a loop spanning multiple labels. The
`test_dns` unit test has been updated to include test cases for these
invalid names.
2024-05-08 18:56:02 -07:00
Abtin Keshavarzian 226f239c5d [owning-list] add RemoveAndFreeAllMatching() to OwningList class (#10210)
This commit introduces a new method, `RemoveAndFreeAllMatching()`, to
the `OwningList<Type>` class. This method removes and frees all
entries in the list that match a given indicator. This is used to
simplify the native mDNS implementation. The unit test
`test_linked_list` is also updated to validate the newly added helper
method.
2024-05-08 11:32:42 -07:00
Li Cao 00f7c3131b [spinel] move definition of coprocessor type to lib/spinel (#10208)
This commit moves the definition of coprocessor_type from posix to
lib/spinel directory. There are two reasons to do so:
1. Allow platforms other than posix to access the definition. For
   example, nxp imt-rx.
2. Allow the user (posix/main.c) of OT system API to access the
   definition. Currently the posix main depends on OT system API but
   doesn't depend on definitions in 'platform-posix.h'. This should be
   kept.
2024-05-08 11:29:25 -07:00
Abtin Keshavarzian 383d0d2815 [routing-manager] add CalculateExpirationTime() (#10207)
This commit adds `CalculateExpirationTime()`, which simplifies the
calculation of expiration times of discovered prefix entry by
clamping a given lifetime to the maximum value (in seconds) first
before converting to milliseconds.
2024-05-07 13:52:50 -07:00
Abtin Keshavarzian 83af14a950 [dataset] send 'reject' response to MGMT_SET on non-leader (#10148)
This commit simplifies the code and adheres to the SHOULD
requirement in the Thread specification, which states: "A Thread
Device that is not a Leader MUST NOT process this message. Instead it
SHOULD respond with 'Reject' state value".
2024-05-07 13:18:07 -07:00
Abtin Keshavarzian 6f0b7631e9 [routing-manager] enhance and streamline PdPrefixManager (#10146)
This commit updates the `PdPrefixManager` class for improved
readability and efficiency:

- Relocated all Prefix PD methods in the header file for logical
  grouping within the same `#if` block.
- Reordered method definitions for better organization (e.g., moved
  `SetEnabled()` closer to the constructor, and logging-related
  methods to the end).
- Renamed variables and types for conciseness (e.g., `Dhcp6PdState` to
  `State`).
- Simplified prefix processing logic, regardless of whether it's from
  RA or directly set.
- Moved additional functions into `PdPrefixManager::Process()`,
  including checking `mEnabled`, logging failures, and updating
  counters.
- Optimized `Process()` to update the timer only when the prefix
  changes.
- Introduced a new nested `PrefixEntry` class with helper methods like
  `IsFavoredOver()` and `IsEmpty()`, simplifying the code and
  improving readability.
- The `IsFavoredOver()` method determines if one PD prefix is favored
  over another.
2024-05-07 12:24:37 -07:00
Abtin Keshavarzian 42ccf281fb [routing-manager] ensure correct handling of shorter PD prefix (#10145)
This commit corrects the order of calls to prefix methods `Tidy()` and
`SetLength(kOmrPrefixLength)`. This was unintentionally reversed in
PR #10000.

PD prefixes can be shorter than `kOmrPrefixLength` (as allowed by
`IsValidPdPrefix()`). To use them as OMR prefixes, `Tidy()` is called
first to clear any extra bits before potentially extending the prefix
to `kOmrPrefixLength`.
2024-05-06 12:18:06 -07:00
dependabot[bot] 973e657c6b github-actions: bump codecov/codecov-action from 4.0.2 to 4.3.1 (#10195)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.2 to 4.3.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1...5ecb98a3c6b747ed38dc09f787459979aebb39be)

---
updated-dependencies:
- dependency-name: codecov/codecov-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>
2024-05-06 11:45:19 -07:00
Yuwen Lan 35a777a295 [cli] fix ipaddr and ipmaddr commands in debug cli (#10200)
This commit corrects "ipaddr" and "ipmaddr" commands used in debug cli
2024-05-06 11:44:39 -07:00
Li Cao 0a16ece8d2 [style] add comment to indicate the which conditional endif is associated with (#10197) 2024-05-06 11:31:31 -07:00
Abtin Keshavarzian ee83d45f76 [cli] add br pd omrprefix command to display DHCPv6 PD OMR prefix (#10147)
This commit introduces the `br pd omrprefix` command, which displays
the DHCPv6 Prefix Delegation (PD) On-Mesh Routable (OMR) prefix when
the DHCPv6 PD feature is enabled. Additionally, the `debug` command
is updated to output `br pd state` and this new command when the
feature is enabled
2024-05-03 11:37:17 -07:00
Abtin Keshavarzian 922059ce20 [dataset] simplify dataset manager MGMT_SET request handling (#10139)
This commit adds `ProcessSetRequest()` to process a received
`MGMT_SET` request message, validate the included `Dataset`, and
determine if it affects connectivity or changes the network key. The
now unused `DatasetTlv` is removed as TLVs are read directly from the
`Message`. This change will also enable future support for
`MGMT_REPLACE` request.
2024-05-02 16:10:36 -07:00
Abtin Keshavarzian d8e3e8380c [dataset] simplify SendSetRequest (#10135)
This commit adds a common `SendSetRequest(const Dataset &)` method
that prepares and sends an MGMT_SET message with the given Dataset.
This removes similar duplicate code.
2024-05-02 16:03:59 -07:00
Abtin Keshavarzian 485cb18ea4 [dataset] add ValidateTlvs(), helper methods, and unit test (#10111)
This commit enhances dataset handling:

- Adds `ValidateTlvs()` which parses and validates all known TLVs
  within the `Dataset` and checks for any duplicates.
- Introduces a set of `SetFrom()` methods for constructing a `Dataset`
  from various types of inputs, e.g., other `Dataset`, TLV sequences,
  `DatasetInfo` structures, bytes read from `Message`. Now they
  consistently clear the `Dataset` before setting it.
- Adds `WriteTlvsFrom()` to update a `Dataset` replacing/appending a
  set of TLVs.
- Adds `AppendTlvsFrom()` to append an already encoded sequence of
  TLVs without validating/checking the format.
- Renames `Get/SetSize()` to `Get/SetLength()` for consistency.
- Adds `test_dataset.cpp` unit test for basic `Dataset` validation.
2024-05-02 14:40:11 -07:00
Abtin Keshavarzian b8f036a570 [simulation] remove example log lines from otPlatLogCrashDump() (#10137)
This commit removes the `LogCrit` example lines emitted from
`otPlatLogCrashDump()` in simulation platform. These extra log
lines can cause test failures.
2024-05-02 12:02:10 -07:00
Ashish f404a228aa [spinel] remove mIsCoprocessorReady flag check (#10144)
- If we check in between SendReset() and WaitResponse(),
  mIsCoprocessorReady may become true before waitResponse() and if
  loop becomes false even successfully reset done.
- mIsCoprocessorReady is already checked before sendReset() to avoid
  resetting in case of Mulipan architecture. There is no need to check
  in between sendReset() and waitResponse().
- Removed mIsCoprocessorReady from if loop check between sendReset()
  and waitResponse().

Signed-off-by: Ashishkumar Vara <ashish.vara@nxp.com>
2024-05-02 10:14:49 -07:00
Abtin Keshavarzian 3517e6ce37 [routing-manager] remove unused method (#10142) 2024-05-02 08:45:30 -07:00
Abtin Keshavarzian 2b65a63ef3 [routing-manager] update and simplify comments (#10141) 2024-05-02 08:31:18 -07:00
Li Cao 9e4cbb8c60 [spinel] breakdown posix radio module (#10051)
This commit breaks down current posix radio module into `Radio` and
`SpinelManager`. The static instance of `SpinelDriver` is moved from
`Radio` to `SpinelManager`. The `platformRadioXXX` methods are also
broken down into `platformSpinelXXX` and `platformRadioXXX`. The
purpose is to make `platformSpinelXXX` resuable under both NCP and RCP
cases. And to use `platformSpinelInit` to detect to co-processor type
during initialization.
2024-05-01 22:00:34 -07:00
Li Cao 3bf281d32d [cli] move a few static util methods to Cli::Utils class (#10138)
This commit moves a few static util methods from the `Interpreter`
class to the `Cli::Utils` class. Since the `Interpreter` class and
other classes for cli components inherit the `Cli::Utils`, they can
still access these methods. Putting these methods in utils class is
more intuitive. This change also makes other cli classes less
dependent on the `Interpreter` class.
2024-05-01 10:56:18 -07:00
Abtin Keshavarzian 0c6c2fedad [dataset] define MgmtSetCallback type (#10120) 2024-04-30 08:56:07 -07:00
Li Cao da72435f3a [cli] fix namespace usage (#10088)
The method `ParseEnableOrDisable` has been moved to the `Utils` class
and these components inherit the `Utils` class so there is no need to
add namespace.
2024-04-29 14:15:50 -07:00
dependabot[bot] f049648c3f github-actions: bump github/codeql-action from 3.24.6 to 3.25.3 (#10077)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.6 to 3.25.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/8a470fddafa5cbb6266ee11b37ef4d8aae19c571...d39d31e687223d841ef683f52467bd88e9b21c14)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2024-04-29 09:59:38 -07:00
Kangping 0884a1be42 [dtls] fix undesired kernel filtering of connected UDP (#10069)
This commit fixes again the same issue which was fixed by
https://github.com/openthread/openthread/pull/8168 with the same
approach. The regression was unintentionally introduced by the initial
TCAT commit https://github.com/openthread/openthread/pull/9210

See https://github.com/openthread/openthread/pull/8168 for the
background and discussion.
2024-04-29 09:13:04 -07:00
Li Cao e89b989703 [cli] fix ifdef guard (#10068) 2024-04-29 09:11:57 -07:00
Abtin Keshavarzian efb80c0b83 [routing-manager] exclude on-link prefixes with short preferred lifetime (#10062)
This commit updates `FindFavoredOnLinkPrefix()` to exclude discovered
on-link prefixes with preferred lifetimes under 30 minutes.
2024-04-29 09:11:27 -07:00
Mason Tran 502797c0b3 [spinel] add support for logging crash dumps (#10061)
This commit adds a new feature that allows platforms to log crash logs.

### Additions
- `void otPlatLogCrashDump(void)` - API that logs a crash dump using
  OpenThread Logging APIs
- `SPINEL_PROP_RCP_LOG_CRASH_DUMP` - spinel prop that calls
  `otPlatLogCrashDump()` when `Set`
- `SPINEL_CAP_RCP_LOG_CRASH_DUMP` - spinel capability denoting that a
  RCP supports logging crash dumps

### Usage
- For `ot-cli-ftd|mtd`, `otPlatLogCrashDump()` is called at the end of
  app initialization, before the main loop. See [main.c]
- For Host/RCP setups, during initialization, the Host gets the RCP
  capabilities. If the RCP has the `SPINEL_CAP_RCP_LOG_CRASH_DUMP`
  capability, the Host will `Set` the `SPINEL_PROP_RCP_LOG_CRASH_DUMP`
  property, triggering the RCP to call `otPlatLogCrashDump()`.
  - If RCP Recovery is enabled, the this will also happen once the RCP
    has been restored
2024-04-29 09:09:54 -07:00
Abtin Keshavarzian 2408c89400 [test] add a CMake macro to simplify adding unit tests (#10067)
This commit adds `ot_unit_test()` macro which adds a unit test.
This is used to simplify the unit test `CMakeList.txt`.
2024-04-26 11:45:05 -07:00
Abtin Keshavarzian 20a6e887f9 [dataset] update SendGetRequest() to use TlvList array (#10066) 2024-04-26 11:40:50 -07:00
Abtin Keshavarzian ca45026ba5 [callback] add InvokeAndClearIfSet() helper (#10064)
Will first clear the callback before invoking its handler so to
allow the callback to possibly set again from the handler
implementation.
2024-04-26 11:39:58 -07:00
Abtin Keshavarzian 7a773681d0 [dataset] simplify DatasetManager::HandleSet() (#10063)
This commit contains smaller enhancements in `HandleSet()`:

- Remove the redundant `IsLeader()` check since it is checked in
  `HandleTmf<kUriActiveSet>` and `HandleTmf<kUriPendingSet>` before
  calling `HandleSet()`
- While reading TLVs from message, ensure that entire TLV is contained
  in the `Message`.
- Simplify the code that verifies an `MGMT_ACTIVE_SET.req` from a
  commissioner does not affect connectivity (change boolean checks to
  positive instead of negative).
- Remove `hasNetworkKey` as the condition is tracked by
  `doesAffectNetworkKey`.
2024-04-26 11:37:50 -07:00
Suvesh Pratapa 6312456eed [cli] add cli toggle (for test harness) to accept tmf udp messages from unknown origins (#10028)
Reference devices that are part of the Thread test harness construct
CoAP packets sent on TMF port 61631 for certain tests, for example in
the 5.9.x series where they have to force address errors (a/ae) for
duplicate DUA or re-registration tests. These tests started to fail
when reference device firmware was updated recently to a newer
OpenThread stack that included the change in
https://github.com/openthread/openthread/pull/9437.

Example:
```
udp send fd00:db9:0:0:0:ff:fe00:5000 61631 -x 4102d63697b16e02646eff0401010010fd007d037d037d0389c3a350cdcf36e0'
Ip6-----------: Dropping TMF message from untrusted origin
```

For certification purposes, we are adding a cli toggle (for reference
devices) as a test sub-command to disable the filter that drops TMF
messages from unknown origins.
2024-04-26 11:31:52 -07:00
Li Cao 93f3113764 [link-metrics] add cli command to show link metrics manager state (#10046) 2024-04-25 08:31:18 -07:00
Abtin Keshavarzian 9a9853bb7c [dataset] relocate IsTlvValid() to Dataset (#10060)
This commit relocates `IsTlvValid()` to the `Dataset` class,
emphasizing its specificity for validating Dataset TLVs and not other
MeshCop TLVs.
2024-04-25 08:26:45 -07:00
Abtin Keshavarzian 79a6a85fed [dataset] add generic Read<Tlv>() methods, refactor timestamp (#10059)
handling

This commit introduces several smaller changes to the `Dataset`
class:

- Provides template methods `Read<Tlv>()` for flexible reading of any
  TLV from dataset, mirroring the existing `Write<Tlv>()` methods.
- Replaces `SetTimestamp()` method with the `Write<Tlv>()` with
  specific timestamp TLVs
- Renames `GetTimestamp()` to `ReadTimestamp()`, aligning the naming
  convention with other methods.
2024-04-25 08:24:51 -07:00
Zhanglong Xia ade9c2b257 [spinel] restore the source match feature setting (#10055)
The RCP Restoration feature missed restoring the source address match
feature configuration. It causes the source match table to be disabled
by default after the RCP restarts. This commit restores the source
address match feature configuration.
2024-04-24 11:05:37 -07:00
Mason Tran 19dc5ce8ca [spinel] fix spinel RCP min host api version cap bug (#10057) 2024-04-23 21:13:53 -07:00
SherySheng b3d300e84c [dhcp] add callback to notify DHCPv6 PD state change (#9926)
When the DHCPv6 PD state changed, we need to throw out a signal to
notify another process running on the OS, then the process will decide
if it need to withdraw or request RA.
2024-04-23 11:08:35 -07:00
ZhangLe2016 de9f978723 [mesh-diag] fix a typo in a variable name (#10056) 2024-04-23 06:30:24 -07:00
Abtin Keshavarzian 9681690fab [mdns] add APIs to iterate over registered host/service/key entries (#9954) 2024-04-22 10:54:47 -07:00
Marius Preda 9af7203ff3 [routing-manager] add support for to use a prefix received from DHCPv6 PD (#10000)
This commit adds support for adding a DHCPv6 delegated prefix to the
Routing Manager via a new Open Thread API. Previously this feature was
only supported using a platform generated RA on a Posix based BR. For
platforms that can get the prefix directly from a DHCPv6 PD client API
there is no point in creating a RA for setting the prefix. It's much
easier to use a direct call to configure it.

This new API uses an otBorderRoutingPrefixTableEntry structure as an
input parameter and evaluates the prefix based on the same rules as
one coming from a platform RA.  The lifetime of the prefix can be
updated by calling the function again with new time values.
2024-04-22 09:15:05 -07:00
Jappie3 7ec0257b0e [zephyr] add module name (#10041) 2024-04-22 07:38:41 -07:00
dependabot[bot] ba7a6ad311 github-actions: bump actions/setup-python from 5.0.0 to 5.1.0 (#10052)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/0a5c61591373683505ea898e09a3ea4f39ef2b9c...82c7e631bb3cdc910f68e0081d67478d79c6982d)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2024-04-22 06:34:47 -07:00
Abtin Keshavarzian 4737231d64 [dnssd] allow Dnssd platform to use native OT mDNS modules (#9944)
Updates the `Dnssd` module to allow it use

- Either the native OT mDNS implementation
- Or use the platform `otPlatDnssd` APIs (delegated to platform)

Also adds `OPENTHREAD_CONFIG_MULTICAST_DNS_AUTO_ENABLE_ON_INFRA_IF`
for mDNS module to be automatically enabled/disabled on the same
infra-if used for border routing based on infra-if state.
2024-04-19 10:20:46 -07:00
Yang Sun 59572efb4e [icmp] add OT_ICMP6_ECHO_HANDLER_RLOC_ALOC_ONLY to otIcmp6EchoMode (#10014)
When an icmp echo request is sent to rloc/aloc address of a Thread
device, OT replies to the packet. The packet is also passed to host
and the kernel may reply to the echo request. This would cause 2 echo
replies and may be confusing when testing packet loss rate by pinging
a rloc/aloc address.

Added OT_ICMP6_ECHO_HANDLER_RLOC_ALOC_ONLY to otIcmp6EchoMode to let
OT only handle echo request to rloc/aloc addresses, this is the
default mode in posix code. Set otIcmp6EchoMode to
OT_ICMP6_ECHO_HANDLER_DISABLED will help to avoid double ping replies
from both OT and host.
2024-04-19 09:29:34 -07:00
Suvesh Pratapa 4c96151c0e [logging] fix print format when enabling csl debug (#10045)
Fix -Wformat trigger on some platforms as an int32_t is printed using %d

    ```
    src/core/mac/sub_mac.cpp:336:73: warning: format '%d' expects argument of type 'int', but argument 5 has type 'int32_t' {aka 'long int'} [-Wformat=]
      336 |     logString.Append("Expected sample time %lu, margin ±%lu, deviation %d", ToUlong(sampleTime), ToUlong(ahead),
          |                                                                        ~^
          |                                                                         |
          |                                                                         int
          |                                                                        %ld
      337 |                      deviation);
          |                      ~~~~~~~~~
          |                      |
          |                      int32_t {aka long int}
    ```
2024-04-18 15:49:38 -07:00
Abtin Keshavarzian 2199db8251 [dataset] simplify AppendMleDatasetTlv() (#10043)
- Inlines `AppendMleDatasetTlv()` in `DatasetManager` (removing from
  `Dataset` class)
- Updates the locally read 'dataset' directly by removing the
  timestamp before appending it to the message as an MLE TLV value.
- Leverages `Read()` which already updates the `DelayTimerTlv` with the
  remaining delay, eliminating the need to re-calculate and update the
  delay.
- Uses `Tlv::AppendTlv()` to append the MLE TLV with `dataset` bytes
  as value.
2024-04-18 15:40:51 -07:00
Abtin Keshavarzian fa6477197c [dataset] use IsActiveDataset()/IsPendingDataset() for type checks (#10040) 2024-04-18 10:18:38 -07:00
Abtin Keshavarzian be7d36e4ff [dns] add Name::StripName() and support in-place ExtractLabels() (#10037)
- Updates `Dns::Name::ExtractLabels()` for in-place label extraction,
  optimizing string operations.
- Introduces `Name::StripName()` to efficiently remove a suffix name
  from a DNS name in place.
- Updates and simplifies unit tests `test_dns` to validate new
  functionality.
2024-04-17 15:21:16 -07:00
Li Cao b6a1dc8fe8 [tests] enhance expect test for link metrics manager feature (#10035)
This commit enhances the expect test against link metrics manager
feature to ensure that the feature can be continuously turned on or
off and work well. Because the feature will be controlled by the
feature flag in ot-br-posix.
2024-04-17 12:56:44 -07:00
Abtin Keshavarzian 8692f2f4b9 [cmake] add OT_BORDER_AGENT_EPSKC in CMake options (#10034)
Tied to `OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE`.
2024-04-17 12:56:07 -07:00
Li Cao cf58985747 [spinel] breakdown radio spinel (#10025)
The commit separates the spinel handling from other rcp specific
handling in `RadioSpinel` by putting the spinel handling into a new
class `SpinelDriver`. The purpose is to make the spinel handling
reusable in further change (for new architecture).

`SpinelDriver` has the following functions:
1. Co-processor initialization
2. Send a spinel command to the co-processor without waiting
3. Drive the processing of received spinel frames. But it will not do
   the actual handling.

In this commit, `SpinelDriver` is added as a member of `RadioSpinel`
and `RadioSpinel` uses `SpinelDriver` to implement some of the
existing functions.

With `SpinelDriver`, it is possible to implement a new
RadioSpinel-like module that provides non-blocking APIs (No
`WaitResponse` is used).  Note that there is a private, simpler
version of `WaitResponse` in `SpinelDriver` which is only used during
Co-processor initialization.  The initialization process of spinel is
still blocking.
2024-04-17 12:55:35 -07:00
Esko Dijk a234addb13 [cli] update README files to clarify a Commissioner is used for changing datasets (#10026)
Based on discussion in #9901 , this clarifies in the documentation
that the CLI `dataset` commands can only be used in specific
situations (like testing), and that these commands allow setting
invalid (combinations of) parameters also. It points to the
Commissioner as the correct way of doing dataset updates in
production.

It also adds "Overview" sections that were missing in two README
files.
2024-04-16 14:21:31 -07:00
Abtin Keshavarzian 23b3641476 [mle] restart role transition timeout from SetRouterEligible(true) (#10033)
Updates `MleRouter::SetRouterEligible()` to restart the role transition
timer if the device is a child and the router eligibility is changed
to `true`.
2024-04-16 12:50:40 -07:00
Abtin Keshavarzian 43cb7a09cf [dataset] enforce maximum delay timer value and improve handling (#10023)
This commit makes the following improvements to Delay Timer TLV
handling in Pending Operational Datasets:

- Enforces maximum delay adhering to the Thread spec's maximum Delay
  Timer value (72 hours), clamping larger values.
- Defines min, max, and default delay timer constants in
  `DelayTimerTlv`.
- Adds `CalculateRemainingDelay()` helper method to calculate
  remaining delay.
- Removes code handling delay values exceeding the OpenThread `Timer`
  limitation (now redundant due to the stricter 72-hour maximum).
2024-04-15 12:25:30 -07:00
Abtin Keshavarzian f68eda9660 [dataset] simplify DatasetManager::HandleGet() & SendGetResponse() (#10020)
This commit contains the following:
- Use `FindTlvValueOffset()` to find `Tlv::kGet` in message.
- Define and use `TlvList` to get list of requested TLV type.
- `TlvList` is an array of TLV types, not allowing duplicate values to
  be added to the list.
- Simplify `SendGetResponse()` to handle including all or a subset of
  TLVs in response.
2024-04-15 09:26:35 -07:00
dependabot[bot] d32c68d84e github-actions: bump docker/login-action from 3.0.0 to 3.1.0 (#10029)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/343f7c4344506bcbf9b4de18042ae17996df046d...e92390c5fb421da1463c202d546fed0ec5c39f20)

---
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>
2024-04-15 09:21:31 -07:00
Abtin Keshavarzian d0f6d17860 [dnssd-server] remove unused private method (#10024) 2024-04-11 22:23:50 -07:00
Handa Wang f72f27f0f7 [daemon] avoid using defined(__ANDROID__) macro in daemon.cpp (#10021)
This commit replaces `defined(__ANDROID__) &&
!OPENTHREAD_CONFIG_ANDROID_NDK_ENABLE` macro checks with
`OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE`. This is to make the build
options more configurable. E.g. there are cases where `__ANDROID__` is
defined but the platform is not fully Android-compatible so we don't
want to enable the Android platform implementation.
2024-04-11 21:52:52 -07:00
Marius Preda 9d852a3b37 [udp] add DHCP ports to ShouldUsePlatformUdpFunction (#10017)
This commit aims to add more flags to the 'ShouldUsePlatformUdp'
function, to let sockets that have ports belonging to the stack send
their packets without using the UDP platform abstraction layer.

Without this change, when Platform UDP is enabled, packets originating
from the DHCPv6 Server/Client will take an undesired route from
socket -> platform UDP -> external IPv6 stack -> Thread IP stack ->
packet over the air.

Co-authored-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2024-04-11 12:49:55 -07:00
Abtin Keshavarzian 3b272023ab [dataset] use Tlv::Find<>() to check commissioner session ID (#10019)
This commit simplifies `DatasetManager::SendSetRequest()` by using
`Tv::Find<TlvType>()` helper method to search within the given
sequence of TLVs for `CommissionerSessionIdTlv`.
2024-04-11 12:40:40 -07:00
Abtin Keshavarzian d7b5939fb7 [dataset] define template method to check/get/set components (#10018)
This commit introduces a `Component` enum to represent dataset
components, and defines templated methods (`IsPresent<>`, `Get<>`,
`Set<>`, etc) for streamlined access. This reduces boilerplate code
for individual component management.
2024-04-11 08:22:17 -07:00
Abtin Keshavarzian 423c0bef37 [dataset] add ApplyConfiguration() overload without default parameter (#10013) 2024-04-11 08:20:45 -07:00
Abtin Keshavarzian 30aa3e881d [message] introduce RemoveFooter() (#10012) 2024-04-09 17:06:14 -07:00
Abtin Keshavarzian 51b94bb879 [dataset] GenerateRandom() to build network name using StringWriter (#10007) 2024-04-09 17:05:04 -07:00
Abtin Keshavarzian bf41332061 [mdns] add native mDNS support in OT (#9797)
This commit introduces native mDNS support within the OpenThread
stack, implementing RFC 6762 compliant registration of hosts,
services, and keys. It supports the following functionalities:

- Sending probes to claim names.
- Sending announcements on initial registration and changes.
- Sending "goodbye" announcements when unregistered or upon record
  removal.
- Negative responses (NSEC).
- Support for service sub-types and their addition/removal.
- Support for `_services._dns-sd._udp` queries (all service types).
- Responding to queries (including "QU" questions).
- Delay mechanism when responding to multi-question query messages,
  ensuring unique answers.
- Providing extra records in the Additional Data section if not
  already in the Answer section (e.g., on a PTR query, include SRV
  and host AAAA addresses).
- Implementing Known-Answer Suppression.
- Supporting multi-packet queries with known answers in follow-up
  messages.
- Rate-limiting record multicasts (once per second).
- Rate-limiting probe responses (once per 250ms).
- Detecting conflicts after probes.
- Limiting the size of emitted responses or probes, breaking into
  multiple messages if necessary.
- Detecting self originating messages (sent by mDNS module).
- Support for service browser.
- Support for service resolvers (SRV and TXT records) and IPv4/IPv6
  address resolvers for hostnames.
- Introduces smart cache management:
  - Passively caches service records for active browsers.
  - Passively caches address records for active service resolvers.
- Enables multiple simultaneous browsers/resolvers for the same
  service/host.

This commit introduces public `otMdns` OpenThread APIs and related CLI
commands for the mDNS module.

For platform abstraction, `otPlatMdns` APIs are defined in
`mdns_socket.h` (e.g., to send or receive mDNS messages):

- An implementation of the platform APIs is provided for posix.
- Also under the simulation platform, a simplified implementation of the
  `otPlatMdns` APIs is provided (intended for testing).

This commit also adds a detailed `test_mdns` unit test, validating
various functionalities and covering potential edge cases.
2024-04-09 08:32:01 -07:00
dependabot[bot] 6de5cd8256 github-actions: bump actions/upload-artifact from 4.2.0 to 4.3.1 (#10005)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.2.0 to 4.3.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4.2.0...5d5d22a31266ced268874388b861e4b58bb5c2f3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2024-04-08 17:27:18 -07:00
Abtin Keshavarzian 5c6b8328bc [utils] implement Verhoeff checksum calculation and validation (#9966)
This commit adds `Utils::VerhoeffChecksum` class along with public OT
APIs and related CLI commands for Verhoeff checksum calculation and
validation. Unit test `test_checksum` is updated to test the new
module.
2024-04-08 17:11:43 -07:00
DaveLacerte 8212acd133 [spinel] add time sync feature to the spinel (#9977)
This commit add the structure needed to support time sync to spinel.
2024-04-08 17:10:27 -07:00
gytxxsy 65eac6f66d [instance] support get multi instance reference or index (#9947)
Provided  two methods  for OpenThread multipan : 
1. Get the index by an openthread instance reference.
2. Get the reference by an openthread instance index.
2024-04-08 17:09:24 -07:00
DaveLacerte a5c17b7763 [mle] MTD to handle udp time sync message (#9978)
This commit add the possibility to handle a udp time sync message when
configured as MTD.
2024-04-05 11:19:39 -07:00
Abtin Keshavarzian b146766e3a [plat-utils] enhance otMacFrameDoesAddrMatch() (#9997)
This commit updates `otMacFrameDoesAddrMatch()` to ensure it
does not match if frame is malformed (`Frame::GetDstAddr()`
fails).
2024-04-05 11:18:41 -07:00
Abtin Keshavarzian e3f97e2362 [netdata-publisher] distinguish SRP/DNS unicast entries (#9937)
This commit refines the `NetworkData::Publisher` to differentiate
between DNS/SRP unicast entries based on whether the address
information resides in service data (part of service TLV) or server
data (part of server sub-TLV).

Additionally, if another BR adds a service data unicast entry,
`Publisher` will zero out the desired count for server data unicast
entries, effectively removing any previously published server data
unicast entries.

The `test_netdata_publisher` has been updated to validate all the
newly added behaviors.
2024-04-05 09:30:26 -07:00
Abtin Keshavarzian 223935bf0c [logging] introduce LogWarnOnError() for standardized error logging (#9996)
This commit adds `LogWarnOnError()` to emit warning-level logs on
errors. The emitted log includes the error code. This replaces custom
`LogError()` across modules, simplifying the code.
2024-04-05 09:07:19 -07:00
Abtin Keshavarzian 65bc830edb [test] add tests for multi-BR network resilience during BR removal (#9990)
This commit adds new test cases for a topology with two BRs when the
primary BR is abruptly powered off. It validates that the second BR
takes over and all nodes successfully re-register their SRP services
with the new BR using new OMR addresses.

The first test (`501`) covers the case where neither BR is acting as
mesh leader. The second test (`502`) covers the case where the
powered-off BR is also acting a mesh leader.
2024-04-04 09:07:36 -07:00
Abtin Keshavarzian 244c223ff1 [srp-sever] add LogError() (#9992)
This commit adds `LogError()` helper method in `Srp::Server` to
simplify logging failures.
2024-04-04 08:48:49 -07:00
Abtin Keshavarzian 875e71e565 [dataset] define Dataset::Tlvs type (#9991)
This commit defines `Dataset::Tlvs` as a core type corresponding to
public OT `otOperationalDatasetTlvs` structure.
2024-04-04 08:48:01 -07:00
Yakun Xu 38418aebe4 [ip6] allow delivering RLOC/ALOC traffic to host (#9987)
Filtering out traffic to/from RLOC/ALOC was added by #423 for #419.
The intention was to filter out Thread's control traffic.

Now we already added filtering out traffic by checking whether it
is destined to a service hosted in OpenThread stack, so filtering
out by RLOC/ALOC is not necessary anymore.

This commit removes this filter, as a result, the core lib gets
rid of the `PLATFORM_NETIF` flag.
2024-04-03 14:57:39 -07:00
Abtin Keshavarzian a3e804101e [mle] simplify CheckReachablity() (#9989)
This commit simplifies `MleRouter::CheckReachablity()`:

- Remove and inline `Mle::CheckReachability()` which is used
  when `IsChild()`.
- Uses local `isReachable` boolean variable.
2024-04-03 13:56:25 -07:00
Handa Wang 843db1e82d [srp-server] retry other ports when failing to prepareSocket (#9981)
Unicast SRP dataset uses a ephemeral UDP port which could be taken by
another process. Currently SRP server creates the socket at the port
after the server is added into netdata. However, at that moment the
port may not be available on the platform so it may fail to create the
socket and start the server.

This commit adds the logic to restart the enabling process with
another port candidate if SRP server fails to create the socket.
2024-04-03 10:51:50 -07:00
Li Cao 0e36799110 [link-metrics] fix race condition (#9986) 2024-04-02 11:42:56 -07:00
Abtin Keshavarzian d099d78620 [doc] use space char instead of tabs in ot_config_doc.h (#9983)
Makes it consistent and follows the OT style guide.
2024-04-01 22:08:57 -07:00
dependabot[bot] 1fb1d9a8c9 github-actions: bump actions/checkout from 4.1.1 to 4.1.2 (#9982)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/b4ffde65f46336ab88eb53be808477a3936bae11...9bb56186c3b09b4f86b1c65136769dd318469633)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2024-04-01 09:46:16 -07:00
Abtin Keshavarzian 37144f078e [mesh-forwarder] update CheckReachablity() to handle malformed messages (#9976)
This commit ensures `MeshForwarder::CheckReachablity()` rejects frames
where `Ip6::Header::DecompressFrom(FrameData)` returns a parse error.
This prevents the processing of potentially malformed messages.
2024-03-28 08:32:55 -07:00
Abtin Keshavarzian 911f0d5a5c [netata] simplify RemoveTemporaryData() (#9975)
This commit simplifies `MutableNetworkData::RemoveTemporaryData()`:
- The `RemoveTemporaryDataIn()` methods return a `bool` indicating
  whether the whole TLV can be removed.
- The code is refactored to combine the call to `RemoveTlv()` for
  all TLV types.
2024-03-28 08:29:09 -07:00
Abtin Keshavarzian 58b230fef0 [cli] netdata show to support filtering by RLOC16 (#9969)
This commit updates the CLI `netdata show` command to allow an
optional RLOC16 as input. Providing an RLOC16 filters the output to
display prefix, route, and service entries associated specifically
with the specified RLOC16. This is helpful for checking entries added
by a specific border router.

`test-011-network-data-timeout.py` is updated to validate the new CLI
functionality.
2024-03-27 15:25:02 -07:00
Abtin Keshavarzian 34a0b0dd7e [mle] improve MLE module comments (#9972)
This commit streamlines MLE module comments by simplifying
explanations and removing redundant ones that are clear from source
code.
2024-03-27 14:36:46 -07:00
Esko Dijk 7271b199d3 [cli] fix CoAP response code for POST 2.03 -> 2.04 per RFC 7252 (#9971) 2024-03-27 10:54:02 -07:00
Abtin Keshavarzian 7d4a1f8c8f [mle] include child RLOC16 in the logs from HandleTimeTick() (#9968)
This commit contains small changes to logs in `HandleTimeTick()`
method in `MleRouter` to include the RLOC16 of child entries when
updating the child table.
2024-03-26 19:02:52 -07:00
Abtin Keshavarzian 8de3298a59 [netdata] refactor MutableNetworkData methods for code organization (#9970)
This commit relocates `NetworkData` and `MutableNetworkData` method
implementations to improve code organization. There is no functional
change.
2024-03-26 19:01:52 -07:00
Abtin Keshavarzian d237cd2c02 [routing-manager] set extra options to append to emitted RAs (#9945)
This commit introduces new API for setting vendor-specific extra
options to append to emitted Router Advertisement messages. Support
for this is also added in CLI under `br raoptions` command.
2024-03-26 14:04:02 -07:00
Maciej Baczmański dcde8826c0 [test] add tcat unit tests (#9953)
Implement basic unit tests for tcat to validate BLE secure part.

Additionally align handling of BLE connection states and connection
callbacks.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-03-26 12:28:20 -07:00
Abtin Keshavarzian 8c3753925a [cli] add OutputNetworkData() (#9965)
This commit simplifies `netdata show` implementation by combining all
different `Output{Entry}()` methods into a single `OutputNetworkData()`
method.
2024-03-26 12:16:27 -07:00
Abtin Keshavarzian 4545daf010 [routing-manager] employ RA hash tracking to detect self-originating RAs (#9939)
This commit updates how `RoutingManager` differentiates between
self-generated RA messages and those from other sources sending RA on
the same device. This enables learning of the RA header, specifically
the default route lifetime.

This commit introduces a new mechanism to calculate and store a SHA256
hash of recently emitted RAs. Received RAs are cross-referenced
against the stored hashes to determine their origin. This replaces
the prior method, which relied on parsing and analyzing the included
options in the received RA.

A new test case is added in `test_routing_manager` to validate the
learning of RA header from other sources on same device.
2024-03-26 11:13:41 -07:00
Martin Zimmermann 4db6520d17 [channel-manager] add local csl channel selection on SSED (#9641)
This commit enables channel manager on SSED, together with channel monitor,
auto-selecting a better CSL channel for the link between child and its parent.

It also fixes tracking of CcaSuccessRate on CslChannel and adds toranj tests
for auto-channel selection and thread_cert test for autocsl-channel selection.
2024-03-25 14:06:29 -07:00
Abtin Keshavarzian 09aa9630aa [netdata] add FindRlocs() to retrieve RLOC16 of entries (#9961)
This commit introduces `NetworkData::FindRlocs()` which returns the
list of RLCO16 of all border routers and servers in the Network Data
matching specified filter conditions. The `BorderRouterFilter` can be
used to filter the entry type. It can be set to `kAnyBrOrServer` to
include all BRs and servers, or `kBrProvidingExternalIpConn` to
restrict the list to BRs providing external IP connectivity. The new
`FindRlocs()` replaces `FindBorderRouters()` and `GetNextServer()`
methods and helps simplify the code. Unit test `test_network_data`
is updated to validate the new method.
2024-03-25 13:18:19 -07:00
Suvesh Pratapa 13ab3a606c [version] introduce OT_THREAD_VERSION_1_4 (#9946)
Update constants and build switch options to reflect the new version
number "1.4" (previously "1.3.1").

Keeping the legacy "1.3.1" and OT_THREAD_VERSION_1_3_1 types for
backward compatibility with projects that might be using those version
names.

Note that this commit does not change the default config value of
`OPENTHREAD_CONFIG_THREAD_VERSION` which is the default version to use
if it is not explicitly specified by build switches or in a project
config file.
2024-03-25 12:57:31 -07:00
dependabot[bot] 7028be6715 github-actions: bump actions/download-artifact from 4.1.1 to 4.1.4 (#9963)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.1 to 4.1.4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/6b208ae046db98c579e8a3aa621ab581ff575935...c850b930e6ba138125429b7e5c93fc707a7f8427)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  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>
2024-03-25 11:37:55 -07:00
Abtin Keshavarzian 97f5bbb09e [config] update docs for SED_BUFFER_SIZE & SED_DATAGRAM_COUNT (#9962)
This commit updates the documentation for two configs
`OPENTHREAD_CONFIG_DEFAULT_SED_BUFFER_SIZE` and `SED_DATAGRAM_COUNT`
clarifying their intended use.
2024-03-25 11:13:50 -07:00
Li Cao 681d08d661 [spinel] extract log module from radio spinel (#9957)
This commit moves the log functions in RadioSpinel to a new Logger
class (only for spinel module) so that:
1. reduce RadioSpinel's code size for better readability
2. make the log functions reusable by the new Spinel class to add in
   the future.
2024-03-25 11:04:37 -07:00
Abtin Keshavarzian 32bef9bef0 [mle] simplify HandleTimeTick() code related to aging routers (#9955)
This commit contains smaller enhancements in the code related to
aging/updating router entries:

- Consolidate nested `if` blocks for readability.
- Add router's RLOC16 to logs for improved router tracking.
- Refactor duplicate code in `SEND_LINK_REQUEST_ON_ADV_TIMEOUT`.
2024-03-25 11:02:47 -07:00
Abtin Keshavarzian 90adc86d34 [mle] retain direct child cache entries on Addr Solicit Response TX (#9956)
Previously, when a child was promoted to a router role, the
leader upon sending "Address Solicit Response" would clear cache entries
associated with the child's old RLOC16. This commit modifies the code
to retain these cache entries when the sender is a direct child
of the leader. By retaining the cache entries, they can be associated
with the promoted router's new RLOC16 when the Link Advertisement is
received.
2024-03-22 10:38:32 -07:00
Abtin Keshavarzian 8f379a638d [test] simplify test_pskc unit test (#9952) 2024-03-22 10:37:30 -07:00
Li Cao 7d6580ee3c [cli] move Process{Get/Set/Enable/Disable} methods to Utils class (#9951)
This commit moves the `Process{Get/Set/Enable/Disable}` methods to the
Output class and rename the `Output` class to `Utils`.  The purpose is
to reduce code size in the Interpreter class to make the class focus
more on the command handling and easier for further refactoring.

The commit also removes the alias typedef of `Arg` in each cli module
because they are unnecessary. Having one definition in the parent
class is enough.
2024-03-22 10:35:46 -07:00
Przemysław Bida 3ae275f1ac [simulation] add simulation tests framework for tcat (#9724)
This commit adds simulation framework for tcat based on posix udp
sockets.
2024-03-22 10:30:59 -07:00
eeumay f917a5320f [coap] fix copying option (#9894)
- remove typo that passed a uint64_t pointer to a function which need
  a sufficiently large buffer
- fix bug that coap copying uri path option or any other long option
  failed
2024-03-22 10:25:59 -07:00
dependabot[bot] 51ab865600 github-actions: bump docker/setup-buildx-action from 3.0.0 to 3.2.0 (#9941)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.0.0 to 3.2.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/f95db51fddba0c2d1ec667646a06c2ce06100226...2b51285047da1547ffb1b2203d8be4c0af6b1f20)

---
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>
2024-03-18 15:47:25 -07:00
Abtin Keshavarzian 8b906eb467 [routing-manager] simplify Ip6::Nd type usage (#9938)
This commit introduces `using` declarations in the `RoutingManager`
class for types defined within the `Ip6::Nd` namespace. This allows
for shorter, more readable type names to be used.
2024-03-15 13:37:23 -07:00
Jonathan Hui 148fa47bde [thread-cert] use unittest assert methods (#9936) 2024-03-15 11:11:51 -07:00
Abtin Keshavarzian 9d6321bdaa [lib] include (void) in function prototype in reset_util.h (#9934)
Addresses warnings generated on some toolchains.
2024-03-14 15:11:30 -07:00
Abtin Keshavarzian c89d4f0d80 [routing-manager] update use of Ip6::Nd::Option enumerator (#9931)
Avoid using the regular `enum` name when referring to one of its
enumerator value.
2024-03-14 14:44:07 -07:00
Abtin Keshavarzian ff3cc7ef69 [posix] remove use of core-internal types in netif.cpp platform (#9928)
Removes the use of `ot::Ip6::Address` and `OT_ASSERT()` in posix
`netif.cpp` module.
2024-03-14 13:43:48 -07:00
Abtin Keshavarzian 4c34a0e4a4 [test] enhance test_netdata_publisher robustness (#9932)
Updates validation logic after published route entry replacement to
prevent occasional failures due to a race condition. This increases
test stability.
2024-03-14 13:43:19 -07:00
Jonathan Hui 542be0f798 [thread-cert] use ROUTER_STARTUP_DELAY in test_detach (#9933) 2024-03-14 13:02:04 -07:00
Jonathan Hui e379f7ca6d [mle] disable MLE retransmissions when detaching (#9929)
When detaching, a child transmits a Child Update Request message with
Timeout TLV set to 0. The child waits for 1 second after sending the
Child Update Request message before stopping Thread
operation. However, during this time, the MLE retransmission timer may
fire and retransmit the Child Update Request message, which can cause
it to send a new Child Update Request message with a non-zero Timeout
TLV.

This commit update the behavior to avoid retransmitting the Child
Update Request message when detaching.
2024-03-14 08:56:07 -07:00
Yakun Xu 3ebc3d3a06 [simulation] allow specify local host (#9925)
This commit adds a argument `-L`/`--local-host` to simulation platform
to specify the source IP address for packets simulating 15.4
frames. This allows the simulation packets being transmitted over
different network interfaces, so that the simulation can run on
different hosts.

This can be used to enable multiple emulation devices(e.g. Android
Virtual Device) communicating to each other over emulated Thread
radio.

The argument accepts either an IPv4 address or a network interface
name. In the latter case, the first found IPv4 address on that
interface will be used will be used.
2024-03-13 11:42:53 -07:00
Abtin Keshavarzian cf6dcc5bc7 [routing-manager] construct RA dynamically using Heap::Array (#9924)
This commit enhances flexibility in Router Advertisement (RA) message
construction by employing `Heap::Array`. This eliminates the need for
a pre-allocated buffer and removes the constraint of predetermining
the maximum RA message size.

Additionally, introduces `TxMessage` and `RxMessage` nested classes
within `Ip6::Nd::RouterAdvert` for efficient handling of outgoing and
incoming RA messages:
- `TxMessage`: Facilitates appending elements to an RA message with
  dynamic buffer allocation.
- `RxMessage`: Enables parsing and iterating over options within a
  received RA message.
2024-03-13 11:15:49 -07:00
Abtin Keshavarzian c4d7859d07 [posix] ensure module names are included in platform logs (#9920)
This commit updates logging in posix platform modules so that the
emitted logs will include the platform log module name. This uses
the `otLogPlatArgs()`.
2024-03-13 11:12:10 -07:00
Handa Wang 8769898255 [tests] fix test_manual_maddress.py (#9923) 2024-03-12 18:50:41 -07:00
Jonathan Hui ec7781a57e [thread-cert] set device mode in test_mle_msg_key_seq_jump (#9921) 2024-03-12 15:37:09 -07:00
Abtin Keshavarzian 2e24098edc [posix] add IPv6 address helper functions in Ip6Utils (#9917)
These helpers are used in `posix/platform/udp.cpp` module.
2024-03-12 14:13:44 -07:00
Handa Wang be06d7c29a [daemon] always initialize the OT CLI when setting up the daemon (#9919)
Previously the OT CLI won't be reiniitalized when it finds there's
already a listening socket. It's actually necessary to do the
initialize, considering this scenario:
1. Run `otSysDeinit()` and `otSysInit()` to reset the OT application.
1. Note that the OT instance is replaced by a new one in `otSysInit()`. We need to
   call `otCliInit()` in `Daemon` to initialize the CLI with the new
   instance. However, this step has been skipped in `Daemon` because the
   listening socket is not cleared.
2024-03-12 09:29:52 -07:00
Li Cao 8e9d58f104 [misc] remove stale forward declaration (#9911) 2024-03-11 11:51:17 -07:00
dependabot[bot] e8f769fe81 github-actions: bump actions/upload-artifact from 4.2.0 to 4.3.1 (#9914)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.2.0 to 4.3.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/694cdabd8bdb0f10b2cea11669e1bf5453eed0a6...5d5d22a31266ced268874388b861e4b58bb5c2f3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2024-03-11 11:41:42 -07:00
Abtin Keshavarzian 2b4b2cfe63 [docs] add documentation for CLI dataset updater command (#9905) 2024-03-11 11:29:21 -07:00
Abtin Keshavarzian 518a849495 [test] add test_key_rotation_and_key_guard_time (#9906)
- Validates that key guard time is updated to 93% of key rotation
  time when it changes.
- Checks for proper key sequence updates after key rotation
  expiration.
- Confirms key guard mechanism blocks key sequence increments
  while mesh nodes staying connected.
2024-03-08 12:58:28 -08:00
Abtin Keshavarzian 53382ec9ed [srp-server] add snoop cache entries for registered host addresses (#9881)
This commit updates `Srp::Server` to add snooped cache entries in
address resolver cache table for all registered host addresses
received in an SRP update message.

Entries are added when an SRP update message is received directly from
a mesh device. The RLOC16 is looked up using `AddressResolver::Lookup()`
for the SRP Update message's sender IPv6 address (SRP client's address).
This leverages snoop entry created during UDP message processing
associating sender's IPv6 address with its RLOC16.

This commit adds a new test-case validating the new behavior.
2024-03-07 23:12:12 -08:00
Abtin Keshavarzian c66d91bdd7 [key-manager] update how key guard time is determined and applied (#9871)
This commit makes changes/fixes to `KeyManager` regarding key switch
guard time.

Key Rotation Time updates:
- When the Key Rotation Time changes (due to security policy updates),
  the key switch guard time (`mKeySwitchGuardTime`) is also adjusted.
  It's set to 93% of the Rotation Time (rounded down).
- Immediately checks if the new rotation time indicates a rotation is
  due and keys are rotated.

New variable `mKeySwitchGuardTimer`:
- This is reset to the current guard time whenever the key sequence is
  updated.
- It decrements hourly until reaching zero.
- Key switch guard comparison is made with this value, aligning the
  implementation with the Thread specification.

`SetCurrentKeySequence()` modification:
- Now accepts a new input parameter that determines whether to apply
  or ignore the key switch guard when updating the key sequence.
- During a key rotation check (when the rotation time has passed), the
  key switch guard is ignored and we always move to the next key
  sequence number.

Other changes:
- Variables handling guard and rotation time now use `uint16_t`
  instead of `uint32_t` to align with security policy definitions.
- API and CLI command documentation for setting the "key switch guard
  time" emphasize that they are intended for testing purposes.
2024-03-07 21:39:52 -08:00
Abtin Keshavarzian 5b88759da9 [toranj-config] disable OT_BORDER_ROUTING on NCP builds (#9907) 2024-03-07 19:05:51 -08:00
Abtin Keshavarzian 39fcc5ea53 [simulation] implement otPlatInfraIf APIs in simulation platform (#9895)
This commit implements a subset of `otPlatInfraIf` platform APIs in
simulation platforms using the `utilsSocket` to emulate communication
between BRs. This can be used for testing.

This commit also adds one (simple) example test case with two BRs
attached to two different network on same infra-if.
2024-03-06 13:26:06 -08:00
Tony Zhou 036f6eb649 [posix] add otSysCliInitUsingDaemon API (#9897)
This is to initialize CLI for daemon instance.

With this API, user can redirect the Vendor server CLI output when
needed, and then reset back using this API when the CLI output should
be restored.
2024-03-06 13:21:11 -08:00
Abtin Keshavarzian 125e72688b [routing-manager] delay sending RAs until after initial policy evaluation (#9896)
This commit modifies the `RoutingManager` to not send any Router
Advertisements (RAs) until the initial policy evaluation has
completed.

This change leverages the `IsInitialPolicyEvaluationDone()` method
which ensures that both OMR and on-link prefixes have been
determined. Specifically, this guarantees that we wait for the
initial set of Router Solicitation (RS) messages to be sent and that
we discover all other routers on the AIL before sending the first RA.
This is because on-link prefix evaluation itself is dependent on the
`mRsSender.IsInProgress()` check that waits till all RS messages are
sent and RAs from other routers are received and processed.

Without this change, the BR could receive its own RS message,
triggering it to send an RA prematurely, potentially with incorrect
M and O flags.
2024-03-06 11:23:08 -08:00
Abtin Keshavarzian d63da4f268 [posix] add missing header guards, style fixes (#9892)
This commit contains smaller changes in the `posix` platform modules:
- Adds missing header guard checks.
- Use consistent names for header guard defines.
- Fix/update comments.
2024-03-05 21:37:34 -08:00
Abtin Keshavarzian 44c39060cd [border-agent] mechanism to use ephemeral key (#9435)
This commit adds a new mechanism in `BorderAgent` to allow the use of
ephemeral key. New `otBorderAgentSetEphemeralKey` API is added to
allow user to set an ephemeral key. The ephemeral key is used
instead of PSKc from Operation Dataset for a given timeout duration.
New API `otBorderAgentClearEphemeralKey` allows users to cancel the
ephemeral key before its timeout expires. While the timeout interval
is in effect, the ephemeral key can be used only once by an external
commissioner to connect. Once the commissioner disconnects, the
ephemeral key is cleared, and Border Agent reverts to using PSKc.

This commit adds a callback mechanism to signal changes related to the
Border Agent's (BA) use of an ephemeral key. It is invoked when the
BA starts/stops using the key, or when parameters (e.g., port number)
change.

This commit also adds CLI command under `ba ephemeralkey` for the new
APIs along with test script validating the new APIs.
2024-03-05 13:53:31 -08:00
Abtin Keshavarzian 88b2b5c621 [posix] enable building infra_if.cpp on macOS (#9891)
This change makes it possible to build the `posix/platform/infra_if`
module on macOS (and other non-Linux systems). It adds guard checks
`#ifdef __linux__` around the use of `mNetLinkSocket`(used for
network interface state change detection). This allows compilation to
proceed on macOS, though equivalent functionality for detecting netif
change is not yet implemented.

This commit also adds a new `toranj-macos` workflow job to validate
that the code builds successfully with the `posix` platform.
2024-03-05 09:36:26 -08:00
Maciej Baczmański 08a7600e4a [string] return 0 if nullptr is passed to StringLength (#9886)
This commit ensures that segfault won't happen if
`nullptr` is passed  to `StringLength()`.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-03-04 10:21:29 -08:00
Abtin Keshavarzian 27eb8ed09f [posix] fix member var access from static CreateIcmp6Socket() (#9887)
Fixes accessing of member variables of `InfraNetif` from `static`
method `CreateIcmp6Socket()`.
2024-03-04 10:10:33 -08:00
dependabot[bot] badfaaf8de github-actions: bump github/codeql-action from 3.23.2 to 3.24.6 (#9890)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.23.2 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/b7bf0a3ed3ecfa44160715d7c442788f65f0f923...8a470fddafa5cbb6266ee11b37ef4d8aae19c571)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2024-03-04 08:31:30 -08:00
dependabot[bot] 41526d5de2 github-actions: bump codecov/codecov-action from 3.1.4 to 4.0.2 (#9877)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.4 to 4.0.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/eaaf4bedf32dbdc6b720b63067d99c4d77d6047d...0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-29 16:26:31 -08:00
Abtin Keshavarzian b9dcdbca4e [cli] add documentation for nexthop command in README.md (#9882) 2024-02-28 13:42:11 -08:00
Abtin Keshavarzian 5960215508 [simulation] add simul_utils.h for socket operation helpers (#9879)
This commit introduces a new module, `simul_utils.h`, under
`simulation` platform. This module provides common utility functions,
primarily related to socket operations (for emulation of radio or
TREL interface). The new functions are used by `radio.c` and
`trel.c`, consolidating code and preventing repetition.
2024-02-28 11:28:00 -08:00
Abtin Keshavarzian acfdcfd2ff [message] track received ThreadLinkInfo in Message metadata (#9878)
This commit changes how the link information is tracked for a received
message over Thread radio.

It removes the `const void *mLinkInfo` field in `otMessageInfo`.
Instead a new public API `otMessageGetThreadLinkInfo()` is added to
retrieve the `otThreadLinkInfo` from an `otMessage`.

All the `ThreadLinkInfo` properties are now directly tracked in
`Message` as part its `Metadata`. The `Message::Clone()` method is
updated to properly copy the link info from the original message to
its clones.

This change helps simplify the code, avoid passing `ThreadLinkInfo`
references. More importantly, it prevents potential errors due to
incorrect use of a pointer to stack-allocated `ThreadLinkInfo` object.
This is especially important for modules that save/enqueue `Message`
and its `Ip6::MessageInfo` for later use, ensuring link information
remains valid.
2024-02-28 10:50:03 -08:00
Ashish 37fef5ed54 [spinel] drop received frames between RCP disable and reset (#9793)
Signed-off-by: Ashishkumar Vara <ashish.vara@nxp.com>
2024-02-27 16:01:29 -08:00
Abtin Keshavarzian aff159f40c [link-quality] prevent overflow in LqiAverager calculation (#9876)
This commit updates `LqiAverager::Add()` to explicitly use a `uint16_t`
local variable for calculating the new running average. This prevents
potential overflows.
2024-02-26 18:37:46 -08:00
jrhodie ac417bdee7 [cli] add @moreinfo Doxygen tags to reference CoAPS Concepts Guide (#9867) 2024-02-26 10:25:13 -08:00
Abtin Keshavarzian 41d05c2a98 [core] use NumericLimits<> constants (#9875)
Use `NumericLimits<UintType>::kMax` constants in core files.
2024-02-26 08:38:48 -08:00
Abtin Keshavarzian f0b6fcea6e [cli-tcat] define VendorInfo as a member variable (#9869)
Changes `mVendorInfo` to be a member variable of `Tcat` class
instead of a static variable.
2024-02-22 11:30:23 -08:00
Abtin Keshavarzian a0d805c8f0 [cli] style fixes & remove core defined error constants (#9868)
This commit contains small changes in the CLI modules:

- Replace use of core-internal `kError` with `OT_ERROR` constants.
- Remove `#endif` comments when the corresponding `#if` is less
  than 20 lines away adhering to OT style guide.
- Adhere to single `return` policy (use `ExitNow()`).
- Avoid calling `static` method `ParseToIp6Address()` with an object.
- Smaller style fixes: New lines after variable declaration, use
  shorter local variable names, etc.
2024-02-22 11:29:38 -08:00
Yang Sun 3aa3cbc341 [ip6] add multicast forwarding restrictions to host (#9863)
On Android, the platform doesn't restrict link-local/mesh-local source
addresses when forwarding multicast packets. For multicast packets sent
from link-local/mesh-local address to scope larger than realm-local,
set the hoplimit to 1 so the packet can be delivered to host, and will
not be forwarded to infrastructure link.

The feature is guarded by OPENTHREAD_CONFIG_IP6_RESTRICT_FORWARDING_LARGER_SCOPE_MCAST_WITH_LOCAL_SRC,
set as 1 to enable.
2024-02-21 10:44:33 -08:00
Abtin Keshavarzian 00f22b52c9 [netdiag] update comments and fix style (#9866)
This commit contains smaller enhancements in `netdiag.h`:

- Changes TLV type constants to use `#define`.
- Removed unused definitions/constants.
- Move constants used by CLI module to related CLI method.
- Update comments and fix style.
2024-02-21 10:42:33 -08:00
jrhodie 6cfe14c941 [cli] add references to CoAP concepts guide from CLI (#9856) 2024-02-20 12:50:22 -08:00
Abtin Keshavarzian 08d21f1f07 [netdiag] add support for Vendor App URL TLV (#9816)
This commit contains the following:

- Adds support for the Vendor App URL TLV.
- Includes new public OT APIs and configurations to get and set the
  TLV value.
- Enables use of the TLV in the CLI `networkdiagnostic` command.
- Updates `test-020-net-diag-vendor-info.py` to validate the new TLV.
2024-02-20 12:49:42 -08:00
Maciej Baczmański 33574ad417 [tools] add missing tcat ble client files (#9857)
Some files were missing during repo migration, this commit adds them.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Co-authored-by: Piotr Jasinski <piotr.jasinski990@gmail.com>
Co-authored-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-02-16 11:12:57 -08:00
sarveshkumarv3 5a4fe05cb6 [mle] generate challenge for "Child Update Request" early (#9850)
This commit updates how random challenge is generated for "Child
Update Request" message sent by a parent during child restoration
(after parent reset/re-attach).

A random challenge is now generated and saved in the `Child` entry
when it is first initialized in `kRestoredState`. The
`SendChildUpdateRequest()` will use the saved challenge rather than
generating a new one.

This change prevents overwriting the saved challenge when the child is
also detached and happens to send a "Parent Request" in the window
where the parent transitions to the router/leader role and before the
parent sends the "Child Update Request". It ensures that the same
random challenge is included in both "Parent Response" and "Child
Update Response," guaranteeing proper acceptance of the
child's "Child ID request".

Co-authored-by: Abtin Keshavarzian <abtink@google.com>
2024-02-16 10:11:12 -08:00
Thomas 49c59ec519 [mbedtls] make debug logging independent from builtin (#9848)
Currently mbedtls debug logging can only be set for builtin
mbedtls. With an external mbedtls the log level does not get
configured. This commit removes the builtin requirement.
2024-02-14 11:03:17 -08:00
jrhodie 9b36a426e1 [cli] update coaps readme (#9849) 2024-02-14 10:47:44 -08:00
Abtin Keshavarzian e0294176c1 [slaac] implement address deprecation mechanism (#9585)
This commit implements address deprecation mechanism in `Slaac` class.
When a prefix is removed from Network Data, its corresponding SLAAC
address is not removed immediately. Instead, it is marked as
deprecated and its "preferred" flag is set to false. After a
deprecation interval (300 seconds), the deprecated address is
removed. If the prefix is re-added to Network Data before the
deprecation time elapses, the SLAAC address is also reinstated.

Since the number of SLAAC address entries is limited, non-deprecated
addresses are prioritized. This means that if a new entry is required
for a new prefix, the earliest deprecating entry can be evicted to
accommodate the new entry.

The `Slaac` module keeps track of the associated Domain IDs for
deprecating SLAAC prefixes, even if the related Prefix TLV has
already been removed from the Network Data. This information is used
during external route lookup in `NetworkData::Leader::RouteLookup()`
if a deprecating SLAAC address is used as the source address in
an outbound message, ensuring that the message is not dropped and
can be delivered.

This commit also adds a detailed test `test-027-slaac-address.py`
validating various behaviors of SLAAC module.
2024-02-13 14:40:55 -08:00
jrhodie 0f00846e7d [cli] add Doxygen tags for coaps commands (#9837) 2024-02-13 09:00:28 -08:00
Abtin Keshavarzian 91acbdd015 [instance] init BackboneRouter::Local before Mle (#9843)
This commit moves the `mBackboneRouterLocal` before `mMleRouter` in
`Instance` class to ensure that it is initialized and its constructor
is called before. This ensures when `Mle()` constructor invokes the
`ApplyNewMeshLocalPrefix()` method on `BackboneRouter::Local`, it
is already initialized.
2024-02-12 09:37:33 -08:00
Lorenzo Rai e092a1785a [csl] reset data poll timer after successful csl transmission (#9840)
Currently the the data poll timer is used to maintain synchronization
with the parent. It sends a data poll once per csl timeout. However
often this is not necessary as other packets that are sent cause
synchronization to be maintained. This commit resets the data poll
timer each time a frame containing the csl ie is successfully
transmitted.
2024-02-12 09:25:34 -08:00
dependabot[bot] a756481c3b github-actions: bump actions/setup-python from 4.7.1 to 5.0.0 (#9845)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.1 to 5.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236...0a5c61591373683505ea898e09a3ea4f39ef2b9c)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 09:20:39 -08:00
dependabot[bot] f94f824988 Bump grpcio from 1.53.0 to 1.53.2 in /tools/harness-simulation/harness (#9842)
Bumps [grpcio](https://github.com/grpc/grpc) from 1.53.0 to 1.53.2.
- [Release notes](https://github.com/grpc/grpc/releases)
- [Changelog](https://github.com/grpc/grpc/blob/master/doc/grpc_release_schedule.md)
- [Commits](https://github.com/grpc/grpc/compare/v1.53.0...v1.53.2)

---
updated-dependencies:
- dependency-name: grpcio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 08:57:11 -08:00
Abtin Keshavarzian b212a0a748 [srp] implement AdvertisingProxy and define Dnssd platform APIs (#9268)
This commit adds a generic SRP Advertising Proxy implementation to
OpenThread core, which uses a set of newly defined `otPlatDnssd`
platform APIs for DNS-SD (mDNS) support on infrastructure network on
a Border Router.

`Srp::Server` provides `ServiceUpdateHandler` callback mechanism that
allows platforms to implement their own advertising proxy function.
While this is still supported, the new generic advertising proxy
implementation makes it easier to port and support the proxy function
on new platforms. The platform needs to provide the DNS-SD platform
APIs, which are designed to be simple and easy to implement.

The `AdvertisingProxy` directly interacts with `Srp::Server` and its
registered `Host` and `Service` entries, tracking whether an entry
has been successfully advertised, is currently being advertised, or
has been replaced by a new registration.

The `AdvertisingProxy` ensures that consecutive SRP updates for the
same host or service are committed on the server in the order they
are received, even if their advertisements are finished in a
different order. This is important for SRP Replication support, as
the server may receive a large number of SRP updates back-to-back for
the same host.

The `AdvertisingProxy` will also register key records for SRP host and
service instance names. This will keep the claim on the name of a
removed entry while its key lease is not expired. It is also used
when an SRP host registration has no off-mesh routable address.

This commit adds a detailed unit test `test_srp_adv_proxy` that
validates the `AdvertisingProxy` under many scenarios. The test
covers a range of cases, including delayed registration callbacks and
timeouts, new registrations replacing outstanding advertisements,
platform DNS-SD state changes and failures, host address changes
adding/removing OMR addresses.
2024-02-09 10:43:47 -08:00
Piotr Jasinski 905a22e0c7 [tools] add tcat ble client (#9739)
Adds TCAT client implementation for BLE transport.

Signed-off-by: Piotr Jasinski <piotr.jasinski990@gmail.com>
Co-authored-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-02-07 13:13:12 -08:00
Jonathan Hui 869c2ded9c [mbedtls] update to 2.28.7 (#9835) 2024-02-07 13:09:43 -08:00
Abtin Keshavarzian aa8dfe10bd [ip6] simplify Ip6::SelectSourceAddress() (#9832)
This commit simplifies `Ip6::SelectSourceAddress()` by adding a new
boolean `newAddrIsPreferred` tracking whether the new address is
preferred over the previously chosen one as we iterate over all
addresses.
2024-02-07 10:38:57 -08:00
jrhodie ffe2f52579 [cli] add Doxygen tags to CoAP commands (#9821) 2024-02-06 08:37:19 -08:00
Abtin Keshavarzian 70b6c53bc1 [ip6] mesh-local addresses as preferred, platform control flag on host stack (#9815)
This commit updates mesh-local addresses to be marked as preferred
(reverting the change from #6532). This ensures that mesh-local
addresses are not skipped over in `Ip6::SelectSourceAddress()`.

The intention behind #6532 was to ensure that mesh-local addresses,
when added to the platform host IPv6 stack (such as lwIP or the Linux
kernel), are not preferred and therefore not selected by the host
stack as the source address of application layer traffic unless
explicitly assigned.

This PR delegates this responsibility to the platform code and updates
`posix/platform/netif` to change the preferred flag for mesh-local
addresses when adding them on the platform IPv6 stack.

To make this easier, the `otIp6AddressInfo` is updated to
include `mMeshLocal` to indicate whether or not the address is
mesh-local. `otNetifAddress` already provides such a variable.
2024-02-05 11:30:34 -08:00
dependabot[bot] df683aa5ae github-actions: bump step-security/harden-runner from 2.6.1 to 2.7.0 (#9831)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.6.1 to 2.7.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/eb238b55efaa70779f274895e782ed17c84f2895...63c24ba6bd7ba022e95695ff85de572c04a18142)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2024-02-05 10:31:53 -08:00
Abtin Keshavarzian 0c0cedc481 [ip6] SelectSourceAddress() rule 1 on preferring same address (#9830)
This commit moves the check for rule 1 on preferring same address as
the destination before the `(bestAddr == nullptr)` check. This
ensures that rule 1 will be correctly applied even when the address
happens to be first one in the `GetUnicastAddresses()` list.
2024-02-05 10:23:57 -08:00
Yakun Xu cf357d70be [posix] do not enable loop back to host (#9826)
There's no clear use case for looping back packets to host.
And it would probably result in host processing duplicate
messages. This commit disables looping packets back to host.
2024-02-02 12:38:15 -08:00
Yakun Xu 74c833b623 [ip6] always deliver multicast to host (#9824)
This commit always delivers multicast traffic to host.

Without this change, host will not be able to receive link-local and
mesh-local multicast traffic, even the host subscribes to some multicast
addresses in these scopes.

Note that this does not change the host forwarding rules, as link-local and
mesh-local traffic are not supposed to be forwarded to adjacent links.
2024-02-02 12:37:46 -08:00
Yakun Xu b5b9a62db7 [ncp] set message origin to host untrusted (#9825)
The IPv6 packets received from host is from a different network stack,
which is untrusted.
2024-02-02 11:43:31 -08:00
Jonathan Hui 890da2c1b8 [trel] fix typo in OPENTHREAD_CONFIG_TREL_PEER_TABLE_SIZE (#9823) 2024-02-02 09:03:51 -08:00
Yakun Xu b6e6b726ed [ci] fix artifact name conflict (#9827) 2024-02-02 09:01:46 -08:00
Abtin Keshavarzian 21cd366b50 [routing-manager] fix IsDeprecated() to handle large preferred lifetime (#9822)
This commit fixes `DiscoveredPrefixTable::Entry::IsDeprecated()` to
properly handle larger preferred lifetime values. It uses the method
`CalculateExpireDelay()` to handle time delay calculation, avoiding
overflow. The `test_routing_manager` test has also been updated to
check for larger preferred/valid lifetime values.
2024-02-01 19:04:54 -08:00
Abtin Keshavarzian 686eb30e9a [common] add ClearAllBytes() template function (#9818)
This commit introduces the `ClearAllBytes<ObjectType>()` template
function to zero out all bytes within an object. This replaces
`memset(0)` calls in OT core modules, simplifying code and improving
safety by automatically using the correct object size.
2024-02-01 11:58:47 -08:00
Abtin Keshavarzian fffb489b26 [netdata-publisher] remove SRP unicast on anycast entry added by a BR (#9807)
This commit updates how the `NetworkData::Publisher` handles "DNS/SRP
Service Unicast Address" entries. Specifically, when a "DNS/SRP
Service Anycast" entry is added by another BR, the publisher will set
the desired count of unicast entries to zero. This effectively
removes any previously added unicast entry. This new behavior is
only applied when the address and port are included in the Server TLV
data in a "DNS/SRP Service Unicast Address" entry.

The `test_netdata_publisher` has been updated to verify this new
behavior.
2024-02-01 11:28:00 -08:00
Jonathan Hui ce8bbfe05a [codecov] enable use of CODECOV_TOKEN (#9819) 2024-01-31 22:56:47 -08:00
gytxxsy 456c448284 [spinel] allow registering callback to restore vendor properties (#9773)
urrently the `RadioSpinel::RestoreProperties` only restores some
properties defined in `spinel.h`.  But if
`OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE` is selected, users may
set some properties of RCP via vendor command. So the radio spinel
should allow users to register a callback to restore the vendor
properties of RCP.
2024-01-31 15:56:24 -08:00
hemanth-silabs 75abc7c871 [key-manager] check if the key is present before exporting the key (#9814)
While trying to read the Pskc or networkkey, we check if the keyref is
valid. We instead need to check if the key is present. There is a
possibility that the persistent data was erased before trying to read
the key, which might result in asserts.
2024-01-31 12:17:26 -08:00
jrhodie 176be05644 [cli] commissioner commands (#9798) 2024-01-31 11:07:51 -08:00
Zhangwx bdb580763b [spinel] fix set rx on when idle for RCP (#9812)
In #9554, a new radio capability is introduced: `RX_ON_WHEN_IDLE`. On
the RCP scenario, if recoverd, there will be an error:
```
OPENTHREAD:[W] P-RadioSpinel-: Error processing result: NotImplemented
OPENTHREAD:[W] P-RadioSpinel-: Error waiting response: NotImplemented
```

When set the rx on when idle on Host to RCP, no `Set property handler`
will be found due to the target handler was surround by the macro
`OPENTHREAD_MTD || OPENTHREAD_FTD`. This `rx on when idle` capability
should not only be used for MTD and FTD, but also used for RADIO on a
NCP. This PR fixes it.
2024-01-30 11:09:17 -08:00
Rongli Sun c73829fdbf [net-diag] add Eui64Tlv support (#9795) 2024-01-29 16:02:50 -08:00
dependabot[bot] 4dae833c54 github-actions: bump github/codeql-action from 2.22.5 to 3.23.2 (#9810)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.5 to 3.23.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/74483a38d39275f33fcff5f35b679b5ca4a26a99...b7bf0a3ed3ecfa44160715d7c442788f65f0f923)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-29 09:41:19 -08:00
parag-silabs bf587dd090 [multipan] Fix for multipan use case to handle tx timeout. (#9781)
There are two changes:
1. Address the issue of handling tx timeout in case of multipan
   enabled. When RCP recovery initiates due to a timeout, the SPINEL
   attempts to transition to the Rx state and switch channels to
   initialize the RCP. However, these actions should be ignored when
   operating as Multiprotocol RCP, as another host/protocol might be
   scanning, and encountering the Rx state or channel switch could
   result in an error. Considering such scenarios, ignore the error
   rather than assert it for multipan.
2. Make the CMake option OT_MULTIPAN_RCP depend on the compile time
   value OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE, rather than being
   initialized to OFF.
2024-01-26 16:01:35 -08:00
Abtin Keshavarzian f718ad7a09 [coap-secure] fix and test to validate max connection attempt limit (#9803)
This commit contains the following
- It fixes `SecureTransport` to ensure we do the max connection
  attempt check when transitioning from `kStateCloseNotify`.
- It adds new public `otCoapSecure` APIs to start the agent with a
  given max connection attempts, and to check the agent's state,
  whether it is connected, connecting or closed.
- It adds CLI commands under `coaps` for the new APIs.
- It adds `test-026-coaps-conn-limit.py` to validate the max
  connection attempt limit of CoAP secure agent.
2024-01-26 15:59:49 -08:00
Abtin Keshavarzian dacdc7d36f [ip6] add method for creating/parsing IPv4-mapped IPv6 address (#9799)
The IPv4-mapped IPv6 address is useful in certain platform/public
APIs where we need to support both IPv6 or IPv4 address. We can
use IPv4-mapped IPv6 address to represent an IPv4 address. This
commit adds simple helper functions to validate, create and
parse such addresses.
2024-01-25 15:14:58 -08:00
Abtin Keshavarzian 81106dff88 [coap-secure] introduce maximum connection attempt limit for CoAP agent (#9694)
This commit introduces a new feature in `SecureTransport` and
`CoapSecure` that allows us to specify the maximum number of allowed
connection attempts before the socket is automatically closed and the
CoAP agent is stopped. This can be used to enhance security by
preventing attacks and excessive retries. This commit also adds a
callback mechanism to notify when the limit is reached and the CoAP
agent is stopped.
2024-01-25 14:47:49 -08:00
whd b2c8147a31 [border-agent] enable otBorderAgentGetId API when Border Agent is enabled (#9794)
This could simplify the build configuration by omitting
`OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE`.
2024-01-25 09:28:06 -08:00
Zhangwx ab28127a2a [spinel] fix passing an unexpected transmit error to mac layer (#9745)
For the Spinel layer, when the state is transmitting, if the received
Spinel frame fails parsing, the current implementation passes the
`OT_ERROR_PARSE` error code to the sub_mac layer via the tx done
handler. This causes an assert because the error code `OT_ERROR_PARSE`
is not a valid one for `SubMac::HandleTransmitDone`. Additionally, I
believe that when the received Spinel frame fails parsing, we should
not trigger a transmit done to the sub_mac layer, as the `TxFrame` and
the `AckFrame` may not be valid for further processing.

In this corner case, I suggest considering ignoring the parsing-failed
received packets, waiting for the tx timeout, and then raising a tx
timeout failure to recover the RCP. This might be a reasonable
approach.
2024-01-24 15:05:36 -08:00
jrhodie 7a2983b01c [docs] add TREL config group (#9791) 2024-01-23 10:07:51 -08:00
Abtin Keshavarzian 7761b81d23 [cli] use static constexpr for constants instead of of enum (#9789) 2024-01-22 23:08:29 -08:00
Maciej Baczmański 84e0e77ce2 [radio] add API for resetting CSL parameters (#9772)
Add `ResetCsl` and `otPlatRadioResetCsl`
This allows handling stack reset as separate call instead of
using `kShortAddrInvalid` as `otShortAddress` and
`nullptr` as `otExtAddress` which can be difficult to handle
on vendor's side.

Default implementation still calls
`otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr)`
So no action is needed if vendor has already implemented handling
this case.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-22 16:37:22 -08:00
dependabot[bot] fab2c9ac2d github-actions: bump actions/upload-artifact from 3.1.3 to 4.2.0 (#9788)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.3 to 4.2.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3.1.3...694cdabd8bdb0f10b2cea11669e1bf5453eed0a6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-22 09:07:19 -08:00
Kangping 6ca49027f5 [posix] use /dev/socket/ot-daemon for OT daemon socket (#9776)
Android traditioanlly use /dev/socket/ directory for unix sockets of
system services. This commit changes ot-daemon to use
"/dev/socket/ot-daemon".

In additional, this disables the .lock file which is not needed
for Android and can't be created along with the socket file

Resolves comments in aosp/2891476
2024-01-22 08:31:35 -08:00
Li Cao 00076aff3a [posix] fix netlink address deletion on posix (#9779) 2024-01-19 14:16:28 -08:00
Jonathan Hui a0b9ac74f1 [github-actions] remove use of geekyeggo/delete-artifact (#9785)
Simply set retention to 1 day for coverage artifacts.
2024-01-18 15:22:25 -08:00
Abtin Keshavarzian f75e2bb567 [net-diag] handle MleCounterTlv in AppendDiagTlv() (#9777)
Adds support for responding to `MleCounterTlv` in `AppendDiagTlv()`
Processing the TLV is a received response is already implemented
and supported. Updates `test-020-net-diag` to check query of MLE
counters TLV.
2024-01-17 07:23:20 -08:00
Jonathan Hui 4a6ebf0983 [github-actions] add write permissions for geekyeggo/delete-artifact (#9780) 2024-01-17 07:04:35 -08:00
dependabot[bot] f621312a45 github-actions: bump geekyeggo/delete-artifact from 2.0.0 to 4.1.0 (#9774)
Bumps [geekyeggo/delete-artifact](https://github.com/geekyeggo/delete-artifact) from 2.0.0 to 4.1.0.
- [Release notes](https://github.com/geekyeggo/delete-artifact/releases)
- [Changelog](https://github.com/GeekyEggo/delete-artifact/blob/main/CHANGELOG.md)
- [Commits](https://github.com/geekyeggo/delete-artifact/compare/54ab544f12cdb7b71613a16a2b5a37a9ade990af...65041433121f7239077fa20be14c0690f70569de)

---
updated-dependencies:
- dependency-name: geekyeggo/delete-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-16 18:05:34 -08:00
Jonathan Hui f1e74a036b [github-actions] bump actions/upload-artifact and actions/download-artifact (#9769)
- actions/upload-artifact from 3.1.3 to 4.0.0
- actions/download-artifact from 3.0.2 to 4.1.1
2024-01-12 10:56:06 -08:00
Jonathan Hui 6be1901dfa [tcat] define config defaults (#9768) 2024-01-12 10:55:41 -08:00
Stefan Agner 71aed827d5 [posix] only add IPv4 route if NAT64 is enabled (#9762)
Currently, when netlink informs that the network interface is up, an
IPv4 route is added if a valid one is specified. However, elsewhere we
only add/update the route when NAT64 is actually enabled. Since IPv4
route is not useful when NAT64 is not enabled, apply the same logic when
the network interface is started.

This avoids warnings when NAT64 is compiled in but disabled:
incoming message is an IPv4 datagram but no NAT64 prefix configured, drop
2024-01-11 17:57:29 -08:00
Przemysław Bida 557ecf925f [srp] simplify crypto ReadOrGenerateKey in srp client (#9764)
In method `ReadOrGenerateKey` removing call to `GetPublicKey`
which was unnecessary operation (value was't used afterward).
2024-01-11 11:04:55 -08:00
SherySheng 5576e0ce0d [cli] add pd state (#9757) 2024-01-11 10:13:24 -08:00
Jonathan Hui 2a2545348d [dtls] fix OPENTHREAD_CONFIG_DTLS_ENABLE check (#9767) 2024-01-11 08:41:30 -08:00
Abtin Keshavarzian 2b0e2af98a [test] move heap plat APIs in unit test under extern "C" block (#9766) 2024-01-11 08:41:17 -08:00
Abtin Keshavarzian b28bb1d1e0 [srp] update config for auto-start mode to be enabled by default (#9738)
Config `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE` is
changed to use `1` by default (unless explicitly overridden in
project configs).

It also updates related test scripts to utilize auto-start mode or
explicitly disable it for manual SRP client control, reflecting this
default change.
2024-01-10 10:37:03 -08:00
Li Cao 36133b93c2 [ncp] differentiate DETACHED role and DISABLED role (#9760) 2024-01-09 23:17:28 -08:00
gavinmcgovern 83d3800db3 [docs] add Aqara to who supports list (#9758) 2024-01-09 22:48:00 -08:00
Li Cao 29177dbbae [cli] separate ping sender as a module (#9756) 2024-01-09 14:41:22 -08:00
jrhodie f40eeeb145 [docs] fixed some common typos (#9752) 2024-01-08 13:55:25 -08:00
Yang Liu d81c6fab98 [telemetry] add API for TREL telemetry (#9710)
Create OT API to support trel telemetry which is supported through
platform API and also add cli support to get/reset trel counters.

Metrics we are adding are:
- trel_frames_tx
- trel_bytes_tx
- trel_frames_rx
- trel_bytes_rx
- trel_frames_tx_failed
- num_trel_peers

Metrics already supported through API:
- trel_enabled
2024-01-05 22:10:27 -08:00
dependabot[bot] 09d07a7c6a Bump pycryptodome from 3.17 to 3.19.1 in /tests/scripts/thread-cert (#9755)
Bumps [pycryptodome](https://github.com/Legrandin/pycryptodome) from 3.17 to 3.19.1.
- [Release notes](https://github.com/Legrandin/pycryptodome/releases)
- [Changelog](https://github.com/Legrandin/pycryptodome/blob/master/Changelog.rst)
- [Commits](https://github.com/Legrandin/pycryptodome/compare/v3.17.0...v3.19.1)

---
updated-dependencies:
- dependency-name: pycryptodome
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-05 17:23:20 -08:00
Yang Liu 5197402363 [trel] add config for peer table size and packet pool size (#9750) 2024-01-04 22:10:24 -08:00
jrhodie d02c4be821 [cli] add Doxygen tags for history commands (#9751) 2024-01-04 16:45:40 -08:00
SherySheng ee745130c7 [telemetry] add upstream DNS metrics (#9729) 2024-01-03 17:35:17 -08:00
Abtin Keshavarzian 666a9bd076 [dns] add Name::ComapreMultipleLabels() and update Matches() (#9744)
This commit introduces a new method, `Name::CompareMultipleLabels()`,
to efficiently parse and compare multiple DNS name labels directly
from a message. This is then used to optimize `Name::Matches()`
eliminating the need to read the entire name into a separate buffer.

This commit also updates `Name::Matches()` method to treat the
first label as a single label allowing it to include dot character
(which is useful for service instance label).

Additionally, `test_dns` unit test is updated to validate the
functionality of the new methods.
2023-12-28 18:26:35 -08:00
Abtin Keshavarzian 3f99b118d4 [dns] clarify trailing dot in Name::ExtractLabels() (#9743)
This commit updates `ExtractLabels()` documentation to clarify that
name and suffix name can include or exclude the trailing dot but both
inputs must follow the same style. It also updates `test_dns` unit
test to validate this behavior.
2023-12-27 22:10:53 -08:00
Abtin Keshavarzian 6751122f0a [heap-data] add Matches() to compare Heap::Data with a given buffer (#9740)
Also updates the unit test to validate the new method.
2023-12-26 07:51:38 -08:00
SherySheng 8167fb3626 [posix] ignore required anycast address (#9717)
Ignore Required Anycast address when it is added to or deleted from
wpan0 interface in openthread.
2023-12-26 07:47:47 -08:00
Jonathan Hui 1e82c4e962 [cmake] always define OPENTHREAD_FTD/MTD/RADIO (#9733) 2023-12-20 14:44:41 -08:00
Abtin Keshavarzian 51a682ec0e [dns] add Name::Matches() to compare DNS names (#9734)
This commit adds `Name::Matches()` method which compares a `Name`
instance (which can be from a C string or encoded in a `Message`)
with a given set of labels and domain name strings. This method
allows the caller to specify name components separately, enabling
scenarios like comparing "service instance name" with separate
instance label, service type, and domain strings. Unit test
`test_dns` is also updated to validate the behavior of the newly
added method.
2023-12-20 14:20:58 -08:00
jrhodie 16596a38c3 [docs] create config variables list (#9721) 2023-12-20 12:51:50 -08:00
Jonathan Hui 1d126effb9 [factory-diags] fix usage of OPENTHREAD_RADIO (#9736) 2023-12-20 11:32:00 -08:00
Li Cao 55cc30b482 [spinel] add spinel net role DISABLED (#9731)
This commit adds net role 'DISABLED' into `spinel_net_role_t` to
differentiate between 'DISABLED' and 'DETACHED' status of NCP.

Since this is only used for NCP and not related with RCP, the
`RCP_API_VERSION` is not updated.
2023-12-20 11:27:33 -08:00
Abtin Keshavarzian a492d04a31 [dns-types] add template variants of reading DNS names or labels (#9720)
This commit introduces template variants for `ReadName()` and other
related methods, allowing flexible reading of DNS names and labels
from messages into a given array buffer. This simplifies the code and
improves readability.

Additionally, this commit defines new types, `Dns::Name::Buffer` and
`Dns::Name::LabelBuffer`, as arrays of char with fixed sizes to hold
DNS names and labels, respectively.
2023-12-19 10:45:46 -08:00
Eduardo Montoya eec54ef46d [github-actions] avoid dependabot pull requests in forks (#9728)
OpenThread forks typically inherit all commits in the repo, including
the `dependabot` changes, so it's not needed to generate the same PRs
in the forks as well.
2023-12-19 08:37:16 -08:00
jrhodie 3400692b03 [config] fix typos in config docs (#9725) 2023-12-19 08:07:47 -08:00
Jonathan Hui 8243591781 [spinel] fix OPENTHREAD_ENABLE_SPINEL_VENDOR_HOOK (#9718)
`OPENTHREAD_ENABLE_SPINEL_VENDOR_HOOK` was not consistent with the
intended `OPENTHREAD_SPINEL_CONFIG_ENABLE_VENDOR_HOOK`.

Rename `OPENTHREAD_SPINEL_CONFIG_ENABLE_VENDOR_HOOK` to
`OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE` for consistency with
other configs.
2023-12-18 14:48:21 -08:00
dependabot[bot] 5ceb5873c7 github-actions: bump docker/login-action from 2.2.0 to 3.0.0 (#9723)
Bumps [docker/login-action](https://github.com/docker/login-action) from 2.2.0 to 3.0.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/465a07811f14bebb1938fbed4728c6a1ff8901fc...343f7c4344506bcbf9b4de18042ae17996df046d)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 10:49:19 -08:00
Zhanglong Xia cca77a7948 [posix] prevent implicit conversion of aUrl to RadioUrl (#9722)
When compiling `mRadioUrl=aUrl` in `Radio::Init()`, some compilers may
implicitly convert `aUrl` to a temporary `RadioUrl` object and then
copy the temporary `RadioUrl` to `mRadioUrl` via a default copy
constructor. The pointer members of `mRadioUrl` point to the content
of the temporary `RadioUrl`, and it eventually causes the program to
access the memory that has been released, which causes the program to
crash.

This commit disables the compiler from implicitly converting `aUrl` to
a `RadioUrl` object and deletes the default copy and move
constructors.
2023-12-18 10:37:31 -08:00
Jonathan Hui 551df11ec1 [posix] fix circular dependency on OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE (#9719) 2023-12-18 10:35:26 -08:00
Jonathan Hui ac7f75181c [posix] fix usage of __linux__ (#9714)
Should be checking for definition rather than value.

Also prefer `#ifdef` over `#if defined`
2023-12-14 20:54:50 -08:00
jrhodie 266a97b80a [docs] reference groups added and typos fixed (#9709) 2023-12-13 12:18:40 -08:00
Jake Swensen de67820c3c [cmake] config posix config file runtime location (#9701)
OpenThread defines a structure to supply runtime configuration files
on a POSIX platform. These runtime configuration files contain factory
and product configuration information. They can include information
such as radio target power, region, and calibration settings.

By default, OpenThread uses an example file located at
`src/posix/platform/openthread.conf.example`. However, the file
location can be modified by supplying a pre-processor definition.

This approach has a few flaws:
- The pre-processor definitions are not accessible outside of the
  OpenThread project structure.
- In order to change the values in project, a new header file must
  be provided, the existing one modified, or the value forcibly set
  in the OpenThread cmake file.

This change introduces OT_POSIX_FACTORY_CONFIG and OT_POSIX_PRODUCT_CONFIG
to the project cmake structure. These values allow projects that are
using OpenThread as a sub-project to pass in these runtime config paths
at compile time. This offers project maintainers flexibility in how
their project is configured.
2023-12-13 11:02:43 -08:00
Jake Swensen 83fb6c29b1 [cmake] posix platform runtime configuration file (#9701)
Allow selection of the POSIX runtime configuration file feature
at build time.
2023-12-13 11:02:43 -08:00
Jake Swensen 3e9e936d65 [cmake] platform power calibration enable (#9701)
Allow selection of the platform power calibration feature at build time.
2023-12-13 11:02:43 -08:00
Przemysław Bida 35424b375a [posix] verify in otPlatUdpBindToNetif if Backbone Interface is set. (#9696)
Commit adds check to `otPlatUdpBindToNetif` if backbone interface is
set to correct value to prevent `setsockopt` from crashing the
ot-daemon.
2023-12-12 18:28:26 -08:00
Abtin Keshavarzian a62e238b7f [unit-test] make sure otPlatLog() is defined as extern "C" (#9711)
This ensures that the function defined in the unit test would be
correctly picked over weak implementations.
2023-12-12 17:39:02 -08:00
Abtin Keshavarzian fd02db638e [routing-manager] advertise local OMR in RA after present in netdata (#9703)
This commit adds `OmrPrefixManager::ShouldAdvertiseLocalAsRio()` which
determines whether the local OMR prefix should be advertised as RIO
in emitted RAs. To advertise, we must have decided to publish it, and
it must already be added and present in the Network Data. This
ensures that we only advertise the local OMR prefix in emitted RAs
when, as a Border Router, we can accept and route messages using an
OMR-based address destination, which requires the prefix to be
present in Network Data. Similarly, we stop advertising (and start
deprecating) the OMR prefix in RAs as soon as we decide to remove it.
After requesting its removal from Network Data, it may still be
present in Network Data for a short interval due to delays in
registering changes with the leader.
2023-12-12 12:17:24 -08:00
jrhodie 12af023121 [cli] add aliases for TCP and SRP concepts guides (#9707)
* Adding aliases for TCP and SRP concepts guides

* TCP and SRP concept guides now referenced by Command Ref CLIs
2023-12-11 15:28:40 -08:00
Abtin Keshavarzian 879fdfa12b [routing-manager] deprecate OMR/on-mesh prefixes when removed from netdata (#9599)
This commit adds `RioAdvertiser` component to `RoutingManager`, which
manages the list of prefixes advertised as RIO in emitted RA messages
by BR. The RIO prefixes are discovered from on-mesh prefixes in
Thread Network Data, including OMR prefixes from `OmrPrefixManager`
and other prefixes. Existing code for maintaining the list, appending
RIOs, and determining/setting the RIO preference is moved to the
`RioAdvertiser` class.

The `RioAdvertiser` adds a new mechanism to deprecate prefixes removed
from Network Data such that any removed prefix is still advertised as
RIO in emitted RA messages up to a deprecation interval of 300
seconds (using a shorter route lifetime in RIO). This mechanism
ensures that when an OMR prefix is withdrawn, traffic can still be
routed during deprecation time from AIL to Thread devices using the
old OMR address.

This commit also updates `test_routing_manager` to validate the new
behavior.
2023-12-11 15:28:15 -08:00
dependabot[bot] c08316fad6 github-actions: bump actions/setup-go from 4.1.0 to 5.0.0 (#9706)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.1.0 to 5.0.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/93397bea11091df50f3d7e59dc26a7711a8bcfbe...0c52d547c9bc32b1aa3301fd7a9cb496313a4491)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-11 09:53:36 -08:00
jrhodie ae6eff5f21 [docs] SRP README update minor fix (#9702) 2023-12-08 18:58:32 -08:00
Abtin Keshavarzian acd16029a7 [cli] add debug command (#9587)
This commit adds cli `debug` command. This command is specifically
designed for testing and debugging purposes. It executes a series of
CLI commands to gather information about the device and thread
network.
2023-12-08 15:56:13 -08:00
Jonathan Hui 70128e06be [github-actions] add arm-gcc-13 to build check (#9695) 2023-12-08 09:57:33 -08:00
Abtin Keshavarzian bf9944887d [secure-transport] add SetState() and log state changes (#9692)
This commit adds `SetState()` in `SecureTransport` class which
also logs the state changes. New helper methods `IsState{}()` is also
added to simplify the code.
2023-12-07 08:50:08 -08:00
Nouman Bashir 5318d421cf [mle] fix uninitialized mLinkRequestAttempts (#9689)
mLinkRequestAttempts is not initialized to zero causing it to get a
random value during power cycle. This causes MTD thread device to send
linkrequest after power cycle.

Create a thread network with two devices with DUT with mode rn. Reset
both devices simultaneously, enable leader and then child device
(DUT). Because class member variable mLinkRequestAttempts is not
initialized to zero during initialization, it will get random value,
and value greater than zero will lead to send a link request message
which should not be the case for a MTD device.
2023-12-06 21:28:42 -08:00
whd 97af664036 [tests] reduce flakiness of test_publish_meshcop_service.py (#9690) 2023-12-06 20:57:00 -08:00
Abtin Keshavarzian 76d0c6e6c5 [coap] remove duplicate method for setting ConnectedCallback (#9691)
This commit removes `CoapSecure::SetClientConnectedCallback()` which
is the same as `SetConnectedCallback()`.
2023-12-06 14:46:16 -08:00
parag-silabs 6e7135e4e1 [spinel] make kTxWaitUs configurable during compile time (#9687)
It is useful in case RCP needs to wait for longer than the hardcoded
value in kTxWaitUs.
2023-12-06 14:42:37 -08:00
Przemysław Bida 8e1ce4bd4a [secure-transport] rename HandleUdpReceive to HandleReceive (#9686)
This commit documents `HandleReceive` previously called
`HandleUdpReceive`.
2023-12-06 14:41:09 -08:00
Abtin Keshavarzian 001b01ee32 [mesh-forwarder] finalize message direct tx on drop or eviction (#9682)
This commit adds `FinalizeMessageDirectTx()`, which clears the
`DirectTx` flag on a given message, updates the IPv6 counter, and
signals other modules about the transmission status(particularly for
`MleDiscoverRequest` and `MleChildIdRequest` messages so their
internal state can be updated).

This commit ensures `FinalizeMessageDirectTx()` is called in various
scenarios:
- Successful message delivery (all fragments reach destination).
- Any fragment transmission failure (frame tx failure)
- Message drop due to address query failure or malformed message.
- Message drop by queue management.
- Message eviction to prioritize higher-priority messages.

This commit also updates `DiscoverScanner` to stop an ongoing discover
scan if the "MLE Discover Request" message transmission fails with error
other than CSMA error. This is necessary because the `DiscoverScanner`
reuses the same `Message` instance for tx on different scan channels.
If the `Message` is freed (e.g., evicted), the `Message` cannot be
reused.

Finally, this commit renames `RemoveMessage()` to `EvictMessage()` to
clarify the purpose and usage of this method.
2023-12-05 13:22:29 -08:00
Abtin Keshavarzian 3754174c54 [meshcop-tlvs] simplify and enhance ChannelMaskTlv (#9675)
This commit simplifies `ChannelMaskTlv` generation and parsing.
Notably, it ensures that when we read this TLV from a `Message` the
TLV value format is validated. The changes include:
- `Entry` class representing a channel page entry is now defined as
  a `private` nested class within `ChannelMaskTlv`.
- A shared `EntriesData::Parse()` method is added that validates and
  parses the entries in the TLV, whether the TLV value resides in a
  buffer (e.g., within `Dataset`) or in a `Message`.
- `ChannelMaskTlv::AppendTo()` method is added to construct entries
  from a given combined channel mask (for all pages) and append the
  `ChannelMaskTlv` to a given `Message`.
- `Radio::kSupportedChannelPages` is changed to an array
  (containing all supported pages) instead of mask.
- Helper functions added in `Radio`, `SupportsChannelPage()` to
  verify if a channel page is supported by the radio, and
  `ChannelMaskForPage()` to obtain the supported channel mask for
  a given page.
2023-12-05 10:54:17 -08:00
whd 4ed44bc7d5 [tests] rename get_netdata_nat64_prefix() to get_netdata_nat64_routes() (#9678) 2023-12-04 22:59:13 -08:00
whd 11622a1b4a [posix] expose platformInfraIfIsRunning() as otSysInfraIfIsRunning() (#9672)
When we are switching to another infra netif via
`otBorderRoutingInit()`, we may want to read the state of the new
infra netif via `otSysInfraIfIsRunning()`.
2023-12-04 22:58:23 -08:00
SherySheng 19af7118b0 [telemetry] add api for DHCPv6 PD telemetry (#9645) 2023-12-04 14:42:51 -08:00
Joakim Andersson e76ddf1050 [crypto] remove PSA mbedtls hybrid setup of PBKDF2 function (#9655)
Remove PSA mbedtls hybrid setup of the PBKDF2 function.
With Mbed TLS 3.5.0 release this function is now supported by PSA
implementation.
2023-12-04 13:24:00 -08:00
Joakim Andersson 93ad604524 [crypto] add error handling to PBDF2 generate key function (#9655)
Add error handling to PBKDF2 generate key function.
The PBKDF2 functions may fail and the error should be handled by the
caller of the function.
2023-12-04 13:24:00 -08:00
Przemysław Bida 5cab15840d [tcat] initial commit of bluetooth-based commissioning (#9210)
This commit introduces first implementation of Bluetooth based
comissioning for thread devices.

Co-authored-by: Arnulf Rupp <a.rupp@inventronicsglobal.com>
Co-authored-by: Piotr Jasinski <piotr.jasinski@nordicsemi.no>
2023-12-04 12:09:25 -08:00
Thomas 3d01ffa65c [spinel] add vendor hook for the spinel host side (#9560)
Allow out-of-tree compilation of vendor specific changes to the host
side of spinel.  By setting `OT_SPINEL_VENDOR_HOOK_SOURCE_DIR`,
`OT_SPINEL_VENDOR_HOOK_SOURCE` and `OT_SPINEL_VENDOR_HOOK_HEADER`, the
corresponding compile flags
`OPENTHREAD_SPINEL_CONFIG_ENABLE_VENDOR_HOOK` and
`OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_HEADER` get set which force the
use of the `VendorRadioSpinel` class instead of the regular
`RadioSpinel` in `src/Posix/platform/radio`.
2023-12-04 09:28:05 -08:00
dependabot[bot] 2d030c4a8e github-actions: bump actions/setup-python from 4.7.0 to 4.7.1 (#9677)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.0 to 4.7.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/61a6322f88396a6271a6ee3565807d608ecaddd1...65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2023-12-04 08:47:54 -08:00
Abtin Keshavarzian c378bd9a25 [meshcop] MeshCoP::ChannelTlv to utilize Mle::ChannelTlvValue (#9674)
This commit introduces `IsValid()` and `SetChannelAndPage()` methods
to `Mle::ChannelTlvValue`, enabling its use as value of
`MeshCoP::ChannelTlv`.
2023-12-04 08:22:47 -08:00
Abtin Keshavarzian b78b71b537 [srp-client] track registered addresses (#9652)
This commit enhances the SRP client to track registered addresses when
auto host address mode is enabled. A new field `mSrpRegistered` is
added to `Ip6::Netif::UnicastAddress` to track whether the address is
registered by the SRP client.

This optimization ensures that the SRP client only performs
registration when there is a change to the list of addresses that
need to be registered, preventing unnecessary re-registration and
reduces communication overhead, e.g., when a deprecating
non-preferred address which is not registered by SRP client is timed
out and removed.
2023-12-01 10:14:44 -08:00
jrhodie 2b57941b85 [cli] SRP Server Readme update - add srp server auto command (#9669) 2023-12-01 09:40:19 -08:00
Abtin Keshavarzian a1816c1564 [meshcop-tlvs] update name style in DiscoveryResponseTlv (#9671)
`CCM` has been replaced with `Ccm` to follow the naming style
conversion for constants and variable names.
2023-11-30 22:48:05 -08:00
Abtin Keshavarzian 685094b378 [dataset] introduce WriteTlv() methods (#9664)
This commit adds different flavors of `WriteTlv()` including template
version as `Write<SimpleTlvType>()`. These methods write or update a
TLV in `Dataset`. The new methods replace the previous `SetTlv()`
methods. This new approach introduces type safety checks during
compilation, guaranteeing the use of the correct value type for each
TLV. For instance, `Write<PanIdTlv>()` only accepts `uint16_t` value,
while `Write<NetworkKeyTlv>()` only accepts `NetworkKey` value. This
commit also renames the previous `GetTlv()` to `FindTlv()`.
2023-11-30 21:29:12 -08:00
Song GUO 5665de2694 [posix] fix a few compiler warnings around nat64 (#9666)
Clang Compilers warns about ignoring return values.

This commit does not change the existing behavior.

Ignoring errors in `processNat64StateChange` should be safe, and we
may work under downgraded experience.

Ignoring errors in `nat64Init` should be safe like the outter if.
2023-11-30 21:28:33 -08:00
Abtin Keshavarzian bbb161b6d4 [test] update channel-announce-recovery test to check router recovery (#9670)
This commit updates the `test-603-channel-announce-recovery` test to
verify router node channel recovery (following channel change) in
addition to child recovery.
2023-11-30 16:04:40 -08:00
Li Cao bbc6d0bc1c [link-metrics] add Subject status check when getting link metrics data (#9665)
This commit adds a check when returning Link Metrics data collected by
the Link Metrics manager so that only subjects in 'active' or 'renew'
state will return the data. This is to avoid showing N/A results for
neighbors that don't support being a Link Metrics Subject. Based on
current implementation, a 'Subject' object is created when the device
is trying to register a Link Metrics probing at its neighbor. If the
neighbor device doesn't support being a Subject, the device won't get
a LinkMetricsManagement response. During this period (before timeout),
the 'Subject' object is in 'kConfiguring' state. So it's unnecessary
to return any value for Subject in such states.
2023-11-30 11:11:19 -08:00
Abtin Keshavarzian 41ef80717f [github-actions] cover NCP build with OT_OPERATIONAL_DATASET_AUTO_INIT (#9663)
This commit updates  `unittest` job in `toranj.yml` workflow to
validate `ncp` builds (with `OT_OPERATIONAL_DATASET_AUTO_INIT`
feature enabled).
2023-11-29 15:59:50 -08:00
Abtin Keshavarzian c60657aca8 [dataset] introduce ContainsTlv() method (#9663)
This commit introduces two new methods, `ContainsTlv()` and its
template variant `Contains<TlvType>()`, in the `Dataset` class. These
methods enable checking whether a specified TLV type exists among the
Dataset's TLVs.
2023-11-29 15:59:50 -08:00
Abtin Keshavarzian 85660ce756 [srp-client] exclude non-preferred addresses in AutoAddress mode (#9642)
This commit updates the `AutoAddress` mode in `Srp::Client` to
exclude any deprecated (non-preferred) address when registering
host addresses.

It also updates `test_srp_auto_host_address` to validate the new
behavior.
2023-11-29 15:52:12 -08:00
Abtin Keshavarzian 63424e2f0c [tlvs] add ReadValueAs() & WriteValueAs() to simplify MeshCop::Tlv (#9661)
This commit introduces template methods `ReadValueAs<>()` and
`WriteValueAs<>()` in `Tlv` class for handling simple TLV types
(single value and uint value). These methods are employed to simplify
the handling of `MeshCoP::Tlv` in `Dataset`. Specifically, the
following TLVs are simplified:

- `PanIdTlv`
- `ExtendedPanIdTlv`
- `PskcTlv`
- `NetworkKeyTlv`
- `MeshLocalPrefixTlv`
- `ActiveTimestampTlv`
- `PendingTimestampTlv`
- `DelayTimerTlv`
- `NetworkKeySequenceTlv`
- `JoinerUdpPortTlv`

These enhance the code by reducing repeated boilerplate code for the
these simple TLVs.
2023-11-29 12:19:52 -08:00
Abtin Keshavarzian 1f7ab82ad0 [bbr-local] smaller enhancements (#9657)
This commit contains smaller change in `bbr_local` module:
- `LogDomainPrefix()` and `LogService()` methods are updated to use
  newly added `Action` enumeration.
- `HandleDomainPrefixUpdate()` is simplfied to pass the event
  directly to `mDomainPrefixCallback`.
- `SetState()` is updated so we we first remove ALOC/multicast
  addresses based on the previous state before adding/updating any
  addresses  based on the new state.
- Some methods/variables are renamed (e.g., use shorter name).
2023-11-29 12:05:02 -08:00
gytxxsy 0da5af5be8 [spinel] fix multipan rcp enable config (#9659) 2023-11-29 10:34:41 -08:00
jrhodie 1d2b549e80 [cli] add Doxygen for SRP server (#9653) 2023-11-28 21:54:10 -08:00
whd af36786f04 [posix] unify the infra netif and backbone netif (#9638)
This commit refactors the code to unify the concept of 'Infrastructure
network interface' (which is for border routing) and 'backbone network
interface' (which is for backbone router). From now on they will both
be referred as 'infrastructure network interface'. In general border
routing and backbone router should be using the same infrastructure
network interface so I made this change.

This commit removes the `posix/platform/backbone.cpp` source file and
put its functionality in `posix/platform/infra_if.cpp`. Previously
`backbone.cpp` maintained its own variables `gBackboneNetifName` and
`gBackboneNetifIndex` which are redundant compared to the ones
maintained at `infra_if.cpp`. I removed these variables and changed
the references to use `otSysGetInfraNetifName` and
`otSysGetInfraNetifIndex` accordingly.
2023-11-28 20:50:26 -08:00
Abtin Keshavarzian 319112b406 [border-router] add missing otBorderRoutingDhcp6PdGetState() declaration (#9654)
This commit adds `otBorderRoutingDhcp6PdGetState()` function
declaration in `border_routing.h` which was already implemented in
`border_routing_api.cpp` file.
2023-11-28 20:45:15 -08:00
Abtin Keshavarzian fcfec95df2 [dataset-updater] fix possible use of uninitialized Timestamp (#9658) 2023-11-28 20:44:52 -08:00
Marek Porwisz 834c8cbc8e [spinel] add support for multiple spinel interfaces (#9360)
This feature allows the RCP to support multiple host stacks on different PANs
by making use of the spinel Interface ID.

Created unit tests for testing multipan feature with multiple ot-instance
support.

Based on Si-Labs PR #8914 by @parag-silabs, but a little different approach.
Instead of handling everything by a single sub-mac instance, multiple
OpenThread instances are created on RCP side that map to different IID.
Thanks to this there are separate data kept for each interface. Platform
is able to determine interface by ot instance pointer passed as an argument
to most of the API functions.
Tx/scan queue was removed as it is possible to request transmission in
parallel, it is up to the platform to decide if it should fail or queue
second tx or it has two radios available.

NOTE:
Platform needs to provide different otRadioFrame of each instance and
the processing needs to take into account the instance being used.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2023-11-28 16:16:37 -08:00
gytxxsy f859987ce6 [spinel] fix compiling issue of enum multiplication (#9649)
A compiling issue occurred (based on gcc 9.4.0) beacuse the
multiplication of different enum types. So it is a good idea to define
the `kUsPerMs` as `constexpr` constants instead of `enum`.
2023-11-28 09:31:03 -08:00
Abtin Keshavarzian c805678511 [dataset] simplify saving/reading of TLVs in/from secure storage (#9626)
This commit simplifies the handling of Dataset TLVs that need to be
securely stored when the `PLATFORM_KEY_REFERENCES_ENABLE` feature is
enabled. Two new methods are added to the `Dataset` class:

- `SaveTlvInSecureStorageAndClearValue()` which  saves the value of a
  given TLV type in secure storage and clears the TLV value by
  setting all value bytes to zero.

- `ReadTlvFromSecureStorage()` which reads the TLV value back from
  secure storage and updates it in the `Dataset`.

These methods are used by `DatasetLocal` to manage the set of TLVs
that need to be securely stored defined by a constant array of
`SecurelyStoredTlv` entries. Each entry provides the TLV type
along with the associated `Crypto::Storage::KeyRef` to use for
active or pending Dataset.
2023-11-28 09:24:27 -08:00
Song GUO dc616d6a6c [dhcp6-pd] stop PrefixManager when RoutingManager is stopped (#9608)
When InfraIf is down and we received a RA from the host interface, we
may trigger the EvaluateRoutingPolicy unexpectly.

This might happen when infra if and uplink are separate interfaces.

This commit fixes this by adding Start and Stop to `PdPrefixManager`
to start / stop handling RA messages.
2023-11-27 21:56:48 -08:00
whd 4b593f9d39 [tests] fix the check of external routes in test_multi_thread_networks.py (#9648)
There was a check `self.assertNotEqual(br1_external_routes,
br2_external_routes)` that verifies the external route entries of BR1
and BR2 are different, based on the fact that their external route
prefixes (in /64) were different. However, today we're using generic
external routes like `fc00::/7` so the external route entries will be
the same when BR1 and BR2 have the same RLOC16.

I updated the test case to verify that the devices have expected
external route entries respectively.
2023-11-27 18:29:02 -08:00
Maciej Baczmański 90d16d95a2 [csl] fix TimerMicro::GetNow() call in sub_mac.cpp (#9639)
Add missing `.GetValue()` for getting values from `TimerMicro`

Add testing with OT_CSL_RECEIVER_LOCAL_TIME_SYNC enabled

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-11-27 18:26:31 -08:00
Yakun Xu b07b176a1a [posix] fix unused private variables (#9644)
This commit fixes the unused private variable kKeyCalibratedPower
error when OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE isn't
enabled.
2023-11-27 18:26:02 -08:00
dependabot[bot] d6827caf06 github-actions: bump step-security/harden-runner from 2.6.0 to 2.6.1 (#9650)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/1b05615854632b887b69ae1be8cbefe72d3ae423...eb238b55efaa70779f274895e782ed17c84f2895)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-11-27 08:53:18 -08:00
Abtin Keshavarzian a8afffbd2a [mlr] use shorter variable/method names (#9635)
This commit contains smaller enhancements in `MlrManager`:
- Use shorter names for variables and methods
- Avoid the use of normal `enum` name as a namespace
- Use core type `Ip6::Address` instead of `otIp6Address`
2023-11-24 19:06:07 -08:00
Timothy Maes f3602b4a0f [config] define OPENTHREAD_CONFIG_TLS_UPDATE in all cases (#9630)
Flag was undefined when TCP is not enabled.
2023-11-24 09:14:50 -08:00
Abtin Keshavarzian 6c84ccad25 [ip6] update Ip6::SelectSourceAddress() to prefer non-deprecated addresses (#9634)
This commit updates `SelectSourceAddress()` to ensure that
non-deprecated addresses are always preferred over deprecated ones.
When iterating over addresses, the best option is tracked in
`bestAddr`. If the new address is not preferred and the currently
selected `bestAddr` is, the new address is skipped to ensure that it
is not picked.
2023-11-24 09:11:19 -08:00
Abtin Keshavarzian 0044def122 [mlr-manager] define AddressArray which uses Array<Ip6::Address> (#9633) 2023-11-24 09:10:40 -08:00
Li Cao bcdd5b0ee1 [typo] fix error message of link metrics option dependency (#9646) 2023-11-24 09:10:03 -08:00
Zhangwx a184dc9bbf [platform] fix compiling issue when use SuccessOrDie (#9640)
Missing a header file included in the file `exit_code.h`, and
'otLogCritPlat' will not be declared. If using the function
`SuccessOrDie` with only inlcude the file
`src/lib/platform/exit_code.h`, it will have a compiling error
`'otLogCritPlat' was not declared in this scope`.
2023-11-24 09:07:57 -08:00
whd 75694d2860 [continuous-integration] fix bootstrap issue for ot-commissioner (#9643) 2023-11-23 12:51:04 -08:00
Jonathan Hui dc6bf363dd [docs] update Code of Conduct to Contributor Covenant v2.1 (#9627) 2023-11-21 10:14:41 -08:00
gytxxsy ebdc026779 [spinel] expose RestoreProperties as a public method within RadioSpinel (#9501)
When running border routers, users have the option to perform RCP
firmware updates. After completing the update, users prefer not to
restart or reinitialize the master device but only want to restart and
restore the RCP device.

Restarting can be initiated by the user; for example, they can restart
the RCP device by triggering the reset pin. However, after this
restart is done, certain RCP information needs to be restored, such as
the panid and extended address.

Typically, the master device can restore the RCP by triggering
`RecoverFromRcpFailure`, but this behavior is not
user-controllable. So there's a need to implement a callable API for
RCP restoration.

If the `RestoreProperties` is made public, users can actively restore
the RCP by calling it and some other public functions.
2023-11-21 10:13:29 -08:00
Li Cao 1d4e6571f9 [cli] make linkmetrics cli as a separate module (#9619) 2023-11-21 09:48:27 -08:00
Konrad Derda 30c94db4a4 [message] add API functions to enable multicast looping of a message (#9524)
At the moment, C API does not allow to get/set the configuration flag
which the message to be looped back to the Thread interface. It is
important within the context of sending already prepared IPv6 mutlicast
packets with `otIp6Send()`.
2023-11-20 19:22:19 -08:00
Yakun Xu 9165bc62d7 [simulation] SIGHUP when parent dies (#9624) 2023-11-20 17:48:17 -08:00
Abtin Keshavarzian 34dd612008 [routing-manager] learn and copy M & O flags from discovered routers (#9607)
This commit implements a mechanism in `RoutingManager` to learn the
Managed Address Config `M` and Other Config `O` flags in received RA
message from discovered routers on the infrastructure link and copy
the same flags in the emitted RA message from BR.

If any discovered router on the infrastructure that is not itself a
stub router (i.e., does not include the Stub Router flag) includes
the `M` or `O` flags, the same flag are included in the emitted RA
message. If a discovered router has failed to respond to the maximum
number of NS probe attempts, we consider it as offline and ignore its
flags.

This commit also adds a detailed test case in `test_routing_manager`
to validate the newly added mechanism.
2023-11-20 16:37:08 -08:00
jrhodie 364e315768 [cli] add Doxygen tags to SRP commands (#9615) 2023-11-20 16:18:25 -08:00
Yakun Xu beea7bac68 [lint] explicitly initialize failedAddresses (#9622)
Compiling with GCC 13.2.0, got the maybe-uninitialized error. This
commit fixes it by initializing the array.
2023-11-20 15:22:14 -08:00
Abtin Keshavarzian 6f3b4317d6 [routing-manager] new API to get list of discovered routers (#9601)
This commit adds `otBorderRoutingGetNextRouterEntry` as a new API to
iterate over discovered routers on the infrastructure link and get
information about them such as their address, their Managed Address
Configuration (`M`), Other Configuration (`O`), and Stub Router
flags.

The `otBorderRoutingPrefixTableEntry` is also updated to contain
the same information.

This commit also updates the CLI `br` sub-commands to provide this
information, adding `br routers` to obtain a list of discovered
routers.
2023-11-20 11:49:26 -08:00
hastigondaliya 0bb9eeb500 [posix] clear SPI tx buffer after usage (#9567)
This commit clear "mSpiTxPayloadSize" buffer once packet has been
successfully transmitted.
2023-11-20 11:33:51 -08:00
dependabot[bot] ece7943a0e github-actions: bump actions/upload-artifact from 3.1.2 to 3.1.3 (#9625)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/0b7f8abb1508181956e8e162db84b466c27e18ce...a8a3f3ad30e3422c9c7b888a15615d19a852ae32)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2023-11-20 08:26:11 -08:00
Abtin Keshavarzian 6e7ed5cb55 [encoding] avoid the use of using for Big/LittleEndian functions (#9621)
This commit refactors the code to eliminate the use of `using` for
`BigEndian` or `LittleEndian` functions like `HostSwap` and `ReadUint`.
As these functions are frequently used in header files, using the
direct namespace enhances code safety by mitigating potential conflicts
arising from the order of included headers in the absence of explicit
`using` declarations. Generally, avoiding the `using` keyword in headers
is considered a recommended practice.

Additionally, this commit removes the `Encoding` namespace to shorten
the full function names.
2023-11-19 21:19:13 -08:00
Abtin Keshavarzian ce9edaf8b5 [num-limits] add kBitsPerByte, BitSizeOf(), and BytesForBitSize() (#9618)
This commit removes the use of `CHAR_BIT` in the code and instead
defines a constant `kBitsPerByte` for this in `numeric_limits.hpp`.
`CHAR_BIT` is generally defined as `8` but there are some platforms
were this may not be the case. The way we use `CHAR_BIT` is to
determine number of bits in a byte, so introducing our own constant
`kBitsPerByte` helps improve code readability and safety.

This commit also adds `BitSizeOf()` macro which is similar to `sizeof()`
but returns the number of bits of a given type or variable. Macro
`BytesForBitSize()` is also added which returns the number of bytes
needed to represent a given bit size. This replaces the
`BitVectorBytes()` macro previously defined in `encoding.hpp`.
2023-11-19 20:10:40 -08:00
Abtin Keshavarzian 7936f8bcf9 [core] add missing platform function for OT_PLATFORM_KEY_REF (#9620)
This commit contains the following changes:
- Adds `CMake` option `OT_PLATFORM_KEY_REF`, corresponding to the
  existing `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE`
  config.
- Add empty implementations of `otPlatCryptoEcdsa{}` under the
  simulation platform.
- Modifies `test_platform.cpp` to ensure that the key-ref related APIs
  are defined only when the key reference feature is enabled.
- Updates `toranj/build.sh` script to provide the option to enable the
  key reference feature.
- Updates GitHub workflow to validate build with key reference feature
  under simulation platform, ensuring that future PRs are validated
  with this feature enabled.
2023-11-19 18:49:30 -08:00
Abtin Keshavarzian 657b973bb2 [dns] support longer key length in otDnsTxtEntryIterator (#9616)
This commit introduces `OT_DNS_TXT_KEY_ITER_MAX_LENGTH` with a value
of `64` to represent the maximum TXT data key length supported by
`otDnsTxtEntryIterator`. We intentionally set this value higher than
the recommended maximum key length of `9` (as specified in RFC 6763
section 6.4) to enable the parsing of TXT data when longer keys are
employed.
2023-11-19 18:47:21 -08:00
Abtin Keshavarzian 23c0fc4d4b [test] define all unit tests in ot namespace (#9617)
This commit updates unit test modules to be defined under the `ot`
namespace. This aligns all the unit tests to follow the same
model, eliminating the need to use `ot::` prefix in unit test
code.
2023-11-19 18:40:20 -08:00
Abtin Keshavarzian b77573586c [joiner-router] enhance & fix appending TLVs to Joiner Entrust msg (#9614)
This commit updates `JoinerRouter::PrepareJoinerEntrustMessage()` to
improve how TLVs from Active Operational Dataset are appended to the
message. The TLV types that should be included in Joiner Entrust are
now defined in an array `kTlvTypes`, and the code iterating over this
array will find the TLV in Dataset and append it to the message.

Previously, if a required TLV type was not present in the Dataset, the
code would have appended the TLV with an uninitialized and possibly
random value, which could lead to unexpected behavior. The new code
will fail if the required TLVs are not present in the Dataset
instead, ensuring that only valid TLVs are included in the Joiner
Entrust message.
2023-11-17 21:45:48 +01:00
Kangping 02ccb9a506 [posix] more robust netlink message handler (#9613)
Check and ensure at least the netlink header is received in the netlink
socket to be safe before intepreting the buffer as a netlink message.

Per https://linux.die.net/man/3/netlink, should make sure
current message type is not NLMSG_DONE before calling NLMSG_NEXT
to properly handle multi-part netlink message.
2023-11-17 21:39:54 +01:00
Abtin Keshavarzian 700f6247e5 [mle] add ChannelTlvValue to use in ChannelTlv & CslChannelTlv (#9612) 2023-11-16 08:47:12 +01:00
Abtin Keshavarzian f596a2ae99 [cli] remove extra line in trel peers docs in README.md (#9611) 2023-11-16 08:29:48 +01:00
Abtin Keshavarzian 7d41c9e27a [mle] remove MleRouter class definition under MTD build (#9610) 2023-11-16 08:23:41 +01:00
Tom Rebbert 5c34ca2cc3 [mle] fix responding to "Child Update Request" from non-parent device (#9609)
After a router with children downgrades, it's former children will
still send child update requests until they timeout. This allows the
downgraded device to respond with status TLV indicating error to help
those children realize they need to reattach sooner.
2023-11-16 04:34:50 +01:00
aalami90 68426231a5 [cli] adding set ipv4 CIDR for NAT64 in README (#9511) 2023-11-16 00:21:01 +01:00
Abtin Keshavarzian 22fcb0effe [test] ensure to FinalizeTest() in TestProcessPlatfromGeneratedNd() (#9606) 2023-11-15 08:03:44 +01:00
Eduardo Montoya 193e77e40e [radio] add OT_RADIO_CAPS_RX_ON_WHEN_IDLE capability (#9554) (#9554)
Add a new `OT_RADIO_CAPS_RX_ON_WHEN_IDLE` radio capability which lets
OpenThread know what the radio idle state operation will be: receive
or sleep.

This allows to save power on sleepy devices since the active --> idle
transition is much faster, specially for the cases in which there is
some kind of serialization between OpenThread core and the radio
driver.
2023-11-14 11:46:10 +01:00
Abtin Keshavarzian 86215fc31c [mle] define IsRouterIdValid() helper in mle_types.hpp (#9598) 2023-11-14 11:43:21 +01:00
dependabot[bot] 588d55cfc7 github-actions: bump docker/setup-buildx-action from 2.9.1 to 3.0.0 (#9600)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.9.1 to 3.0.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/4c0219f9ac95b02789c1075625400b2acbff50b1...f95db51fddba0c2d1ec667646a06c2ce06100226)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-14 11:42:36 +01:00
Abtin Keshavarzian 6eb358f6e3 [test] address occasional failure of test_routing_manager (#9603)
This commit addresses occasional failures in `test_routing_manager` in
the `TestBorderRoutingProcessPlatfromGeneratedNd` case. Unlike other
tests, this test sets the `heapAllocations` after the call `InitTest
(/* aEnableBorderRouting */ true)` (which enables `RoutingManager`).
This means that depending on the random timing, the `heapAllocations`
may already count some allocated heap items by `RoutingManager`
itself. With the change in this commit, at the end of the test, we
check that the number of remaining heap allocations is less than
`heapAllocations`.
2023-11-14 11:42:18 +01:00
Abtin Keshavarzian f239c49d78 [toranj] update config header to use OT_LOG_LEVEL_INFO (#9595) 2023-11-10 11:01:08 -08:00
Abtin Keshavarzian 1723ae9d71 [routing-manager] check mIsRunning in ScheduleRoutingPolicyEvaluation() (#9594) 2023-11-10 09:48:16 -08:00
Abtin Keshavarzian cd425ebdc1 [multi-radio] perform tag duplication check for first fragment (#9590)
This commit updates the duplicate detection mechanism for the frag
header tags under `MULTI_RADIO` config. The tag check is now
performed upon receiving the first fragment. For subsequent
fragments, older tags are permitted to be processed, but they will be
discarded if there is no matching entry in the reassembly list.

This change addresses an issue where lowpan fragment frames using
older tags could be erroneously discarded if they are interrupted by
higher-priority messages (e.g., an MLE message).
2023-11-10 07:26:39 -08:00
Abtin Keshavarzian 0f55e79263 [routing-manager] use Heap::Array for OnMeshPrefixArray (#9592)
This commit updates `RoutingManager` to use heap allocated array
for `OnMeshPrefixArray` under `BORDER_ROUTING_USE_HEAP_ENABLE`
config.

This commit also updates the `toranj-config-posix` header to
explicitly disable `BORDER_ROUTING_USE_HEAP_ENABLE` under the POSIX
config to validate builds with this config disabled. This aligns with
the main purpose of the `toranj` posix build config, which is to
validate builds under different configs (run from the
`toranj-unittest` job in the `toranj.yml` GitHub action workflow).
2023-11-09 15:31:41 -08:00
jrhodie e987138701 [cli] TCP readme corrections (#9593) 2023-11-09 14:26:52 -08:00
whd 6edb06e4e0 [posix] allow OT process to run when infra netif gets lost (#9583)
In `ot::Posix::InfraNetif::GetFlags()`, the OT process would die if
the infra network interface is removed on the POSIX platform. On
Android platform, this is not the desired behavior because the system
server may tell the OT process to switch another infra network
interface. It's fine for OT process to keep running when the previous
infra network interface disappears because later system server will
call `otSysSetInfraNetif()` to specify the new infra network
interface.
2023-11-08 18:20:46 -08:00
Abtin Keshavarzian a05954b01e [slaac] simplify adding/removing addresses and other enhancements (#9579)
This commit makes the following smaller enhancements in `Slaac`
class:
- Adds a new `ShouldUseForSlaac()` method to check if a network data
  prefix should be used for SLAAC, checking flags and applying the
  filter if set.
- Introduces separate `RemoveAddresses()` and `AddAddresses()` methods
  to manage SLAAC addresses, replacing the previous `Update()` method.
- Adds helper methods to `RemoveAllAddresses()`, `RemoveAddress()` to
  remove a specific address, and `AddAddressFor(prefix)` to  generate
  and add an address for a given prefix.
- Simplifies `GenerateIid()` by removing unused input parameters.
2023-11-07 12:43:02 -08:00
Eduardo Montoya 3b30c842a2 [csl] add OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_LOCAL_TIME_SYNC option (#9568) (#9568)
Allow platforms to reduce the periodic access to `otPlatRadioGetNow`
to calculate CSL synchronization elapsed time in the case when those
radio API calls are costly.
2023-11-06 22:23:37 -08:00
jrhodie 0d74e43fa6 [docs] TCP Commands - add Doxygen tags (#9578) 2023-11-06 15:41:32 -08:00
Kangping 74061eebd4 [dataset] returns OT_ERROR_REJECTED when MGMT_SET is rejected by leader (#9582)
The current code won't return a failure error code when a MGMT_SET
request is rejected by the leader, so the client doesn't know whether
the operation succeed or not.

This commit fixes this issue by converting the REJECTED state to the
OT_ERROR_REJECTED error code which is propagated back via the
otDatasetMgmtSetCallback callback.
2023-11-06 11:21:45 -08:00
dependabot[bot] f889bf9f2e github-actions: bump ossf/scorecard-action from 2.2.0 to 2.3.1 (#9584)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.2.0 to 2.3.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/08b4669551908b1024bb425080c797723083c031...0864cf19026789058feabb7e87baa5f140aac736)

---
updated-dependencies:
- dependency-name: ossf/scorecard-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>
2023-11-06 08:23:14 -08:00
Zhanglong Xia 5058500e5d [build] move radio_spinel.cpp to new lib openthread-radio-spinel (#9530)
The lib `openthread-spinel-ncp` is used by the NCP build, it doesn't
need the file `radio_spinel.cpp`. This commit changes the CMake file
to make only the lib `openthread-spinel-rcp` include the file
`radio_spinel.cpp`.
2023-11-02 09:11:26 -07:00
Abtin Keshavarzian 4a9fb0609e [netdata] simplify Leader class (#9563)
This commit updates the `NetworkData::Leader` sub-class model,
removing `LeaderBase` (which intended to provide common functions
shared between FTD and MTD) and instead adding all methods directly
in `Leader` class with all `FTD`-specific methods having conditional
`#if` check.
2023-10-31 15:36:20 -07:00
Abtin Keshavarzian c6ffe1ae2c [mac] validate received ack frame PSDU in ProcessEnhAckSecurity() (#9565) 2023-10-31 15:33:33 -07:00
dependabot[bot] 7074a43e45 github-actions: bump github/codeql-action from 2.22.3 to 2.22.5 (#9571)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.3 to 2.22.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/0116bc2df50751f9724a2e35ef1f24d22f90e4e1...74483a38d39275f33fcff5f35b679b5ca4a26a99)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2023-10-30 14:04:51 -07:00
Mason Tran 0b0db37a13 [api] add API to reset to bootloader mode (#9523) 2023-10-27 15:54:15 -07:00
Abtin Keshavarzian 1528c8831d [core] define core/instance folder for instance modules (#9561)
This commit moves the `instance` module to a newly added folder
`core/instance` (from `core/common`.  Header file `extension.hpp`
and its example is also moved to the same folder.
2023-10-26 05:08:24 -07:00
hastigondaliya 4c75b6b489 [posix] fix uninitialized pointer read (#9562) 2023-10-26 04:47:41 -07:00
Abtin Keshavarzian 91b7c3ff3f [log] add otLogGenerateNextHexDumpLine() to generate hex dump (#9555)
This commit adds a public OT API to generate hex dump output line by
line. This function is then used for both `LogDump{}()` and frame
capture output by CLI `promiscuous` command (removing repeated
similar code) and harmonize the hex dump outputs.
2023-10-25 14:54:33 -07:00
whd 9106817c62 [posix] add otSysSetInfraNetif API (#9528)
This commit adds a new API `otSysSetInfraNetif` to support specifying
the infrastructure network interface for the platform. This can be
useful in following cases:
- The infra link cannot be determined at the start up of
  `otbr-agent`. We can call this API to specify the infra link without
  specifying it in the command line arguments.
- Let Thread Border Router switch to another infra link without
  restarting the whole OpenThread stack.
2023-10-25 01:33:52 -07:00
Abtin Keshavarzian 52e0c8bdd9 [mle] add TxMessage::AppendSteeringData() (#9559) 2023-10-24 22:11:31 -07:00
hastigondaliya fbeb4d18f2 [posix] addressing coverity warning: resource leak (#9472)
The "assert" and "VerifyOrDie" were checking same condition, so
the second validation was never executed if (rval != sizeof(key)).
Additionally,"aSwapFd" was not freed on assertion.

With this commit,
1. addressed the memory leak to system resources.
2. Replaced VerifyOrDie() or assert() by VerifyOrExit()
3. handle error at exit
2023-10-24 14:38:30 -07:00
Zhanglong Xia 4275c5826f [mac] update the cached supported channel mask when the region code changes (#9418)
The current code of the `mac.cpp` caches the supported channel mask to
a local variable. But the supported channel mask may be changed after
the country code is changed. This will cause the supported channel
mask used in `mac.cpp` to be inconsistent with the actual supported
channel mask.

This commit adds an API `otLinkSetRegion()` to set the region code and
then update the cached supported channel mask to avoid the channel
mask inconsistencies. The current Thread channel may be not included
in the new supported channel mask. When the Thread stack detects this
case, it detaches the current Thread network gracefully.
2023-10-24 14:36:57 -07:00
jrhodie d26f4e59a2 [docs] added xrefs from UDP CLI to UDP Concepts Guide (#9558) 2023-10-24 01:01:38 -07:00
Abtin Keshavarzian b73b124d37 [ip6] log checksum error from Checksum::VerifyMessageChecksum() (#9556) 2023-10-23 05:19:07 -07:00
Abtin Keshavarzian 28f30b3ce8 [nedata] add API to retrieve Commissioning Dataset (#9551)
This commit adds `otNetDataGetCommissioningDataset()` as a public
API to retrieve the Commissioning Dataset from the Network Data.

It also updates CLI `netdata show` command to output the Commissioning
Dataset information. The documentation in `README_NETDATA.md` and
in `cli_network_data` are also updated. The test scripts that parse
`netdata show` output are also updated.
2023-10-23 05:17:51 -07:00
dependabot[bot] a7643db4f2 github-actions: bump actions/checkout from 4.1.0 to 4.1.1 (#9557)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/8ade135a41bc03ea155e62e844d188df1ea18608...b4ffde65f46336ab88eb53be808477a3936bae11)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-10-23 05:15:46 -07:00
Abtin Keshavarzian 837c7fd357 [netdata] simplify and update HandleTmf<kUriCommissionerSet>() (#9550)
This commit updates `HandleTmf<kUriCommissionerSet>()`, which is used
to set the Commissioning Dataset. The following changes have been made:
- `Tlv::Find<TlvType>()` methods are used to find and parse TLVs in the
  received request message.
- The existing code required the dataset to contain either Joiner UDP
  or Steering Data TLVs. This check has been removed, making the
  implementation aligned with the Thread specification. This permits a
  commissioner to disallow MeshCoP Joining by not including Steering
  Data.
- A new flavor of `SetCommisioningData()` is added, which reads the
  TLVs directly from a given `aMessage`. This method is now used
  when processing `kUriCommissionerSet` to avoid using temporary
  local buffers to read and copy the TLVs.
- `SetCommisioningData()` and its related methods have been moved to
  `network_data_leader_ftd` since they are limited to and used on
  FTD devices acting as leader.
- A new private `UpdateCommissioningData()` method has been added.
  This method first checks whether or not we can add a Commissioning
  Data TLV with a given length into Network Data, before removing
  the current TLV. This is used as a common method when Commissioning
  Data is set from a message or from a given data buffer.
2023-10-19 17:36:23 -07:00
Abtin Keshavarzian c8aeeefffe [netdata] resign active commissioner on NetData restore on leader (#9549)
This commit updates `HandleNetworkDataRestoredAfterReset()`, which is
called after Network Data is restored on the leader after a leader
reset and recovery.

We now resign any active Commissioner by clearing the Commissioning
Data and adopt the Session ID from the restored Network Data
Commissioning Data. This ensures that any stale Commissioning Data
is not retained in Network Data for longer after a leader reset.
2023-10-19 17:34:26 -07:00
whd 6ff277841e [tests] fix verification in test_routing_manager.cpp (#9548)
Some equation checks accidentally became non-zero checks due to
typo. Such tests may fail in certain build configurations when the
heap allocation is zero after initialization of the test.
2023-10-19 11:07:53 -07:00
Abtin Keshavarzian 1b59c97bbc [udp] remove aIpProto from Ip6::Udp::SendDatagram() (#9547)
This commit removes the input `aIpProto` in `Upd::HandleDatagram()`
method and assumes `kProtoUdp`.
2023-10-18 20:55:05 -07:00
Abtin Keshavarzian 95b0869912 [netdata-leader] simplify HandleTmf<kUriCommissionerGet> (#9546)
This commit simplifies the handling of `kUriCommissionerGet` TMF
message and preparation of its response.
2023-10-18 20:54:10 -07:00
Abtin Keshavarzian a69c2db333 [meshcop] simplify processing of Commissioner ID TLV (#9543)
This commit updates CommissionerIdTlv to be defined as `StringTlvInfo`
(a TLV with a UTF-8 string value with a specified maximum length). This
allows us to use `Tlv` helper methods to `Find` and `Append` this
TLV, simplifying the code.

This commit also adds a helper `StringCopy()` method that copies a
C string into a given target string buffer array if it fits in the array.
This method can also optionally perform an encoding check on the string,
such as a UTF-8 encoding check. This helper method is used to simplify
setting different strings, such as Commissioner ID, Provisioning URL,
Vendor Name, etc.
2023-10-18 16:11:49 -07:00
Abtin Keshavarzian 2457ba7c18 [netdata] simplify parsing of Commissioning Dataset sub-TLVs (#9541)
This commit contains changes related to parsing of Commissioning
Dataset sub-TLVs in `NetworkData::Leader`:
- Adds `FindInCommisioningData<SubTlvType>` to search for a given
  `SubTlvType` in Commissioning Data.
- Adds `FindCommissioningSessionId()`, `FindBorderAgentRloc()`,
  and `FindJoinerUdpPort()` to parse and get get the info
  from Commissioning Dataset.
2023-10-18 16:11:25 -07:00
Abtin Keshavarzian 03bfced292 [radio-spinel] simplify SetMacKey() (#9539)
This commit simplifies the `RadioSpinel::SetMacKey()` method.
A common `private` overload of `SetMacKey()` is added that uses
`const otMacKey &` as its input key type.

When `KEY_REFERENCES_ENABLE` is not enable the `SetMacKey()` simply
passes the key from the `otMacKeyMaterial` directly. This avoids the
unnecessary copying of the key into a local variable.

When `KEY_REFERENCES_ENABLE` is enabled, the keys are read from
secure storage. A new `ReadMacKey()` helper method is added which
also validates that the read key size is correct.
2023-10-18 16:11:04 -07:00
Abtin Keshavarzian 47272e4270 [meshcop-leader] simplify adding CommissioningData (#9540)
This commit contains smaller changes in` MeshCoP::Leader` class:
- Changes `CommissioningData` to be a `private` type in this class
- Adds `Init()` to `CommisioningData()` to init all sub-tlvs.
2023-10-18 10:44:50 -07:00
hemanth-silabs 6bfe59dabf [spinel] use local variables to export mac key before sending over SPINEL (#9536)
In RadioSpinel::SetMacKey we try to reuse the otMacKey passed to
export the literal key from PSA to be sent over SPINEL to RCP. But as
the passed param is const, we cant really use this. Better option is
to extract it into a local buffer and use that to pass the keys to
RCP.
2023-10-17 11:39:25 -07:00
Abtin Keshavarzian cd5768b89d [logging] add new otLogPlat() APIs with sub-module name (#9516)
This commit adds new public OT logging APIs `otLogPlat()` and
`otLogPlatArgs()`, which allow the caller to specify a platform
sub-module name to be included in the emitted log. This makes it
easier to distinguish logs from the platform layer and filter the
logs.

This commit also updates the `RadioSpinel` class to use the new API,
ensuring that its logs use the "P-RadioSpinel" module name.
2023-10-17 10:42:47 -07:00
dependabot[bot] 1d812831c6 github-actions: bump github/codeql-action from 2.21.8 to 2.22.3 (#9537)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.8 to 2.22.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/6a28655e3dcb49cb0840ea372fd6d17733edd8a4...0116bc2df50751f9724a2e35ef1f24d22f90e4e1)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2023-10-16 14:24:53 -07:00
Abtin Keshavarzian 4808b76c88 [tlv] add helper method to find/read TLVs in a sequence of TLVs (#9538)
This commit moves the helper methods to find a specific TLV in a
sequence of TLVs from the `MeshCoP::Tlv` class to the base `Tlv`
class. This makes these helper methods accessible to all subclasses.
2023-10-16 12:50:59 -07:00
Esko Dijk 66eaeec41a [cli] update Dataset documentation with Pending Dataset usage and time units (#9475)
Also fixes a pskc -> PSKc typo; and explain better how to init
dataset. Based on existing documentation I struggled a long time to
create a Pending Dataset in the proper way, so I thought it would be
good to document this better.
2023-10-16 11:35:01 -07:00
Abtin Keshavarzian ee82a5728a [dataset] highlight SetTlv<ValueType>() specializations in the docs (#9534)
This commit updates the `Dataset::SetTlv<ValueType>()` documentation
to mention its specifications for `uint` types (which use big-endian
encoding). It also adds `static_assert` checks to ensure that the
general template implementation is not used with `uint16/32/64`
types.
2023-10-16 11:31:45 -07:00
Abtin Keshavarzian 6bc02986f0 [ip6] use OwnedPtr<Message> to simplify message lifetime (#9533)
This commit updates the `Ip6` class to use `OwnedPtr<Message>`. This
smart pointer automates the freeing of messages and helps to simplify
the code by removing all the logic that tracks whether a message
needs to be freed. It also makes the transfer of ownership of
`Message` instances between methods more clear.
2023-10-16 11:31:08 -07:00
Abtin Keshavarzian 18e214b639 [github-actions] add job summary to size.yml workflow (#9532)
This commit uses `GITHUB_STEP_SUMMARY` to add a summary (in markdown
format) to the GitHub action workflow `size.yml` runs.
2023-10-16 11:13:58 -07:00
Abtin Keshavarzian d5697604d0 [meshcop-leader] check IsLeader() processing `LeaderPetition/KeepAlive (#9531)
This commit adds an `IsLeader()` check to ensure that the device is
acting as the leader before processing `kUriLeaderPetition` or
`kUriLeaderKeepAlive` TMF messages. This adds a safeguard to ensure
that only the leader can update the commissioner dataset.
2023-10-13 17:57:01 -07:00
Abtin Keshavarzian 3e18032d2f [netif] simplify applying mesh-local prefix change to addresses (#9527)
This commit simplifies how the `Netif` unicast and multicast addresses
that use the mesh-local prefix are updated when the mesh-local prefix
is changed.

The `Netif::UnicastAddress` class now includes a `mMeshLocal` flag,
which is set for all mesh-local addresses (RLOCs, ALOCs, and ML-EID).
When the mesh-local prefix is changed, `Mle` will inform `ThreadNetif`
to apply the new prefix. `ThreadNetif` will then update all of the
assigned unicast addresses that are marked as mesh-local, as well as
all of the subscribed mesh-local prefix-based multicast addresses
(such as link-local or realm-local All Thread Nodes addresses). The
`Netif` class first signals the removal of the previous address based
on the old prefix, and then the addition of the new address with the
new mesh-local prefix.

This change simplifies the code, in particular the modules such as
`Commissioner`, `BorderAgent` and `BackboneRouter::Local`, which need
to manage specific ALOC addresses. These modules no longer need to be
informed when the mesh-local prefix is changed to update their
address, as it will be done by the `Netif` class directly.
2023-10-13 17:15:58 -07:00
Abtin Keshavarzian 9876468006 [meshcop-leader] update local variable name to follow convention (#9526) 2023-10-13 09:55:38 -07:00
Abtin Keshavarzian 17e433c95a [mac] skip logging trel frame tx error when trel interface is disabled (#9522)
This commit updates `Mac::LogFrameTxFailure` to skip logging when
`Trel::Interface` is disabled.
2023-10-12 19:33:34 -07:00
Abtin Keshavarzian 094bae0e57 [ip6] update otNetifAddress.mNext to be pointer to const (#9519)
This commit contains the following smaller changes in `Ip6` and its
public APIs:

- Updates the `otNetifAddress.mNext` field to be a pointer to `const`.
  This prevents users of OT APIs from modifying addresses as they
  iterate over the list of addresses. The `otNetifMulticastAddress`
  structure already uses this model.

- Adds new API `otIp6HasUnicastAddress()` to check whether or not a
  unicast IPv6 address is assigned to the Thread interface. This is
  used to simplify CLI and `posix/platform/netif.cpp`.

- Fixes the returned error from `otIp6AddUnicastAddress()` to be
  `OT_ERROR_INVALID_ARGS` when the address is a Thread internal
  address, to match the documentation.

- Fixes documentation and style in `ip6.h`.
2023-10-12 13:39:30 -07:00
Abtin Keshavarzian fc307401a6 [ip6] add PrepareMulticastToLargerThanRealmLocal() (#9513)
This commit adds `Ip6::PrepareMulticastToLargerThanRealmLocal()`,
which prepares to transmit a multicast message with destination
larger than realm-local address. It checks if any sleepy child of
device is subscribed to the multicast address and clones the message
for indirect tx if needed, before adding the IP-in-IP tunnel header.
The new method helps remove repeated code in `SendRaw()` and
`SenDatagram()`.
2023-10-11 17:20:16 -07:00
Abtin Keshavarzian 543b5da0b8 [ip6] update tunnel message receive in HandleDatagram() (#9503)
This commit updates how `Ip6::HandleDatagram()` processes a tunneled
IP-in-IP message. Previously, if a message was marked for both
`receive` and `forwardThread`, e.g., possible for a multicast message
from host with multicast-loop flag, it would be received but not
forwarded to the Thread mesh. This commit ensures that such messages
are handled properly.

Without this change, multicast transmission still works fine due to
the MPL layer retransmitting the message, which would then be
forwarded to the Thread mesh. However, this change improves the
multicast behavior by ensuring that the original/first message is
also forwarded to the Thread mesh.

This commit changes the code so that if we need to both `receive` and
`forwardThread`, we create a copy of the message by cloning it.
Otherwise, we take ownership of the original message and use it
directly. We then remove the encapsulating header before processing
the embedded message by calling the `HandleDatagram()` recursively.
2023-10-11 14:56:35 -07:00
jrhodie be317ecb73 [docs] UDP commands - added Doxygen tags (#9504) 2023-10-11 13:27:37 -07:00
Abtin Keshavarzian 8f6d6703a2 [ping-sender] allow setting multicast loop (#9494)
This commit updates `PingSender` and its config to include a
`mMulticastLoop` flag and allow the caller to set this flag. When
set, multicast ping echo request messages are looped back and
received by the device itself if it is subscribed to the same
address. The `ping` CLI command is also updated to allow setting this
flag.

This commit also updates `test-008-multicast-traffic.py` to add new
test cases to cover the multicast loop flag behavior (pinging with or
without this flag). In particular, it covers when the ping
destination is a realm-local multicast address and when it is a
larger-than-realm-local multicast address (where the `ot::Ip6` module
would use a tunnel header for forwarding the message).
2023-10-11 11:37:34 -07:00
Abtin Keshavarzian 57ef721eee [ip6] fix constant name style and simplify filtering of ICMP types (#9512)
This commit contains smaller changes in `Ip6` class:
- Rename constant `kForwardIcmpTypes` to follow naming convention
- Simplify how it it used to filter which ICMP types are forwarded
  to Thread mesh.
2023-10-10 20:34:13 -07:00
Abtin Keshavarzian 0d0655ded9 [ip6-mpl] remove aIsOutbound input and use aMessage.GetOrigin() (#9510)
With the recent addition of `GetOrigin()`, the origin of a message is
tracked by `Message` itself. With this change, we no longer need to
pass `aIsOutbound` to `Ip6::Mpl` methods, as it can be determined
from the origin of `aMessage`. This commit simplifies the code by
removing the `aIsOutbound` input parameter.
2023-10-10 14:14:44 -07:00
Abtin Keshavarzian ca97cf7a0f [ip6-mpl] simplify Mpl::HandleRetransmissionTimer() (#9509)
This commit contains smaller changes in `HandleRetransmissionTimer()`:

- Remove nested if/else blocks and use `continue`.
- We clone the MPL message if more retx are needed, otherwise use the
  `message` directly.
- In both cases, we now use the same code path for preparing and
  sending the `message`, avoiding repeated code.
- Rename `GetTimerExpirations() to `DetermineMaxRetransmissions()`.
2023-10-10 12:14:33 -07:00
Zhanglong Xia 7568e31c08 [spinel] create spinel interface based on the radio url protocol (#9393)
The posix platform is able to support the HDLC, SPI and vendor spinel
interfaces, but the spinel interface type can't be changed
dynamically. It is inconvenient to use different spinel interfaces for
Thread stack in Android. This commit enables the posix platform to
support the HDLC, SPI and vendor interface at the same time, and the
final spinel interface type is determined by the radio url protocol.

Some other changes:
1. Not use CRTP style for the radio spinel.
2. Deprecate the OT_POSIX_CONFIG_RCP_BUS and
   OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL.
2023-10-10 10:15:32 -07:00
Abtin Keshavarzian 2fe077037d [mesh-forwarder] simplify multicast forward to sleepy children (#9505)
This commit simplifies the `MeshForwarder::SendMessage()` method and
its logic for determining whether to send a multicast message to
sleepy children. We first determine whether the destination address
is link-local or realm-local all-nodes, meaning it is destined to all
nodes. Otherwise, we need to check whether each sleepy child is
subscribed to the address. We then iterate through the child table
and mark the message for indirect transmission accordingly.
2023-10-10 10:03:45 -07:00
Abtin Keshavarzian 8cefa49877 [cli] update ip6addr -v to include more info about address (#9488)
This commit updates the `ip6addr -v` CLI command to provide more
information about each address including origin, prefix length, and
preferred and valid flags.
2023-10-10 10:02:39 -07:00
Abtin Keshavarzian 786bd7f2e9 [message] add IsOrigin{}() helper methods (#9506)
This commit adds helper methods to the `Message` class to check if the
message origin matches a specific origin. These methods are used in
the code as syntactic sugar to simplify the code.
2023-10-09 21:28:09 -07:00
dependabot[bot] 652e3f20ca github-actions: bump step-security/harden-runner from 2.5.1 to 2.6.0 (#9499)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.5.1 to 2.6.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/8ca2b8b2ece13480cda6dacd3511b49857a23c09...1b05615854632b887b69ae1be8cbefe72d3ae423)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-10-09 09:43:59 -07:00
Abtin Keshavarzian af5938e389 [test] fix unused returned error warning in test_message (#9496) 2023-10-08 20:50:15 -07:00
Abtin Keshavarzian 1b271a40c8 [mesh-forwarder] remove message if no pending tx in SendMessage() (#9495)
This commit updates `MeshForwarder::SendMessage()` on FTD to check if
the message is marked for direct transmission and/or indirect
transmission to a sleepy child. If there is no pending transmission,
the message is removed.

This situation can occur if the message destination is a multicast
address larger than realm-local scope. In such a case, `SendMessage()`
skips `SetDirectTransmission()` on the message(since such message
will be forwarded using IP-in-IP encapsulation by `Ip6` module) and
assumes the message is for a sleepy child. However, if none of the
children are subscribed to this address, the message will not be
marked for indirect transmission either. Without the fix in this
commit, such messages would have remained in the `mSendQueue` and not
been removed or freed, as messages are only checked for removal after
a direct or indirect transmission attempt.
2023-10-08 20:49:57 -07:00
Mahavir Jain 017c7ab915 [crypto-platform] fix build issue with mbedtls v3.5.0 (#9492)
As per the mbedTLS v3.5.0 release notes:

Ref: https://github.com/Mbed-TLS/mbedtls/releases/tag/mbedtls-3.5.0

MBEDTLS_CIPHER_BLKSIZE_MAX is deprecated in favor of
MBEDTLS_MAX_BLOCK_LENGTH (if you intended what the name suggests:
maximum size of any supported block cipher) or the new name
MBEDTLS_CMAC_MAX_BLOCK_SIZE (if you intended the actual semantics:
maximum size of a block cipher supported by the CMAC module).

This commit fixes the build issue keeping the backward compatibility
intact.
2023-10-08 20:48:54 -07:00
Abtin Keshavarzian 50e20c8958 [mle-router] add RouterRoleTransition nested class (#9490)
This commit adds `RouterRoleTransition` nested class to `MleRouter`.
This class tracks the timeout and jitter intervals for router role
transitions, i.e., device upgrading to router role from REED or
downgrading from router to REED. It provides helper methods like
`IsPending()` and `StartTimeout()` to check if role transition
is pending or to start the timeout countdown. These methods help to
simplify the code and make it more readable.
2023-10-06 12:09:48 -07:00
Abtin Keshavarzian 4f6b4923aa [routing-manager] include Stub Router flag in emitted RAs by BR (#9486)
This commit updates `RoutingManager` to include the Flags Extension
Option with Stub Router flag in its emitted Router Advertisement
messages.

Config `STUB_ROUTER_FLAG_IN_EMITTED_RA_ENABLE` can be used to enable
or disable this behavior which is enabled by default.
2023-10-05 13:58:21 -07:00
whd e64f38a816 [ip6] drop UDP datagrams from an untrusted origin to TMF port (#9437)
This commit drops UDP datagrams from an untrusted origin to TMF port.

Examples of untrusted origin:
- A process other than OT on the host sends the packet to Thread
  network via platform API.
- A packet forwarded from infrastructure network to Thread network by
  Thread Border Router.

OT shouldn't allow UDP datagrams from untrusted origins going to TMF
port of any Thread device.

To implement this, there's an API `otIp6SendFromOrigin`
introduced. This can be used for specifying the origin of a packet you
want to send. This commit also encapsulates the 'origin' information
in `Message::Metadata`.
2023-10-05 09:50:57 -07:00
Abtin Keshavarzian a363396eb5 [mle] handle received Advertisements from RxOnlyNeighbor on FED (#9484)
This commit updates `Mle` class such that on an FED (FTD child) when
an MLE message is received, we use `FindRxOnlyNeighborRouter()` in
addition to `FindNeighbor()` before performing security check. This
ensures that the key sequence and frame counters are validated for
messages from a rx-only neighbor router.

After security check and before calling `Handle{MleCommand}()` we
clear the `neighbor` if it is a rx-only except for a subset of MLE
messages such as MLE Advertisement. This ensures that, as an FED, we
are selective about which messages to process from rx-only
neighbors.

This commit also adds a new flavor of `FindRxOnlyNeighborRouter()`
that accepts an `Mac::ExtAddress` as its input parameter.
2023-10-04 21:57:07 -07:00
Abtin Keshavarzian 4e52d85dff [docs] fix typos in Doxygen documentation (#9485)
This commit fixes typos in Doxygen documentation, ensuring that
`@param` variable names match the function/method declaration. It
also adds any missing `@param` tags and removes extra ones.
2023-10-03 19:58:59 -07:00
sarveshkumarv3 9d80fbc4ba [mle] send data polls after Child ID Request ack (#9264)
Currently, when SED sends out the Child ID request, the first data
poll goes out immediately (from the SendChildIDRequest method in
MeshForwarder (snippet A). This does not check for any failures in RCP
or SubMac (Channel Access failures or Abort which can cause Child ID
request to fail transmission). In such failure scenarios, additional
data polls are sent out (to retrieve Child ID response which seems
like wasted OTA transmissions).  Request to delay the start of data
polling procedure after the Child ID request is sent successfully.
2023-10-03 19:24:35 -07:00
Abtin Keshavarzian 21d62ec6d7 [mle] simplify reattach on losing connectivity to leader (#9479)
This commit updates the attach process to the same partition after
a router/REED losing connectivity to the leader. It removes the
`kSamePartitionRetry` enumerator from `AttachMode`. With this change,
after trying to attach using `kSamePartition` attach mode (with a
total of six Parent Request attempts to Routers and REEDs), the
device will switch to `kAnyPartition` attach mode. This helps to
reduce the total number of attempts before the device can decide to
take the leader role.
2023-10-03 18:27:23 -07:00
Abtin Keshavarzian 4ab8334bd9 [backbone-router] use TimeTicker directly to delay registration (#9483)
This commit update `BackboneRouter::Local` to be a `TimeTicker`
receiver directly instead of using the `MleRouter for this. The
`TimeTicker` callback is used to delay registration by counting down
`mRegistrationTimeout`.
2023-10-03 18:26:17 -07:00
Abtin Keshavarzian 3043f2e196 [bbr-local] simplify AddService() and its use (#9477)
This commit contains smaller changes in `BackbonRouter::Local`:

- `AddService()` now gets a `RegisterationMode` enum as its input
  either decide based on current state or force registration.
- We remove the `NetworkData::Notifier::HandleServerDataUpdated()`
  calls after calling `AddService()` since `AddService()` method
  itself will already call this (when successfully adds the service
  to Network Data)
- We also remove the extra state check before calling `AddService()`
  as it is done by the `AddService()` method itself.
2023-10-03 15:46:37 -07:00
Abtin Keshavarzian becba6bd95 [github-actions] fix the codespell version in spell-check job (#9482)
This commit fixes the version of `codespell` installed in the
`spell-check` job of `build` workflow to version `2.2.4`.
2023-10-03 13:26:21 -07:00
dependabot[bot] c6eaeda5a1 github-actions: bump actions/checkout from 4.0.0 to 4.1.0 (#9476)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/3df4ab11eba7bda6032a0b82a6bb43b11571feac...8ade135a41bc03ea155e62e844d188df1ea18608)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-10-02 09:36:17 -07:00
Abtin Keshavarzian eaa62613a5 [routing-manager] new config to use heap for PrefixTable entries (#9455)
This commit introduces a new configuration option for the routing
manager to use heap-allocated entries in the `DiscoveredPrefixTable`,
which maintains a list of discovered routers and their advertised
on-link prefixes. This makes the implementation more flexible when
dealing with a large number of routers and/or discovered prefix
entries.

The config option `OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE`
enables this behavior. By default, it is enabled. When disabled, the
previous model, which uses pre-allocated arrays and pools, is used
instead.

This commit also updates the unit test `test_routing_manager` to track
heap allocations and validate that all heap allocations by the
routing manager are freed when it is stopped.
2023-09-29 14:58:48 -07:00
jrhodie bd63637696 [docs] Doxygen tags for CLI commands [neighbor linkqualitynetworkidtimeout] (#9466) 2023-09-28 16:51:15 -07:00
Abtin Keshavarzian 50c70d8abe [nd6] add RaFlagsExtOption and track flags in received RAs (#9448)
This commit adds the `RaFlagsExtOption` class to represent an "RA
Flags Extension" Option. It also adds code to `RoutingManager` class
to process this option in received RA messages and check whether or
not the Stub Router Flag is set. Additionally, it checks and tracks
whether or not the `M` (Managed Address) and `O` (Other Config) flags
are set in the received RA message's header.
2023-09-28 14:14:19 -07:00
Abtin Keshavarzian 9f76d45de6 [mle] simplify ProcessRouteTlv() call in HandleAdvertisement() (#9465)
This commit simplifies the checks to decide whether or not to call
`ProcessRouteTlv()` in `MleRouter::HandleAdvertisement()`. The whole
check is guarded by `aRxInfo.IsNeighborStateValid()`, which ensures
that we only process Route TLVs for Advertisements received from
valid neighbors. In particular, we can remove the additional checks
in the case where the device is itself `IsChild()` (i.e., acting as
an FED). In this case, `aRxInfo.mNeighbor` will be determined using
`NeighborTable::FindNeighbor()`, which checks and accepts the parent
as the only valid neighbor of the FED child.
2023-09-28 10:53:03 -07:00
Suvesh Pratapa f19548b4b1 [joiner] check for non-zero joiner UDP port before electing a joiner router (#9445)
An invalid Discovery Response that carries no Joiner UDP Port TLV will
be accepted by the joiner, but we shouldn't qualify it as a valid
joiner router since we can only open a connection with a non-zero
port.
2023-09-28 08:24:12 -07:00
hastigondaliya 50487a647d [posix] address coverity warning: argument cannot be negative (#9453)
Added validation to check for the negative value of sMLDMonitorFd, as
setsockopt parameter cannot be negative.
2023-09-27 11:09:57 -07:00
Abtin Keshavarzian 09a0fbe9c6 [ip6] update where HandlePayload() check message is not null (#9462)
This commit updates `Ip6::HandlePayload()` to check the `message`
pointer for null in the common flow, instead of in the `if()` block
where the message is cloned when `aMessageOwnership` is set to
`kCopyToUse`. If `aMessageOwnership` is `kTakeCustody` the `message`
is initialized as `&aMessage` already which cannot be `nullptr`.

This protects against code checker warnings that `message` may remain
null if the given `aMessageOwnership` enum value is not one of its
two defined enumerator values.
2023-09-27 10:59:37 -07:00
whd 17286dbd24 [script] exclude ot_testing and __pycache__ when building the OTBR docker (#9457)
This commit excludes `ot_testing` and `__pycache__` directories when
copying the files before building the docker.

Such files are usually generated by root user and will cause errors
when copying them as a non-root user.
2023-09-27 10:41:07 -07:00
jrhodie 0c5966de81 [docs] adding Doxygen tags for CLIs mac retries direct - mac send (#9451) 2023-09-26 09:02:42 -07:00
jrhodie 9099a13015 [docs] add Doxygen tags for CLI commands (macfilter rss add - macfilter rss remove) (#9442) 2023-09-25 15:42:25 -07:00
Jonathan Hui 6943dd2587 [address-resolver] set minimum kMaxNonEvictableSnoopedEntries to 1 (#9460)
Resolves issues when `OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES` is
too small.
2023-09-25 15:29:22 -07:00
dependabot[bot] 9b7c78f960 github-actions: bump github/codeql-action from 2.21.4 to 2.21.8 (#9459)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.21.4 to 2.21.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/a09933a12a80f87b87005513f0abb1494c27a716...6a28655e3dcb49cb0840ea372fd6d17733edd8a4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2023-09-25 12:12:06 -07:00
GuoYuchao f31a583408 Revert "[nat64] enable discovering NAT64 AIL prefix for OpenWRT (#9441)" (#9458)
This reverts commit 93e72bcbf9.
2023-09-25 11:01:02 -07:00
gabekassel f0530afa37 [spinel] reset mState to kStateDisabled if recovering from kStateDisaled (#9450)
This commit changes openthread rcp recovery code to keep `mState` as
`kStateDisabled` if the state before recovery was
`kStateDisabled`. This is needed to avoid otbr-agent crash in the
scenario where rcp recovery is triggered before otbr initialization.
2023-09-22 06:49:20 -07:00
Abtin Keshavarzian 85aff45965 [tmf] set default snoop cache entry count to 1/16 of total (#9440)
This commit sets the default value of the configuration
`TMF_ADDRESS_CACHE_MAX_SNOOP_ENTRIES` to `1/16` of the total number
of address cache entries. This ensures that the snoop entries scale
with the total number of entries.
2023-09-21 12:47:26 -07:00
ihidchaos 93e72bcbf9 [nat64] enable discovering NAT64 AIL prefix for OpenWRT (#9441)
According to the description of
https://github.com/openwrt/openwrt/pull/11559, libanl is already
included in the musl c library, so we can turn this option on.

We enable OPENTHREAD_POSIX_CONFIG_NAT64_AIL_PREFIX_ENABLE on OpenWrt
platform for better experience.
2023-09-20 18:06:45 -07:00
jrhodie 390500639f [docs] add Doxygen tags for CLI commands (macfilter - macfilter addr) (#9424) 2023-09-20 14:43:18 -07:00
Abtin Keshavarzian 753b305207 [border-agent] simplify ForwardContext allocation and ownership (#9444)
This commit updates `ForwardContext` to be `Heap::Allocatable` and
uses `OwnerPtr` to simplify the ownership (and freeing) of allocated
`ForwardContext` objects.
2023-09-20 14:17:45 -07:00
Zhanglong Xia df128246ac [posix] update the default channel masks in the configuration file (#9443)
The default supported channel mask is set to 0x7fff000 in the default
configuration file. The dbus client test case sets the channel to 11
which is not valid in the supported channel mask. It causes the CI test
failures in https://github.com/openthread/ot-br-posix/pull/2027.

This commit updates the default supported and preferred channel masks
in the configuration file to avoid the CI test failures.
2023-09-20 10:53:57 -07:00
Jonathan Hui 21ac9f54cf [tcp] address uninitialized variable warning (#9438) 2023-09-19 12:31:01 -07:00
Abtin Keshavarzian 07c56c28e0 [cli] fix ba state output and conversion of state to string (#9433) 2023-09-18 18:36:11 -07:00
Abtin Keshavarzian 851e00ffdb [border-agent] smaller enhancements (#9432)
This commit contains smaller changes in `BorderAgent` class:

- Define `kUdpPort` as a private constants in `BorderAgent` class.
- Add `SendMessage()` method to send message through `SecureAgent`.
- Add `LogError()` as a method so the correct log module is used.
- Remove unused `mMessageInfo` member variable.
- Harmonize log messages.
2023-09-18 16:26:12 -07:00
dependabot[bot] 5f8f05cab5 github-actions: bump actions/checkout from 3.6.0 to 4.0.0 (#9429)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/f43a0e5ff2bd294095638e18286ca9a3d1956744...3df4ab11eba7bda6032a0b82a6bb43b11571feac)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 07:54:11 -07:00
Zhanglong Xia ea61838e66 [spinel] save MAC frame counter to a local variable (#9407)
This commit saves the MAC counter to a local variable to avoid calling
the core function Get<Settings>().Read() in radio_spinel_impl.hpp. This
is useful when spinel module is used as a lib in other projects.
2023-09-18 07:18:45 -07:00
Zhanglong Xia 2a502abb88 [posix] add channel mask configurations to configuration file (#9391)
This commit allows developers to set the preferred channel mask and
the supported channel mask in the configuration file. The posix
platform selects channel masks from the configuration file based on
the region code when the region code is updated.
2023-09-18 07:17:54 -07:00
whd a383e366ba [firewall] implement packet filtering in OT core (#9402)
This commit implements the packet logic in OT core. It aims to have
the same effect as what's already achieved by our iptables-based
firewall. Instead of leveraging iptables, this commit filters the
border routing packets in user space by checking the
source/destination addresses of a packet.

This commit also adds a job to do BR regression test when this feature
is enabled and iptables-based firewall is disabled.
2023-09-15 11:52:26 -07:00
Abtin Keshavarzian b5b93423d8 [netdata] remove unallocated router ID entries on recovery after reset (#9421)
This commit updates `HandleNetworkDataRestoredAfterReset()` which is
called when a leader device is reset and recovers the Network Data
from other routers. With the new code, leader will now check and
remove entries in the restored Network Data that are from any
currently unallocated router ID.

This change acts as a safeguard against an edge case where the leader
is reset at an inopportune time, such as right after it removed an
allocated router ID and sent MLE advertisement but before it got the
chance to send the updated Network Data to other routers.
2023-09-14 16:41:31 -07:00
Yang Sun 8ed949e6fd [posix] add a flag to turn posix multicast routing feature on/off (#9412)
This commit adds a separate flag to be able to turn the posix part of
multicast routing implementation off/on.

The new
OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE flag
guards the feature of posix multicast routing using MFC(multicast
forwarding cache) in MRT(multicast routing table).

The existing
OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE continues
to guard the core multicast routing feature, for example handling the
MLR.req message and the multicast listeners table.

In a system where it has its own multicast routing support for packet
forwarding between Thread network and AIL, it should set
OPENTHREAD_POSIX_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE to 0.
2023-09-14 16:32:00 -07:00
jrhodie df010bcbe5 [docs] add Doxygen tags for CLI commands (tvcheck - unsecure) (#9419) 2023-09-14 08:50:51 -07:00
Zhanglong Xia 20a12eb728 [url] add methods to parse parameters from url (#9392)
This commit adds methods to parse parameter values directly from the
url, moves the url unit test to the test/unit, and updates the url
processing methods in posix platform.
2023-09-14 08:46:11 -07:00
hastigondaliya 31df6363ab [mac] fix channel switching issue during energy scan (#9405)
- This commit resolves inconsistency between Host and RCP channel on
  scan energy when network not created.
- Added fix in MAC layer to update the channel on scan energy.
2023-09-13 12:43:29 -07:00
Abtin Keshavarzian 45727d3dc9 [address-resolver] remove cache entry if its RLOC16 is unreachable (#9411)
This commit updates `AddressResolver::Resolve()` to validate that the
associated RLOC16 is reachable in the sense that a valid next hop can
be found towards it, before using a matching cache entry in
`mCachedList` or `mSnoopedList`. If the RLOC16 is not reachable, the
cache entry is removed to trigger a new address query.
2023-09-13 11:35:32 -07:00
Li Cao 694528a9b9 [include] remove include of core config file (#9417)
The core config file shouldn't be included in public API headers
because they will be included from high level project code (like
ot-br-posix) and the config file cannot be located if included here.
2023-09-12 16:27:58 -07:00
Eduardo Montoya d62167ee34 [csl] ignore zero valued CSL IE period (#9414)
Ignore a CSL IE with period set to 0.

Accepting it would eventually lead to a division by 0 fault in
`CslTxScheduler::GetNextCslTransmissionDelay`.
2023-09-11 17:59:58 -07:00
Florian Grandel 6da6e09392 [mac] document and adjust to standards based timing concepts (#9322)
Adds a precise specification for the local radio clock that is at the
core of all timing-sensitive aspects of the IEEE 802.15.4 protocol
(currently mostly CSL) and refers to this definition for fields that
reference the radio clock.

Specifies the reference planes and message timestamp points for RX
timestamps, RX windows and timed TX.

Documents the Thread-specific interpretation of the CSL Phase and
derives the formula for CSL TX timestamps from it.

Based on the standard based definitions given, the TX timestamp used
for timed TX now refers to the start of PHR. This change needs to be
synchronized with the platform radio driver implementations. An
appropriate change set has been prepared for Zephyr.
2023-09-11 16:17:48 -07:00
dependabot[bot] 2ce6e9514a github-actions: bump actions/setup-go from 4.0.1 to 4.1.0 (#9413)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/fac708d6674e30b6ba41289acaab6d4b75aa0753...93397bea11091df50f3d7e59dc26a7711a8bcfbe)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-09-11 09:24:33 -07:00
Abtin Keshavarzian d94c4e0085 [mle] suppress Announce response to orphan child on same channel and PAN ID (#9388)
This commit updates MLE to skip sending an Announce response when
receiving an Announce message from a detached/orphan device and the
included channel and PAN ID in the received Announce message are the
same as the current network's channel and PAN ID.
2023-09-11 06:49:08 -07:00
jrhodie 0b269e12b9 [cli] add Doxygen tags to all trel commands (#9406) 2023-09-08 10:02:42 -07:00
jrhodie 79a3a26db6 [docs] CLI updates (#9401) 2023-09-06 13:53:38 -07:00
Abtin Keshavarzian d3608df7d4 [srp-server] process completed update from proxy from taskelt (#9398)
This commit enhances `Srp::Server` to process and commit the completed
`UpdateMetadata` entries (signaled by the "proxy service handler"
calling `HandleServiceUpdateResult()`) from a `Tasklet`. This change
is helpful in the case where the `HandleServiceUpdateResult
()` callback is invoked directly from the "update service handler"
itself. While `Srp::Server` can handle this situation, the change
makes it easier for platform implementations of advertising proxy.

In particular, it addresses an issue with the `otbr` advertising proxy
implementation. This implementation can potentially access an already
freed `Host` object. This can happen because the implementation may
hold on to the `Host` object while iterating over its `Service`
entries as advertising an earlier `Service` of the same `Host` may
fail immediately and invoke the callback directly. This would then
cause the `Host` to be freed by `Srp::Server`.
2023-09-06 11:22:49 -07:00
Abtin Keshavarzian 5c051ffeb5 [script] check-size to generate formatted table on push (#9382)
This commit updates the `check-size` script to generate a formatted
table on a branch push. The table will first include the code size
difference for all binary files, followed by the difference for all
library files. This allows us to use the `check-size` script on local
machines during development to get a full size impact report, similar
to what will be reported on the GitHub Action branch push.

This commit also generates a size report for posting on a pull request
in Markdown format. In particular, the table with the size difference
for all library files is added as a collapsible section after the
main table for binary files.
2023-09-06 11:13:18 -07:00
Eduardo Montoya c6bece0729 [data-poll-handler] reset tx attempts when replacing a frame (#9397)
Whenever an indirect/CSL transmitted frame is being purged or replaced,
make sure that both indirect and CSL transmission attempts counts are
reset in order to avoid issues like considering a new frame as a
retransmission.
2023-09-05 10:48:03 -07:00
dependabot[bot] a0a9cf26f0 github-actions: bump actions/checkout from 3.5.3 to 3.6.0 (#9396)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/c85c95e3d7251135ab7dc9ce3241c5835cc595a9...f43a0e5ff2bd294095638e18286ca9a3d1956744)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-09-05 10:11:48 -07:00
Li Cao 8c2abba2f8 [link-metrics] implement link metrics manager (#9375)
This commit implements a new module LinkMetricsManager, which utilizes
the Link Metrics feature to get the Link Metrics data from neighboring
devices.

The commit also adds a few tests to the module:
- Unit Test: tests/unit/test_link_metrics_manager.cpp, will be run in
  `unit-tests` in `unit.yml`.
- Expect Test: tests/scripts/expect/v1_2-linkmetricsmgr.exp, will be
  run in `expects` in `simulation-1.2.yml`.
- Simulation Test:
  tests/scripts/thread-cert/v1_2_LowPower_test_link_metrics_manager.py,
  will be run in `packet-verification-low-power` in
  `simulation-1.2.yml`.
2023-09-02 08:14:24 -07:00
jrhodie 830572f816 [docs] added Doxygen tags to new CLIs (#9384) 2023-08-31 10:46:20 -07:00
Abtin Keshavarzian af013a9da0 [mle] add OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE (#9387)
This commit adds a build configuration flag for the feature to set and
get device properties, which are then used to calculate the local
leader weight on a device. The feature is enabled by default on
Thread 1.3.1 or later. The new configuration flag allows OpenThread
project integrators to enable this feature on earlier versions if
desired.
2023-08-31 08:40:22 -07:00
Zhangwx 4ae691476f [cli] fix RTT compiling issue (#9385)
If macro OPENTHREAD_UART_RTT_ENABLE is not enabled, the file
SEGGER_RTT.h and related should not be included.
2023-08-30 13:25:33 -07:00
Karol Witusik e4d953c9bf [meshcop] print TLV State after receiving responses (#9350) 2023-08-29 09:51:08 -07:00
Abtin Keshavarzian 98292673fb [core] add separate neighbor.hpp, child.hpp, and router.hpp (#9376)
This commit adds separate files for `Neighbor`, `Child`, and `Router`
classes.
2023-08-29 08:47:11 -07:00
Abtin Keshavarzian 7b0fe821a3 [mesh-forwarder] update aIp6Header arg name to follow style guide (#9378) 2023-08-28 11:28:41 -07:00
dependabot[bot] 746b82570a github-actions: bump github/codeql-action from 2.20.3 to 2.21.4 (#9377)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.20.3 to 2.21.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/46ed16ded91731b2df79a2893d3aea8e9f03b5c4...a09933a12a80f87b87005513f0abb1494c27a716)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2023-08-28 11:27:53 -07:00
jrhodie d4155e4e5f [docs] add tags to new CLIs (#9367) 2023-08-25 12:24:16 -07:00
Abtin Keshavarzian d5a09415be [script] update the check-size report (#9368)
This commit updates the `check-size` script and how the OpenThread
size report is generated and reported.

The size report now includes four device types:
- FTD (not acting as a BR)
- MTD (including SED)
- Border Router (BR)
- RCP

Each type uses its own example config header file (e.g., BR uses
`examples/config/ot-core-config-check-size-br.h`). These header files
specify all the OT configs and enable/disable the set of features
that make sense for the given type.

This replaces the previous model where the same set of configs were
used for all types. This change allows us to track the code size of a
typical BR build, as well as the code size of other device types.

In order to build and generate a size report for the BR configuration
example with BR-specific features enabled (such as Border Routing
Manager or NAT64), we need an implementation of the related platform
APIs that are used by these features (e.g. `otPlatInfraIf` APIs).
This commit adds mock empty implementations of these APIs, which are
only included in the size-report builds.
2023-08-25 11:29:39 -07:00
sarveshkumarv3 6009decd43 [trel] bugfix for MAC security failure on key sequence change (#9371)
In multi-radio scenarios, any key sequence change currently resets the
MAC frame counter for the PHY link over which the first frame (with
new keyId and frame counter) is received. Since the neighbor key
sequence is already modified, any subsequent frame received over the
alternate PHY would have match the neighbor key sequence, but
potentially smaller frame counter, which leads to drops due to
security failure.
2023-08-24 09:19:03 -07:00
Abtin Keshavarzian c10f650468 [cli] simplify dataset commands (#9366)
This commit simplifies the `Cli::Dataset` implementation by defining
an array of `ComponentMapper` structures. Each `ComponentMapper`
structure corresponds to a Dataset component, and provides the
following information:
- The component's CLI name
- A method pointer to output that component
- A method pointer to parse that component
- A pointer to the component's mIsPresent boolean flag

A new `LookupMapper()` method allows us to find (using binary search)
the entry corresponding to a given component name. This model allows
us to reuse code patterns for the main dataset sub-commands,
`mgmtsetcommand`, and `mgmtgetcommand` commands when outputting or
parsing dataset components.
2023-08-23 14:30:30 -07:00
gavinmcgovern 9dd3f2005b [docs] cli cmd doc updates (locate - log level) (#9354) 2023-08-23 10:48:27 -07:00
Sam Kumar 519537dd9b [tcplp] add support for TCP Fast Open (without cookie management) (#9165)
This commit adds support for TCP Fast Open, without cookie management.

To add support for this, I looked at the FreeBSD codebase and brought
in some code from FreeBSD 12.0 that implements TCP Fast Open --- the
version of FreeBSD that TCPlp is based on did not fully support TCP
Fast Open.

Normally, a part of TFO is cookie management --- the server generates
a cookie and includes it in the initial handshake, and client is
expected to present this cookie on future handshakes. This part is not
yet implemented, and I changed the logic from FreeBSD to allow data to
be exchanged in the TFO handshake even if the client does not present
a cookie. If we implement this functionality for TFO later, it is
probably worth departing from FreeBSD's data structures and policies
for maintaining cookie state in favor of something that is simpler and
more memory-efficient.
2023-08-21 15:00:52 -07:00
dependabot[bot] 8bafcd36ed github-actions: bump step-security/harden-runner from 2.5.0 to 2.5.1 (#9365)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.5.0 to 2.5.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/cba0d00b1fc9a034e1e642ea0f1103c282990604...8ca2b8b2ece13480cda6dacd3511b49857a23c09)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-08-21 10:27:34 -07:00
Abtin Keshavarzian d808119b8d [mesh-forwarder] minimize use of default parameters in methods (#9364)
This commit removes default parameters from methods in
`MeshForwarder` class
2023-08-21 10:12:50 -07:00
Kangping 102a631cb3 [posix] allow disabling CLI for daemon (#9357)
The CLI interface for the posix daemon ise useful for testing and
debugging but may not be useful for release/user builds. on size
sensitive plaforms such as Android, disabling the daemon CLI will
reduce the ot-daemon binary size by around 150 KB.

So this commit defines config
"OPENTHREAD_POSIX_CONFIG_DAEMON_CLI_ENABLE" to make the daemon CLI
interface optional.
2023-08-17 15:20:55 -07:00
Abtin Keshavarzian f14d7264da [dnssd-server] simplify resolving of query by proxy (#9353)
This commit enhances the DNSSD Server by updating how it stores and
tracks information when trying to resolve a received query using a
discovery proxy.

The previous approach used a fixed-size array to retain information
for pending proxy queries. The new approach uses the already
allocated `Response.mMessage` and appends the newly defined
`ProxyQueryInfo` struct to it. The `ProxyQueryInfo` struct specifies
all the information we need to track associated with a query.
`ProxyQuery` message entries are placed in a message queue waiting
for a callback from the proxy. Once a callback is received, the
`ProxyQuery` message is converted back to a `Response.mMessage` and
response is prepared and sent. The new approach removes the
restriction on the number of outstanding proxy queries and simplifies
the code.

This commit also updates the `Response` to use `OwnedPtr<Message>` to
track the allocated response message (`mMessage`). This simplifies
the logic for freeing the message in case of errors. It also helps to
make it easier to track ownership transfers of the message. For
example, if `ResolveByProxy()` successfully takes over the message to
use as a `ProxyQuery`, the owned pointer (`mMessage`) in the
`Response` class is cleared, ensuring that the response is not sent
immediately and the message is not freed. Overall, `ProcessQuery()`
method becomes simpler, as we can now decide whether or not to send
a response based on whether or not `mMessage` is nullptr.
2023-08-16 11:37:19 -07:00
Abtin Keshavarzian 7e32165bee [dnssd-server] determine query type & simplify processing of query name (#9349)
This commit simplifies and enhances the DNSSD Server implementation:

- A new method, `ParseQuestions()`, has been added to process the
  questions in a received `Request` message and determine the
  `QueryType`.

- The processing and appending of the query DNS name has been
  simplified. The query name is now read and copied label by label
  from the `Request` message into the `Response`. When matching the
  name against SRP entries, the names are compared with the query
  name directly as it is encoded in the `Response` message using the
  `Dns::Name::CompareName()` method. This approach is more flexible
  and simpler, and it works for all query types and name formats,
  including service instance names where the first label can itself
  contain a dot (`.`) character. This simplification allows us to
  remove the helper functions that were previously used to parse the
  query name and deal with the ambiguity that arises when service
  instance names are read as strings of dot-separated labels.

- The management of offsets for DNS name compression has also been
  simplified. A new method, `Response::ParseQueryName()`, has been
  added to validate the query name (e.g., that it contains the
  correct domain) and determine all offsets.

- The `ResolveBySrp()` method has also been simplified using query
  type and the newly added flavors of `Append{Ptr/Srv/Txt}Record()`
  methods.

- Finally, this commit adds the `Dns::Name::ExtractLabels()` helper
  method, which extracts label(s) from a full DNS name string by
  first checking that it contains a given suffix name (e.g., the
  suffix name can be a domain name or a service name) and then
  removing it, returning the label(s).
2023-08-15 12:12:02 -07:00
Abtin Keshavarzian 3b291108a9 [mac-frame] update GenerateEnhAck() to use InitMacHeader() (#9338)
This commit updates the `GenerateEnhAck()` method to add checks to
validate the received frame before preparing the ACK. These checks
are added as a safeguard in case the caller (radio platform
implementation) does not validate the received frame before calling
this method to generate the ACK.

Specifically, the checks verify that the received frame is using the
2015 version, has the "Ack Request" flag, has a valid source address
(which is used as the destination in the generated ACK), and has a
valid destination address that is not broadcast. The checks also
verify that if the received frame is secured, it uses security level
`kSecurityEncMic32`.

The commit also simplifies the code by using `InitMacHeader()` to
prepare the header and addresses. Enhanced ACK frames always have a
destination address and no source address (to keep the frame
shorter). If the received frame has a source PAN ID, it is used in
the ACK frame. If it does not, the code checks if the received frame
has a destination PAN ID and uses that in the ACK frame.
2023-08-14 21:45:38 -07:00
Abtin Keshavarzian 4d494a864f [mle] reorganize MLE constants (#9355)
This commit reorganizes the MLE constants that were previously defined
in the `mle_types.hpp` header file.

Global constants (those that are used by multiple classes) are kept in
`mle_types.hpp`. Other constants are moved to the specific class that
uses them. For example, many of the delay and timeout definitions are
now defined in the `Mle` and `MleRouter` classes as `private`
constants.

Some of the constants are renamed to simplify or shorten their names,
or to make it clear how they are used. Also, some of the time interval
constants are now defined directly in milliseconds (avoid using
`Time::SecToMsec()`).
2023-08-14 17:06:39 -07:00
dependabot[bot] 10af1b275b github-actions: bump actions/setup-python from 4.6.1 to 4.7.0 (#9356)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.1 to 4.7.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/bd6b4b6205c4dbad673328db7b31b7fab9e241c0...61a6322f88396a6271a6ee3565807d608ecaddd1)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2023-08-14 17:00:02 -07:00
Abtin Keshavarzian 4639dc6fd1 [mac-frame] update InitMacFrame() (#9337)
This commit updates the `InitMacFrame()` method to allow the caller to
specify whether the source or destination PAN IDs are present or not.
It also handles all cases related to PAN ID compression as defined by
IEEE 802.15.4-2015. While these cases are not used by the Thread
stack itself, adding them to `InitMacFrame()` makes it more capable
allowing future use-cases of this method such as generating enhanced
ACKs based on a received frame.

The `test_mac_frame` unit test has been updated to cover the newly
added cases.
2023-08-14 13:35:08 -07:00
Lorenzo Rai b03022b2af [cli] support RTT as cli interface (#9148)
This commit adds an RTT implementation for the cli uart api. This can
be enabled using the `OT_RTT_UART` flag for cmake or
`OPENTHREAD_ENABLE_RTT_UART` for make.
2023-08-14 09:05:15 -07:00
jrhodie 68c05650ee [docs] added Doxygen tags to 4 CLIs (#9352) 2023-08-13 14:41:43 -07:00
Li Cao 73daf43bbd [link-metrics] update link metrics callback parameter (#9343)
This commit updates the type of parameter `status` in
`otLinkMetricsReportCallback` and `otLinkMetricsMgmtResponseCallback`
from `uint8_t` to `otLinkMetricsStatus` for better readability.
2023-08-13 11:43:03 -07:00
dependabot[bot] 6f73ce204c github-actions: bump docker/setup-buildx-action from 2.5.0 to 2.9.1 (#9344)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.5.0 to 2.9.1.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c...4c0219f9ac95b02789c1075625400b2acbff50b1)

---
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>
2023-08-13 11:40:16 -07:00
Przemysław Bida 973b594eaa [posix] fix rcp reset flow in ResetRcp (#9314)
Remove call to `WaitResponse` after calling `HardwareReset` which didn't
trigger any spinel transaction.

`kOpenFileDelay` change form 500 to 50.
2023-08-13 11:08:59 -07:00
Abtin Keshavarzian 6f7767a8ae [mesh-forwarder] disallow new message eviction in ApplyDirectTxQueueLimit() (#9348)
This commit updates the `ApplyDirectTxQueueLimit()` method. We mark
the "do not evict" flag on the newly queued `aMessage` so that it
will not be removed from `RemoveAgedMessages()`. This protects
against the unlikely case where the newly queued `aMessage` may
already be aged due to execution being interrupted for a long time
between the queuing of the message in `SendMessage()` and the call to
`ApplyDirectTxQueueLimit()`. This protects against the message being
potentially removed and freed twice.
2023-08-13 10:43:26 -07:00
Abtin Keshavarzian 70adcabca6 [dns-client] handle multiple CNAME record in response (#9339)
This commit updates the `CheckForHostNameAlias()` method to handle the
case where the response may include multiple CNAME records. For
example, host name mapped to another name which is itself mapped
again. In order to detect CNAME record loops, we limit the number
of CNAME record name changes to `kMaxCnameAliasNameChanges = 40`.
2023-08-04 15:27:31 -07:00
whd 499f6680a3 [netdata] fix the source address check in LeaderBase::RouteLookup() (#9335)
In `LeaderBase::RouteLookup()`, OT currently checks the source address
of the packet to ensure it matches any of the Prefix TLV in leader's
netdata. Actually it should also verify that the Prefix TLV has a
Border Router sub-TLV.

In the current implementation, OT may wrongly send/forward a packet to
BR when its source address matches with a Prefix TLV which only
contains an External Route sub-TLV. This lets BR accidentally forward
packets from Thread to infra network. For example, a packet from
Mesh-Local address to On-Link address will be wrongly forwarded to
infra network.

I recently noticed this problem because we're now using either
`fc00:/7` or `::/0` for external routes in netdata, which always
matches Mesh-Local source addresses and makes the issue more obvious.
2023-08-03 10:04:40 -07:00
Abtin Keshavarzian 037056b97e [dnssd-server] simplifications and enhancements (#9334)
This commit contains changes and enhancements in the DNS-SD
server/resolver class `Dns::ServiceDiscovery::Server`.

- It defines `Request` and `Response` structures, which contain all
  related information for a DNS query request and response. These
  structures simplify the code by encapsulating all the related
  information in one place.
- The `Response` class provides methods for preparing the response,
  such as appending records, DNS names to the response, or checking
  the questions or updating the header. These methods replace the
  previous `static` methods, which required all the information to be
  passed as input parameters.
- The `QueryTransacation` type is simplified by declaring it as a
  subclass of `Response`. It inherits all the helper methods from
  `Response`. Other previously defined `static` methods are now
  defined as methods of `QueryTransacation` (such as `CanAnswer()`).
- `ResolveBySrp()` and its related methods now directly populate the
  DNS response code in the `Response` DNS header instead of returning
  it.
- `ResolveBySrp()` is updated such that if a failure is encountered
  when preparing the answer section, no further processing is
  performed. This ensures that a previous failure `rcode` is not
  overwritten. When preparing the additional section, certain
  `rcode` failures are allowed, such as if the DNS name is not found.
- The processing of `Timer` is simplified, using `FiretAtIfEarlier()`
  and determining next expire time from `HandleTimer()`.
- This commit also adds an empty implementation of the `otPlatDns{}`
  functions (used with `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE`)
  under the simulation platform.
2023-08-03 09:33:31 -07:00
Abtin Keshavarzian 992be2781f [dnssd-server] send response if ResolveByUpstream() fails (#9331)
When `ResolveByUpstream()` returns an error, we ensure that the error
is cleared so that the transmission of the DNS response (with
`kResponseServerFailure` rcode) is not skipped at the `exit` label.
2023-08-01 16:54:29 -07:00
Jonathan Hui 7d6740c9b5 [clang-tidy] fix bugprone-too-small-loop-variable warnings (#9321) 2023-08-01 16:52:34 -07:00
Axel Le Bourhis 94822eadb5 [spinel] networkInfo may not exist when recovering from RCP failure (#9327)
Current implementation of RestoreProperties() assumes there's always a
networkInfo structure stored in the settings.  But, it's possible the
RCP device needs to be recovered before this structure is populated.

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
2023-07-31 11:27:51 -07:00
Abtin Keshavarzian a361aebc8b [mle] reorder Mle class member variables (#9320)
This commit reorders member variables in the `Mle` class, bringing
booleans and `uint`s of the same size close to each other to avoid
alignment gaps.
2023-07-31 10:41:06 -07:00
Maciej Baczmański dc97b87376 [thci] fix for ncs thci issues (#9328)
After recent reference device release, two THCI issues
have been found.

This commit adds `"` around command arguments that have
escapable characters (like `ot networkname aa\ bb`),
and skips lines containing only ANSI escape codes
in commissioning logs.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2023-07-31 10:18:08 -07:00
Zhangwx 29b87786cd [docs] fix some typos (#9324) 2023-07-31 10:02:01 -07:00
dependabot[bot] b4367909e1 github-actions: bump step-security/harden-runner from 2.4.1 to 2.5.0 (#9325)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/55d479fb1c5bcad5a4f9099a5d9f37c8857b2845...cba0d00b1fc9a034e1e642ea0f1103c282990604)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-07-31 10:01:30 -07:00
Abtin Keshavarzian e958f8827e [mle] change protected declarations as `private (#9317)
This commit changes the `protected` declarations in the `Mle` class to
be `private` since `Mle` class and its subclass, the `MleRouter`, are
declared as `friend` classes.

The commit also re-arranges the `private` definitions in the `Mle`
class into five sections: constants, enumerations, nested classes,
methods declarations, and member variable definitions.

With the change to `private`, this commit also removes the redundant
documentation of methods.
2023-07-28 09:18:34 -07:00
Abtin Keshavarzian 3fd192dfa7 [mac-frame] check rx frame security level in GenerateEnhAck() (#9315)
This commit updates the `Mac::TxFrame::GenerateEnhAck()` method to
check the security level of the received frame. If the security level
is not `kSecurityEncMic32`, it will return `kErrorParse`. This should
help prevent radio platform implementations from trying to perform tx
security on an invalid generated enhanced ack frame. Specifically, it
can help prevent radio platforms from calling `ProcessTxSecurity()`
on an enhanced ack frame with a security level of `kSecurityNone`
which can cause an assert in `AesCcm::Init()` due to the tag length
being zero.
2023-07-28 09:16:39 -07:00
Abtin Keshavarzian 650e30f81c [mle] update Avd trickle timer interval based on router neighbor count (#9307)
This commit updates the `TrickleTimer` to allow `IntervalMax` and
`IntervalMin` to be changed while the timer is running. In particular,
when `IntervalMax` is changed to a value that is shorter than the
current interval being used by the timer, the timer will adapt the
new shorter interval and may fire immediately.

A unit test `test_trickle_timer` has been added to validate the
behavior of `TrickleTimer` in detail. All different scenarios where
`IntervalMax` or `IntervalMin` are changed are covered by the
unit test.

The new mechanism to change the trickle timer `IntervalMax` is
used to update the MLE Advertisement trickle timer. The `IntervalMax`
is determined based on the number of router neighbors of the device
with link quality 2 or better. If the device has fewer router neighbors,
it will use a shorter `IntervalMax`. As new links are established
with routers, the `IntervalMax` is recalculated and updated on the
Advertisement trickle timer.

This commit also adds a new test `test-024-mle-adv-imax-change.py` to
validate updates to the `IntervalMax` value based on the number of
router neighbors.

Co-authored-by: David Smith <david.smith@mmbnetworks.com>
2023-07-26 15:50:40 -07:00
Jonathan Hui 9b0d3db228 [link-metrics] verify neighbor state when processing messages (#9311) 2023-07-25 09:13:45 -07:00
Zhangwx 5be432edeb [routing-manager] add SetIfIndex in RoutingManager (#9305)
This commit adds `SetIfIndex` method to `RoutingManager` class. This
method allows the infrastructure interface to be changed. The user may
initialize multiple interfaces and choose one interface as
infrastructure interface. During run time, there might be some
networking congestion or other network issue. The user can change the
infrastructure interface via this function.

This commit also adds docs for the `init` command.
2023-07-24 14:18:27 -07:00
Jonathan Hui 1f1c155dc2 [clang-tidy] move config to .clang-tidy file (#9308) 2023-07-24 11:45:18 -07:00
dependabot[bot] 34906f4a57 github-actions: bump step-security/harden-runner from 2.3.1 to 2.4.1 (#9310)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.3.1 to 2.4.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/6b3083af2869dc3314a0257a42f4af696cc79ba3...55d479fb1c5bcad5a4f9099a5d9f37c8857b2845)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-07-24 11:44:52 -07:00
Abtin Keshavarzian 8ea2031c74 [srp-server] ensure Host is freed when committing with zero key-lease (#9309)
This commit updates `CommitSrpUpdate()` to ensure that `aHost` is
freed when granted key lease is zero and host is fully removed.

This commit also updates unit test `test_srp_server` (which checks the
heap allocations by server) to cover the situations where client sends
an update to remove host and all its services with or without
clearing key-lease.
2023-07-22 08:18:27 -07:00
Abtin Keshavarzian 955b07416b [cli] add docs for detach command (#9303) 2023-07-21 10:33:57 -07:00
Abtin Keshavarzian 793bf78df1 [config] define separate project and platform core config header (#9291)
This commit updates and enhances the specification of OT core config
header files. It adds `OPENTHREAD_PLATFORM_CORE_CONFIG_FILE`, which
can be used by platforms to provide a core config header file name.

The project and platform specific config header files are included in
the following order:

1. Project specific header (`OPENTHREAD_PROJECT_CORE_CONFIG_FILE`)
2. Platform specific header (`OPENTHREAD_PLATFORM_CORE_CONFIG_FILE`)
3. Default config values as specified by `config/{module}.h`

CMake config options `OT_PROJECT_CONFIG` and `OT_PLATFORM_CONFIG` are
also defined, which can be used to specify project and platform
config headers. Platforms can define a default config header for
`OT_PLATFORM_CONFIG`. The existing `OT_CONFIG` CMake option is marked
as deprecated (with a warning message which recommends use of the new
configs).

This commit also updates the default simulation and POSIX core config
headers to remove extra Doxygen-style documentation and ensure that
all definitions have an `#ifndef` guard check.
2023-07-21 10:33:12 -07:00
Abtin Keshavarzian b19b2cfa75 [mle] define separate TxChallenge and RxChallenge types (#9304)
This commit defines two types to track challenge or response TLV data
in MLE messages:

- `TxChallenge` represents the maximum-sized challenge data to include
  and send in MLE messages. OpenThread always uses the maximum size
  of 8 bytes for challenge data in the messages it sends.
- `RxChallenge` represents variable-length challenge data read from a
  received MLE message.

The two separate types help to simplify their use in code.
2023-07-20 10:07:09 -07:00
Abtin Keshavarzian 5fc0e7774c [csl] update CSL public APIs to use microseconds unit for period (#9285)
This commit updates public APIs for getting and setting CSL period to
use microseconds unit instead of the internal ten symbols unit. This
makes the APIs easier to use.

The CSL APIs have been renamed to follow the `otLinkGet/SetCsl{Item}()`
pattern, which is the common naming style of OpenThread. This
renaming will make the APIs more consistent and avoid potential
confusion with the now-removed APIs, which used a different unit for
CSL period.

This commit also updates the related CLI CSL commands:
- The `csl period` expects the given period to be in microseconds.
- The `csl` command (which outputs all CSL parameter) shows the CSL
  period in microsecond unit (e.g., "Period: 160000us").

The NCP spinel `SPINEL_PROP_THREAD_CSL_PERIOD` is also updated to use
microsecond unit for CSL period.

The related test script are updated to use the new unit, in particular
the test harness `setCSLperiod()` in `harness-thci/OpenThread.py` is
updated (no need to convert from msec).
2023-07-19 13:21:29 -07:00
Abtin Keshavarzian 5340a6e944 [srp-server] simplify tracking of host key (#9296)
This commit simplifies tracking of host key in `Srp::Server` by saving
the `Key` directly in a `Host` instead of the saving the `KeyRecord`.
2023-07-19 10:35:42 -07:00
Abtin Keshavarzian a0f7253017 [srp-server] simplify RemoveHost() method (#9295)
This commit simplifies the `Sever::RemoveHost()` method by removing
the input parameter `aNotifyServiceHandler`. This is because, unlike
the `RemoveService()` method, the `RemoveHost()` method always needs
to notify the service handler.
2023-07-19 10:35:18 -07:00
Kangping 7f4c7fca2e [posix] loose check for NETLINK_EXT_ACK and NETLINK_CAP_ACK (#9299)
`NETLINK_EXT_ACK` and `NETLINK_CAP_ACK` are for getting netlink reply
details from the kernel and we can still function without the two
options.

This commit loose the check of enabling the two options to make
ot-posix works on platforms where the features are missing.
2023-07-19 00:20:25 -07:00
Nick Bertoldi 57d9541675 [posix] fix name of vendor-supplied target to OT_POSIX_CONFIG_RCP_VENDOR_INTERFACE (#9297)
This commit fixes the name of the vendor supplied target to
OT_POSIX_CONFIG_RCP_VENDOR_INTERFACE so that this target name and the
misspelled target name do not both need to be defined by vendors.
2023-07-18 23:57:20 -07:00
Nick Bertoldi d973b60658 [posix] replace RCP vendor extension find package with include command (#9241)
This change updates the mechanism used by vendor.cmake to include a
cmake file to define the required vendor targets used by the rcp
vendor interface library instead of the find_package command that was
previously used.

The find_package command would allow for a package to be searched for
and a target to be linked unconditionally if defined by the CMake
project. This would lead to problems if the target was already
defined, perhaps as a subdirectory of a super project, and the cache
variable is still set for the openthread build. Additionally, this
change also brings the vendor extension of the posix library more in
line with the cli vendor extension, which was created after
find_package was used in vendor.cmake.
2023-07-18 20:22:01 -07:00
Jake Swensen 5b196bb5ea [random] remove mbedtls header from api (#9286)
When trying to opaquely bind to the public facing API, including
<mbedtls/ctr_drbg.h> forces an external dependency on mbedtls.
2023-07-18 15:23:30 -07:00
Abtin Keshavarzian ec8c7b7f17 [mle] simplify HandleChildIdRequest() (#9292)
This commit simplifies the `MleRouter::HandleChildIdRequest()` method
by directly tracking the list of MLE TLVs to be included in the
response in a `TlvList`. This replaces the previous approach of using
boolean flags to track which TLVs should be included. The use of
`TlvList` also protects against the case where the child may have
included the same TLV type in the "TLV Request TLV" and ensures
that we do not include duplicate TLVs in the response.
2023-07-18 10:22:32 -07:00
Li Cao 199931fe90 [link-metrics] minimize the Link Metrics entry count for MTD (#9188)
Currently to support Link Metrics Subject, we pre-allocate 128
entries. But this is unnecessary for MTD since it will only have one
neighbor. This commit minimizes the number to 2 - one for Enhanced-ACK
Probing and one for Forward Tracking Series.
2023-07-18 10:01:59 -07:00
Abtin Keshavarzian 0e0a49716e [cmake] add macros to simplify CMake config definition (#9288)
This commit simplifies the definition of CMake configurations by
adding new macros:
- `ot_string_option` for string-valued options (`OT_VENDOR_NAME`)
- `ot_int_option` for int-valued options (`OT_MLE_MAX_CHILDREN`)
- `ot_multi_option` for multi-valued options (`OT_LOG_LEVEL`)

The option definitions have also been moved to the `options.cmake`
file from `./CMakeLists.txt`.
2023-07-17 17:45:08 -07:00
Abtin Keshavarzian bec592084c [dnssd-server] skip additional records on a PTR query with multiple answers (#9281)
This commit updates `Dns::ServiceDiscovery::Server` such that when
answering a PTR query with more than one answer, it does not include
additional records. This is to keep the size of the response small.

This commit also updates the test scripts validating browse (PTR
query) function to check the new behavior. In particular, a common
python function `_parse_dns_service_info()` is added to parse service
info in CLI output of "dns browse" or "dns service" commands and
handle if output of "dns browse" does not include service info.
2023-07-17 13:09:06 -07:00
Kangping 55cb65de62 [posix] fix logging of netlink errors (#9287)
This commit fixes the netlink ACK error logging by extracting error
messages from the `NLMSGERR_ATTR_MSG` attribute. The key point is that
the error code in the `nlmsgerr` header is not necessary `errno` and
can't be used with `strerror()`.
2023-07-17 10:57:43 -07:00
dependabot[bot] ce44625357 github-actions: bump docker/login-action from 2.1.0 to 2.2.0 (#9289)
Bumps [docker/login-action](https://github.com/docker/login-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/f4ef78c080cd8ba55a85445d5b36e214a81df20a...465a07811f14bebb1938fbed4728c6a1ff8901fc)

---
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>
2023-07-17 08:54:20 -07:00
Abtin Keshavarzian f7690fe7e9 [routing-manager] support Advertising PIO (AP) flag in published route (#9274)
This commit adds support for the Advertising PIO (AP) flag in Network
Data `ExternalRoute` entries. It also updates the `RoutingManager`
class to set the AP flag on its published Network Data route when the
local on-link prefix is included as PIO in emitted RA messages, which
is equivalent to when the local on-link prefix is being published,
advertised, or deprecated.

This commit also updates the `test_routing_manager` unit test to
validate the AP flag in the published route under different
scenarios.
2023-07-13 10:19:52 -07:00
Abtin Keshavarzian 5beae14370 [toranj] remove docs from test specific config headers (#9276)
This commit removes the unnecessary Doxygen-style documentation of
used configuration options from toranj config header files. This
makes the test-specific config header simpler and avoids confusion
with the main config parameters documentation, which is included in
the corresponding `src/config/<name>.h` header files.
2023-07-12 16:44:37 -07:00
Abtin Keshavarzian 0dd706e56e [github-action] install prettier@2.0.4 in pretty job (#9279)
This commit adds command to install `prettier@2.0.4` from the
Bootstrap step in `pretty` job of `build.yml` GitHub Action workflow.
This should help with occasional failure of `pretty` check.
2023-07-12 16:39:34 -07:00
Abtin Keshavarzian 34e9b9243b [routing-manager] add SetState() in OnLinkPrefixManager (#9273)
This commit adds `SetState()` method to the `OnLinkPrefixManager`
class. This method allows the state of the on-link prefix manager to
be changed in a single place, which simplifies the logging and makes
it easier to take additional actions on state change. For example,
the `SetState()` can be used to update the Advertising PIO (AP) flag
in the published route in Network Data.
2023-07-12 15:47:35 -07:00
Zhangwx fd62216aa8 [border-agent] fix struct typedef for otBorderAgentId (#9277) 2023-07-12 14:14:43 -07:00
Zhangwx b964db6f11 [spinel] fix error code when waiting rcp response timeout (#9278)
For the RCP waiting response timeout handle logic, the error code of
processing `WaitResponse()` will be checked, if there is no error, the
function `ResetRcp` will return with a log "Software reset RCP
successfully". But the implementation of the `WaitResponse` it will
always return OT_ERROR_NONE even if waiting response timeout.

This commit returns `OT_ERROR_RESPONSE_TIMEOUT` on response timeout.
2023-07-12 10:06:22 -07:00
Abtin Keshavarzian ec93c24007 [srp-server] simplify sub-type services (#9208)
This commit updates and simplifies how `Srp::Server` stores the
sub-type services. The earlier implementation treated each sub-type
as its own service, which was tracked by a `Service` object. This
design allowed sub-type services to be registered and deleted
individually. However, the latest SRP RFC draft requires SRP servers
to treat updates to a service and all its sub-types as atomic. This
means that when a service and its sub-types are being updated, the
SRP Update message must contain the entirety of information about
that service and its sub-types. As a result of this change, we can
simplify the server implementation by tracking sub-types as an array
of sub-type names in the `Service` object.

This commit also updates the way the server commits a received SRP
update info into its existing data. Previously, the server would try
to merge the new information into existing `Host` and `Service`
objects. However, this could be inefficient, as it would require
moving heap-allocated items like "txt data" and/or array of host IPv6
addresses from one object to another. The new `CommitSrpUpdate()`
implementation now starts from the new `Host` object that is
constructed as the received SRP Update message from the client is
parsed. Any previously registered services that are not present in
the new `Host` object are then moved into it.

This commit adds new public OT APIs for retrieving the sub-types
associated with a service and making it easier to iterate over the
list of registered services by a host. Due to fundamental changes in
how services are stored by the `Srp::Server` class, some existing
public `otSrpServer` APIs for filtering and iterating over services
are being removed.
2023-07-11 13:21:34 -07:00
Eduardo Montoya edb7f05047 [mle] ensure key sequence is updated in MLE responses (#9271)
Processing of the Key Sequence is happening after each individual MLE
command processing, which leads to generating MLE responses with
outdated Key Sequence.

Make sure that the new greater Key Sequence is applied before
generating any MLE response.

A test case is updated to catch the case in which fragmented Child Id
Response was generated with the old Key Sequence whereas each
individual MAC fragment is already updated with the new Key Sequence,
leading to a security error.
2023-07-11 13:18:40 -07:00
Abtin Keshavarzian e6df00dd66 [mesh-forwarder] add time-in-queue statistics collection feature (#9170)
This commit adds the ability to collect statistics on the time
messages spend in the TX queue.

When enabled, a histogram of the time-in-queue is collected. The
time-in-queue is tracked for direct transmissions only, and is
measured as the duration from when a message is added to the TX queue
until it is passed to the MAC layer for transmission or dropped.

The histogram data consists of a number of bins, each representing a
range of time-in-queue values. The bin interval length and maximum
tracked interval can be configured using newly added configuration
options.

This commit also adds a new public OT API and a related CLI command
(`timeinqueue`) to get the collected statistics or reset the data.
2023-07-10 13:34:35 -07:00
Abtin Keshavarzian 1839f15417 [net-diag] define Child, Neighbor, and Child IPv6 Address List TLVs (#8866)
This commit contains multiple changes to Network Diagnostics
modules.

It adds new TLVs: Child TLV, Child IPv6 Address List TLV, Router
Neighbor TLV and MLE counters TLV.

Child TLV contains information about a child entry including RLOC16,
extended MAC address, mode (rx-on-idle, FTD/MTD, full netdata,
CSL-sync), timeout, age, supervision interval, CSL period and
timeout, and link quality info such as RSS (last and average) and
frame/message error rates. Neighbor TLV provides similar info for a
router neighbor. The Child IPv6 Address List TLV allows to query a
parent to get the list of IPv6 addresses registered by its MTD
children.

The new Child and Neighbor TLVs can be requested in Network Diagnostic
Get Query "d/dq" message to a router (unicast) or multiple routers
(multicast). The router responds with one or more Network Diagnostic
Get Answer "d/da" messages.

We allow multiple Answer messages to be sent in response to a Query.
This is to support the case where a router has many children, and we
want to avoid sending a large message that contains all of the TLVs
for all of the children. Instead, we can send a sequence of Answer
messages, each of which contains a subset of the TLVs.

Each Answer message includes an Answer TLV that indicates the index of
the message in the sequence. The first Answer message has an index of
0, the second has an index of 1, and so on. The Answer TLV also
indicates whether the message is the last one in the sequence, or if
there are more Answer messages to come. Answer messages are sent in
sequence, and the next one is not sent until we receive a successful
CoAP ACK/response for the previous one.

This commit adds a Query ID TLV (with a 16-bit identifier as it
value) that can be optionally included in a Query message. The Query
ID is echoed back in all Answer messages associated with the same
Query message. This allows a node that sends multiple Queries to
distinguish between the received Answers.

This commit updates `MeshDiag` to use the newly added TLVs
to query the child table or children IPv6 addresses of a router.
New public OpenThread APIs under `otMeshDiag` are added for this,
along with CLI commands and their documentation. A test-case is added
to validate the newly added mechanism.
2023-07-10 11:35:27 -07:00
dependabot[bot] 9ed5c5e72f github-actions: bump github/codeql-action from 2.3.5 to 2.20.3 (#9265)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.5 to 2.20.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/0225834cc549ee0ca93cb085b92954821a145866...46ed16ded91731b2df79a2893d3aea8e9f03b5c4)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2023-07-10 11:12:33 -07:00
Abtin Keshavarzian 5fc78a94cb [time] update DistantFuture/Past() to exclude value half range apart (#9263)
This commit changes the `Time::GetDistantFuture/Past()` methods to
exclude the ambiguous time value which is half range `(1 << 31)`
apart. The returned value is now `(1 << 31) - 1` apart. This ensures
that `Min(now.GetDistantFuture(), now)` is well-defined and the same
as `Min(now, now.GetDistantFuture())`. This commit also updates
`test_timer` to validate this.
2023-07-10 09:27:33 -07:00
Abtin Keshavarzian ad6545a5de [commissioner] simplify and fix scheduling of expiration timer (#9262)
This commit simplifies scheduling of `mJoinerExpirationTimer` by using
`FireAtIfEarlier()` when adding or updating a `Joiner` entry instead
of recalculating the fire time. When a `Joiner` entry is removed, we
keep the timer unchanged and let it be rescheduled when the currently
scheduled timer expires. The next expiration time is determined in
`HandleJoinerExpirationTimer()`, which ensures that all expiration
times are strictly after `now` and avoids any potential issue with
the order of comparison between `now` and `next` being
`now.GetDistantFuture()`.
2023-07-10 09:25:45 -07:00
Abtin Keshavarzian 8bc25042ba [test] fix unused returned value warning in test_hdlc (#9256)
This commit updates unit test `test_hdlc` to check the returned
error from `SaveFrame()` (which was recently changed in #9244).
2023-07-06 20:27:43 -07:00
dependabot[bot] 6fe8b6f380 Bump grpcio from 1.20.1 to 1.53.0 in /tools/harness-simulation/harness (#9257)
Bumps [grpcio](https://github.com/grpc/grpc) from 1.20.1 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc/releases)
- [Changelog](https://github.com/grpc/grpc/blob/master/doc/grpc_release_schedule.md)
- [Commits](https://github.com/grpc/grpc/compare/v1.20.1...v1.53.0)

---
updated-dependencies:
- dependency-name: grpcio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-06 20:27:18 -07:00
Eduardo Montoya 37fb770989 [cli] fix childsupervision commands documentation (#9201)
Previous documentation could be wrongly interpreted as that the
supervision interval should be set on the parent (FTD).
2023-07-05 10:21:11 -07:00
Zhanglong Xia f7b189c882 [posix] fix the snprintf buffer overflow issue (#9251) 2023-07-05 10:20:07 -07:00
Eduardo Montoya cc6fa77b42 [mac] remove duplicated method for getting the MAC frame length (#9254) 2023-07-05 10:02:11 -07:00
hemanth-silabs 4eace79c98 [spinel] return error from SaveFrame if not enough space is available (#9244) 2023-07-05 10:01:22 -07:00
dependabot[bot] 6736ef2676 github-actions: bump actions/setup-python from 4.6.0 to 4.6.1 (#9252)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.6.0 to 4.6.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/57ded4d7d5e986d7296eab16560982c6dd7c923b...bd6b4b6205c4dbad673328db7b31b7fab9e241c0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2023-07-05 06:56:39 -07:00
Abtin Keshavarzian 0f7e8491e2 [routing-manager] PdPrefixManager to clear prefix bits when extending length (#9249)
This commit updates the `RoutingManager::PdPrefixManager::Process()`
method to `Tidy()` the prefix before setting the prefix length and
potentially extending the prefix to `kOmrPrefixLength` (64 bits).
This ensures that extended bits in the prefix are set to zero.
2023-07-03 05:52:11 -07:00
Abtin Keshavarzian 809cdc40be [ncp] keep timeout zero during ramp-down in spinel ADDRESS_CACHE_TABLE (#9247)
This commit updates the NCP code to set the timeout field in spinel
`SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE` as zero when in ramp-down
mode. This ensures that the behavior of the NCP remains unchanged and
that test cases like `ncp/test-039-address-cache-table-snoop.py`,
which expect the timeout to reach zero, to pass.
2023-07-02 18:35:44 -07:00
Martin Zimmermann 8081664d37 [csl] add APIs to retrieve status (#8793) 2023-07-01 13:42:22 -07:00
Abtin Keshavarzian 96eb2a4386 [address-resolver] implement ramp-down mechanism for retry delay (#9162)
Address resolver retry delay determines how long the device needs to
wait after a failed address query for a target address to allow a
next query attempt. This is tracked per target (in `CacheEntry`).

The retry delay starts with an initial value (15 seconds). If
consecutive queries fail, the retry delay doubles each time, up to a
maximum value (120 seconds). In the current code, the retry delay is
only reset to the initial value after a successful address
resolution.

This commit implements a new mechanism to reduce the retry delay over
time when there is no activity (no queries for the target address).
The ramp-down countdown starts after a previous retry delay has
expired. If no query is requested within the maximum retry delay
interval (120 seconds), the retry delay is divided by two. This
process is repeated until the retry delay reaches the initial
(minimum) value.

If a query is requested during the ramp-down process, the ramp-down is
stopped. The next actions are determined based on whether the query
is successful or fails. If the query is successful, the retry delay
is reset to the initial value. If the query fails, the retry delay
timeout is applied and the ramp-down process is started again after
the retry delay duration has expired.

This commit also updates the `test-014-address-resolver`  to validate
the newly added ramp-down behavior.
2023-07-01 11:12:25 -07:00
Abtin Keshavarzian 422f673c7c [routing-manager] determine route preference from parent link quality (#9080)
This commit updates how `RoutePublisher` determines the published
route preference:
- Medium preference is used on a border router (BR) acting as a router
  or a BR acting as an end-device (ED) connected to a parent with
  link quality 3.
- An ED BR with lower link quality publishes its route with low
  preference.

For ED BRs, the preference is updated if the parent's link quality
changes. However, to avoid frequent preference changes due to link
variability, the following rules are used:
- If the link quality goes to 1 or 2, the route preference is
  immediately changed to low.
- On transition to link quality 3, we wait for 5 minutes before
  changing the preference to medium.
- If the ED BR switches parents, the link quality to the new parent is
  used to determine preference.

It also adds new APIs and related CLI commands to allow users to get
and manually set the published route preference. A new test script
`test-021-br-route-prf.py` is added to validate the selection of
route preference by BR.

This commit also adds a new mechanism to detect when the link quality
to the parent changes and signal it using a newly added `Notifier`
event.
2023-07-01 07:50:01 -07:00
Jonathan Hui 3d5cb364f2 [mesh-forwarder] only mark Key ID Mode 0 and 1 as secure 2023-07-01 07:40:25 -07:00
cw8466 561966a01f [posix] fix missing nullptr pointer check (#9179)
Avoid segmentation fault for interfaces without link.
2023-07-01 07:28:28 -07:00
Jonathan Hui e772e8a86f [examples] remove example platform redirects (#9246) 2023-06-30 15:14:26 -07:00
Jonathan Hui de5afd0e36 [build] cleanup autotools references (#9242) 2023-06-30 15:14:13 -07:00
Jonathan Hui bad7994c28 [mac] move ack processing to HandleTransmitDone() (#9245) 2023-06-30 15:14:00 -07:00
Abtin Keshavarzian ef8deb506f [mle] delay router role downgrade on security policy change (#9187)
This commit adds a mechanism to delay the downgrade of routers or
leader when the security policy TLV changes in the Active Operational
Dataset such that the device is no longer eligible to act as a
router.

If the decision to become a child is made due to a security policy
change, the device first delays a random period up to the "router
selection jitter" before downgrading. If the device is the leader, an
additional fixed delay of 10 seconds is added to the random period.

If the security policy changes again while the device is waiting to
downgrade such that it becomes router-eligible again, the downgrade
is cancelled and the device remains in its current role.

This commit adds a `test_router_downgrade_on_sec_policy_change` to
validate the behavior of newly added mechanism.

This commit also updates the CLI `dataset` sub-commands to allow
getting and setting the "version threshold for routing" (VR) field in
security policy.
2023-06-30 15:09:50 -07:00
Jonathan Hui 60db56f0c0 [dataset] add build option for GenerateLocal (#9215) 2023-06-30 09:53:28 -07:00
Abtin Keshavarzian 77d1f3d1b5 [dns] add otDnsEncodeTxtData() API (#9214)
This commit adds the `otDnsEncodeTxtData()` public API, which encodes
a given list of TXT record entries (key/value pairs) into TXT data
(following the format specified by RFC 6763). The decoding of TXT
data was previously provided by the `otDnsGetNextTxtEntry()` API.
2023-06-29 10:37:02 -07:00
Joakim Andersson 9fd1da5b9e [meshcop] fix compilation error mbedtls_base64_encode not defined (#9206)
Fix compilation error mbedtls_base64_encode not defined when compiling
with MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED disabled.

The logic for including the mbedtls/base64.h header file is doing the
wrong define check.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2023-06-28 20:20:05 -07:00
andrei-menzopol c4a8badcda [message] allow heap usage when using non-thread commissioning (#9205)
Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com>
2023-06-28 20:02:17 -07:00
Yakun Xu 11a38a63de [build] remove autotools (#9027)
This commit removes autotools support from OpenThread project.
2023-06-28 08:54:23 -07:00
Lorenzo Rai d91ecc5cdd [message] remove child mask from message metadata in MTD (#9213)
Saves a few bytes in MTD message metadata since they don't need the
child mask.
2023-06-28 07:42:27 -07:00
Jonathan Hui 52e157b17b [tmf] BRs default to 256 address cache entries (#9078) 2023-06-27 14:35:00 -07:00
Zhangwx d2f828f6d0 [logging] fix print format related to infra netif logs (#9212) 2023-06-27 11:18:33 -07:00
Jonathan Hui 3901e29e89 [tests] properly configure operational dataset in BR tests (#9209) 2023-06-26 22:23:53 -07:00
Abtin Keshavarzian 8e9bbbc88e [netdata] mechanism to detect & signal when network data gets full (#9073)
This commit adds a new mechanism to detect when Network Data (local or
leader) becomes full. When this happens, a callback function is
invoked. This callback function can be set using a newly added OT
API. The callback is invoked whenever:
- The device is acting as the leader and receives a Network Data
  registration from a Border Router (BR) that it cannot add to
  Network Data (running out of space).
- The device is acting as a BR and new entries cannot be added to its
  local Network Data.
- The device is acting as a BR and tries to register its local Network
  Data entries with the leader, but determines that its local entries
  will not fit.

The `OPENTHREAD_CONFIG_BORDER_ROUTER_SIGNAL_NETWORK_DATA_FULL` config
controls the new mechanism and its API. It is enabled by default when
`OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is enabled.

This commit also adds CLI support for the new mechanism and adds a
test case to validate its behavior.
2023-06-26 18:08:13 -07:00
Jonathan Hui 1a682fe2c8 [toranj-cli] properly configure operational dataset (#9207) 2023-06-26 18:04:55 -07:00
Jonathan Hui 3f4dcbc2ec [unit-test] properly configure operational dataset (#9203) 2023-06-26 17:18:24 -07:00
Abtin Keshavarzian 0cc1de7b5a [srp-server] allow service instance label with dot character (#9198)
This commit updates the `Srp::Server` class to correctly handle the
case where a service is registered with a dot character in its
service instance name. The first label in a service instance name is
intended as a user-friendly name and can contain dot characters
(it has fewer restrictions than other labels in a DNS name).

In particular, this commit contains the following changes:
- The `PtrRecords::ReadPtrName()` method is used in `Srp::Server` to
  read and validate the first label and the rest of the labels
  separately. This also validates the format of the parsed PTR
  record.
- The `Service::Description` class now remembers the instance label in
  addition to the full instance name. This allows the instance label
  to be easily retrieved.
- The `Dns::Name::ReadName()` method is updated to only verify that
  the labels after the first label do not contain any dot characters.
  This allows it to be used to read instance service names.
- The tests are updated to validate the behavior of the SRP server
  when the instance label contains a dot character.
2023-06-26 12:55:45 -07:00
dependabot[bot] 97e9f58026 github-actions: bump ossf/scorecard-action from 2.1.3 to 2.2.0 (#9204)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.3 to 2.2.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/80e868c13c90f172d68d1f4501dee99e2479f7af...08b4669551908b1024bb425080c797723083c031)

---
updated-dependencies:
- dependency-name: ossf/scorecard-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>
2023-06-26 09:25:25 -07:00
Jonathan Hui 434ea2c0d0 [script] properly configure dataset in check-posix-pty (#9202) 2023-06-24 12:51:50 -07:00
Abtin Keshavarzian aa7ce0d4da [test] update unit test emulating radio (#9200)
This commit updates the unit tests that emulate the radio platform API
to define `otPlatRadioGetCaps()`, which returns the ACK_TIMEOUT and
CSMA capabilities. This is to avoid having CSMA being implemented by
the `SubMac`, which then uses the microsecond timer that is not
emulated in the unit test platform.

It also updates the `InitTest()` function to clear the radio platform
variable `sRadioTxOngoing`. This is to avoid the possible
(though unlikely) situation where an earlier test finishes in the
middle of a transmission, causing an extra `TxDone` event in the
following test.
2023-06-22 15:00:40 -07:00
gavinmcgovern 79b056add6 [docs] add radio defgroup for proper documentation (#9195) 2023-06-22 14:59:21 -07:00
Eduardo Montoya 337ea25da3 [csl] ensure child is synchronized when preparing a CSL transmission (#9199)
Avoid potential CSL Transmitter crash when using a CSL period with
0 value in `GetNextCslTransmissionDelay`.
2023-06-22 14:01:40 -07:00
Jonathan Hui dad7754752 [otci] properly configure operational dataset (#9190) 2023-06-21 10:44:42 -07:00
Jonathan Hui 330c8088b9 [thread-cert] properly configure operational dataset (#9189) 2023-06-21 10:44:28 -07:00
Song GUO e4aca89f09 [posix] add posix support for sending RA messages to routing manager (#9160) 2023-06-20 20:38:39 -07:00
Eduardo Montoya e1bfbe80a3 [cli] expose otLinkSetEnabled (#9193) 2023-06-20 19:33:49 -07:00
dependabot[bot] 88cc6c8ef3 github-actions: bump actions/checkout from 3.5.2 to 3.5.3 (#9192)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/8e5e7e5ab8b370d6c329ec480221332ada57f0ab...c85c95e3d7251135ab7dc9ce3241c5835cc595a9)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-06-19 06:10:25 -07:00
Jonathan Hui 36b1b838d9 [expect] properly configure operational dataset (#9183) 2023-06-16 11:38:09 -07:00
Przemysław Bida 5ffdab8302 [thci] revert spellcheck in THCI method names (#9175)
Reverting name change intialize -> initalize. To fix thread harness
issues.
2023-06-16 10:12:44 -07:00
Jonathan Hui 6d557383e8 [coap] fix minor typo (#9180) 2023-06-14 20:07:24 -07:00
Abtin Keshavarzian d629ddc947 [netif] simplify signaling address events (#9173)
This commit adds two new methods, `SignalUnicastAddressChange()` and
`SignalMulticastAddressChange()`. These methods signal changes to
unicast or multicast addresses to the `Notifier`, `HistoryTracker`,
and user address callback.
2023-06-14 13:41:20 -07:00
Eduardo Montoya 068ec09135 [mac] enable/disable radio together with MAC (#9156)
Fix the behavior of `Mac::SetEnabled` for also enabling/disabling
the radio.

This ensures that the radio is turned off when `otLinkSetEnabled(false)`
is used.
2023-06-14 13:31:49 -07:00
Li Cao 55e3440ee2 [cli] add command to get tcp results (#9142)
This commit updates the cli command of TCP benchmark so that the
result of TCP benchmark could be queried any time. This enables test
scripts to automate TCP benchmark test. Currently the command `tcp
benchmark` is asynchronous and return immediately. If we use `ot-ctl
tcp benchmark` on posix, it's hard to fetch the test results. With the
newly added command, we can write a script to poll and get the result.
2023-06-14 13:31:09 -07:00
Li Cao 4b0b93ad00 [radio] add radio statistics of tx/rx/sleep cycle (#9071)
This commit implements time counting in radio to collect the time when
radio is in sleep/tx/rx time. 2 new APIs are added to get and reset
the statistics. This feature is only available on FTD and MTD. This PR
also adds cli commands to call the APIs on example cli firmware.  This
feature is by default disabled in OT core config. It's enabled on
simulation platform by default now.

Regarding implementation, this feature is totally implemented by
software.  It uses a simplified model to calculate the time. It may
not be very accurate, but it should be enough to give us an overview
of the time.
2023-06-14 13:30:02 -07:00
Jonathan Hui 0178ac83e5 [routing-manager] remove unnecessary kOnMeshPrefixLength decl (#9176) 2023-06-14 12:33:32 -07:00
Zhanglong Xia 4e2ed6476c [spinel] move SpiFrame implementation to spi_frame.hpp (#9151)
The `SpiFrame` is used by `ncp_spi.hpp` and `spi_interface.hpp`. This
commit moves the `SpiFrame` implementation from `ncp_spi.hpp` to
`spi_frame.hpp` as a dependent module.
2023-06-13 14:39:28 -07:00
Abtin Keshavarzian cbc62cda08 [cli] update OutputEidCacheEntry() (#9171)
This commit updates `OutputEidCacheEntry()` and how it converts
cache entry state to string.
2023-06-13 13:36:48 -07:00
Abtin Keshavarzian b128deec01 [mesh-diag] fix initializing of mEndOffset in ChildIterator (#9172) 2023-06-13 13:34:18 -07:00
Jonathan Hui 3a2969d922 [routing-manager] require valid on-link prefix to be /64 (#9167) 2023-06-13 12:28:44 -07:00
Abtin Keshavarzian d56059e022 [config] add mesh_forwarder.h config header file (#9164)
This commit adds the `config/mesh_forwarder.h` header file, which
defines all of the configurations used by the `MeshForwarder`.
These configs were previously included in `misc.h`.
2023-06-12 11:46:23 -07:00
dependabot[bot] 8157e5d0e2 github-actions: bump codecov/codecov-action from 3.1.3 to 3.1.4 (#9166)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/894ff025c7b54547a9a2a1e9f228beae737ad3c2...eaaf4bedf32dbdc6b720b63067d99c4d77d6047d)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  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>
2023-06-12 11:40:39 -07:00
Zhanglong Xia 47f15e3483 [spinel] move the MultiFrameBuffer implementation to multi_frame_buffer.hpp (#9150)
The `MultiFrameBuffer` is not only used by `hdlc.hpp`, it is also used
by `spi_interface.hpp` and `radio_spinel.hpp`. This commit moves the
`MultiFrameBuffer` implementation from `hdlc.hpp` to
`multi_frame_buffer.hpp` as a dependent module.
2023-06-12 11:32:23 -07:00
Abtin Keshavarzian 90c090f1ef [mle] send unicast Link Request to 1.2 parent on router role promo (#9154)
This commit adds a new mechanism to send a unicast MLE Link Request to
the device's former parent if its version is earlier than 1.3.0, when
the device is promoted from a child to a router role. This is to
address a potential compatibility issue with some non-OpenThread
stacks which may ignore MLE Advertisements from a previous/existing
child.
2023-06-12 11:29:06 -07:00
gavinmcgovern 9b99fbfd09 [docs] cli cmd doc updates (mliid - multiradio neighbor) (#9155) 2023-06-09 15:52:38 -07:00
Abtin Keshavarzian ff57bce41a [toranj] update build.sh script to use Thread version 1.3.1 (#9159)
This commit updates toranj `build.sh` script to use Thread version
1.3.1. This ensures that we can cover features that are restricted to
this version in `toranj` test-cases.
2023-06-09 15:52:04 -07:00
Eduardo Montoya 6acff9a9ad [csl] improved CSL debug logging (#9040)
Improve logging in CSL debug mode by properly calculating the drift
of the received frame compared with the established CSL sample time.

The new log also shows what was the accepted margin for the drift at
the reception time, and increases the logging level when the drift
is outside the margin.

Neither kCslReceiveTimeAhead or kMinReceiveOn* are considered for
the margin since they have no impact on understanding possible drift
errors between transmitter and receiver.
2023-06-09 13:15:54 -07:00
Abtin Keshavarzian cc851aacda [mle] restrict otDeviceProperties to version 1.3.1 or later (#9157)
This commit restricts the `otDeviceProperties` functionality to
OpenThread builds with `OT_THREAD_VERSION` set to `1.3.1` or later.
This functionality was added in PR #8670 and is used to calculate and
set the local Leader Weight on the device based on its properties,
such as power supply configuration and whether or the device is
acting as a Border Router, etc.
2023-06-09 12:51:16 -07:00
Zhanglong Xia b2116446bc [spinel] remove fetching the ncp dataset (#9140) 2023-06-09 00:00:32 -07:00
Abtin Keshavarzian e7b591e0e7 [cmake] fix OT_THREAD_VERSION comparison in CMake (#9158)
This commit fixes the check for CMake `OT_THREAD_VERSION` against
different version strings ("1.1", 1.2", "1.3", and "1.3.1"). The
previous check used `EQUAL`, which would do a numerical match and
would treat `1.3` and `1.3.1` as equal. This commit changes the check
to use `STREQUAL`, which does a string match and will correctly
distinguish between `1.3` and `1.3.1`.

This commit also adds new `message(STATUS)` commands to output the
selected Thread version. This makes it easier to see which version of
Thread is being built.
2023-06-08 20:44:02 -07:00
Abtin Keshavarzian 82b31adfd0 [bbr] simplify DomainPrefixEvent (#9152)
- Rename to `DomainPrefixEvent` from `DomainPrefixState`
- Remove the unused `kDomainPrefixNone` enumeration
2023-06-08 19:54:59 -07:00
Song GUO 9cb667c01f [routing-manager] initial PD support with platform generated RA (#9050)
This commit adds the following new API:
- otBorderRoutingProcessIcmp6Ra

And related APIs:
- otBorderRoutingDhcp6PdSetEnabled
- otBorderRoutingGetPdOmrPrefix

They are used to support the DHCPv6 PD on Thread Border Routers. On a
typical OS, the DHCPv6 Client of the platform network stack will
request a IPv6 subnet via DHCPv6-PD, then invoke the daemon for
sending router advertisements on the given interface.

With this commit, the RA will be catched by the processTransmit in
netif.cpp, which will then pass the message to
otBorderRoutingAddPrefixByRouterAdvertisement, RoutingManager will
then add the prefix according to the PIO in the router advertisement,
and take care of the lifetime of the prefix added.
2023-06-07 22:52:39 -07:00
Abtin Keshavarzian edc1a3fe23 [tlvs] new helper to find the start and end offsets of a TLV value (#9144)
This commit adds two changes to the `Tlvs` class:
- A new method, `FindTlvValueStartEndOffsets()`, has been added to
  find the start and end offsets of a TLV value within a `Message`.
  This method is useful for code that needs to find the value of a
  TLV and then search within that value.
- The unused method, `FindTlvOffset()`, has been removed. This method
  was previously only used by the `Tlvs` class itself.
2023-06-07 13:25:09 -07:00
Zhanglong Xia 4c5320168c [spinel] fix the non-virtual destructor error (#9139) 2023-06-07 10:33:11 -07:00
Zhanglong Xia cc09029188 [posix] replace fd_sets with the mainloop context (#9127) 2023-06-06 22:44:39 -07:00
Lorenzo Rai 439b58279b [logging] fix rtt logging not using defined buffer index (#9133) 2023-06-06 21:48:46 -07:00
Yakun Xu fd46c16a5c [netif] use fix type to u8 for addr_gen_mode (#9147)
From the kernel code, addr_gen_mode should be uint8_t.
2023-06-06 21:11:49 -07:00
Abtin Keshavarzian b69dfef1cc [mlr] use Array<> to track old registered MLR addresses (#9134) 2023-06-06 18:10:58 -07:00
Abtin Keshavarzian 6a549d1cdb [cli] add helper ProcessEnableDisable() methods (#9138) 2023-06-06 15:49:40 -07:00
Abtin Keshavarzian 982057e095 [mle] simplify tracking of registered DUA address by child (#9137) 2023-06-06 15:06:21 -07:00
Zhanglong Xia 7e8f77b55e [posix] unify the spinel interface functions (#9107)
This commit adds all Spinel interface functions to the `SpinelInterface`
as pure virtual functions and inherits all Spinel interfaces from
`SpinelInterface`, so that the Thread Network HAL can dynamically
create the Spinel interface based on the configuration of the radio URL
in Android. This commit also removes the macro guard from the Spinel
interface header files.
2023-06-05 14:59:38 -07:00
dependabot[bot] 98fe3f3875 github-actions: bump actions/checkout from 3.3.0 to 3.5.2 (#9132)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8e5e7e5ab8b370d6c329ec480221332ada57f0ab)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-06-05 12:40:25 -07:00
Abtin Keshavarzian 161a7fddcf [bbr] move BBR constants to related source files (#9129)
This commit moves BBR and DUA related constants to the related source
files (from `mle_types.hpp`). Additionally, unused constant variables
are removed. Some of the constants are renamed to make the definition
more clear.
2023-06-05 12:34:28 -07:00
Abtin Keshavarzian 41d6fc861c [cli] add CLI Backbone Router (Bbr) sub-module (#9128)
This commit adds `Bbr` CLI sub-module that implements all
"bbr" sub-commands.
2023-06-05 12:32:25 -07:00
Abtin Keshavarzian 977ac21743 [sntp-client] smaller enhancements (#9125)
This commit contains the following changes in the `Sntp::Client` class:

- The `Header` and `QueryMetadata` classes are moved to be internal
  (nested) classes of `Client`.
- The `Header` constructor is removed and replaced with an `Init()`
  method. This is to avoid unnecessary initialization of a `Header`
  instances when reading it from a received message.
- The `QueryMetadata` constructor has been removed.
- The `QueryMetadata` uses `Callback<>` for `ResponseHandler`.
2023-06-05 12:31:26 -07:00
Jonathan Hui fd1a247ae4 [github-actions] update ubuntu to 22.04 on ot-commissioner test (#9130) 2023-06-05 08:29:09 -07:00
Abtin Keshavarzian 80eb7f512f [toranj] update build.sh script to use CMake for all builds (#9115) 2023-06-01 21:39:45 -07:00
Abtin Keshavarzian 9bff9f0807 [routing-manager] fix deprecating on-link prefix from inactive router (#9121)
This commit fixes `RemoveOrDeprecateEntriesFromInactiveRouters()`
to ensure to skip over an already deprecating on-link prefix (and
not remove it).
2023-06-01 17:49:50 -07:00
Abtin Keshavarzian 3eb48ca00c [backbone-router] use Clamp to check MLR timeout value (#9119) 2023-06-01 13:05:06 -07:00
Abtin Keshavarzian 87e3250a51 [core] use Min(), Max() to clip values (#9117) 2023-06-01 13:04:09 -07:00
Abtin Keshavarzian 8f5d4376c6 [build] delete the removed child supervision config in cmake-build (#9111) 2023-05-31 13:26:39 -07:00
Song GUO 9c7e679ed1 [posix] add unified platform API for setting NAT64 CIDR during runtime (#8947)
We should notice that the default CIDR (`192.168.255.0/24`) is not
safe to use, however, in most cases, the CIDR used can only be
determined during runtime since the single binary might be distributed
to BRs in different network conditions. And we cannot conclude an
always safe CIDR in all conditions.

This commit will emit an event when NAT64 CIDR is changed. So the
platform driver can update the route for NAT64.
2023-05-30 23:16:43 -07:00
Li Cao fa81b21f4c [link-quality] fix corner case of ScaleRawValueToRssi (#9102)
Currently if we call `ScaleRawValueToRssi` with value 0 or 1, the
result is incorrect.  Because it tries to static_cast `-130` or `-129`
to `int8_t`. I think it's not worthwhile to widen int8_t to int16_t
only for the 2 corner cases. So I prefer returning the smallest value
-128 for the 2 cases.
2023-05-30 22:31:14 -07:00
Damian Królik 74c5e4ba01 [posix] fix setting non-standard baudrate on mac (#9090)
tcsetattr() fails on mac OS when a non-standard baudrate,
such as 1000000, is used. There is a separate ioct() that
accepts non-standard baudrates though.
2023-05-30 19:25:44 -07:00
Abtin Keshavarzian f05f222b44 [routing-manager] update logs (#9095)
This commit updates logs in the `RoutingManager` module:
- The log module name is changed to "RoutingManager".
- State changes are logged (enabling, disabling, starting, etc.).
- The `ScheduleRoutingPolicyEvaluation()` log will show the delay in
  both milliseconds and "<mm>:<ss>.<msec>" format(e.g. `05:15.234`).
- Logging of PIOs and RIOs are harmonized (when preparing RA to send
  or processing a received RA).
- Local on-link prefix logs are harmonized in `OnLinkPrefixManager`.
- `RsSender` logs are simplified.
2023-05-30 13:26:08 -07:00
Abtin Keshavarzian edf539ce27 [random] add Fill<ObjectType>() function (#9097)
This commit adds template `Fill<ObjectType>(ObjectType &aObject)`
functions for both `Crypto` and `NonCrypto` random number generation
modules. These functions fill a given object with random byes.
2023-05-30 13:25:10 -07:00
Damian Królik b14646b5a8 [csl] fix 15.4-secured broadcast frames (#9103)
The CSL present flag was not cleared in the frame structure,
causing that the MAC security was not be processed for Key
ID Mode 2 frames. Consequently, MLE Announcements would be
rejected by the sub-MAC layer after a CSL receiver detached
from its parent.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2023-05-30 11:31:57 -07:00
Zhanglong Xia c187e4d049 [posix] add Thread network default interface name configuration (#9089)
The default Thread interface name `wpan0` has been occupied by
other programs in Android. Thread network has to use other
network interface name. Then users have to specify an interface
name when they are using the command `ot-ctl`. It's very inconvenient.

This commit adds a configuration for developers to set the default
Thread interface name.
2023-05-29 10:14:44 -07:00
dependabot[bot] 4650e341a4 github-actions: bump github/codeql-action from 2.3.3 to 2.3.5 (#9100)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.3 to 2.3.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/29b1f65c5e92e24fe6b6647da1eaabe529cec70f...0225834cc549ee0ca93cb085b92954821a145866)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2023-05-29 10:12:36 -07:00
Li Cao c092fab737 [radio] fix return code doc of link metrics api (#9098) 2023-05-29 10:12:10 -07:00
Jonathan Hui 73ce42c6e6 [docs] remove redundant "This method" and "This function" (#9096)
- "This method "
- "This static method "
- "This function "
- "This structure "
- "This enumeration "
- "This class "
- "This methods "
- "This constructor "
- "This struct "
- "This type "
- "This template method "
- "This template class "
- "This const method "
- "This macro "
2023-05-29 10:11:10 -07:00
Abtin Keshavarzian 77d4b78a69 [cli] update documentation of Process() method in CLI sub-modules (#9093) 2023-05-26 15:41:09 -07:00
Abtin Keshavarzian 323ffd894b [cli] add CLI MacFilter sub-module (#9088)
This commit adds `MacFilter` CLI sub-module that implements all
"macfilter" sub-commands. It also simplifies the implementation by
adding a common `OutputFilter()` method that can output either the
Address filter, the RSS filter, or both.
2023-05-26 08:57:45 -07:00
Abtin Keshavarzian 9ad692488c [cli] add helper OutputNat64Counters() (#9087)
This commit adds a new helper method `OutputNat64Counters()` which
outputs a table row for NAT64 counters (4to6/6to4 packets/bytes).
This helps simplify the `nat64` commands.
2023-05-25 20:32:32 -07:00
whd c6ea8afc85 [tests] check whether the unreachable address is included in the DNS-SD response (#9075)
This commit enhances the DNS-SD server test that it verifies if the
unreachable address is included in the DNS-SD response.
2023-05-24 15:28:01 -07:00
Abtin Keshavarzian b82cfddd68 [uptime] requires UPTIME feature to be enabled on FTD build (#9079) 2023-05-23 12:36:18 -07:00
David Smith afe5041d07 [alarm] otPlatAlarm requirements clarification (#9067)
The requirement in the code comments is not completely accurate wrt to
the example implementations. As such, the requirements are updated to
match what is implemented for the posix platform.
2023-05-23 09:50:39 -07:00
Zhanglong Xia f64b7cc73c [test] add code spell check and correct wrong spelling (#9066) 2023-05-22 18:04:09 -07:00
dependabot[bot] cba9363627 github-actions: bump actions/setup-go from 4.0.0 to 4.0.1 (#9076)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/4d34df0c2316fe8122ab82dc22947d607c0c91f9...fac708d6674e30b6ba41289acaab6d4b75aa0753)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-05-22 14:50:14 -07:00
Abtin Keshavarzian 804ba31056 [notifier] add missing event in EventToString() (#9072) 2023-05-22 14:10:49 -07:00
Abtin Keshavarzian db4606871a [cli] add CLI DNS sub-module (#9069)
This commit adds `cli_dns` CLI module which contains implementation
of all "dns" sub-commands.
2023-05-19 11:58:18 -07:00
Zhanglong Xia 853f6eab0b [core] add the instance id (#9055)
It is difficult for testers to know whether the stack has been
automatically restarted in the background. This commit adds an
instance id to indicate whether the stack has been restarted.
The instance id is set to a random value when the OpenThread
instance is constructed and its value will not change after
initialization.
2023-05-18 15:40:45 -07:00
Abtin Keshavarzian b420a860ab [cli] fix config check for "vendor" command (#9068)
The "vendor" command should be available on both FTD and MTD.
2023-05-18 13:44:01 -07:00
Piotr Koziar deaec54dbf [ncp] fix RegisterPeekPokeDelegates call (#9064)
This commit fixes an issue where `RegisterPeekPoke` was called instead
of `RegisterPeekPokeDelegates`, causing compilation errors in some
builds.
2023-05-18 13:01:54 -07:00
Kangping 62f8205993 [border-agent] set Border Agent ID via CLI (#9049)
This commit adds:
1. A new `otBorderAgentSetId()` API to override the auto generated
   random ID
2. CLI commands to read write the Border Agent ID.
2023-05-18 11:12:35 -07:00
Abtin Keshavarzian d9abe3071c [dns-client] new API resolve host and address (#9054)
This commit adds `otDnsClientResolveServiceAndHostAddress()` function
as a new DNS Client API. This function starts a DNS service instance
resolution for a given service instance, with a potential follow-up
address resolution for the host name discovered for the service
instance (when the server/resolver does not provide AAAA/A records
for the host name in the response to SRV query).

In order to test the behavior of the newly added function, `TestMode`
in `Dns::ServiceDiscovery::Server` is updated to add a new mode where
no RR is added in the Additional Data section of a DNS query response.

This commit adds a related CLI command for the new API and updates
`test_dns_client` to validate the behavior of new API using the new
`TestMode` on `Server`.
2023-05-17 17:03:46 -07:00
Abtin Keshavarzian f8f6cf95f6 [routing-manager] add OmrPrefixManager (#9062)
This commit adds the `OmrPrefixManager` class to the `RoutingManager`.
The `OmrPrefixManager` class manages OMR prefixes. In particular, it
determines the favored and local OMR prefixes, and decides when/if to
add/remove the local OMR prefix to/from Network Data.
2023-05-17 14:47:42 -07:00
Eduardo Montoya a44919038c [csl] split min receive window into MHR ahead and after times (#9041)
Existing `kMinCslWindow` does not account for needed radio on time
before MHR. Solve it by splitting the configuration option into both
ahead and after minimum times.
2023-05-17 13:29:14 -07:00
Song GUO caf9ce839a [ip6] add Tidy method to Ip6::Prefix (#9057)
Given the fact that we may accept a string from `otIp6Address`, this
commit makes a copy in `ToString()` to make result more consistent.
2023-05-17 12:31:07 -07:00
Nick Bertoldi dae3ff2c50 [cli] support adding vendor command list to cli apps (#9001) 2023-05-16 19:59:20 -07:00
Abtin Keshavarzian 0186152d40 [radio-spinel] add log on RCP timeout error during init (#9059)
This commit adds new logs to `HandleRcpTimeout()` when an RCP timeout
occurs during initialization. This error is often incorrectly
reported as a bug, but it is usually caused by an incorrect
configuration or a bad RCP image. The new logs aim to provide
information and hints to the user about the cause of the error.
2023-05-16 18:40:37 -07:00
Abtin Keshavarzian 9ed8a071c1 [mle] echo back "Supervision TLV" in Child ID Response (#9061)
This commit updates the `MleRouter` to echo back the "Supervision
TLV" in MLE Child ID Response message when it is included in
MLE Child ID Request by a child.
2023-05-16 18:39:18 -07:00
Jonathan Hui 7c5dca178f [tests] fix routing_manager unit tests (#9053) 2023-05-15 14:22:16 -07:00
Yi 73d3ea5449 [nat64] check OMR prefix when selecting favored NAT64 prefix (#8995)
This commit adds a check on OMR prefix before selecting AIL prefix as
the favored NAT64 prefix for publishing.
2023-05-15 09:57:20 -07:00
dependabot[bot] fc08dd62f5 github-actions: bump github/codeql-action from 2.2.12 to 2.3.3 (#9051)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.12 to 2.3.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/7df0ce34898d659f95c0c4a09eaa8d4e32ee64db...29b1f65c5e92e24fe6b6647da1eaabe529cec70f)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2023-05-15 09:42:37 -07:00
Abtin Keshavarzian b200c968e7 [routing-manager] update OMR prefix def-route flag when publishing ::/0 (#9042)
This commit adds a new mechanism to update the default route flag on
the local OMR prefix based on whether or not the BR is publishing
the `::/0` external route prefix.

When `RoutePublisher` (the component that determines which route
prefix to publish) decides to publish/unpublish the default route as
`::/0`, it will inform `LocalOmrPrefix` (the component that manages
when the local OMR prefix is added/removed in Thread Network Data) of
the def-route flag to use.
- If the local OMR prefix is not yet added, the def-route flag will be
  remembered to be used when/if it is added.
- If the local OMR prefix is already added, the entry in Network Data
  is updated to use the new def-route flag.

This change addresses a backward compatibility issue with devices running
1.2 or earlier Thread versions. These devices may not correctly parse or
accept a zero-length `::/0` route prefix in the Network Data. Adding
the default-route flag on the OMR prefix ensures that these devices
can reach the border router that added the OMR prefix.
2023-05-12 12:02:01 -07:00
Jonathan Hui e2cb3c647d [alarm] update docs to explicitly require 32-bit alarms (#9043) 2023-05-12 11:34:42 -07:00
Abtin Keshavarzian 48abf12e00 [dns-client] check all responses in GetHostAddress() (#9044)
This commit fixes an issue with `ServiceResponse::GetHostAddress()`
method. The issue only occurs when separate queries (e.g., for SRV
and TXT records) are used, and therefore separate `Response` objects
are collected and chained together as a linked list. The change
ensures that we check every response in the list when getting host
addresses.
2023-05-11 19:37:13 -07:00
Abtin Keshavarzian 2f995999f4 [ip6] add new versions of NewMessage() (#9038)
This commit adds new versions of `NewMessage()` in `Ip6`, `Udp` with
different set of parameters. It also updated the code to avoid use of
default parameter value.
2023-05-11 11:49:46 -07:00
Li Cao cea434e98f [log] log the port for backbone (#9039)
To follow the convention to log any not well-known ports.
2023-05-11 11:26:42 -07:00
Abtin Keshavarzian 4cba902db1 [ip6] simplify and update NewMessageFromData() (#9037)
This commit simplifies and updates the `NewMessageFromData()` method
to always determine the priority from the IPv6 header, even if a
`Message::Settings` is provided. This change aligns the behavior of
`NewMessageFromData()` with the documented and intended behavior of
`otIp6NewMessageFromBuffer()`.
2023-05-10 17:59:32 -07:00
Jonathan Hui 161a4407e2 [github-actions] add arm-gcc {10,11,12} checks (#9035) 2023-05-10 16:42:28 -07:00
Nick Bertoldi 1203ea6426 Define posix radio RadioSpinel accessor (#9018)
When adding cli commands to be used by a posix platform is is useful
to have access to the spinel interface when trying to communicate with
a RCP using vendor specific spinel properties. It is inadvisable to
create a separate spinel interface for custom properties as the two
interfaces would need to avoid contention on the hardware interface.

This accessor method allows access to the static spinel interface
defined in radio.cpp for external code segments. Dependent source
files can do so with: `(RadioSpinel<InterfaceType,
ProcessContextType>*)Posix::Radio::getSpinelInstance()` or similar.
2023-05-09 18:37:54 -07:00
Jonathan Hui fb45cf23fd [network-name] consolidate default network name definition (#9036) 2023-05-09 14:51:33 -07:00
Abtin Keshavarzian c09b57392e [topology] track connection time of neighbors (#9007)
This commit introduces a mechanism to track the connection time of
neighbors as the number of seconds since the last successful link
establishment with the neighbor. This feature requires  the
configuration `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled which
is now enabled by default on FTD builds. The connection time of each
neighbor is available in the `otNeighborInfo` and `otChildInfo`
structures as the `mConnectionTime` member variable. A new CLI
command, `neighbor conntime`, has been added to display the
connection time and age of all neighbors.
2023-05-09 13:12:19 -07:00
Abtin Keshavarzian a259d23e7f [string] add StringParseUint8() helper function (#9026)
This commit adds a helper function to parse a decimal number from a
given string as `uint8_t` and skip over the parsed characters. This
is used to simplify the methods parsing IPv6/IPv4 address or prefix
from a string.
2023-05-09 12:54:39 -07:00
Przemysław Bida 5081882bb9 [link-metrics] fix compilation errors (#9033)
Link metric macros `OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE`
and `OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE` were guarding
incorrect parts of code.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2023-05-09 11:33:54 -07:00
Mason Tran f86d560e0a [build] add CMake Android NDK support (#9010) 2023-05-09 11:01:51 -07:00
Mariusz Poslinski 3d3ed4fbc1 [tcp] remove EXCLUDE_TCPLP_LIB option (#8883)
Signed-off-by: Mariusz Poslinski <mariusz.poslinski@nordicsemi.no>
2023-05-08 21:23:40 -07:00
Abtin Keshavarzian 92b954ae1d [netdata] add otNetDataReplacePublishedExternalRoute() API (#9013)
This commit adds a public OT API to replace a previously published
external route entry in the Thread Network Data. It also adds a
related CLI command, and updates `test_netdata_publisher` to
validate the new behavior.
2023-05-08 20:05:21 -07:00
Kangping 874b6beca8 [border-agent] fix BorderAgentId compile and enable it in CI tests (#9030) 2023-05-08 09:09:46 -07:00
dependabot[bot] 9eb22897ea github-actions: bump codecov/codecov-action from 3.1.1 to 3.1.3 (#9031)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.1 to 3.1.3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70...894ff025c7b54547a9a2a1e9f228beae737ad3c2)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  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>
2023-05-08 09:00:29 -07:00
Kangping eaa2779047 [settings] define new Settings key for Border Router ID (#8971)
This commit adds new Border Agent functionality that generates and
saves 16 bytes ID in settings.  The ID can be published in the MeshCoP
mDNS service and used by the client to identify a Border Router
device.

A new `otBorderAgentGetId()` API is defined and the ID is generated
the first time this API is called.
2023-05-05 10:48:57 -07:00
Song GUO 96ea73076e [posix] update upstream DNS addresses after a few minutes (#8972)
On some platforms, the /etc/resolv.conf might be a generated file, and
is not available at the first few minutes after boot.

This commit records the time when we read the DNS server addresses
from the upstream, and reload the server list when it expires.

We may want to use inotify or add a platform specific API to notify
the openthread about the change of DNS server list.
2023-05-04 20:59:06 -07:00
Li Cao 612f21e776 [link-metrics] refactor link metrics module (#8966)
This commit breaks Link Metrics Initiator and Subject into two classes
and fixes incorrect swtich guard. For example, code for Initiator was
guarded by macro of Subject.
2023-05-04 20:58:06 -07:00
Song GUO 9affbabc53 [cli] refactor br command prefix type (#9022)
We are adding another new type of prefix. This commit refactors
`ParsePrefixTypeArgs` to make it more flexible.
2023-05-04 10:41:46 -07:00
Yakun Xu 30b79ccee8 [test] migrate tests to cmake (#8929)
This commit migrate tests not targeting autotool to cmake.

* removed openthread-test-driver
* removed functional tests from autotool based check
* corrected file permission of python scripts
* added --run-directory to specify directory to collect logs and captures
* get test-ot-test-srp-server pass on POSIX platform
2023-05-04 09:59:24 -07:00
Abtin Keshavarzian 2caf6b818a [ip6] add otIp6PrefixFromString() (#9016)
This commit adds the `Ip6::Prefix::FromString()` method, which parses
a human-readable IPv6 prefix string into a binary representation. It
also updates the unit test `test_ip_address` to validate the new
method, and updates the `parse_cmdline` module to use the new
function.
2023-05-03 18:28:32 -07:00
Abtin Keshavarzian a7edd859ee [netdata] prefer BR acting as router over ED (when all other checks are same) (#9012)
This commit updates the `CompareRouteEntries()` method so that if all
of the earlier checks (preference, path cost) are the same, it will
prefer a border router (BR) acting as a router over one acting as an
end device. The reason is that a device can more accurately calculate
the path cost to a router node than to an end device. This is because
the link quality between an end device and its parent is not known to
other devices.
2023-05-03 17:20:38 -07:00
Abtin Keshavarzian 4fed5ea0f0 [net-diag] vendor name, model, and sw version TLVs (#8898)
This commit adds new Network Diagnostic TLVs for vendor name, vendor
model and vendor software version. The TLVs follow similar format as
the MeshCoP TLVs with the same name, i.e., all of them use UTF8
strings as value with name and model limited to 32 characters, and
software version to 16 characters.

The values for these TLVs can be set at build-time using a set of
newly added configs `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_*`, or their
equivalent CMake options (e.g., `OT_VENDOR_NAME`).

It is recommended that these parameters are set at build time using
the configs. This way they are stored as constant strings and won't
consume RAM. However, for situations where the OT stack is integrated
as a library into different projects/products, we can enable a
feature for APIs to be added to set these strings at run-time. In
this case, the `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_*` are treated as
the default values (used when OT stack is initialized).

This commit also adds Thread Stack Version TLV which has a string
value (up to 64 characters) and provides the version string from
`otGetVersionString()`.

This commit also adds CLI commands to get and set (when enabled) the
vendor name, model, and sw version on device. Also adds a test case
`test-020-net-diag-vendor-info.py`.
2023-05-03 13:57:25 -07:00
Abtin Keshavarzian 6f909a1d6a [mle] request "Route TLV" after quick re-attach as FED (#8956)
This commit allows an FED child to request Route TLV (in "TLV Request
TLV") in an MLE Data Request message. Parent will include the Route
TLV when requested by the child.

After successfully performing a quick re-attach upon reset, an FED
child requests Route TLV when sending MLE Data Request to its parent.
This is tracked by a newly added boolean `mRequestRouteTlv`, which is
set after quick re-attach and cleared when Route TLV is successfully
processed.

This commit also simplifies methods related to sending Data Request.
2023-05-02 23:15:33 -07:00
Abtin Keshavarzian b9a318092c [mle] fix how time per role is tracked after counters are reset (#9011)
This commit fixes an issue with tracking time spent in each role after
`Mle::ResetCounters()`. The  `mLastUpdatedTimestamp` is now updated
from `ResetCounters()`.
2023-05-02 12:05:17 -07:00
Nick Bertoldi 6b7cbbcd7b [posix] vendor support with lib dependencies (#8950)
A vendor interface implementation for the posix library is currently
supported through linking a specified c++ source file. However, this
is unable to accomodate dependencies for external libraries or header
files that this vendor implementation source file may need.

The posix vendor support is changed to allow a vendor to specify a
cmake RcpVendorDeps module file to resolve missing dependencies for a
provided vendor support source file.

Additionally, this commit adds the ability for a vendor to define a
radio url help message when the vendor rcp bus is selected instead of
defaulting to the UART help message.
2023-05-02 11:24:26 -07:00
Abtin Keshavarzian d6221f4d32 [routing-manager] RoutePublisher and new route publishing model (#8986)
This commit updates the `RoutingManager` module to implement a new
model for publishing routes. The new model replaces the previous
model, which explicitly published all discovered routes and on-link
prefixes (from processing Router Advertisements on AIL) as external
routes in the Network Data.

The new model simplifies this logic by publishing either a `fc00::/7`
(ULA) route or a `::/0` (default) route in the Network Data,
depending on the set of discovered routes and on-link prefixes, and
the currently favored OMR prefix.

This commit adds the `RoutePublisher` class, a nested sub-component of
the `RoutingManager` class. The `RoutePublisher` class is responsible
for determining the route prefix to publish and its preference. The
preference of the published route is determined based on the current
role of the Border Router (BR): low preference if the BR is a child,
and medium preference if the BR is acting as a router.

This commit also updates `test_routing_manager` unit test validating
the new behavior.
2023-05-01 18:30:14 -07:00
dependabot[bot] 2dcecb7ac0 github-actions: bump actions/setup-python from 4.5.0 to 4.6.0 (#9008)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.5.0 to 4.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435...57ded4d7d5e986d7296eab16560982c6dd7c923b)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2023-05-01 08:31:30 -07:00
Abtin Keshavarzian 34ecac8536 [mle] clear/update address cache entries on promotion of child to router (#8987)
This commit contains two related changes:
- On a parent, when we detect a former child has been promoted to
  router role by receiving an MLE Advertisement from it, we replace
  the address cache entries associated with the old (child) RLOC16
  with it new RLOC16.
- On leader, when we successfully reply to an "Address Solicit"
  message and assign a new RLOC16 to a node, we clear all entries
  associated with old RLOC16. We do not change to new RLOC16 since we
  cannot be sure that child will successfully receive the Address
  Solicit" response.
2023-04-29 10:41:45 -07:00
Abtin Keshavarzian c59eb37c60 [mle] add parent request callback config (#8989)
This commit adds `MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE` config
which enables support for `otThreadRegisterParentResponseCallback()`
API. This API registers a callback to notify user of received
Parent Response message(s) during attach. This API is mainly intended
for debugging and therefore is is disabled by default. It is enabled
in `toranj-config` so to validate the code (i.e. it causes no build
errors) during CI GitHub action runs.
2023-04-28 20:36:42 -07:00
Abtin Keshavarzian 0ce28ba1c2 [dns-client] update API docs (#8962)
This commit updates `otDnsClient` API documentation making the service
resolution `otDnsClientResolveService()` behavior more clear, in
particular that it sends queries for SRV/TXT records. The new
documents also highlight how records in Additional Data section
in a query response is parsed and provided in the callbacks and that
servers/resolvers may not provide the records.
2023-04-28 15:42:06 -07:00
Mason Tran f3701b746a [build] add cmake option for generating .map files (#9006)
This adds the CMake option `OT_LINKER_MAP` which will generate `.map`
files for any executables built when the option is `ON`.
2023-04-28 13:39:59 -07:00
parag-silabs 2952d2389f [diag] implement diag stream command (#8975)
- Add `expect` simulation test.
- Update the diag/README.md
2023-04-28 12:01:09 -07:00
Yakun Xu 674cbfaa5c [otci] fix some style issues (#8996)
This commit fixes some style issues of otci. Also includes some minor
changes:
* added pytype check in otci
* exported `OTCommandHandler`
2023-04-27 20:05:02 -07:00
Nick Bertoldi 5657335de4 [cli] store cli user commands in container and support list prepend (#8977)
Calls to otCliSetUserCommand overwrite the pointer user command list
pointer each time it is invoked, which results in successive calls to
otCliSetUserCommand replacing the previously registered command list
instead of appending to it. This is particularly relevant for the
posix platform in which the main function registers a set of posix
specific commands without any way to extend the set.

This commit replaces the command list pointer with a container of
command lists associated with a registered context in order to support
prepending the active list of user commands up to a configurable value
which defaults to 1 to maintain current behavior.
2023-04-26 09:07:30 -07:00
Abtin Keshavarzian 5e15b93ff2 [daemon] remove log of CLI input (#8994)
This commit removes logging of the CLI input in `Daemon::Process()`.
This ensures that sensitive info (e.g. dataset and/or network key)
is not emitted in the logs. The CLI input/output can be logged using
the CLI related configs `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE`
and/or `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL`.
2023-04-26 06:41:36 -07:00
hemanth-silabs 25942910ab [crypto] allow key reference usage for ECDSA (#8961)
Add new class to handle ECDSA using key refs.
Update SRP to use key refs.
2023-04-25 21:48:53 -07:00
dependabot[bot] 4b0f566bd5 github-actions: bump step-security/harden-runner from 2.3.0 to 2.3.1 (#8991)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.3.0 to 2.3.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/03bee3930647ebbf994244c21ddbc0d4933aab4f...6b3083af2869dc3314a0257a42f4af696cc79ba3)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-04-24 07:21:25 -07:00
Yakun Xu 6bfcc0d7d4 [test] require either mdns or avahi (#8959)
This commit relax the requirement of mDNS so that it's OK when either
mdns or avahi is present.
2023-04-20 19:11:19 -07:00
Abtin Keshavarzian 2a93eeabce [sub-mac] check key-id to match in SignalFrameCounterUsed() (#8978)
This commit ensures to check that `KeyId` on a frame matches the
current `mKeyId` from `SignalFrameCounterUsed()`. This addresses
corner-case situation where on key sequence change, an ongoing frame
tx or enhanced ack to a received frame, can be processed  after the
`mKeyId` change.
2023-04-20 17:42:58 -07:00
Abtin Keshavarzian 658179fa93 [dns-client] fix finalizing query from HandleTimer() (#8982)
This commit fixes an issue in `HandleTimer()` where we need to use
`break` instead of `continue` after calling `FinalizeQuery()`. Note
that we now have two loops, an outer loop on `mMainQueries` and then
an inner loop on queries associated with a `mainQuery`. When we
finalize a query, its related `mainQuery` (along with all its
sub-queries) are finalized and removed.
2023-04-20 17:40:48 -07:00
Jonathan Hui 6955fde6ae [github-actions] replace deprecated set-output commands (#8976) 2023-04-20 08:48:20 -07:00
Jonathan Hui 4a41cb48d5 [mle] enable Inform Previous Parent feature by default (#8969) 2023-04-18 21:51:03 -07:00
dependabot[bot] f0232d0f79 github-actions: bump github/codeql-action from 2.2.5 to 2.2.12 (#8968)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.5 to 2.2.12.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/32dc499307d133bb5085bae78498c0ac2cf762d5...7df0ce34898d659f95c0c4a09eaa8d4e32ee64db)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
2023-04-17 10:34:05 -07:00
Song GUO 9783c14e24 [nat64] add function for parsing IPv4 CIDR (#8954) 2023-04-17 10:14:08 -07:00
Abtin Keshavarzian 25fe46d8dd [mle] simplify parsing of Address Registration TLV entries (#8963)
This commit adds `ProcessAddressRegistrationTlv()` method which
finds an Address Registration TLV in a received MLE messages from
a child and processes its entries updating the child's registered
addresses.
2023-04-17 10:00:14 -07:00
Abtin Keshavarzian e63c5d321a [mle] simplify appending of Address Registration TLV entries (#8958)
This commit adds helper methods to append an IPv6 Address Entry in an
Address Registration TLV using compressed format where the entry
contains a lowpan context ID and the address's IID, or uncompressed
format where the full IPv6 address is appended.
2023-04-14 11:00:19 -07:00
Abtin Keshavarzian f9cd4b4182 [net-diags] fix GetNextDiagTlv() when skipping over unknown TLVs (#8957)
This commit fixes `GetNextDiagTlv()` to correctly return error
`kErrorNotFound` if the message happens to end with an unknown TLV.
We ensure to set the `error` after the end of `while()` loop. With
the previous code we could return `kErrorNone` (since we would
successfully read and skip over the unknown TLV which would set
`error`).
2023-04-13 23:03:04 -07:00
Yakun Xu 720965ae1b [test] disable INTER_OP_BBR by default (#8952)
This commit disables `INTER_OP_BBR` by default to avoid unnecessary
build in most times.
2023-04-13 22:58:07 -07:00
Abtin Keshavarzian 0ca01ae501 [mle] simplify SendChildUpdateRequest() (#8951)
This commit updates `Mle::SendChildUpdateRequest()`:
- It removes the use of default parameter.
- It adds a private version which accepts `ChildUpdateRequestMode`
  indicating actions like whether to append challenge TLV, or
  whether to append zero timeout value (used for graceful detach).
2023-04-12 13:49:21 -07:00
Zhanglong Xia e7a92f6aaa [posix] unify the RCP reset sequence (#8858)
This commit unifies the RCP reset sequence on the HDLC and SPI
interfaces. The host will try the software reset first, and then try
the hardware reset if the software reset fails or allowed.

Reasons for unifying the RCP reset sequence:
- The parameters of the Thread stack are fixed on Android. Developers
  can't use different parameters to specify SPI or HDLC interfaces to
  use different methods to reset RCP.
- If the Thread stack and the BLE stack are running on the same radio
  chip, the hardware reset chip will cause the BLE stack to crash. The
  host needs to software reset RCP first, and try the hardware reset
  if the software reset fails. This can reduce the impact on the BLE
  stack.
2023-04-12 11:11:21 -07:00
Jonathan Hui 3d39d24a21 [style] fix spelling errors (#8939) 2023-04-11 22:39:35 -07:00
dependabot[bot] 0fc8ce95ea github-actions: bump step-security/harden-runner from 2.2.1 to 2.3.0 (#8943)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/1f99358870fe1c846a3ccba386cc2b2246836776...03bee3930647ebbf994244c21ddbc0d4933aab4f)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-04-10 19:07:28 -07:00
Song GUO 91e1be0b34 [posix] initialize pointers to avoid potential using uninitialized pointers (#8942) 2023-04-10 18:48:08 -07:00
Abtin Keshavarzian 0f94f26a20 [net-diag] introduce Server and Client classes (#8936)
This commit introduces `Server` and `Client` classes breaking the
`NetworkDiagnostic` module into two components. The `Server` responds
to queries and requests (handling Net Diag TMF commands), while
`Client` issues queries/requests and processes responses. The
`Server` is available under both FTD and MTD (which follows the
requirement of Thread spec). The client is enabled using newly added
`OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE` config option which is
also available as `OT_NETDIAG_CLIENT` CMake option or the autoconf
build switch `NETDIAG_CLIENT`. The client functionality is by default
enabled on Border Routers (tied to `CONFIG_BORDER_ROUTING_ENABLE`
config).

The previous `TMF_NETWORK_DIAG_MTD_ENABLE` config is now removed
along with its CMake `OT_MTD_NETDIAG` and autoconf switch. This
commit adds checks to trigger build error if the previous config
and/or its related CMake option are used.
2023-04-07 15:58:07 -07:00
Abtin Keshavarzian d9ea37a3bb [tmf] add local IPv6 DSCP values to indicate TMF message priority (#7869)
This commit adds new IPv6 header DSCP values which indicate a TMF
message priority. This allows intermediate routers forwarding TMF
message to be able to determine and use the TMF message priority that
originator of the message selects (e.g., address query/notification
use net-level priority whereas network diagnostics message use normal
priority). This replaces the previous behavior where on intermediate
routers all TMF messages were treated as net-level priority.

The new DSCP values are allocated from local codepoint range
`0bxxxx11` (per RFC 2474 - section 6). If the sender does not use
TMF-specific DSCP values, we use `kPriorityNet` as default on
intermediate router. This ensures that senders that are using older
code (do not use the new) experience the same behavior as before.
2023-04-07 12:23:01 -07:00
Abtin Keshavarzian cb40a45298 [joiner] use Clamp() function to calculate priority from RSS (#8937) 2023-04-07 09:26:38 -07:00
Abtin Keshavarzian 6865b83d7f [coap] avoid using default parameter values for common methods (#8932)
This commit adds overloads of commonly used methods in `Coap` and
`MessagePool` replacing default parameter values. This helps reduce
code size.
2023-04-06 09:52:33 -07:00
Abtin Keshavarzian 356b4a6a58 [build] address new warnings with clang-14 (#8924)
This commit adds two small changes to address new warnings when
building with clang-14.

It also updates `mbedtls` CMakeLists to set `MBEDTLS_FATAL_WARNINGS`
option as `OFF` (so that compiler warnings are not treated as errors).
This avoid issues with new warning for `unused-but-set-variable` emitted
by clang-14.
2023-04-06 09:51:29 -07:00
Zhanglong Xia b48544c3b8 [posix] reset the signal actions after processing signals (#8934)
When compiling the otbr-agent in Android, Android will link the
function debuggerd_init() and call it before calling the function
main(). The function debuggerd_init() sets signal handlers to
catch signals. This commit resets the signal actions to default and
re-raises the original signal to let the pre-configured functions
to catch signals.
2023-04-05 23:23:01 -07:00
Abtin Keshavarzian adde085fce [tmf] add UriToString() for logging (#8930)
This commit adds a helper function `UriToString<Uri>()` to convert
a given `Uri` enumeration value to a human-readable string. This is
used for logging.
2023-04-05 18:00:30 -07:00
Zhanglong Xia cbdabbc542 [spinel] add openthread config header file (#8928)
This commit adds the openthread config header file to the spinel config
file to allow developers to configure the spinel configurations in the
openthread config file.
2023-04-05 15:54:18 -07:00
Abtin Keshavarzian 3ffe8516f7 [dns-client] add ServiceMode to control service resolution (#8772)
This commit updates DNS client to add `otDnsServiceMode` to the
`otDnsQueryConfig`. This new config property determines which records
to query and allow the API user to control the behavior during
service resolution: We can query for SRV record only or TXT record
only, or query for both SRV and TXT records in the same message, or
in parallel in different messages, or an "optimized" mode where
client will first try to query for both records together in the same
message but if server responds with an error, it then retries using
two parallel separate queries.

This gives flexibility and control to the API user. It also helps
address situations where the server (DNS resolver) may not accept
queries with more than one questions.

To support this new feature, this commit updates and enhances the
internal design of the `Dns::Client`. A new mechanism is added to
allow multiple `Query` instances to be associated with each other
under a main `Query` and responses for the related queries are saved
until all are received and validated before finalizing the main
`Query` and invoking the callback and allowing caller to retrieve the
info.

This commit also adds a detailed unit test `test_dns_client` which
covers DNS client browse and service resolution validating behavior
under all service modes. In order to test `Client` functionality,
this commit also adds a `TestMode` in `Dns::ServiceDiscovery::Server`
allowing us to change server behavior, e.g., reject messages with
more than one question in query.
2023-04-05 15:49:08 -07:00
Abtin Keshavarzian e587d43e4b [tmf] skip copy of MessageInfo for empty ack (#8926) 2023-04-05 11:00:23 -07:00
Jonathan Hui 6e79add03f [data-poll-sender] clamp poll period based on child timeout (#8927) 2023-04-04 09:48:33 -07:00
dependabot[bot] 9ba91a4b8f github-actions: bump ossf/scorecard-action from 2.1.2 to 2.1.3 (#8925)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/e38b1902ae4f44df626f11ba0734b14fb91f8f86...80e868c13c90f172d68d1f4501dee99e2479f7af)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  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>
2023-04-03 12:58:39 -07:00
Eduardo Montoya 4577fb21a7 [csl] take into account radio header for aiming at the CSL phase (#8743)
This commit fixes CSL operations timing taking into account that the
CSL phase should refer to the beginning of the SHR.

On the CSL transmitter, corrects the transmission delay timing taking
into account that the timestamp of the received frame from the CSL
receiver refers to the start of the PHR.

On the CSL receiver, no changes are needed assuming the platform
injects the proper CSL phase value.
2023-04-03 10:48:06 -07:00
Abtin Keshavarzian 61d13e291f [tmf] allow pan-id query on MTD (#8919) 2023-04-03 10:44:43 -07:00
Jeff Bumgardner daf704d87c [docs] remove clang-format tags and implement multi-line cparam tags (#8921) 2023-04-03 10:44:12 -07:00
Abtin Keshavarzian edce936b1c [network-data] change 6LoWPAN context ID reuse delay to 5 minutes (#8896)
This commit changes the context ID reuse delay from 48 hours to
5 minutes. It also updates `test-019-netdata-context-id.py` to
check the default value.
2023-04-03 10:37:47 -07:00
Song GUO fa6824c9cb [test] add tests for DNS forwarding (#8847)
This commit adds a new file
`tests/scripts/thread-cert/border_router/nat64/test_upstream_dns.py`
to test scripts for testing the DNS forwarding functions.

The test adds a record `test.domain` to the bind9 interface since when
adding to DNSSD tests, the OpenThread's DNSSD server will be conflict
with the Docker's DNS forwarding functions.
2023-03-30 15:06:55 -07:00
Lukasz Duda 59277d0925 [sub-mac] prefer scanning and RX after data poll over CSL RX (#8832)
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
2023-03-30 15:02:39 -07:00
Lukasz Duda 1c190a4f6d [expect] split and extend tests for discovery (#8832)
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
2023-03-30 15:02:39 -07:00
Lukasz Duda 7ec184d68e [discovery] allow (S)SED devices to perform MLE Discovery (#8832)
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
2023-03-30 15:02:39 -07:00
Esko Dijk 2c8a0af244 [radio] clarify mTimestamp meaning in comments (#8894) 2023-03-29 16:06:13 -07:00
Łukasz Duda edd92c6cdf [netif] add diagnostic log for when no valid route is found (#8907)
The added log may assist in diagnosing problems where packet
transmission over the air is absent.

Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
2023-03-28 20:32:27 -07:00
Jeff Bumgardner c03ca44662 [docs] disable Doxygen autolink for the word "Joiner" (#8915) 2023-03-28 10:55:53 -07:00
Zhanglong Xia 7bdcf8a5d4 [spinel] abort host after receiving unexpected reset from RCP (#8909)
Some platforms, such as Android and CastOS, can monitor program crash.
And they can upload the crash dump to the crash server for developers
to analyze the crash reason.

This commit aborts the host after receiving a unexpected reset to
trigger platforms to upload the crash dump.
2023-03-27 23:03:26 -07:00
Abtin Keshavarzian 4b97fd7e46 [ip6] combine PassToHost() calls in Ip6::HandleDatagram() (#8908)
This commit simplifies `Ip6::HandleDatagram()` by combining the
two places where we call `PassToHost()` into one. It simplifies
how we perform the three actions `receive`, `forwardHost`, and
`forwardThread`.
2023-03-27 20:08:54 -07:00
dependabot[bot] 21c31b633e github-actions: bump actions/setup-go from 3.5.0 to 4.0.0 (#8910)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.5.0 to 4.0.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/6edd4406fa81c3da01a34fa6f6343087c207a568...4d34df0c2316fe8122ab82dc22947d607c0c91f9)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-27 10:57:25 -07:00
Suvesh Pratapa 57a3480871 [logging] fix print format for some variables requiring %u or %lu (#8899) 2023-03-24 21:50:35 -07:00
kylorene 3ef109c7cd [cli] add docs for partitionid through pollperiod (#8875) 2023-03-24 21:42:33 -07:00
Abtin Keshavarzian e8f3ec0fd3 [common] add Preference helper methods for 2-bit preference value (#8895)
This commit introduces a common `Preference` class which defines
constants and helper methods (e.g., to convert between an `int8_t`
preference and its 2-bit unsigned representation). This is used for
`RoutePreference` in Network Data entries and also for Parent
Priority in `ConnectivityTlv`.
2023-03-23 18:47:57 -07:00
Abtin Keshavarzian 84be135243 [srp] add support for short (4-bytes) lease option variant (#8879)
This commit updates SRP client and server to support short variant
format for Update Lease Option. The short variant includes the lease
interval only (4 bytes) vs the long variant which includes both lease
and key lease intervals (8 bytes). Client and server can parse and
process both formats in received messages. Client by default uses the
long variant. Server will also use the long variant in its response
unless the request message uses the short variant format, i.e., if
the client uses the short variant, the server will also respond using
the short variant. This behavior is required by the latest Update
Lease draft.

This commit also updates `test_srp_server` unit test, adding a new
test-case to validate the behavior of client and server when short
Update Lease Option is used. A new method (intended for testing and
and only available under `REFERENCE_DEVCIE` config) is added which
configures the client to use the short variant format changing the
default behavior.
2023-03-23 17:43:33 -07:00
Abtin Keshavarzian a43484ed44 [tlv] fix ReadStringTlv() (#8897)
This commit fixes `ReadStringTlv()` avoid returning an extra
character and making sure `\0` is added at the correct index
at `[length]`.
2023-03-22 18:48:14 -07:00
Abtin Keshavarzian a4f1c7afa7 [trel] protect against invalid long TXT data keys from TREL peer (#8891)
This commit adds checks to protect against an edge-case where TXT
data entries from a TREL peer may contain invalid and long keys. If
the TXT data happens to include keys longer than `Dns::kMaxKeyLength`,
the `mKey` in `Dns::TxtEntry` will be set to `nullptr` and the entire
entry will be provided in `mValue`. This commit adds code to skip over
such entries (check that `entry.mKey` is not null) at beginning of the
loop to avoid using a potential null `mKey` in `strcmp`.
2023-03-22 17:20:45 -07:00
Abtin Keshavarzian b8335e0772 [mle] add otDeviceProperties to calculate local leader weight (#8670)
This commit adds `otDeviceProperties` which represents a set of device
properties which are used to calculate and set the local Leader
Weight on the device.

The device property set contains a `otPowerSupplyConfig` enum value
specifying the device power supply:
- Battery powered.
- Externally powered (mains-powered).
- Stable external power with a battery backup or UPS.
- Unstable external power (e.g., a light bulb powered via a switch).

It also indicates whether or not device is a border router, supports
CCM, and specifies a Leader Weight adjustment value.

The `otDeviceProperties` can be set through the newly added OT public API
`otThreadSetDeviceProperties()`. Its default value (upon OT stack start)
can also be configured using OT configs:
- Newly added `OPENTHREAD_CONFIG_DEVICE_POWER_SUPPLY` specifies the
  default power supply config to use. This config can also be set
  using the newly added CMake option `OT_POWER_SUPPLY`.
- Existing `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` will indicate
  if device is acting as a BR.

This commit also adds CLI command `deviceprops` for getting/setting
the device config. It also adds a unit test to validate the Leader
Weight calculation algorithm from a given device config.
2023-03-21 22:51:49 -07:00
Suvesh Pratapa 07d69f30ce [dua] remove DUA address if network data no longer contains DUA prefix (#8874)
Fix for the following bug:

Leader/Parent (OTBR) is reset (taken off the network), leading to its
MTD child being detached. When the parent is brought back on the
network without configuring the previous DUA prefix, the MTD asserts
complaining that its DUA prefix is not valid anymore.

1. We don't assert anymore in this situation, rather the MTD just
   won't include the DUA address in its address registration TLV.

2. More importantly, we remove a "cached" DUA address if we find that
   the network leader is no longer configured with a DUA prefix.
2023-03-21 22:14:31 -07:00
Abtin Keshavarzian 32a538f773 [netif] simplify ThreadNetif (#8882)
This commit simplifies `ThreadNetif` class by removing methods
like `IsOnMesh()` and `SendMessage()` which just call same method
on other modules (`NetworkData::Leader` and `MeshForwarder`). It
also moves the `RouteLookup()` method to `Ip6` class.
2023-03-21 17:54:08 -07:00
kylorene b3dbc6c2e9 [cli] add docs for networkkey through parentpriority (#8868) 2023-03-21 17:32:22 -07:00
doru91 c7925dd1df [dua] avoid unnecessary time ticker processing (#8872)
If there is no DUA request sent/scheduled, then there is no need to
trigger the periodic one second ticker timer.

This helps SEDs to be more power efficient and to avoid unnecessary
wakeups.

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
2023-03-21 17:28:42 -07:00
dependabot[bot] da66f629c0 github-actions: bump step-security/harden-runner from 2.2.0 to 2.2.1 (#8885)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/c8454efe5d0bdefd25384362fe217428ca277d57...1f99358870fe1c846a3ccba386cc2b2246836776)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-03-21 09:36:10 -07:00
Abtin Keshavarzian 922cf5ac98 [mle] update how we set/get Parent Priority on ConnectivityTlv (#8878)
This commit updates `ConnectivityTlv` methods which get/set the Parent
Priority field (high, medium, low). This change ensures that we do
not use bitwise shift of a signed and potentially negative value
(`a >> b` where `a` is negative). Note that the behavior of right
bitwise shift of a negative value is not specified by C++ standard
and it is implementation/toolchain dependent.
2023-03-18 23:05:13 -07:00
Abtin Keshavarzian 8ad7b2bd64 [netdata] simplify tracking of lowpan context IDs (#8876)
This commit simplifies how the 6LoWPAN Context IDs are assigned and
tracked by `NetworkData::Leader` using a new nested class
`ContextIds`. A Context ID can be in one of the 3 states:
- It is unallocated.
- It is allocated and in-use.
- It is scheduled to be removed (after reuse delay interval).

This commit also adds a test-case `test-019-netdata-context-id.py`
which validates the assignment and removal of Context IDs under
different scenarios.
2023-03-18 22:45:28 -07:00
Abtin Keshavarzian af031f3b50 [netdata] new API to get lowpan context IDs (#8870)
This commit adds `otNetDataGetNextLowpanContextInfo()` to iterate
through the list of LoWPAN Context entries in Thread Network Data
providing info about the prefix, its LoWPAN Context ID and Compress
flag (relating to `ContextTlv` sub-TLVs of `PrefixTlv`s in Network
Data).

This commit also updates CLI command `netdata show` to list the
context IDs in addition to prefixes, routes, and services.
2023-03-17 21:39:59 -07:00
Przemysław Bida 89d5799d76 [dns] implement DNS query over TCP (#8474)
This commit introduces DNS query over TCP protocol.
2023-03-17 09:44:26 -07:00
Abtin Keshavarzian 30be45dc5c [mle] add IncrementLinkQuality() to ConnectivityTlv (#8877)
This method helps when preparing the `ConnectivityTlv` and counting
the neighbors with which device shares a link at different
Link Quality values (1,2,3).
2023-03-17 09:07:15 -07:00
doru91 5a21384833 [mac] add build config for timeout for receiving a Data Frame (#8863)
This setting is targeted for SEDs which may need to decrease the
timeout for receiving a Data Frame (which follows an ACK with FP bit
set) for power saving reasons.

IEEE 802.15.4-2015 specification doesn't enforce a specific timeout
value for this parameter so the application should be able to
configure it.

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
2023-03-16 11:12:41 -07:00
Jonathan Hui 2542cabc20 [cli] update dataset to operate directly on TLVs (#8871) 2023-03-16 09:36:41 -07:00
Jonathan Hui fffd5bac8c [dataset] add otDatasetUpdateTlvs API (#8871) 2023-03-16 09:36:41 -07:00
Li Cao 41f051d69b [csl] add code comment & explanation for HandleCslTimer (#8867) 2023-03-16 09:27:31 -07:00
Abtin Keshavarzian 2d0d9bef88 [tcp] update otTcpConnect() doc to indicate currently supported behavior (#8835)
This commit updates the documentation for `otTcpConnect()` indicating
that caller need to wait for `otTcpEstablished` callback indicating
that TCP connection was established  before it can start sending
data (e.g., calling `otTcpSendByReference()`).

It also removes the mention of "TCP Fast Open" which is not yet
supported.
2023-03-13 22:17:51 -07:00
Abtin Keshavarzian 5ddd9d7346 [mle] update and enhance processing of Route TLV (#8851)
This commit updates how we process Route TLV in a received
"MLE Link Accept" message when device is already acting as
router or leader:

- We ensure that the Router ID Sequence number in the received
  Route TLV is more recent compared to the current one being
  used before adopting the Router ID Set. We still update
  the router table (next hops and costs) based on the received
  Route TLV even if Sequence number is older.
- We also check that the ID of the router which sent the Link
  Accept is marked as allocated in the Route TLV that it includes
  in the message. This protects against an edge-case where the
  sending router may be misbehaving.

In addition to the above two changes, this commit contains some
enhancements and simplifications:

- `RxMessage::ReadRouteTlv()` is added which reads and validates
  a `RouteTlv` from an `Mle::RxMessage`.
- `MleRouter::ReadAndProcessRouteTlvOnFed()` is added which reads
  and processes `RouteTlv` on an FED (avoid repeating same code).
- `MleRouter::ProcessRouteTlv()` is simplified.
2023-03-13 19:51:06 -07:00
Abtin Keshavarzian 7ecc5d104e [netdata] ensure to free context ID once (#8860)
This commit updates `NetworkData::Leader::HandleTimer()` such that
once the reuse delay time for a previously used Context ID is reached
and the ID is freed, the `mContextLastUsed` is also set to zero. This
ensures that context ID is freed only once from `HandleTimer
()` calls (which avoids incrementing the version again).
2023-03-13 16:52:13 -07:00
Abtin Keshavarzian c81e8d3fd0 [netdata] update StartContextReuseTimer() to start time if not running (#8859)
This commit contains two changes to `StartContextReuseTimer()`:
- We now start the context reuse timer only if the timer is not already
  scheduled (`mContextLastUsed` will be non-zero when reuse timer
  is already scheduled).
- The `mTimer` (which is used as a periodic timer) is only started
  if it is not already running.
2023-03-13 13:20:06 -07:00
Abtin Keshavarzian b2e813429b [mesh-diag] update kMaxTlvsToRequest constant (#8853)
This commit updates `kMaxTlvsToRequest` constant to account for the
recently added `VersionTlv`. It also moves its definition from header
file to cpp file in `SendDiagGetTo()` method so to make it easier to
track and update it when/if new TLV types are added.
2023-03-13 10:37:24 -07:00
dependabot[bot] baa796dd47 github-actions: bump docker/setup-buildx-action from 2.2.1 to 2.5.0 (#8856)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.2.1 to 2.5.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/8c0edbc76e98fa90f69d9a2c020dcb50019dc325...4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c)

---
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>
2023-03-13 09:27:27 -07:00
kylorene 1616357d4c [cli] update dns docs (#8831) 2023-03-10 21:40:51 -08:00
Abtin Keshavarzian a0b5198c02 [dataset] add otDatasetConvertToTlvs() API (#8720)
This commit adds `otDatasetConvertToTlvs()` to covert a given
Operational Dataset `otOperationalDataset` to TLVs. It also adds a
related CLI command `dataset tlvs`.
2023-03-10 14:10:50 -08:00
Zhanglong Xia 295f63f370 [build] fix the -Wunused-command-line-argument warning on macOS (#8839)
Use the command `make -f src/posix/Makefile-posix` to build the posix
platform on macOS, it generates the `-Wunused-command-line-argument`
warning (refer to #8828).

This commit moves the linker option `-rdynamic` from `COMMONCFLAGS` to
the `LDFLAGS` to resolve the warning.
2023-03-09 16:55:46 -08:00
Abtin Keshavarzian 742f53f64a [version] introduce OT_THREAD_VERSION_1_3_1 (#8849)
This commit adds `OT_THREAD_VERSION_1_3_1` constant (equal to `5`) for
Thread Version 1.3.1. It also updates the build switch options for
CMake `OT_THREAD_VERSION` and autoconfig `THREAD_VERSION` and `BUILD.gn`
to support the new version value of "1.3.1".

Note that this commit does not change the default config value of
`OPENTHREAD_CONFIG_THREAD_VERSION` which is the default version to
use if it is not explicitly specified by build switches or in a
project config file.
2023-03-09 09:34:19 -08:00
Axel Le Bourhis 83307580fe [srp-server] fix -Werror=maybe-uninitialized (#8848)
Build errors are raised by arm-none-eabi-gcc toolchain when building
with -Og option.

Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
2023-03-09 09:32:09 -08:00
Abtin Keshavarzian 1f1a826d18 [net-diag] add Net Diag Version TLV (#8834)
This commit adds support for Net Diag Version TLV (TLV number 24)
which returns the Thread version of device (as `uint16_t`).
It also updated the `MeshDiag` to query for the Version TLV and
provide it in `otMeshDiagRouterInfo`. The related CLI commands
are also updated.
2023-03-08 16:11:10 -08:00
Song GUO 452132dd08 [dnssd] change OT_DNS_QUERY_UPSTREAM to OT_DNS_UPSTREAM_QUERY for consistency (#8846) 2023-03-08 13:26:02 -08:00
Jonathan Hui 8ff0734c75 [github-actions] update otns to python 3.9 (#8845) 2023-03-08 10:51:50 -08:00
Abtin Keshavarzian 3a688cb9cc [rcp] fix DecodeStreamRawTxRequest() to handle missing optional fields (#8844)
This commit updates `DecodeStreamRawTxRequest()` to set the read
boolean flags immediately after they are decoded (not wait till
all fields are read). This ensures correct processing of optional
fields.
2023-03-07 18:17:37 -08:00
Abtin Keshavarzian a94fc44425 [radio] mechanism to switch to PAN channel more quickly on CSL tx (#8701)
This commit adds `mRxChannelAfterTxDone` in `otRadioFrame` which
specifies the RX channel  after frame TX is done (after all retries
and ack received).

This is intended for situations where they may be delay in
interactions between OT stack and radio, as example this is used in
RCP and host architecture to make sure RCP switches to PAN channel
more quickly. In particular, this can help with CSL tx to a sleepy
child, where the child may use a different channel for CSL than the
PAN channel. After frame tx, we want the radio/RCP to go back to PAN
channel quickly to ensure that parent does not miss any tx from child
afterwards, e.g., child responding to the earlier CSL transmitted
frame from parent using PAN channel while radio still staying on CSL
channel.

This commit adds support for the `mRxChannelAfterTxDone` parameter in
spinel and posix host `RadioSpinel`. This is added in a backward
compatible way, i.e., if RCP is using a newer version but host is
older and does not provide the new parameter, RCP will use
`frame.mChannel` as default value for this, and if host is using a
newer version, older RCP will ignore it.
2023-03-07 13:09:34 -08:00
Li Cao 130ef49cc4 [thread-cert] add Low Power test case 7_1_02 (#8807) 2023-03-07 12:54:45 -08:00
Abtin Keshavarzian c661791e87 [netdata] mechanism to track max Network Data length since start/reset (#8826)
This commit adds new mechanism in `NetworkData::Leader` to track the
the maximum observed length of the Thread Network Data since OT stack
initialization or since the last time user reset the tracking
mechanism by calling `otNetDataResetMaxLength()`. This commit also
adds public OT API and  CLI commands for this.
2023-03-07 10:10:02 -08:00
Abtin Keshavarzian d756a2275b [mle] add InitNeighbor() method (#8836)
This commit adds a helper method `Mle::InitNeighbor()` which performs
common initialization of a `Neighbor`  using `RxInfo`, e.g., setting
the Extended MAC address from the sender's IPv6 address IID, updating
the `LinkInfo`, and setting `LastHeard` time. This method is used
from different methods in `Mle` and `MleRouter where a new neighbor
(router, child, or parent candidate) is initialized.
2023-03-07 10:09:02 -08:00
Abtin Keshavarzian d2d9aff012 [mle] send MLE Avd on router promo & accept former child as router (#8307)
This commit updates `MleRouter to send an immediate MLE Advertisement
on promotion to `router` role and assignment of new Router ID. This
helps inform our former parent of our newly allocated Router ID and
cause it to reset it own advertisement trickle timer. This can help
speed up the dissemination of the new Router ID to other routers. It
can also help with quicker link establishment with our former parent
and other routers.

It also removes tx of multicast Link Request (including its delay
mechanism) upon promotion to `router` role.

It also updates `Mle` so if we receive an MLE advertisement from a
former child (which is recently get promoted to router) to accept it
immediately and copy the info from `Child` entry to `Router`.

Finally this commit updates the following test-cases which are
impacted by the changes above (e.g., skipping the checks for
multicast Link Request):

- `v1_2_router_5_1_1`
- `Cert_5_1_01_RouterAttach`
- `Cert_5_2_04_REEDUpgrade`
- `Cert_5_5_02_LeaderReboot`
- `Cert_5_5_05_SplitMergeREED`
2023-03-06 21:15:32 -08:00
gabekassel 6e975c5875 [docs] dns browse: explain dns-sd proxy zone (#8824)
Explain dns-sd proxy zone with an example.
2023-03-06 15:43:13 -08:00
dependabot[bot] 391f526fbc github-actions: bump github/codeql-action from 2.1.39 to 2.2.5 (#8837)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.39 to 2.2.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/a34ca99b4610d924e04c68db79e503e1f79f9f02...32dc499307d133bb5085bae78498c0ac2cf762d5)

---
updated-dependencies:
- dependency-name: github/codeql-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>
2023-03-06 13:11:22 -08:00
Abtin Keshavarzian 0a79c30a20 [mesh-diag] new module and new API to discover network topology (#8682) 2023-03-02 00:43:46 -08:00
Song GUO d93521de06 [dnssd] add API for getting the upstream query status (#8815) 2023-03-01 22:42:29 -08:00
Jeff Bumgardner 3d8406b31c [docs] add plat-dns module to Doxygen menu (#8819)
New API module from #8668 wasn't added to the high-level Doxygen
menu. This causes the module to show up incorrectly when we import
reference docs into openthread.io.
2023-03-01 21:54:26 -08:00
whd a3d1aa7309 [pretty] fix script/clang-format (#8814)
`script/clang-format` is supposed to add an EOF newline for every file
passed in as an argument. However, the script only processed the first
file. This can cause `script/make-pretty check` to fail even after
`script/make-pretty clang`.
2023-03-01 18:10:28 -08:00
Abtin Keshavarzian 091f68ed70 [child-supervision] mechanism to inform interval from child to parent (#7993)
This commit contains changes to child supervision feature. It adds a
new mechanism for a child to inform its desired supervision interval
to its parent. A new optional MLE TLV is added with type 27 and value
of `uint16_t` indicating the supervision interval in seconds. This
TLV is included in MLE Child ID Request and MLE Child Update Request
(sent from the child). The parent echoes back this TLV in the
corresponding responses to indicate that it supports supervision. This
commit changes the parent implementation to track the supervision
interval per child.

This commit also updates the OT public APIs along with the related
CLI commands:
- API now allows the supervision interval to be set on a child.
- New field in `otChildInfo` to indicate the child's supervision
  interval.
- New counter is added to track the number of supervision check
  timeouts failures on a child (intended for testing and debugging).

This commit adds a test `test_child_supervision` to cover behavior of
child supervision and its new behaviors.

This change allows backward compatibility: If the parent does not
support child supervision, it ignores the new TLV in the MLE messages
and the child would fall back to periodically exchanging MLE Child
Update Request with parent. If the child does not support supervision
and/or does not indicate its desired child supervision interval, the
parent will fall back to use the configured default interval.
2023-02-28 23:01:43 -08:00
Abtin Keshavarzian 0491c8ff2c [mle-router] add common SetStateRouterOrLeader() (#8813)
`SetStateRouter()` and `SetStateLeader()` share a bunch of common
code (things that need to be updated on transition to either router
or leader role). This commit adds `SetStateRouterOrLeader()` method
for this.
2023-02-28 14:45:21 -08:00
Jeff Bumgardner 68b3e60ad0 [cli] fix bad CLI command tag (#8818) 2023-02-28 14:44:55 -08:00
kylorene 5714213d46 [cli] added documentation for rcp and route (#8800) 2023-02-28 11:11:43 -08:00
Abtin Keshavarzian ee32965f7e [mle] smaller enhancements (#8812)
This commit contains smaller enhancements in `MleRouter` class,
defining `kChallengeTimeout` constant, using ternary `? :` replacing
`if/else` checks, combining `#if` blocks, etc.
2023-02-28 10:26:56 -08:00
Abtin Keshavarzian 27802bc0df [message-pool] track max used buffers (#8796)
This commit updates `MessagePool` to track number of in use buffers
along with max used so far since OT stack initialization or since
last time counter was reset. This info is then provided in
`otBufferInfo` and in CLI command `bufferinfo`. A new OT API
`otMessageResetBufferInfo()` is added to reset this counter.
2023-02-27 23:14:55 -08:00
Li Cao 982327ac1e [time-sync] define cpp enum/types mirroring public definitions (#8811) 2023-02-27 21:19:49 -08:00
Abtin Keshavarzian 2caa934410 [routing-manager] new APIs to get state and new CLI commands (#8784)
This commit adds new public OT APIs in `border_routing.h` to get the
current state of `RoutingManager` and to get the current favored
on-link prefix.

This commit also updates CLI `br` commands:
- It moves the CLI `br` implementation into own `cli_br` module.
- It adds `br state` to get the current state
- It changes `br omrprefix`, `br onlinkprefix`, and `br nat64prefix`
  to output both local and favored prefixes when no additional arg
  is provided and allow the use of `local` or `favored` extra arg to
  specify the type.
- It updates the documentation of `br` related commands in the source
  code and also adding `cli/README_BR.md`.
2023-02-27 19:03:29 -08:00
Abtin Keshavarzian 2b8779ec0b [net-diag] define AppendDiagTlv() (#8805)
This commit adds `AppendDiagTlv()` to append a dig TLV with a given
type to a `Message`. It also simplifies the `AppendRequestedTlvs()`
to directly parse the "Type List TLV".
2023-02-27 11:43:25 -08:00
Abtin Keshavarzian ea9533cdaf [core] use Min() and Max() to track next timer fire time (#8808) 2023-02-27 10:53:08 -08:00
Abtin Keshavarzian 108ce57b9d [backbone-router] define C++ enum/types mirroring public definitions (#8809)
This commit defines C++ style types for use in core module mirroring
the public OT C definitions. It also contains renames and smaller
enhancements in BackBone Router modules.
2023-02-27 09:48:56 -08:00
Li Cao c49acfc385 [unit] add a README guide for unit tests (#8791) 2023-02-27 09:02:36 -08:00
dependabot[bot] ddae76b7bf github-actions: bump step-security/harden-runner from 2.1.0 to 2.2.0 (#8810)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/18bf8ad2ca49c14cbb28b91346d626ccfb00c518...c8454efe5d0bdefd25384362fe217428ca277d57)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-02-27 09:00:55 -08:00
Abtin Keshavarzian 7f0b5fac4b [cmake] fix OT_TCP option (#8804)
This commit fixes the `OT_TCP` option (removes extra comma in the
definition).
2023-02-24 13:24:57 -08:00
Kangping f4f2d90d6a Add missing dependencies to "openthread-posix" target (#8801)
The `openthread-posix` library calls OT public APIs and library APIs
(e.g. radio_spinel, HDLC), but it doesn't link against the library
targets.

This commit also adds `extern "C"` for posix impl of `otPlatFree`
and `otPlatCAlloc`.
2023-02-24 10:52:39 -08:00
Diego Ismirlian 57ed65edf4 [commissioner] add joiner session timeout (#8776)
This commit adds a session timeout for the integrated Commissioner.

When the Joiner and Commissioner have a weak link, and the session
doesn't time out after a communication failure, the Joiner may fail to
join in subsequent attempts if the Commissioner is not stopped and
restarted. With the proposed modification, the Commissioner times out
the session after a configurable time, so the Joiner may be able to
join in a future attempt.
2023-02-23 09:08:15 -08:00
Kangping 952420a4fa [cli] update dataset readme with the latest output (#8790)
The dataset examples are generated by version 1.1 OT stack
where the Security Policy value has length of 3 bytes but 1.2
extends it to 4 bytes.

The real problem is that spec requires that **ZERO** Key Rotation
**SHALL NOT** be allowed:
```
Key rotation period in hours. The
minimum key rotation period SHALL be
1 hour and a key rotation period of 0
SHALL NOT be allowed.
```

But the example is using ZERO.

This commit fix this by updating the examples to 1.2 version.
This commit fix also problems that incomplete TLV HEX string
(Pending Timestamp and Delay Timer are missing) are used for
setting the Pending Dataset (e.g. `dataset set pending`).
2023-02-22 14:18:29 -08:00
Abtin Keshavarzian 9e1e8f546d [ip6] simplify Ip6::HandleDatagram() (#8787)
This commit updates `HandleDatagram()` simplifying the code related to
determining `forwardThread` and `forwardHost` based on the
destination address.
2023-02-22 14:15:45 -08:00
Song GUO 852d076f00 [dnssd] support forwarding DNS queries to platform upstream (#8668)
This commit adds a set of APsI for forwarding a DNS query to the
upstream DNS server via platform API and a posix platform
implementation.

This feature is disabled by default, and this PR adds a `dns server
upstream {enable|disable}` command CLI for enabling and disabling this
feature.

Tests will be added after ot-br-posix adds related support.
2023-02-21 21:15:03 -08:00
gavinmcgovern c311b85cc9 [docs] add Nabu Casa to supporter list (#8785) 2023-02-21 16:17:36 -08:00
whd 8c2187ee72 [docker] avoid unnecessary copying when building an image for testing (#8780)
This commit lets `do_build_otbr_docker()` skip unnecessary files when
copying the source code for building a docker image. It can save time
and disk space for the user.
2023-02-21 09:28:50 -08:00
Abtin Keshavarzian e3f5bd56a1 [build] add CMake option for enabling TCP (#8778)
This commit adds CMake option `OT_TCP` (`TCP` in `common-switches`)
which map to `OPENTHREAD_CONFIG_TCP_ENABLE` (enabling TCP).
2023-02-21 09:24:32 -08:00
dependabot[bot] af5eb1f945 github-actions: bump actions/upload-artifact from 3.1.1 to 3.1.2 (#8781)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.1 to 3.1.2.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3.1.1...0b7f8abb1508181956e8e162db84b466c27e18ce)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
2023-02-20 21:30:27 -08:00
Abtin Keshavarzian 13ac7297a0 [routing-manager] use NA target address (#8777)
This commit updates `ProcessNeighborAdvertMessage()` method in
`RoutingManager` to use the Target Address included in Neighbor
Advertisement to find the related `Router` (instead of sender's
IPv6 address). This addresses situations where the router
responding may use a different address.
2023-02-20 21:20:57 -08:00
Yang Sun afbb2d5799 [trel] remove deprecated otTrelEnable/otTrelDisable APIs (#8775) 2023-02-17 22:41:58 -08:00
Yang Sun 72fa12a204 [test] allow TREL disabled by default (#8774) 2023-02-17 11:50:22 -08:00
sarveshkumarv3 2060039bbf [csl] fix indirect retransmission of frame previously transmitted via CSL (#8770)
Bug fix for an issue where any frame which fails CSL transmission gets
treated as a new frame (instead of a retransmission) for a subsequent
indirect retransmission (in the data poll handler). This fix checks
for the previous CSL transmit attempts and if it is greater than 0,
retransmits with the same frame counter, sequence number and key id as
previous attempt.
2023-02-16 09:49:14 -08:00
Abtin Keshavarzian a0ff14c475 [test] update test_srp_server to clear the service instances (#8768)
This commit updates `PrepareService()` functions to `memset` the
`Service` instance to zero before populating its fields. This ensures
that all new properties (e.g., recently added `mLease`/`mKeyLease`)
are set to zero and use the corresponding default value.
2023-02-15 22:34:43 -08:00
Li Cao 6020d01bfc [code-utils] use num_utils Min/Max to simplify code (#8762)
This commit uses Min and Max from num_utils to replace Ternary
operators.
2023-02-15 20:48:13 -08:00
Kangping 3c65092344 [tests] add build tests for BR features (#6570)
BR features are tested with "Border Router" CI task but it is built
with gcc by default. This commit adds BR features to posix build
checks which apply clang/clang++.
2023-02-15 13:20:59 -08:00
Stefan Agner 7a6546c2b7 [posix] set link type to none explicitly (#8526)
Linux kernels with CONFIG_MCTP enable (available in 5.16 or newer)
seem to have an issue when setting the link type to ARPHRD_VOID.
There seem to be no good reason why ARPHRD_VOID is used. Stick to
the default ARPHRD_NONE.
2023-02-15 10:22:57 -08:00
Jiachen Dong 242c7cc7c3 [harness-simulation] keep capture files in sync at runtime (#8138)
This commit keeps capture files in sync at runtime. Therefore, Harness
can obtain the addresses directly from the capture files in manual DUT
mode without having to enter the addresses manually.
2023-02-14 19:08:02 -08:00
Sylvain Baubeau 9ff2eefee0 [bootstrap] install bzip2 to uncompress arm toolchain (#8621) 2023-02-14 13:57:41 -08:00
esp-jiangguangming d28793c104 [net] fix typo multicast in comments (#8756) 2023-02-13 22:02:08 -08:00
Yakun Xu 4d14dad95d [posix] disable addrconf generating LL address (#8749)
This commit disables addrconf generating address by set addr_gen_mode to
IN6_ADDR_GEN_MODE_NONE, otherwise linux may generate a link local address
based on link type and presence of EUI64 address. This allows OpenThread
to fully manage link local address of its network interface.
2023-02-13 22:01:43 -08:00
Yang Sun 27e56b301b [trel] add otTrelSetEnabled API (#8731) 2023-02-13 21:30:39 -08:00
kylorene 4c5ee625d2 [tcp] correct misspelling in API docs (#8750) 2023-02-13 15:05:12 -08:00
dependabot[bot] b8eb7362c0 github-actions: bump actions/setup-go from 3.4.0 to 3.5.0 (#8748)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/d0a58c1c4d2b25278816e339b944508c875f3613...6edd4406fa81c3da01a34fa6f6343087c207a568)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-02-13 09:49:46 -08:00
Abtin Keshavarzian 67fe9924fa [net-diag] simplify NetworkDiagnostic (#8746)
This commit contains smaller enactments in `NetworkDiagnostic`
class:

- `SendCommand()` method is updated to accept a `Uri` for the
  intended diag command.
- `PrepareMessageInfoForDest()` method is added which prepares a
  `Tmf::MessageInfo` for sending diag commands to a destination
  deciding which source address to use.
- The TLV class is renamed to `Tlv` from `NetworkDiagnosticTlv`
  (since it is under the namespace `NetworkDiagnostic` already).
  This makes it similar to TLVs from other modules, `Mle::Tlv`,
  `MeshCoP::Tlv`, etc).
- Logging in `NetworkDiagnostic` is updated and simplified, now
  using `Log(Action, Uri)` method. The logs provide more info
  like the IP6 address of sender/receiver of a message.
2023-02-13 08:45:39 -08:00
Abtin Keshavarzian 2b67cd8ebb [simul-platform] enhance radio nodeidfilter command (#8740)
This commit updates the custom CLI command `nodeidfilter` defined for
simulation platform enabling filtering at radio level. This commit
enhances this command so it can be used as both a deny-list or an
allow-list. It also adds support to output the list and filter mode
when no arg is given.
2023-02-13 08:42:36 -08:00
Abtin Keshavarzian a4223001f2 [history-tracker] track changes to router table (next hop, cost) (#8734)
This commit adds anew feature in `HistoryTracker` to track the history
of changes to routers. In particular we track when a new router is
added or removed, or when next hop and/or path cost towards a router
is changed. On a cost change the recorded entry, provides the old
cost value along with the new path cost. This helps to track the cost
changes more easily (no need to look back at history to find the old
cost value).

This commit also adds CLI command `history router` for the new
feature.
2023-02-13 08:41:42 -08:00
Jonathan Hui 3d7626f560 [cmake] guard unit tests with BUILD_TESTING (#8739) 2023-02-09 18:24:20 -08:00
Jonathan Hui 630099bde6 [github-actions] fix coverage reporting in unit workflow (#8737) 2023-02-09 18:24:03 -08:00
Eduardo Montoya bbd96473fd [mac] ensure CSL parameters are initialized to zero (#8736)
Fix bug that prevented to initialize CSL parameters for non-FTD builds.
2023-02-09 10:19:27 -08:00
Yakun Xu 0e667b8e03 [test] use cmake to run unit tests (#8724)
This commit migrates unit tests to cmake.
* build unit tests with cmake
* add missing tests in cmake
* use ctest
* add platform udp stubs for test platform
* skip some static_assert with gcc-4
2023-02-09 10:19:01 -08:00
Yakun Xu 6e6a2ae145 [ncp] remove legacy network support (#8723)
This commit removes legacy network support as it's not used anymore.
2023-02-08 22:36:53 -08:00
Abtin Keshavarzian 5507465290 [cli] nexthop command to output next hop and path cost table (#8729)
This commit extends `nexthop` command such that when it is used
without any input, it lists all currently allocated router IDs and
the next hop and path cost for each. Note that this info is
different from `router table` (which provides direct link along
with any backup next hop option).

This commit also adds a new API `otThreadIsRouterIdAllocated()` to
indicate whether or not a given router ID is currently allocated.
2023-02-08 15:07:19 -08:00
Abtin Keshavarzian f575021cdb [router-table] use Tasklet to signal changes (#8730)
This commit updates `RouterTable` class to use a `Tasklet` to track
and signal when there is any change to the table, e.eg., new router
added or removed and/or next hop or cost for a router gets changed.
2023-02-07 20:23:12 -08:00
Abtin Keshavarzian f9ab9dfd44 [ip6] add Option::ParseFrom() and common PadOption (#8719)
This commit contains changes related to handling of IPv6 Options. It
adds a new method `Option::ParseFrom()` which parses and validates an
IPv6 Option from a given message. This method handles the Pad1 Option
as well as other Option Types. This makes it easier (and safer) to
iterate through Options in an Extension Header. `Option::GetSize()`
is also updated to return the correct size for Pad1 Option since Pad1
Option does not follow the common Option format (has Type field with
no Length field).

This commit also adds a common `PadOption` class which based on the
desired padding size uses Pad1 or PadN as its type. It also provides
`InitToPadHeaderWithSize()` which prepares the option with proper
length to pad an Extension Header with a given current size (also
determining whether or not padding is needed).

This commit also updates `Ip6` methods to use `kLengthUnitSize`
constant.
2023-02-07 15:10:15 -08:00
kylorene 2e07758d78 [cli] add documentation for the DNS CLI commands (#8727) 2023-02-07 14:54:32 -08:00
Yang Sun 82e816b82f [mle] retransmit link request after router reset (#8704)
According to Thread 1.3.0 Section 4.7.1.3, router synchronization
after reset requires the multicast link request message to be
retransmitted until a response is received, or the maximum
transmission limit has been reached. If the router was a leader or had
more than 5 children prior to reset, it MUST be retransmitted as a
critical message. Each multicast retransmission of an MLE Message on a
TL1 or TL2 Link must be delayed by MLE_MULTICAST_RETRANSMISSION_DELAY
multiplied by a random value between 0.9 and 1.1 with a resolution of
at least 1 ms.

This commit implements the above requirement. With this requirement,
in the cases when a router is reset and there is no other router to
respond to the link request then it takes longer time for the router
to join thread network. Thus some test cases are modified to allow
longer router sync time in such cases.
2023-02-06 21:10:38 -08:00
Tristen Pierson 7aaf33478d [coap] copy token from block2 request message to next response token (#8700) 2023-02-06 14:12:40 -08:00
dependabot[bot] 5fe2b3e85a github-actions: bump actions/setup-python from 4.3.1 to 4.5.0 (#8725)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.3.1 to 4.5.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/2c3dd9e7e29afd70cc0950079bde6c979d1f69f9...d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
2023-02-06 14:01:52 -08:00
Jonathan Hui eb6377f1d7 [tests] declare python dependencies with specific versions (#8721) 2023-02-04 21:09:54 -08:00
Abtin Keshavarzian 7defbc95bf [link-metrics] simplify HandleManagementRequest() (#8714) 2023-02-03 21:37:55 -08:00
Abtin Keshavarzian a3d353af8c [ip6] ensure to make room for new header at correct offset (#8717)
In `InsertMplOption()` we need to insert the Option at the original
end of Hop-by-hop Extension header which we track in `hbhSize`. Note
that the read `hbh` is updated (we increment the `Length` field which
increases the `hbh.GetSize()` by 8 bytes).

The code before this commit which inserted the header at the new
`hbh.GetSize()` offset still works correctly since we copy all the
bytes before the insertion offset back. It just copies more bytes than
necessary.
2023-02-03 21:31:19 -08:00
Abtin Keshavarzian 48128acb76 [ip6] remove default constructor for Ip6::Option (#8712)
All sub-classes of `Option` provide `Init()` method to initialize
the Option.

This commit also updates `Lowpan::CompressExtensionHeader()` to
check that we did read an option from message before checking if
it can be compressed.
2023-02-02 21:26:38 -08:00
Abtin Keshavarzian d0f6f8dc30 [cli] add documentation for dns resolve4 command (#8710) 2023-02-02 21:25:28 -08:00
Abtin Keshavarzian 213792f85b [github-actions] update toranj-ncp to trigger on pull request only (#8648)
This commit updates the github actions `toranj` workflow and the
toranj `start.sh` script to trigger `toranj-ncp` tests on a Pull
Request only if there are changes in any of the `src/ncp` files.
2023-02-02 12:52:08 -08:00
Abtin Keshavarzian 88b3367402 [message] add WriteBytesFromMessage() and Remove/InsertHeader() (#8708)
This commit updates `Message` class adding new methods. A new
method `WriteBytesFromMessage()` is added which writes bytes read
from another or potentially the same message to the message at
a given offset.  This method replaces the `CopyTo()` and unlike
`CopyTo()` it can be used to copy bytes within the same message
in either forward or backward directions.

This commit adds `RemoveHeader()` which removes header bytes from
the message at a given offset and length. It shrinks the message
and copies existing header bytes before the removed segment forward
to replace the removed bytes.

This commit also adds `InsertHeader()` method which grows the
message to make space for new header bytes at a given offset.
The existing header bytes are copied backward to make room for the
new header bytes.

Unit test `test_message` is updated to validated all the newly
added methods.
2023-02-02 11:01:24 -08:00
Abtin Keshavarzian e5530a7e5f [ip6] refer to correct RFC in comments/docs (#8711)
This commit updates comments to refer to correct RFC number. RFC 6052
instead of 6502 (typo in some comments).
2023-02-02 10:07:58 -08:00
Abtin Keshavarzian 632b63089c [ip6] rename Option sub-classes (#8709)
This commit renames the `Ip6::Option` and its sub-classes, e.g.,
we use `MplOption` instead of `OptionMpl` to follow similar naming
pattern as `Tlv`s.
2023-02-01 15:13:10 -08:00
Yakun Xu 7fc806fa38 [test] move tcplp tests into unit workflow (#8707)
The tcplp test is not testing POSIX platform. This commit creates a new
workflow unit to host this test. In future, we may put all unit tests
in this workflow after automake support is removed.
2023-02-01 15:10:14 -08:00
Yakun Xu 3eea48cc52 [posix] remove Android.mk (#8706)
This commit removes Android.mk to reduce maintenance effort.
2023-02-01 15:07:46 -08:00
Markus Becker 985f811804 [mle] add API for changing number of child router links (#8410)
Multicast has been proven to work unreliably with a low value of
OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS for big dense networks.
Since there is no silver bullet value that suits all installations,
this commit makes it possible to configure its value at runtime.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2023-01-31 18:31:24 -08:00
Michael Gebremariam c28bb194d4 [api] include mLinkMargin in otNeighborInfo (#8697) 2023-01-30 11:06:21 -08:00
dependabot[bot] abfa1371f0 github-actions: bump step-security/harden-runner from 2.0.0 to 2.1.0 (#8703)
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.0.0 to 2.1.0.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5...18bf8ad2ca49c14cbb28b91346d626ccfb00c518)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  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>
2023-01-30 09:19:31 -08:00
Eduardo Montoya 25506997f2 [cli-tcp] fix TLS configuration for different platforms (#8693)
This commit addresses two issues:
- Use agnostic crypto API regardless of `OPENTHREAD_CONFIG_CRYPTO_LIB`
  choice.
- Limits the configured ciphersuites in order to avoid client-server
  conflicts during handshake.
2023-01-26 10:02:16 -08:00
Abtin Keshavarzian abbf38570d [core] use AppendBytesFromMessage() to copy bytes between messages (#8686)
This commit updates multiple core modules to use the `Message` helper
method `AppendBytesFromMessage()` to append bytes read from one
message at a given offset and length to the end of another message.
2023-01-25 21:33:29 -08:00
Abtin Keshavarzian 8b1d0a9d5a [net-diags] include link quality in child table entry (#8398)
This commit updates the `ChildTableEntry` which is included in Network
Diagnostic "Child Table TLV" to also provide the Link Quality In info
for the child (using the unused two-bit field in the existing entry
format).
2023-01-25 21:32:31 -08:00
Abtin Keshavarzian 3f50b606df [csl] reset tx attempt on mCslTxChild when msg is replaced/purged (#8683)
This commit contains two updates/fixes in `CslTxScheduler`:

In `CslTxScheduler::Update()` method, this commit adds a new call to
`ResetCslTxAttempts()` on `mCslTxChild` when the current indirect
message associated with the child gets changed (replaced or purged),
while MAC is busy with tx of a CSL frame to this child. This ensures
that the next CSL tx associated this child will be correctly treated
as a new frame (and not a retx) and gets its own frame counter.

This commit also updates `HandleSentFrame()` to ensure that we always
call `RescheduleCslTx()` from this method. `Update()` method is
called whenever there is a change to the head of indirect message
queue of any sleepy child. If we are not in the middle of CSL tx at
MAC layer, `RescheduleCslTx()` is called immediately to determine the
next CSL tx among all children and schedule it. Otherwise, we wait
for MAC to signal that frame TX is done. Current code only called
`RescheduleCslTx()` when there was a tx error in `HandleSentFrame()`.
This can cause the issue of not scheduling the next CSL in case
of tx success and/or if the current message was replaced/purged.
2023-01-24 20:55:32 -08:00
Abtin Keshavarzian dbadefa5c8 [ip6] add GetSize() to ExtensionHeader and OptionHeader (#8684)
This commit adds `GetSize()` to `Ip6::ExtensionHeader` and base
class `OptionHeader`. This method returns the size (number of bytes)
of the header/option. In case of `ExtensionHeader` the size is
derived from "Length" field which is in 8-bye unit and does not
count the first 8 bytes.
2023-01-24 20:54:53 -08:00
dependabot[bot] a1a223fcd1 github-actions: bump github/codeql-action from 2.1.37 to 2.1.39 (#8679)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.37 to 2.1.39.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/959cbb7472c4d4ad70cdfe6f4976053fe48ab394...a34ca99b4610d924e04c68db79e503e1f79f9f02)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-23 12:57:05 -08:00
Zhanglong Xia 03c98e08eb [diag] add power calibration related diag commands (#8584)
he power calibration is supported by OT, this commit adds diag
commands that are used to measure the mapping between the actual power
and raw power settings, show the platform used power settings table.
1. Add "diag powersettings" to show the platform currently used power
   settings table.
2. Add "diag rawpowersetting" to make the platform to use the given
   raw power settings to transmit frames.
3. Add "diag cw" to transmit the continuous carrier wave.
2023-01-23 12:55:48 -08:00
Sam Kumar 65a8d520b1 [cli-tcp] add TLS mode to TCP CLI tool and TLS callbacks to TCP API (#8257)
This commit adds support for TLS in the TCP CLI tool, along with a
test of TLS functionality.

The main purpose of this is to provide an example of how to use
mbedTLS with TCPlp to run TLS. I felt it is important to have an
example because I expect that many applications that use TCP,
particularly those in which a Thread device exchanges data with a
device outside the Thread mesh, will need to run TLS over TCP for
security reasons.

A secondary benefit is to add TCP functionality to the TCP CLI
tool. Additionally, by having the example code be part of a "real"
application (the CLI tool), there is less risk of the code going stale
as OpenThread evolves.

I added an "expects" test for the TLS functionality in the CLI tool. I
also ran the code on two Nordic NRF52840-DK boards to make sure it
works.

The performance impact of TLS appears to be small. When using TCP
without TLS, I am able to achieve ~80 kb/s goodput between two
NRF52840-DK boards. With TLS in the same setup, I am able to achieve
~70-75 kb/s goodput.
2023-01-23 10:56:16 -08:00
Abtin Keshavarzian 30aebb5e74 [ip6-mpl] check the length when reading MPL Option (#8672)
This commit enhances/fixes how we validate an `OptionMpl` we read from
a received message. In `Mpl::ProcessOption()`, we first ensure that
we can read the minimum expected size of an MPL Option and then check
based on the read Control field, the Seed ID length and ensure we can
read the full `OptionMpl` under `kSeedIdLength2`.
2023-01-20 08:30:23 -08:00
Jonathan Hui e5383ca9db [github-actions] fix cmake 3.10.3 install (#8671) 2023-01-19 15:10:35 -08:00
Abtin Keshavarzian dbe1f7019c [radio] new API to update frame counter only if new value is larger (#8607)
This commit adds a new radio platform API which updates the MAC Frame
Counter only if the new value is larger than current value being used
by radio platform, i.e., `otPlatRadioSetMacFrameCounterIfLarger()`.
OT stack provides a default weak implementation of this API which
calls the existing `otPlatRadioSetMacFrameCouter()`.

This API is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC`
capability and thereby is responsible for assigning the frame counter
to tx frames. It helps address an edge-case where OT stack may not
yet know of the latest frame counter values used by radio platform
(e.g., due to enhanced acks processed by radio platform directly or
due to delay between RCP and host) and then setting the value from OT
stack may cause the counter value on radio to move back (OT stack
will set the counter after appending it in `LinkFrameCounterTlv` on
all radios when multi-radio links feature is enabled).

This commit also updates spinel and RCP and `radio_spinel`
implementations to support the new API. This is added in a fully
compatible way, i.e., a new host firmware works with older RCP, and
similarly an old host can work with new RCP firmware.
2023-01-19 09:12:07 -08:00
Abtin Keshavarzian a1953a7a34 [ip6] check role to allow forwarding back to Thread (#8666)
This commit updates `Ip6::HandleDatagram()` to check the device role
to determine whether to allow messages received from the Thread mesh
to be forwarded back to the Thread mesh. This is allowed only when
device is acting as router or leader. This then lets us remove
`SetForwardingEnabled()` method.
2023-01-18 11:59:32 -08:00
Abtin Keshavarzian 75b1a56c3c [ip6] style enhancements and renames (#8665)
This commit renames the method which passes a message to host
by invoking the registered receive callback to `PassToHost()`.
It also contains smaller style enhancements.
2023-01-18 11:57:55 -08:00
Zhangwx 62cfa5144a [logging] fix print format when enabling csl debug (#8667)
Fix some `uint32_t` variables using `%u` format when enabling csl debug.
2023-01-18 11:28:17 -08:00
Abtin Keshavarzian fe1cf3a294 [mac-frame] update InitMacHeader() (#8660)
This commit updates how we prepare the MAC headers:
- New `enum`s are defined in `Mac::Frame` to specify the frame
 `Type`,  `Version`, `SecurityLevel`, etc.
- `InitMacHeader()` will itself determine the Frame Control Field
  from the given address info.
- It now uses `FrameBuilder` to prepare the headers.
- New helper `MeshForwarder::PrepareMacHeaders()` is added which
  takes care of adding MAC (address, security header) along with
  any IE headers.
- These changes ensure that PAN ID Compression bit is properly
  set on MAC frames when using 2015 version (ensure that PAN
  IDs are not omitted when both addresses use Extended format).
2023-01-17 20:01:26 -08:00
Abtin Keshavarzian 57733ea668 [router-table] new API to get next hop and cost (#8653)
This commit updates `RouterTable` to provide a common method to
determine both the next hop and the path cost towards a given
destination. This helps us combine and reuse similar code.

This commit also adds `otThreadGetNextHopAndPathCost()` as a new
public OT API to get the next hop and path cost. It also adds a
related CLI command `nexthop`.

A new test `test-018-next-hop-and-path-cost.py` is added which
validates the next hop and path cost calculation on different
network topologies and from different nodes (FEDs, routers).
2023-01-17 13:31:44 -08:00
dependabot[bot] c766c8735e github-actions: bump actions/download-artifact from 3.0.1 to 3.0.2 (#8658)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/9782bd6a9848b53b110e712e20e42d89988822b7...9bc31d5ccc31df68ecc42ccf4149144866c47d8a)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-17 10:09:12 -08:00
Eduardo Montoya 0614ff6e43 [data-poll-sender] faster rtx polling for CSL (#8654)
Make sure that retransmission of data polls happens at least at the
CSL period rate, when this is lower than
OPENTHREAD_CONFIG_MAC_RETX_POLL_PERIOD.

This greatly improves latency under situations of heavy traffic, where
CSL synchronization might be lost ocassionaly due to the mix of CSL
and indirect transmissions.
2023-01-17 09:58:27 -08:00
Abtin Keshavarzian b832cb2c49 [mle] keep router table next hop and cost on REED to router promotion (#8657)
This commit updates `MleRouter` such that on promotion from REED to
router role, we keep the router table's next hop and cost as what we
had as a REED, i.e., our parent being the next hop towards all other
routers and we tracked its cost towards them. As an FED, device may
have also established links with a subset of neighboring routers. We
ensure to clear the link to these neighbor to avoid using them since
the neighboring router will drop messages from us till we re-establish
link using our new RLOC16.
2023-01-17 09:45:23 -08:00
Abtin Keshavarzian 19475e3de8 [netdata] update CompareRouteEntries() on MTD to prefer self (#8656)
This commit updates `CompareRouteEntries()` so that on MTD we replace
the `PathCost()` check with a check to see if entry's RLOC matches
the device itself. This handles the uncommon case where an MTD itself
may be acting as a BR. This then allows us to remove the `MleRouter`
`PathCost()` method (which on MTD was returning zero).
2023-01-17 09:43:23 -08:00
Abtin Keshavarzian a1979fdd8e [mac] ensure to apply RSS filter on all rx frame including ack (#8651)
This commit updates how we apply `Mac::Filter` ensuring the fixed RSS
filter is applied to all rx frames including received ack frames.

We add a new method `Mac::Filter::ApplyToRxFrame()` which applies the
filter rules directly to a rx frame, potentially updating its signal
strength to a fixed RSS. This common method is then called from
`Mac::HandleReceivedFrame()` replacing the existing code and also
from `Mac::RecordFrameTransmitStatus()` to a received `aAckFrame`.
This ensures that fixed RSS is correctly tracked on the corresponding
neighbor.

This commit also updates `Mac::Filter` methods which do not change
the `Filter` to be marked as `const`.
2023-01-13 11:41:07 -08:00
Abtin Keshavarzian 23b5b2845f [trel] use same constant for noise-floor under TREL radio link only (#8650)
This commit applies to edge-case where OT is build with only TREL
radio link and no 15.4 radio link.

We define `Radio::kDefaultReceiveSensitivity` as the default rx
sensitivity value returned from `GetReceiveSensitivity()` and use the
same constant for noise floor returned from `SubMac::GetNoiseFloor()`.

This ensures that fixed RSS value applied through `macfilter add-lqi`
CLI command uses the same value for noise floor when calculating the
typical RSS for a given Link Quality value.
2023-01-12 21:16:48 -08:00
Abtin Keshavarzian b876cc3e03 [router-table] simplify UpdateRoutes() and how to reset Adv interval (#8644)
This commit changes `RouterTable::UpdateRoutes()`. Before updating the
routes, we track which routers have finite path cost. After the
update we check again to see if any path cost changed from finite to
infinite or vice versa and use this to decide whether to reset the
MLE Advertisement interval. This helps simplify the code and handle
some edge-cases related to resetting the Advertisement interval where
changing the Link Quality on the neighbor may impact the cost towards
routers which used it as next hop.
2023-01-12 12:03:13 -08:00
Abtin Keshavarzian 7b4f9e26fa [mle] always check for stale parent in HandleAdv() (#8646)
This commit contains smaller fixes and enhancements in `Mle` method
`Mle::HandleAdvertisement()`
- We add `VerifyOrExit(IsAttached())` at the top of the method.
- We always perform the check for stale parent i.e., check if we
  got an MLE Advertisement from parent but with a different RLOC16.
  The `MleRouter` method also does the same check, however in certain
  cases (e.g., when there is Partition ID or leader ID mismatch) the
  `MleRouter` method will exit early and expect the `Mle` method
  to handle these cases.
- When on `Mle` method we handle Partition ID or leader ID mismatch
  and then process `RouteTlv` we now also call `UpdateRoutesOnFed()`.
2023-01-11 23:19:28 -08:00
Abtin Keshavarzian 66933e4fcc [mle] update HandleAdv to not exit when deciding to promote to router (#8645)
This commit updates `MleRouter::HandleAdvertisement()` to not call
`ExitNow()` and exit early when as a child we decide to try to
promote to router role and set `mRouterSelectionJitterTimeout`. This
ensures that we continue processing the message and call
`UpdateRoutesOnFed()` and `router->SetLastHeard()`.
2023-01-11 23:12:15 -08:00
whd 22fa54dfa2 [infra-if] add API for querying infra link status (#8619)
This commit introduces 2 APIs to query infra link status:
- `otSysGetInfraNetifFlags` returns the `ifr_flags` of the infra
  network interface.
- `otSysCountInfraNetifAddresses` counts the numbers of LLA, ULA and
  GUA on the infra network interface.
2023-01-11 07:58:38 -08:00
Abtin Keshavarzian 7dd9543687 [mle] simplify HandleAdvertisement() (#8643)
This commit contains smaller enhancements in `MleRouter` method
`HandleAdvertisement()` processing received MLE Advertisement
message:
- We remove all the `IsFullThreadDevice()` checks in this method
  since it is only called from `Mle` when device is FTD (already
  checked by `Mle` before calling).
- Also this method is called only when device is attached (in child,
  router, or leader role). So we can simplify the checks related to
  the device's role.
- We pass the already read TLV values (e.g., `LeaderDataTlv`) to
  this method (to avoid re-reading the same TLVs from message).
2023-01-11 06:15:50 -08:00
Abtin Keshavarzian 1e5c664a9a [router-table] update cost on FED and enhance GetPathCost() (#8629)
This commit adds new method `RouterTable::UpdateRoutesOnFed()` which
tracks cost towards all routers on an FED child based the parent's
cost towards them. This method is called whenever we receive an MLE
Advertisement from the parent (replacing the code which tracked the
cost only towards the leader) and also during attach process upon
receiving a Child ID Response containing `RouteTlv` from the parent.

This commit also updates `GetPathCost()` to handle more case:
- Where device is detached or disabled, we return `kMaxRouteCost`.
- If device is a child, we derive the path cost as the link cost
  to the parent plus the cost from parent towards the destination.
- If device is a child and destination is another child of the
  same parent, we use link cost to parent plus an estimated cost
  towards the other child.

This commit also adds a new helper method `GetPathCostToLeader()`
which is then used in `MleRouter` to simplify the code, e.g.,
when deciding whether to respond to an MLE Parent Request to
to check the current path cost to leader.
2023-01-10 19:05:54 -08:00
Abtin Keshavarzian 6a21b5f9ae [netdiag] include netdiag.h header in network_diagnostic_tlvs.hpp (#8639)
The `network_diagnostic_tlvs.hpp` defines the net diag TLVs and uses
the public definitions (constants) from `openthread/netdiag.h` but
did not include it directly. This commit ensures we include it
directly.
2023-01-10 15:12:47 -08:00
Li Cao 00044dc821 [radio] refine the definition of SYMBOL_TIME (#8634)
This commit simplifies the definition of `OT_RADIO_SYMBOL_TIME` and
provided the reference of the value from IEEE 802.15.4-2015.
2023-01-10 15:12:25 -08:00
Li Cao 287ff433fb [posix] rename and move the configuration of host-rcp time sync interval (#8630)
This commit renames the configuration `RCP_TIME_OFFSET_CHECK_INTERVAL`
to `OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL` and moves it to
posix configuration file because this configuration may need to be
configured on different platforms.
2023-01-10 15:10:54 -08:00
Li Cao f02b8cd985 [cli] add csl info in single child info (#8606)
There's a use case to check the CSL state of one certain child from
the parent. For now this can only be done by showing the full child
table. This commit adds the CSL state in the display of single child
info (cli command `child <id>`).
2023-01-10 15:10:01 -08:00
Abtin Keshavarzian a32d1c0b64 [router-table] update FillRouteTlv() to use GetPathCost() (#8638) 2023-01-10 14:28:57 -08:00
Jonathan Hui f5e3078ec0 [github-actions] fix bootstrap on macos (#8640) 2023-01-10 13:16:16 -08:00
dependabot[bot] f4c5fa6d01 github-actions: bump actions/checkout from 3.1.0 to 3.3.0 (#8631)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.3.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...ac593985615ec2ede58e132d2e21d2b1cbd6127c)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-09 21:07:51 -08:00
Abtin Keshavarzian e7eb94a693 [router-table] simplify GetNextHop() (#8624) 2023-01-09 19:35:57 -08:00
Abtin Keshavarzian b5fafccdef [router-table] move cost calc and related methods to RouterTable (#8623)
This commit moves existing methods for cost and next hop calculation
and updating router table entries to `RouterTable` class from
`MleRouter`.
2023-01-09 09:50:08 -08:00
Abtin Keshavarzian bf5576c93b [rcp] RCP to inform host of its supported RCP API version range (#8617)
This commit adds a new mechanism for RCP to inform host of the range
of RCP API versions that it can work with. This helps address
situations where RCP may be running a newer firmware (with higher
RCP API version) and host side is older, ensuring that version
checks can be performed correctly.

This commit introduces a new RCP-specific spinel property
`SPINEL_PROP_RCP_MIN_HOST_API_VERSION`. This new property is
available when RCP indicates that it has the newly added capability
`SPINEL_CAP_RCP_MIN_HOST_API_VERSION`. This is used on host side to
determine if we can get this property from RCP.

With addition of this new property, the `RadioSpinel` version check
code is changed to get the min version from RCP itself and then check
on the host side that its version is within the supported range.
2023-01-09 09:47:38 -08:00
Abtin Keshavarzian fd9f3237eb [toranj] add cli-based test-cases (#8599)
This commit updates cli-based `toranj` test framework and adds new
test-cases using this framework. The new test-cases re-implement all
the current ncp/wpantund based ones that cover OpenThread core
behavior (including the multi-radio and trel test-cases). Some of
the tests are enhanced (e.g. adding new checks) and some related
tests are combined into a single script.

This commit also updates the `toranj` CI GitHub workflow to use the
new cli-based model for multi-radio and trel (removing the ncp
based versions).
2023-01-05 22:49:06 -08:00
Abtin Keshavarzian ec494348f8 [netdata] use LeaderBase::FindNextMatchingPrefixTlv() (#8616)
This commit contains smaller changes in `NetworkData::Leader`
class:
- Use `FindNextMatchingPrefixTlv()` in methods to iterate over
  Prefix TLVs matching a given address.
- Simplify `IsOnMesh()` to iterate over Border Router sub-TLVs.
- Rename local variables to include `tlv` if they are a TLV.
2023-01-05 16:47:03 -08:00
Abtin Keshavarzian b64fab65cc [ip6] simplify SelectSourceAddress() (#8615)
This commit updates `Ip6::SelectSourceAddress()`. A new version of
is added which as its input gets a destination `Ip6::Address`
instead of an `Ip6::MessageInfo`, and returns the selected source
address as an `Ip6::Address *`. This helps simplify its use (no need
to create or pass `MessageInfo` instances). This commit also moves
the implementation of `otIp6SelectSourceAddress()` from `ip6_api.cpp`
to `Ip6` class adding a version of `SelectSourceAddress()` which
updates a passed-in `MessageInfo`directly.
2023-01-05 16:44:39 -08:00
Zhanglong Xia 28b40106b1 [posix] add posix config file configuration (#8612)
The ot-br-posix uses the posix platform's config file as its config
file. So the ot-br-posix can't set different configurations with posix
platform via the config file. This commit adds a config macro
`OPENTHREAD_POSIX_CONFIG_FILE` for ot-br-posix to specify a config
file to overwrite the posix platform's configurations.
2023-01-05 11:34:23 -08:00
Abtin Keshavarzian 6bb5eb50d0 [cli] new command to enable/disable discovery request callback (#8579)
This commit add `discover reqcallback {enable/disable}` CLI command
which registers callback to output whenever device gets a "MLE
Discovery Request". This command allows the callback to be explicitly
set when needed and avoid having it be enabled by default (since the
extra output from this callback can be treated as unexpected result by
tests that parse the CLI output).
2023-01-03 21:14:36 -08:00
Abtin Keshavarzian 3886436e46 [mle] define constants (C++ style) for OT configs used in MLE (#8602) 2023-01-03 20:56:22 -08:00
Abtin Keshavarzian e7493499ee [notifier] update to use Callback<HandlerType> (#8611)
This commit updates `Notifier` class to use the recently added
`Callback<HandlerType>` for the external callbacks.
2023-01-03 20:42:37 -08:00
Abtin Keshavarzian beb8a9040b [mle] add helper RxInfo::IsNeighborStateValid() (#8610)
This commit adds a new helper method in `RxInfo` to check whether or
not the `mNeighbor` field (the neighbor from which message was
received) is non-null and in valid state.
2023-01-03 17:09:53 -08:00
Jeff Bumgardner 41275372d3 [docs] fix typo in comment (#8609) 2023-01-03 17:08:15 -08:00
Abtin Keshavarzian cde7fd02c7 [mle] use DUA address directly in AppendAddressRegistrationTlv() (#8608)
This commit skips creating a local copy of DUA address and directly
uses `Get<DuaManager>().GetDomainUnicastAddress()` which will be fully
inlined.
2023-01-03 17:07:08 -08:00
dependabot[bot] 13a0df858c github-actions: bump github/codeql-action from 2.1.36 to 2.1.37 (#8600)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.36 to 2.1.37.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2.1.36...959cbb7472c4d4ad70cdfe6f4976053fe48ab394)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-02 22:29:09 -08:00
Abtin Keshavarzian f2c02dfd18 [mle] update GetPathCost() calculation to handle child dest (#8586)
This commit updates `GetPathCost()` method to handle the cases where
the destination RLOC16 is the device itself or if it is the child of
the device. It also handles when the device itself is acting as a
child (cost is calculated if destination is the parent).

This change addresses situation where `GetPathCost()` is used in
`NetworkData::CompareRouteEntries()` to select between BRs (e.g.,
multiple BRs providing the same off-mesh route prefix) ensuring a
direct child BR is preferred over other routers that are multiple
hops away.
2022-12-30 13:55:37 -08:00
hastigondaliya 23135aa90d [tcplp] TCP support on 15.4 (#8590) (#8593)
This commit is fix to avoid dual processing on single TCP packet,
added fix which restricts TCP packet to pass from opentghread
stack. These changes are applicable only when openthread TCP stack is
used and it is implemented under feature flag -
OPENTHREAD_CONFIG_TCP_ENABLE
2022-12-29 21:03:00 -08:00
Abtin Keshavarzian 25c6e0ec89 [nat64] fix message leak when NAT64 translator is enabled (#8592)
This commit fixes a potential message leak when NAT64 translator
feature is enabled in `Ip6::ProcessReceiveCallback()` where a cloned
copy of message is not freed if `TranslateFromIp6()` returns an
error or if `mReceiveIp4DatagramCallback` is not set.

This commit updates how we track and free the message in this method
(to help simplify the code and avoid similar situations). Variable
`message` points to the `Message` instance we own in this method. If
we can take ownership of `aMessage`, we use it as `message`.
Otherwise, we may create a clone of it. `message` will be set to
`nullptr` if the message ownership is transferred to an invoked
callback. At the end of this method we free `message` if it is not
`nullptr` (indicating it was not passed to a callback.
2022-12-29 17:16:33 -08:00
Abtin Keshavarzian 3aab651adc [network-data] ensure ExternalRouteLookup() picks longest match (#8582)
This commit updates the `ExternalRouteLookup()` to ensure we pick
the longest match before checking the route preference.
2022-12-28 17:09:30 -08:00
dependabot[bot] 60700b1562 github-actions: bump ossf/scorecard-action from 2.1.0 to 2.1.2 (#8585)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.1.0 to 2.1.2.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/937ffa90d79c7d720498178154ad4c7ba1e4ad8c...e38b1902ae4f44df626f11ba0734b14fb91f8f86)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-28 17:05:33 -08:00
Abtin Keshavarzian 19e18753c1 [routing-manager] add feature to skip NS probe with router on same device (#8563)
This commit adds a new behavior in `RoutingManager` to skip performing
NS probe with a router with an address belonging to device infra
interface itself. This addresses the situation where platform may not
be be able to receive and pass the NA message responses from device
itself.
2022-12-22 19:23:51 -08:00
Sam Kumar 9bb00f7e2d [tcplp] fix code scanning alerts relating to integer overflow in multiplication (#8578) 2022-12-22 17:11:10 -08:00
Abtin Keshavarzian db0670e033 [routing-manager] determine RIO preference based on current role (#8574)
This commit updates how BR determines the preference to use when
advertising Route Info Options (RIO) in emitted Router Advertisement
(RA) messages.

User can explicitly set the preference by calling OpenThread API
`otBorderRoutingSetRouteInfoOptionPreference()`.

But if not set or the previously set value is cleared by user,
RIO preference is determined based on device's current role:
- Medium preference when device is in router/leader role,
- Low preference when in child role.

If a role change causes RIO preference to change, BR schedules
to send a new RA using the updated RIO preference.
2022-12-22 14:55:52 -08:00
Abtin Keshavarzian fcc9c7b70a [cli] add new command neighbor linkquality (#8508)
This commit adds a new CLI command `neighbor linkqulaity` which prints
the collected link quality info (such as frame error rate, message
error rate, average/last RSSI) for all neighbors.
2022-12-22 14:55:29 -08:00
Abtin Keshavarzian 289d24e06e [router-table] signal if router is removed from UpdateRouterIdSet() (#8573)
This commit updates the `RouterTable::RemoveRouter()` to check
if `Router` being removed is a neighbor and signal its removal.
This ensures that we correctly signal neighboring router removal
from a call to either `UpdateRouterIdSet()` or `Release(aRouterId)`.
2022-12-22 10:41:08 -08:00
Abtin Keshavarzian ddde5fa5d6 [mesh-forwarder] use constant for hopsLeft in lowpan MeshHeader (#8569)
This commit updates how we set the `hopsLeft` when preparing a lowpan
`MeshHeader` frame so to use a constant max value. The max hops lefts
value is determined based on `kMaxRouteCost`(estimate on max hops
between routers within Thread mesh) and additional guard increment
(e.g., adding for two for source or destination being child and
require one more hop).

This change replaces the previous model where number of hops was
predicted on source using the routing cost towards the destination.
While the cost can be a good estimate for number of hops, it may not
necessarily be correct, as the source's view of route cost may be
less than what its neighbor and next hops on the path currently have
(e.g., sender can have stale information).
2022-12-22 10:27:40 -08:00
Piotr Koziar 98e7c35da7 [link-metrics] fix build flags for Link Metrics Initiator (#8568)
This commit fixes the placement of the preprocessor directive to avoid
linking errors.
2022-12-21 23:43:07 -08:00
whd 9e0f4ae619 [routing-manager] GetFavoredOmrPrefix should return an error when Routing Manager is not running (#8565) 2022-12-21 21:14:15 -08:00
Abtin Keshavarzian 54acf042b9 [test] update toranj-cli logging to use log to file model (#8547)
This commit updates `toranj-cli` to use the simulation platforms "log
to file" feature and CLI feature to emit CLI input/output to log. This
helps simplify the log collection during testing and decouple it from
parsing/processing the CLI output while performing the test.
2022-12-21 20:52:43 -08:00
Abtin Keshavarzian c3b73283ef [common] add Callback<HandlerType> class (#8560)
This commit adds a new class `Callback<HandlerType>` which represents
a callback as a function pointer handler and a `void *` context pair.
The context is passed as one of the arguments to the function pointer
handler when the callback is invoked.

The `Callback` provides two specializations based on the position of
the context argument in the function pointer, i.e., whether it is
passed as the first argument or as the last argument. The
`Callback<HandlerType>` class automatically determines this at
compile-time based on the given `HandlerType` and passes the context
properly from `Invoke()` method.

The `Callback` class is used by OT core modules to simplify how
callbacks are defined and used.
2022-12-21 20:51:39 -08:00
Song GUO 4c70cbb162 [nat64] NAT64 translator should be active only when local prefix is published (#8558)
If an infrastructure-provided NAT64 prefix is present, we should
bypass the NAT64 translator to let the border router forward the
packet to the infra NAT64 service.
2022-12-21 17:52:00 -08:00
David Smith 438fb78720 [cli] fix incorrect mask "channel manager" CLI output (#8571) 2022-12-21 17:44:53 -08:00
Jonathan Hui 8e09b9f4d1 [github-actions] disable harden-runner in OTBR workflow (#8572)
The `harden-runner` action causes the OTBR workflow jobs to hang for
some reason. Disable until we are able to resolve the issue.
2022-12-21 16:29:22 -08:00
Abtin Keshavarzian e167a1f071 [core] use kThreadVersion1pX constants (#8562) 2022-12-21 11:36:38 -08:00
Abtin Keshavarzian 052fccbed8 [link-quality] move CostForLinkQuality() to link_quality.hpp (#8561)
This commit renames and moves the function which coverts a given
`LinkQuality` value to a link cost to `link_quality` source files.
2022-12-21 10:19:17 -08:00
Abtin Keshavarzian 11a4a70959 [simul-plat] new option to write logs to a given file (#8516)
This commit adds a new option in simulation platform to allow us to
specify a file name to write the logs into. This is applicable when
`LOG_OUTPUT` is set to `PLATFORM_DEFINED`. The filename can be
specified by `-l <name>` or `--log-file=<name>` options. If no log
file is provided then logs are emitted to syslog.
2022-12-21 10:16:44 -08:00
Zhanglong Xia 8b59f4d31e [posix] add power calibration support (#8293)
The actual output power of the Thread device may be determined by both
the Thread radio chip and the FEM. Consider the output power error of
the Thread radio chip and the gain error of the FEM, the actual output
power is inconsistent with the expected output power.  To guarantee
that the actual output power is accurate and meet the regulatory
requirements, the output power should be calibrated in the factory if
the output power is not accurate.

This commit contains the following changes:

- Adds a power calibration implementation
- Adds a config file to configure the target power for different
  countries
- Adds a tool for the factory to persist the power calibration data
2022-12-21 10:15:48 -08:00
Maciej Baczmański 9af0bfa60e [diag] modify gpio diag functions description (#8538)
This commit modifies descriptions of diag gpio functions to better
describe returned errors.
2022-12-20 11:14:20 -08:00
Abtin Keshavarzian ddc1c7c8b1 [netif] add helper to signal fixed multicast address changes (#8559)
This commit adds a private method `SignalMulticastAddressChange()`
which signals changes to fixes multicast addresses.
2022-12-20 09:27:49 -08:00
Thomas 1641eced0d [spinel] remove incorrect static_cast (#8512)
This should not be cast to an unsigned integer. If the
mRadioTimeOffset is negative, the resulting time instance is incorrect
and breaks e.g. CSL over RCP.
2022-12-19 14:50:54 -08:00
Abtin Keshavarzian 58c9ca84ff [pretty] combine strings in node.py (#8550) 2022-12-19 14:37:30 -08:00
David Smith 6a3ed83037 [docs] SRP Service Clarification (#8541)
Adding some clarification around the display of TXT records in `srp
server service`.
2022-12-19 13:40:49 -08:00
Abtin Keshavarzian a720d1422c [mle] add ShouldDowngrade() method (#8543)
This commit adds `MleRouter::ShouldDowngrade()` which determines
whether all conditions are satisfied for the router to downgrade
after receiving info for a neighboring router. This method is then
used in `HandleAdvertisement()`. It effectively combines some of the
other methods into one.
2022-12-19 12:50:48 -08:00
Abtin Keshavarzian 8d3c8dc79d [mle] define constant for "Child ID Response" timeout (#8536)
This commit defines `kChildIdResponseTimeout` as a new constant
in `mle_types.hpp` which is used as maximum wait time to receive
a "Child ID Response" message from parent during attach. This
commit also removes the now unused `kMaxChildUpdateResponseTimeout`.
2022-12-19 12:22:41 -08:00
Abtin Keshavarzian a09e8813f9 [test] replace sprintf with snprintf in otPlatDiagProcess() (#8549)
It also removes stale comments in `ncp_hdlc.cp` about use of
`sprintf`.
2022-12-19 12:12:45 -08:00
Abtin Keshavarzian b366867de2 [mle] simplify IsSingleton() methods (#8548) 2022-12-19 12:11:25 -08:00
Abtin Keshavarzian 81487725b0 [cli] add config for log level for emitting cli input/output to logs (#8545)
This commit adds `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL` to
specify the log level to use when CLI input/output is emitted to logs
(`OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled).
2022-12-19 12:05:00 -08:00
Abtin Keshavarzian 84308ca504 [mle] remove redundant OPENTHREAD_FTD checks in mle_router.cpp (#8544)
This commit removes the `#if` checks for `OPENTHREAD_FTD` in
`MleRouter` method implementations as the entire `mle_router.cpp` is
covered with a `#if OPENTHREAD_FTD` check at the top of the file.
2022-12-19 12:03:43 -08:00
dependabot[bot] 26edd52e77 github-actions: bump ossf/scorecard-action from 2.0.6 to 2.1.0 (#8552)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.0.6 to 2.1.0.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/99c53751e09b9529366343771cc321ec74e9bd3d...937ffa90d79c7d720498178154ad4c7ba1e4ad8c)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-19 11:06:13 -08:00
Kangping 50ed30fcd9 [posix] make mInfraIfIndex non-static for posix::InfraIf (#8546)
We should not use static member fields given the `posix::InfraIf` is
already a singleton. Instead, let's make it consistent with the rest
of the fields which are all non-static.
2022-12-19 09:10:54 -08:00
Kangping a0d35548d9 [posix] add build option for posix infra if implementation (#8540)
On some platforms, we need to support the cases that:
1. The infrastructure interface can't be determined when the Thread
   daemon is started and we need to enable the Border Router features
   after the infra interface is available.
2. Some BR devices want to send/recv RAs in a coordinated way to be
   more efficient and consistent. For example, a BR which is also a
   Wi-Fi router may want to send/recv RAs by a single component.

This commit add a new `OPENTHREAD_POSIX_CONFIG_INFRA_IF_ENABLE` for
disabling the default posix infra if implementation so that posix
platforms can add their own version.
2022-12-19 08:37:52 -08:00
whd eff14060c1 [otci] fix parsing route flags (#8537)
A route in network data's output may have more than one flag. For
example, a NAT64 route can have `sn` as its flags. The previous
`__parse_routes` would crash when processing such a route.
2022-12-19 08:33:19 -08:00
Song GUO 117c8519ec [posix] add / delete route to NAT64 CIDR according to NAT64 translator state (#8505)
Adds a callback for platform getting adding / removing the NAT64 route
when NAT64 translator is enabled / disabled.

The cases of adding / removing routes to NAT64 CIDR:

- NAT64 inactive -> active:
  - interface down: noop
  - interface up: add route
- NAT64 active -> inactive:
  - interface down: noop
  - interface up: delete route
- interface down -> up:
  - NAT64 enabled: add route
  - NAT64 disabled: noop
- interface up -> down:
  - Noop, kernel will delete all routes on the interface
2022-12-16 02:53:08 -08:00
Abtin Keshavarzian 0f3de13ca8 [mle] fix NeighborHasComparableConnectivity() (#8535)
This commit updates `NeighborHasComparableConnectivity()` method which
is used as one of conditions to decide whether the router needs to
downgrade to REED. This method check whether a given neighboring
router has as good or better-quality links to all our neighboring
routers with two-way link quality of two or better.

The previous implementation assumed that routers in `RouterTable`
would match the same set of routers and their order as in the
received `RouteTlv` from the peer router. This may not necessarily be
the case (particularly after #8483). This commit changes the
implementation so that we iterate over all Router IDs and directly
track the index of each allocated router ID in the received
`RouteTlv`.
2022-12-15 22:38:38 -08:00
parag-silabs f2ed78770e [rcp] fix transaction ID caching and guard max power table code (#8408)
- Separate out max power table related code.
- Cache the transaction ID for async response only if
  otLinkRawTransmit() succeeds.
2022-12-15 21:37:12 -08:00
Abtin Keshavarzian 8ec9ede47a [router-table] add documentation for {Get/Set}RouterIdRange() (#8532) 2022-12-15 20:49:01 -08:00
Abtin Keshavarzian 6e50af9b0e [toranj update build.sh to use cmake for CLI builds (#8529) 2022-12-15 20:47:58 -08:00
Abtin Keshavarzian 6ab41a7383 [cmake] add OT_15_4 option for RADIO_LINK_IEEE_802_15_4_ENABLE (#8529)
This commit adds new cmake option `OT_15_4` to enable 802.15. radio
link. It also adds additional `message(STATUS)` to output the common
`OT_APP_CLI/NCP/RCP` and `OT_FTD/MTD/RCP` options.
2022-12-15 20:47:58 -08:00
Abtin Keshavarzian 281732fa3d [mle] avoid multiple return in HasSmallNumberOfChildren() (#8534) 2022-12-15 16:41:38 -08:00
Jonathan Hui 6d87e1a28b [continuous-integration] remove LGTM.com (#8528) 2022-12-14 14:11:51 -08:00
whd 01f9e89ffb [posix] enable receiving Neighbor Advertisement on infra interface (#8521)
This commit enables receiving Neighbor Advertisements (NA) on the
infra link.

OTBR relies on receiving Neighbor Advertisement to check if a router
is active. Without receiving NA, OTBR may wrongly see a router as
inactive and remove the discovered prefixes from Network Data too
early, which breaks the border routing feature.
2022-12-14 13:28:17 -08:00
Abtin Keshavarzian 144d480ca9 [router-table] simplify tracking of routers and allocated IDs (#8483)
This commit simplifies how `RouterTable` tracks the allocated Router
IDs and the `Router` entries. A new class `RouterIdMap` is added
which tracks the currently allocated Router IDs. For allocated IDs,
it also tracks the index of the `Router` entry in `mRouters` array.
For unallocated IDs, it tracks the remaining reuse delay time in
seconds (using the same underlying `uint8_t` per Router ID). This new
class makes it easier to find a `Router` by its ID. With this change,
we no longer need to keep the `mRouters` array sorted based on Router
ID (this was used when populating `RouteTlv`).

This commit also changes the `mRouters` to use `Array<Router>` which
will then tracks its length and also simplify range-based `for`
iteration over `RouterTable` entries.
2022-12-13 23:07:45 -08:00
Song GUO 2db38b0335 [test] ensure NAT64 is enabled when running NAT64 tests (#8520)
We cannot ensure NAT64 is enabled when running tests, and calling an
extra nat64_set_enabled has no side-effects.
2022-12-13 12:50:07 -08:00
Jonathan Hui b02bdb9e3b [github-actions] set top-level permissions to read (#8518) 2022-12-12 16:18:44 -08:00
whd c5ee313500 [tests] verify the RA/RS fields in border routing counters (#8494) 2022-12-12 16:18:13 -08:00
Jonathan Hui 98e644d538 [github-actions] apply step-security updates (#8509) 2022-12-10 16:12:12 -08:00
Eduardo Montoya 768072a6e0 [crypto] remove legacy otCryptoEcdsaSign (#8514)
This API was introduced for convenience but it's not used anymore.
2022-12-10 08:02:47 -08:00
Abtin Keshavarzian d27316c3e9 [simul-plat] fix parsing of "enable-energy-scan" option (#8515) 2022-12-09 22:08:49 -08:00
Eduardo Montoya da5434bc8f [cli] document pskcref (#8511) 2022-12-09 22:07:01 -08:00
Eduardo Montoya 35f51e2b17 [crypto] move Pskc generation to platform API (#8468) 2022-12-09 22:05:06 -08:00
Jonathan Hui 507d1b7971 [github-actions] enable OSSF Scorecards supply-chain security analysis (#8506) 2022-12-08 21:32:29 -08:00
Abtin Keshavarzian 80da0397d1 [mle] remember current RLOC16 in a member variable (#8499)
This commit updates `Mle` to store the current RLOC16 in a member
variable `mRloc16` (in addition to setting it on `Mac` as device's
short address). This allows `Mle::GetRloc16()` to be defined as an
inline method instead of using `Get<Mac::Mac>().GetShortAddress()`.
2022-12-08 17:55:47 -08:00
whd c9f3d08843 [tests] verify that SRP services are removed when their host expires (#8493)
This commit adds a step in `test_srp_lease.py` to verify that SRP
services are removed when their host expires.
2022-12-08 17:28:39 -08:00
Abtin Keshavarzian 927ac66735 [mle] allow rx-on/off with no re-attach based on initial attach mode (#8498)
This commit adds a new variable `mInitiallyAttachedAsSleepy` which
tracks whether or not device was initially attached as a sleepy
child. This is then used to determine whether or not we need to
re-attach on mode changes between rx-on and sleepy (rx-off). If we
initially attach as sleepy, then rx-on/off mode changes are allowed
without re-attach (device sends "Child Update Request" to its parent
to update its mode). Otherwise mode transition from rx-on to sleepy
requires a re-attach.
2022-12-08 17:27:37 -08:00
Mason Tran f765e1fa30 [clang-tidy] add missing symlinks to bootstrap (#8507)
I needed to add these symlinks because `script/clang-tidy` couldn't
find these files.
2022-12-08 14:20:22 -08:00
Abtin Keshavarzian 99a615bec2 [clang-format] use AllowShortFunctionsOnASingleLine: All (#8502)
This commit updates `AllowShortFunctionsOnASingleLine` to `All`
from `InlineOnly`.
2022-12-08 09:34:05 -08:00
Jonathan Hui 48c0582e4e [shellcheck] fix SC2155 warning (#8490)
Declare and assign separately to avoid masking return values.
2022-12-07 16:23:20 -08:00
Jonathan Hui 864236cbf1 [clang-tidy] apply v14 changes (#8490) 2022-12-07 16:23:20 -08:00
Jonathan Hui 49c5736f70 [clang-tidy] update to v14 (#8490) 2022-12-07 16:23:20 -08:00
Jonathan Hui 9c467a23ae [clang-format] apply v14 changes (#8490) 2022-12-07 16:23:20 -08:00
Jonathan Hui 351298e85f [clang-format] update to v14 (#8490) 2022-12-07 16:23:20 -08:00
Jonathan Hui b9514bf025 [docs] add security policy (#8497) 2022-12-07 16:21:29 -08:00
Jonathan Hui 2bfbd6b3f5 [github-actions] add codeql workflow (#8355) 2022-12-07 14:20:28 -08:00
Abtin Keshavarzian 6f1631aeba [mle] re-attach on FTD/MTD mode changes or from rx-on to sleepy (#8484)
This commit updates behavior when device mode gets changed
so to re-attach on switching between MTD/FTD modes and also on
switching from rx-on to sleepy (rx-off) mode (when attached as a
child).

This commit also updates `test-027-child-mode-change.py` to match
the new behavior.
2022-12-07 11:11:45 -08:00
Zhangwx e609eef7cc [logging] fix print format using %lu for uint32_t variables (#8495) 2022-12-07 10:14:22 -08:00
Abtin Keshavarzian 27be812bad [mpl] use TimeTicker for aging mSeedSet entries (#8488)
This commit updates the `Ip6::Mpl` to use `TimeTicker` instead of
its own `Timer` to age the entries in its `mSeedSet`. This commit
also updates the default number of seed entries by 3 to use the
memory saved by using `TimeTicker`.
2022-12-06 16:04:57 -08:00
Zang MingJie e8b34a46a7 [cli] add platform command which returns current platform (#8444)
Sometime we need to identify which platform we are currently using,
especially in a test cases, where a unified interface is provided to
control devices, the test cases have no idea about current platform.
2022-12-06 13:23:55 -08:00
Abtin Keshavarzian 9950ccf2fa [mpl] smaller enhancements in Ip6::Mpl (#8475)
- Use MLE `GetMeshLocal16()` to check if seed ID can be elided
  (remove `mMatchingAddress).
- When processing MPL option if seed ID is elided, we ensure that
  sender's address is RLOC format and use the RLOC16 as seed ID.
- When preparing MPL option directly use device's RLOC16 as seed ID
  (removing `Mpl::Get/SetSeedId()` methods).
- Determine number of timer expirations (MPL retransmission) based
  on device's current role.
2022-12-06 12:40:10 -08:00
Abtin Keshavarzian 852bc76f48 [mpl] reset seed entry lifetime on rx/tx (#8482)
This commit updates `Mpl::UpdateSeedSet()` to reset the `SeedEntry`
lifetime to `kSeedEntryLifetime` if we rx/tx a message with same
ID and sequence. This ensures that the entry is kept in the array
while other routers are forwarding the same message.
2022-12-05 21:27:06 -08:00
Abtin Keshavarzian cf4e514d00 [netdata] ensure to update version on leader if there is any change (#8472)
This commit updates `RegisterNetdataData()` to ensure that versions
are updated if there is any change even if there is an error during
integration of new entries (e.g., running out of space in Network
Data, or failing to allocate new service ID).
2022-12-05 14:11:33 -08:00
Yi 2167fda5a8 [nat64] delete nat64_set_enabled() when starting BR in tests (#8476)
NAT64 is enabled by default.
2022-12-05 11:53:21 -08:00
Abtin Keshavarzian 27b43146a9 [mle] rename variables to indicate if they are a TLV (#8465) 2022-12-01 21:26:40 -08:00
Abtin Keshavarzian 0337ff3e7e [csl] ensure current window is not missed when preparing CSL frame (#8464)
This commit fixes how we determine the CSL timings when preparing a
frame for CSL transmission. When scheduling the next CSL, we use
`mCslFrameRequestAheadUs` time in `GetNextCslTransmissionDelay()`. We
basically schedule `Mac` to start the CSL tx operation a bit earlier
than the desired CSL tx time. In `HandleFrameRequest()` (when we are
preparing the frame to be sent) we should be already within
`mCslFrameRequestAheadUs` time from the tx time. So this commit changes
the code such that we invoke `GetNextCslTransmissionDelay()` with zero
`aAheadUs` interval when preparing the frame. This ensures that we do not
skip the current CSL window and move to the next.

This commit also adds a check in `HandleFrameRequest()` to ensure that
we did not miss the current CSL window. This situation can happen if
`Mac` happens to be busy with some other operation and therefore late
to start CSL tx and invoke `HandleFrameRequest()`. In such a case we
don't want to use delay tx time for next CSL window (which may be way
later) and instead we abort the current CSL tx operation by returning
a `nullptr` frame.
2022-12-01 21:00:17 -08:00
Abtin Keshavarzian 89e403815a [mle] update RouteTlv to check number of allocated IDs (#8463)
This commit contains smaller enhancements in `RouteTlv`:

- `RouteTlv::IsValid()` checks that number of allocated IDs in
  the Router ID Mask is less than max number of routers.
- It also checks that the TLV contains correct number of Route
  Data entries matching the number of allocated router IDs.
- A new method `SetRouteData()` is added to set all the
  data fields (link quality in/out and route cost) for a given
  router index.
- These changes help ensure that messages containing invalid
  `RouteTlv` are rejected (avoid situation where we may have
  more allocated router IDs than max routers).
2022-12-01 19:45:31 -08:00
whd 87284f22eb [netdata] increase kInfoStringSize (#8454) 2022-11-29 19:43:18 -08:00
Jonathan Hui 0759de4fc5 [dependabot] update commit message prefix (#8457) 2022-11-29 10:45:21 -08:00
Jonathan Hui e61e64d2b7 [github-actions] exclude dependabot branches (#8456) 2022-11-29 10:45:03 -08:00
Eduardo Montoya 45c2cb4332 [indirect-sender] reset CSL Tx attempts in DataPollHandler (#8455)
Fix an issue in which a CSL Transmitter would start to send malformed
frames to the radio in the ocassion of a data poll arriving while a
delayed CSL transmission was already scheduled.

Notice that `CslTxScheduler::HandleSentFrame` is reseting both CSL Tx
attempts and Indirect Tx attempts, so it makes sense to do the same
in `DataPollHandler::HandleSentFrame`.
2022-11-29 10:19:14 -08:00
andrei-menzopol 1b88b045d0 [logging] fix format strings (#8446)
This commit fixes the format string in logging functions.

When openthread is included in other projects that use the -Werror
option in their builds, such as Matter, these format string errors
appear. In this case, it can be seen in radio.h that the structure
members are uint32_t but printed with %u.

The size of types depends on the target, there needs to be a casing.
2022-11-29 08:29:52 -08:00
whd 746557d52c [build] fix LOCAL_EXPORT_CFLAGS (#8453)
`LOCAL_EXPORT_CFLAGS` is exporting `OPENTHREAD_PROJECT_CFLAGS` which
contains quotes. This sometimes can cause compile errors due to
limitation of Android build system.

Also, `ot-cli` is repeating the flags in `LOCAL_CFLAGS`, which can
cause macro redefinition error. Since `ot-cli` depends on `ot-core`,
it already gets the flags from `LOCAL_EXPORT_CFLAGS`.
2022-11-28 21:14:06 -08:00
Abtin Keshavarzian d2e1c1e14d [router-table] move FillRouteTlv() to RouterTable (#8437)
This commit moves `FillRouteTlv()` method to `RouterTable` class.
2022-11-28 21:12:21 -08:00
Abtin Keshavarzian 43a6430083 [router-table] add new helper methods FindNextHopOf() and renames (#8437)
This commit contains smaller enhancements in `RouterTable` class:

- New method `FindNextHopOf()` is added to find the next hop of a
  given router.
- Methods which find router are renamed: `FindRouterById()` to search
  for a given Router ID, `FindRouterByRloc16()` to search for a given
  RLOC16.
- The methods which find a neighbor router are declared as `private`
  and only used by `friend` class `NeighborTable`. Other modules use
  `NeighborTable` methods to find neighbors.
2022-11-28 21:12:21 -08:00
dependabot[bot] d88ea9a463 github-actions: bump actions/upload-artifact from 1 to 3 (#8448)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 1 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-28 12:13:45 -08:00
dependabot[bot] 25d8f54d56 github-actions: bump docker/setup-buildx-action from 1 to 2 (#8447)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-28 12:13:09 -08:00
jinran-google e66c21c3da [api] include Thread version in neighbor info (#8435) 2022-11-23 21:34:13 -08:00
Abtin Keshavarzian eeb6ab0c8e [routing-manager] ensure local prefix is changed on xpanid change (#8436)
This commit updates `RoutingManager` to check if a change to xpanid
does impact the generated local on-link prefix. This can address two
situations: (1) when BR is started before Thread/MLE operation where
we can get a signal that xpanid is changed on MLE start (without it
actually changing), (2) if the xpanid does change but since not all
the xpanid bytes are used in the derivation of the local prefix, it
can remain as before.

This commit also updates the unit test to start the BR early (along
with MLE operation) under the `TestSavedOnLinkPrefixes()` case.
2022-11-22 22:04:55 -08:00
Song GUO b468a25a61 [nat64] use dbus API for NAT64 tests (#8392) 2022-11-22 21:39:11 -08:00
Abtin Keshavarzian afcc48edde [router-table] remove duplicate method (#8434)
This commit removes `RouterTable::GetActiveLinkCount()` and uses
`GetNeighborCount()` instead (which does the same).
2022-11-22 18:21:13 -08:00
Abtin Keshavarzian 2b579767ad [test] test_routing_manager to check duplicate PIO/RIO prefixes (#8431)
This commit updates the `RoutingManager` unit test to check that
there are no duplicate PIO/RIO prefixes in the emitted RA message.

It also updates the `TestSavedOnLinkPrefixes()` to check behavior
after device resets/restarts while it was advertising its local
on-link prefix or deprecating it.
2022-11-22 18:20:31 -08:00
Abtin Keshavarzian c5af37fbc7 [router-table] fix router next hop change on Release(aRouterId) (#8433) 2022-11-22 17:54:57 -08:00
Abtin Keshavarzian 4e44471431 [meshcop] update processing of UDP Encapsulation TLV (#8427)
This commit updates how UDP Encapsulation TLV is processed. In
particular, when handling a received TMF `kUriProxyTx` message
containing this TLV, we allow the TLV to be extended or not. This is
aligned with the Thread specification for this TLV. When appending
this TLV in `kUriProxyRx` TMF message, we continue to use Extended
TLV so to keep the behavior same as before.
2022-11-22 13:12:52 -08:00
Abtin Keshavarzian b102e4172c [tlv] add private helper methods to parse and find TLVs in a message (#8421)
This commit adds new private type `ParsedInfo` in `Tlv` class
which contains parsed TLV info such as TLV type, length, size,
value offset. This class provides `ParseFrom()` and `FindIn()`
methods to parse or find a TLV from a message.

This commit also adds a unit test `test_tlv` to validate the TLV
methods.
2022-11-22 12:52:21 -08:00
whd 9f702782bd [telemetry] implement RA/RS counters (#8416) 2022-11-22 09:23:58 -08:00
dependabot[bot] a8367287a5 github-actions: bump actions/download-artifact from 2 to 3 (#8426)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 22:44:48 -08:00
dependabot[bot] 49cf1e1dc2 github-actions: bump docker/login-action from 1 to 2 (#8425)
Bumps [docker/login-action](https://github.com/docker/login-action) from 1 to 2.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v1...v2)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 22:44:28 -08:00
dependabot[bot] d3b3a0b5ef github-actions: bump actions/setup-python from 1 to 4 (#8424)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 1 to 4.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v1...v4)

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

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 22:44:07 -08:00
dependabot[bot] c8ff3ba445 github-actions: bump codecov/codecov-action from 2 to 3 (#8423)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 22:43:47 -08:00
dependabot[bot] 233b589cdb github-actions: bump actions/setup-go from 1 to 3 (#8422)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 1 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v1...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-21 22:43:21 -08:00
Ewout ter Hoeven bf33e2b4bc [github-actions] add Dependabot configuration for GitHub Actions updates (#8418)
Add a Dependabot configuration that checks once a week if the GitHub
Actions are still using the latest version. If not, it opens a PR to
update them.

It will actually open few PRs, since only major versions are specified
(like v3), so only on a major release (like v4) it will update and
open a PR. But it helps actively keep GitHub Actions workflows up to
date and secure.
2022-11-21 19:22:55 -08:00
Zhanglong Xia 5e9c7d914d [spinel] update the updating/adding RCP spinel property guideline (#7937)
When adding a new spinel property or updating the existing spinel
property, it may cause the host can't work with the old RCP. The
host can be updated independently on some of our products. If the
compatibility issue happens, it causes the host dies after the
host is updated.

To reduce the compatibility issues between the host and RCP, this
commit updates the guideline of updating/adding RCP spinel properties.
2022-11-21 08:52:56 -08:00
Abtin Keshavarzian faeea3d2b9 [tlv] helper methods to read/find/append TLVs with UTF8 string value (#8417)
This commit adds new methods in `Tlv` to read, find, or append simple
TLVs with a UTF8 string value. `StringTlvInfo<Type, kMaxStringLen>`
can be used to define constants and types for such TLVs. This helps
simplify implementation of many such TLVs, e.g., Vendor Name TLV,
Provisioning URL TLV, Network Name TLV, etc.
2022-11-18 19:49:20 -08:00
Abtin Keshavarzian 411a20a62b [mle] use Tlv::FindTlvValueOffset() instead of FindTlvOffset() (#8413)
This commit updates `Mle` modules to use `FindTlvValueOffset()`
instead of `FindTlvOffset()` when trying to find a variable length
TLV (e.g., Network Data TLV or Address Registration TLV). This helps
simplify the code (we avoid reading the TLV again and can directly
read and process the TLV's value).
2022-11-18 13:01:56 -08:00
Yakun Xu 564d667790 [doc] add doc for coex command (#8415) 2022-11-18 12:58:30 -08:00
Abtin Keshavarzian 4e83caf42d [commissioner] fix provisioning URL comparison (#8411)
This commit fixes the comparison of the received Provisioning URL
string with the commissioner's one when handling Joiner Finalize TMF
message.
2022-11-17 19:45:37 -08:00
Jonathan Hui 439a5ba234 [docker] update ubuntu to 22.04 (#8405) 2022-11-17 09:05:47 -08:00
Abtin Keshavarzian 16c6b04537 [meshcop] simplify StateTlv (#8404)
This commit simplifies `StateTlv` and updates the reading of TLV in
`DatasetManager::HandleMgmtSetResponse()` (which could previously
allow a TLV with empty value).
2022-11-17 09:05:27 -08:00
canisLupus1313 593c2b0a8d [bootstrap] remove brew from apt package installations (#8399)
This commit chages incorrect pkg manager tool used in
`install_packages_pretty_format` from brew to apt-get.
2022-11-17 08:52:22 -08:00
Abtin Keshavarzian 4a7c447f6c [cli] update OutputSpaces() to use literal format string (#8394)
This commit updates `OutputSpaces()` to use literal format string.
2022-11-16 20:28:43 -08:00
Jonathan Hui 2caab0c331 [spinel] fix printf style output (#8401) 2022-11-16 13:02:46 -08:00
Jonathan Hui dadd60f88a [github-actions] fix macos build checks (#8397)
- install `ninja` binary directly
- use pre-installed clang on macos
2022-11-15 09:14:13 -08:00
Zhanglong Xia 3e138d3f5d [diag] add gpio mode commands (#8391)
This commit adds diag commands for setting the GPIO mode to resolve
the conflict https://github.com/openthread/openthread/issues/8362.
2022-11-12 04:51:24 +01:00
whd caec27dcf1 [tests] add tests for Border Routing Counters (#8341)
This commit adds tests for verifying the functionality of the D-BUS
API `GetBorderRoutingCounters`.
2022-11-12 04:42:58 +01:00
whd 902ce1ca7f [build] add build option OT_BORDER_ROUTING_COUNTERS (#8389) 2022-11-10 09:15:43 +01:00
Zhanglong Xia 3d4f617a00 [spinel] log radio spinel frame (#8342) 2022-11-09 11:40:14 +01:00
whd 8045c829d7 [cli] add commands for Border Routing counters (#8372) 2022-11-09 11:31:11 +01:00
Abtin Keshavarzian 537002352f [netdata] update Notifier to prepare and send SVR_DATA.ntf msg (#8376)
This class moves all the related code for preparing and sending
`kUriServerData` message to `NetworkData::Notifier`. In particular,
`RemoveStaleChildEntries()` and `UpdateInconsistentData()` are moved
to the `Notifier` class.
2022-11-08 19:14:46 +01:00
Abtin Keshavarzian f4d7f1a719 [netdata] add helper method to compare two BR entries (#8375)
This commit adds `CompareRouteEntries()` which performs a three-way
comparison between two network data BR route entries:
- Entry with higher preference is selected first.
- If the same preference, prefer BR that is this device itself.
- If all same, prefer the one with lower mesh path cost.
2022-11-08 18:29:53 +01:00
Jonathan Hui 8d39d9c075 [tests] fix comparison width warning (#8380) 2022-11-08 16:33:50 +01:00
Abtin Keshavarzian fd23fb1add [netdata] simplify RouteLookup() methods (#8374)
This commit updates the `RouteLookup()` methods in `NetworkData`
and `ThreadNetif`:
- Removes the unused `aPrefixMatchLength` parameter.
- Requires `aRloc` to be a reference instead of a pointer.
2022-11-08 11:49:31 +01:00
Jonathan Hui 73c48595b7 [cli] fix printf style output (#8377)
When `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
2022-11-08 11:15:22 +01:00
Zhanglong Xia 91fa1f455a [posix] use __GLIBC__ instead of __linux__ in backtrace (#8373)
he `execinfo.h` is a glibc specific header, and the glibc doesn't
exist under openwrt. It causes the compile errors under openwrt in
ot-br-posix. This commit uses __GLIBC__ instead of __linux__ to avoid
the compile errors when the OS doesn't contain the glibc.
2022-11-07 22:23:24 +01:00
Abtin Keshavarzian 6b03d55cc4 [cli] add compile-time printf style arg check in CLI (#8369)
This commit adds compile-time check of format string to all CLI
`Output` methods. It also updates CLI module to  make arg string
formats consistent. In particular we use `'%lu` for `uint32_t`
arguments and they are explicitly cast to `unsigned long` using
`ToUlong()`.
2022-11-07 22:05:55 +01:00
Abtin Keshavarzian 4e52ffb54e [net-diag] simplify processing of TLVs, allow extended TLV (#8368)
This commit updates `NetworkDiagnostic` class's generation and
processing of TLVs. When appending list based TLVs (IPv6 Address List
TLV or Child Table TLV) depending on the number of entries we use
regular or extended TLV. When processing the message and reading the
TLVs, this commit updates the code to handle extended TLVs as well.

This commit changes the behavior of `GetNextDiagTlv()`. The
`otNetworkDiagTlv` data structure defines limited-size arrays for
IPv6 address list and child table. When processing a received message
if the number of entries is larger than the array size, the first set
entries (as many as fits in the array) are read and the rest are
ignored. This changes the existing behavior which returned a
`kErrorPrase` error in such a case.
2022-11-07 09:41:46 +01:00
Abtin Keshavarzian 727002e9fe [cli] add OutputUint64() for 64-bit integer value in decimal format (#8354)
This commit also adds a helper `Uint64ToString()` method to convert a
`uint64_t` to decimal format string. The new methods allow us to
output `uint64_t` values without needing to cast to `unsigned long
long` and/or use of `%llu` (which may not be provided by certain
embedded libraries).
2022-11-07 09:35:27 +01:00
Jonathan Hui ba826ffb2a [clang-tidy] add readability-redundant-control-flow (#8365) 2022-11-04 16:34:37 -07:00
Jonathan Hui 8e020b4018 [clang-tidy] add modernize-loop-convert (#8361) 2022-11-04 10:36:42 -07:00
Abtin Keshavarzian 7ec7620975 [tlv] ReadTlvValue() to handle regular or extended TLVs (#8364)
This commit changes `ReadTlv()` methods so that they can be used
independent of whether the read TLV is an Extended TLV or not. This
makes them similar to `FindTlv()` methods.
2022-11-04 08:53:52 -07:00
Abtin Keshavarzian 13223b0104 [net-diag] add a common SendDiagnosticCommand() method (#8357)
This commit adds a common `SendDiagnosticCommand()` which is then
used for sending `DiagnosticGet` or `DiagnosticReset` commands.
2022-11-04 08:51:04 -07:00
Zhanglong Xia d92520c3e2 [posix] add backtrace support (#8358)
This commit logs the backtrace when the Thread crashes on the Linux
and Android.
2022-11-04 08:48:03 -07:00
whd df20f3d91a [telemetry] border routing packet counters (#8280)
This commit introduces `otBorderRoutingCounters` which contains the
number of packets and bytes forwarded via border routing.

The counters have 4 categories: inbound unicast, inbound multicast,
outbound unicast, outbound multicast.

I've verified this feature locally on a BR device by ping command in
following scenarios:
- A host pings an ED's OMR.
- An ED pings a host's onlink address.
- A host pings a multicast address which an ED subscribes to.
- An ED pings a multicast address which a host subscribes to.
2022-11-04 00:13:10 -07:00
andrei-menzopol a532ce6e57 [crypto] add ECDSA API (#8273)
- remove ecdsa tinycrypt implementation
- add crypto API, move default implementation in crypto_platform.c
- define crypto ecdsa structures and format
2022-11-03 09:40:51 -07:00
Abtin Keshavarzian f5367f6238 [log] add arg format check to otLog{Level}Plat() functions (#8356) 2022-11-02 22:45:05 -07:00
Abtin Keshavarzian d7de66671a [net-diag] reuse similar MLE TLV definitions (#8350)
This commit updates some of the `NetworkDiagnostic` TLV definitions
to reuse similar MLE TLVs (e.g. `LeaderDataTlv`). It also updates
the code to reuse helper methods to parse `Mle::DeviceMode` and
`Mle::LeaderData`.
2022-11-02 08:57:07 -07:00
Jinwon Kim c6179c24ed [netif] fix bug in print statement with no corresponding argument (#8353) 2022-11-02 00:16:53 -07:00
Abtin Keshavarzian ac11f66419 [log] add compile-time check for printf style arg check to log functions (#8339)
This commit adds compile-time check of format string to all log
functions and macros. It also updates different core modules to make
arg string formats consistent under different platforms. In particular
we use `'%lu` for `uint32_t` arguments and they are explicitly cast
to `unsigned long` using `ToUlong()`.
2022-11-01 22:45:16 -07:00
Abtin Keshavarzian f5acfb2dac [cli] update CLI Output class (#8343)
This commit updates the `Cli::Output` class and the related types. A
new type `OutputImplementer` is added which provides the basic output
functionality, i.e., method `OutputV()`. `Output` class requires a
reference to an `OutputImplementer` which it then uses to provide all
the different `Output{}()` method flavors. The new model allows all
CLI sub-modules to directly inherit `Output` class while reusing a
single and common underlying `OutputImplementer` provided by the
`Cli::Interpreter`.
2022-11-01 13:28:37 -07:00
Zhanglong Xia 11a24d111f [diag] add gpio diag command support (#8316) 2022-10-31 17:05:20 -07:00
Abtin Keshavarzian 1d1e5d16e0 [cli] enhance parsing of flags for route commands (#8340)
This commit enhances `ParseRoute()` method allowing flags to be
specified in one arg (sequence of char indicating different flags) or
potentially over different args. This commit also allows `-` to be
used in `route` or `prefix` commands to indicate empty flag.
2022-10-28 16:04:59 -07:00
Suvesh Pratapa 778e3b9ead [netif] fix bug in print statement (#8338) 2022-10-28 15:55:58 -07:00
Abtin Keshavarzian ca8799a4b8 [routing-manager] persist deprecating old prefixes in Settings (#8330)
This commit adds mechanism to save deprecating old on-link prefixes
in non-volatile `Settings`. With this, if the BR is restarted, it
will remember the old prefixes and keep deprecating them (advertising
them in emitted RA and publish them in Thread Network Data).

This commit also adds `TestSavedOnLinkPrefixes()` test case in
`test_routing_manager` to cover the behavior of the newly added
mechanism.
2022-10-27 15:12:59 -07:00
Jonathan Hui b9b9c19640 [network-data] do not process TMF messages if waiting for sync (#8332) 2022-10-27 02:08:56 -07:00
Abtin Keshavarzian 2a5a926952 [mle] log sending of "Link Accept and Request" (#8328)
This commit update `SendLinkAccept()` method so to log the message type
(whether we send "Link Accept and Request" or "Link Accept").
2022-10-27 02:08:36 -07:00
Abtin Keshavarzian d4d872c05c [test] increase wait time after ether re-enable (#8322)
This commit increases the wait time in `test_single_border_router`
after re-enabling `ether` link. It also changes the order of pings
in the test (first ping from host to Thread router and the opposite
direction).
2022-10-27 02:07:30 -07:00
Yaoxing Shan 2592e3433a [tcplp] fix call to tcplp_sys_accept_ready() (#8327)
aAddr should be the source address not the destination address.
2022-10-26 04:38:25 -07:00
Abtin Keshavarzian ed31bfefb6 [address-resolver] allow addr resolution using net data service (#8318)
This commit implements a new optimization in `AddressResolver`
allowing it to resolve on-mesh IPv6 addresses using info from Thread
Network Data DNS/SRP Service (Unicast Address) entries.

When determining EID-to-RLOC mapping in `Resolve()`, we first try to
match the EID against unicast addresses discovered from DNS/SRP
service entries. This is limited to entries where the address/port
info is encoded as part of server data. If a match is found the
associated RLOC16 of the BR which added the entry in Network Data
will be used (i.e., the `server16` field from Network data server
sub-TLV). This optimization is used on devices where MLE Mode
indicates they receive full Network Data and not the stable subset
(since stable subset will not provide RLOC16 info).

This commit adds a similar check in `UpdateSnoopedCacheEntry()` so
that the limited snoop cache entries are not unnecessarily used for
addresses which can be resolved using Network Data services.
2022-10-26 01:37:40 -07:00
Abtin Keshavarzian 53305d4762 [routing-manager] add Neighbor Solicit probe mechanism (#8090)
This commit adds a new mechanism in `RoutingManager` to periodically
check that discovered routers are still active and operational, so
that if the router providing the favored on-link prefix becomes
offline, we can detect it more quickly (instead of waiting for the
prefix lifetime to expire) and then the BR can start advertising its
own on-link prefix.

Receiving a Router or Neighbor Advertisement message from a router
indicates that it is active. After a timeout interval passes from the
last receive from a router we start sending Neighbor Solidification
(NS) probes to it. This timeout interval can be specified by newly
added build-time OT config parameter (default value is set to one
minute). If no response is received after multiple NS attempts, the
router is considered to be inactive and the discovered prefix entries
associated with the router are removed or deprecated.

This commit also updates the unit test for routing manager to validate
the behavior of the newly added mechanism.
2022-10-25 00:04:47 -07:00
Seth Rickard b7471733c5 [mac] add reserved value to source address parsing (#8326)
Fails packet parsing if the reserved value is found in the source
addressing field instead of marking the address as "none".
2022-10-24 15:07:34 -07:00
Zang MingJie e4bf2ffe34 [netif-posix] add an option to persistent interface (#8033) 2022-10-24 14:57:48 -07:00
Abtin Keshavarzian d1653a8edc [routing-manager] new mechanism for deprecating old on-link prefixes (#8315)
This commit updates how `OnLinkPrefixManager` retains and deprecates
old local on-link prefixes. Instead of remembering a single old
prefix, a list of old prefixes are remembered and the number of
entries in the list can be configured at build-time using an OT
config.

If the BR is stopped, the deprecating prefixes are still remembered
and the the expire timer keeps running. They are removed from the
list when they expire. If the BR is started again the deprecating old
prefixes are again included as PIO in the emitted RA and also
published in Network Data.

The changes in this commit also ensure we can correctly handle the
situation where the extended PAN ID is changed to a previous value
before the corresponding on-link prefix expires, i.e. when a
currently deprecating prefix becomes the current local on-link prefix
again.

This commit also updates the unit test case validating the behavior of
newly added mechanism under different situations.
2022-10-21 21:27:57 -07:00
Abtin Keshavarzian ed43da9110 [routing-manager] new mechanism for deprecating old on-link prefixes (#8315)
This commit updates how `OnLinkPrefixManager` retains and deprecates
old local on-link prefixes. Instead of remembering a single old
prefix, a list of old prefixes are remembered and the number of
entries in the list can be configured at build-time using an OT
config.

If the BR is stopped, the deprecating prefixes are still remembered
and the the expire timer keeps running. They are removed from the
list when they expire. If the BR is started again the deprecating old
prefixes are again included as PIO in the emitted RA and also
published in Network Data.

The changes in this commit also ensure we can correctly handle the
situation where the extended PAN ID is changed to a previous value
before the corresponding on-link prefix expires, i.e. when a
currently deprecating prefix becomes the current local on-link prefix
again.

This commit also updates the unit test case validating the behavior of
newly added mechanism under different situations.
2022-10-21 21:27:35 -07:00
Tobías Lifschitz 8c73c9747b [mle] add time tracking to mle roles (#8312)
A useful metric for a device is the amount of time it spends in each
mle role. This could help to identify connectivity issues on SED with
weak signal and frequent detaches by checking the time spent in
detached mode. It would also be useful to know the time spent in
leader state when having multiple FTDs frequently joining and
splitting in different partitions.

This information is not available from the role counters, since time
spent in each state is not related to the number of entries to that
state.

This commit adds mle counters to track time spent in each role, when
uptime feature is enabled (`OPENTHREAD_CONFIG_UPTIME_ENABLE=1`).
2022-10-21 21:26:41 -07:00
Abtin Keshavarzian c3bb95d5f4 [string] add compile-time check for printf style arg consistency (#8277)
This commit adds `OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK` macro in
`toolchain.h`. It specifies that a function or method takes `printf`
style args. It asks the compiler to check the args for consistency
with the passed-in format string.

The commit uses the new macro in `String::Append()` and its uses are
updated to ensure consistency between format string and the args.
2022-10-21 16:26:21 -07:00
Tom Rebbert acf44c45cd [mac] Bugfix: Messages without a source address handled incorrectly (#8321)
When a message is received that does not contain a source address (ex:
IEEE 802.15.4 Beacon Request) find neighbor should not be called to
attribute the message to a particular device in the network.

The bug was found in the following scenario:
* Network operating with REED devices.
* Other non-Thread IOT devices in the space periodically sending
  beacon requests.
* Note that the REED devices have unexpectedly low average RSSI values
  for their parents.

When the child processes the beacon request, it calls FindNeighbor(),
which defaults to returning the parent of the device if srcaddr is
none. The RSSI of the beacon request is then averaged into the value
for the device's parent.

Fix: Do not look up the neighbor if there is no source address in the
message, because there's no way to know who the message came from.
2022-10-21 13:27:52 -07:00
Yakun Xu ff259b845b [android] only set -std=c99 for mbedtls (#8310) 2022-10-21 13:02:18 -07:00
Tom Rebbert 488ee63b4c [coap] Bugfix: CoAP not sending 4.04 when URI handler is not found (#8297)
Update CoAP base handler to correctly detect when a handler is not
found and send a 4.04 response.

Prior to this change, the error code would be overridden in the case
where a URI handler was not found to kErrorNone. This meant that when
the exit code was reached, no 4.04 message was generated. This fixes
the logical flow to ensure the error message is sent on the link.
2022-10-20 19:24:05 -07:00
Jonathan Hui d8509e6254 [github-actions] update geekyeggo/delete-artifact to v2 (#8314) 2022-10-20 09:51:06 -07:00
Abtin Keshavarzian d805b5dd1c [routing-manager] add OnLinkPrefixManager (#8285)
This commit renames `LocalOnPreifx` class to `OnLinkPrefixManager` and
moves all the code related to managing of the on-link prefix to this
class, e.g., method `Evaluate()` to evaluate and make a decision
about on-link prefix (whether we need to advertise our local on-link
prefix or there is a favored discovered on-link prefix provided by
another router on infra link).
2022-10-19 15:49:59 -07:00
Jonathan Hui 3d5c4b41df [docs] fix build option table format (#8306) 2022-10-18 14:44:32 -07:00
Abtin Keshavarzian 68083d8a67 [srp-client] inform server on service remove even if not added yet (#8299)
This commit updates `Srp::Client` so that on `RemoveService()` we
always send an SRP Update message to server to remove the service even
if the service is not yet registered (from perspective of client).
2022-10-18 14:43:41 -07:00
Song GUO aae250af89 [nat64] add runtime switch for NAT64 prefix publisher and translator (#8194) 2022-10-18 14:42:25 -07:00
Simon Lin 77fd973a76 [multicast-forwarding] reduce warn logs (#8292) 2022-10-17 19:25:02 -07:00
Tom Rebbert 778fbfa82d [heap] move static heap construction to singleton accessor (#8242)
Move static heap construction to singleton accessor to avoid
non-trivial construction at global scope, which has an unpredictable
ordering.
2022-10-17 18:57:50 -07:00
parag-silabs c3bc9481e2 [cmake] disable OPENTHREAD_CONFIG_NCP_HDLC_ENABLE when OT_NCP_SPI is set (#8282) 2022-10-17 18:56:18 -07:00
Sarah 992f9c6374 [docs] Doxygen formatting updates (#8286)
For various reasons, we're not able to use `<` and `>` in our Doxygen
descriptions. I made some minor edits, LMKWYT. In the HTML, it renders
similar to this:

The IPv6 socket address string is formatted as [`address`]:`port`
where `address` is shown as 16 hex values separated by `:` and `port`
is the port number in decimal format, for example "[%x:%x:...:%x]:%u".
2022-10-17 11:09:10 -07:00
Sam Kumar d5333ca831 [cli-tcp] fix bug causing "accept" action for all incoming connections (#8291) 2022-10-17 09:10:47 -07:00
Sam Kumar 3d1bdf3317 [tcplp] fix bad memory access when refusing incoming TCP connection (#8291) 2022-10-17 09:10:47 -07:00
gavinmcgovern bdb9382976 [docs] resized Qorvo logo (#8279) 2022-10-14 11:07:41 -07:00
Jonathan Hui 05590e2dc8 [github-actions] migrate to actions/upload-artifact@v3 (#8278) 2022-10-14 08:47:48 -07:00
gavinmcgovern 9ebe41f16e [docs] who supports OT updates (#8263) 2022-10-13 11:38:44 -07:00
Abtin Keshavarzian f5e2a0f961 [routing-manager] adv local on-link prefix after added in net data (#8119)
This commit enhances `RoutingManager` so that when we decide to
advertise the local on-link prefix and publish it in Network Data as
an external route, we wait for it to be seen in the leader's Network
Data before including it in the emitted RA messages as PIO. If the
prefix is already present in Network Data (e.g., may have been added
by another BR on the same Thread mesh) we start advertising it
immediately. When publishing prefixes in Network Data, it may take a
short random time before the entry is registered with leader and the
updated Network Data is propagated to all Thread nodes. This change
delays the advertisement of the on-link prefix on the infra link side
till it is configured as an external route on the Thread side.
2022-10-13 09:15:17 -07:00
Jonathan Hui f92364c977 [dns-client] validate response timeout <= TimerMilli::kMaxDelay (#8275) 2022-10-13 08:37:22 -07:00
Abtin Keshavarzian f459d9e333 [core] remove OT_UNREACHABLE_CODE(break) (#8274)
This commit removes `OT_UNREACHABLE_CODE(break)` which is used
in `case` statements performing an `OT_ASSERT()` in a `switch` block.
If the `case` is the last one in the `switch` we can skip the `break`
and therefore we don't need to use `OT_UNREACHABLE_CODE()`.
2022-10-13 08:37:01 -07:00
Abtin Keshavarzian 16c927ea1c [routing-manager] enhance mechanism to publish/unpublish route prefixes (#8187)
This commit updates and enhances the mechanism in `RoutingManager`
to publish/unpublish external route prefixes in Thread Network Data.

Instead of each sub-component (e.g., `DiscoveredPrefixTable`,
`LocalOnLinkPrefix`, `Nat64PrefixManager`, ...) directly trying to
publish/unpublish its entries which can lead to conflicting requests
that then needs to be checked and handled by each component, this
commit adds a new method `EvaluatePublishingPrefix()`. This method
makes a collective decision by checking with different sub-components
to see whether or not each wants this prefix published and if so at
what preference level and flags.

This change help simplify the code and handling of conflicting
situations and edge cases (e.g., while deprecating current/old local
on-link prefix, other routers adding/removing same prefix as PIO or
RIO in their emitted RAs).
2022-10-12 15:13:16 -07:00
Sarah 23c01d7eaf [docs] CLI commands ifconfig - linkmetrics (#8253) 2022-10-12 14:34:45 -07:00
Abtin Keshavarzian 06bd4d6161 [link-metrics] update method finding neighbor to validate its version (#8271)
This commit renames and updates the `LinkMetrics::FindNeighbor()`
helper method which finds the neighbor for a given link-local address
for use in `LinkMetrics` class. This method now also validates that
the neighbor's Thread version is 1.2 or higher.
2022-10-12 14:17:24 -07:00
Yakun Xu 74cc79d7a2 [cmake-build] allow specify multiple targets (#8264)
This commit allows using OT_CMAKE_NINJA_TARGET to specify multiple
targets.
2022-10-12 13:09:04 -07:00
Jonathan Hui 3811b6529e [github-actions] migrate to actions/checkout@v3 (#8269) 2022-10-12 10:15:04 -07:00
Song GUO 43c66a3d5f [nat64] fix build issues related to NAT64 on POSIX (#8167)
The build might fail when using build systems other than cmake and
NAT64_TRANSLATOR is enabled.
- Reorder the functions in `src/posix/platform/netif.cpp`
- Define a default NAT64 CIDR
- Define `kNat64RoutePriority`
2022-10-11 22:47:50 -07:00
Abtin Keshavarzian 131e42c60f [cli] fix log filename command arg check (#8270) 2022-10-11 15:23:50 -07:00
Tom Rebbert 9c6b45c1dc [meshcop] support a zero-length network name for backwards compatibility (#8241)
Add a configuration option to support a zero-length network name
within the OT stack.
2022-10-11 15:22:57 -07:00
Abtin Keshavarzian 04feddc458 [netdata] update Publisher to reserve entries for RoutingManager (#8148)
This commit updates `NetworkData::Publisher` to reserve a set of
prefix entries for use by `RoutingManager` only. This allow us to
simplify how `RoutingManager` publishes route prefixes in Network
Data (assert on failure). In particular, this commit defines a new
enum `Requester` which specifies the requester (`kFromUser` or
`kFromRoutingManager`) associated with a published prefix. This is
used by methods `PublishExternalRoute()`/`PublishOnMeshPrefix()`.
When allocating new entries, we ensure that each requester is
limited to its maximum number of entries.
2022-10-11 12:57:33 -07:00
Abtin Keshavarzian ee83b1cb5d [backbone-router] simplify TMF URI resource handling (#8265)
This commit updates `BackboneTmfAgent` to handle TMF URI resources
(similar to the model used by `Tmf::Agent` added in #8233).
2022-10-11 09:11:20 -07:00
Jonathan Hui 76010bc9ad [docs] remove versioning note (#8266) 2022-10-11 08:31:43 -07:00
Eduardo Montoya f23eee42f8 [thci] fix setBbrDataset (#8261)
Cover the case when neither `MlrTimeout` or `ReRegDelay` are being
modified.
2022-10-11 08:31:08 -07:00
Abtin Keshavarzian 697c5e53a2 [border-agent] simplify ForwardToLeader() (#8260)
This commit updates `BorderAgent::ForwardToLeader()` to determine the
`petition` and `separate` boolean flags from the passed-in `aUri`.
2022-10-10 12:40:26 -07:00
Abtin Keshavarzian 13311256f6 [tmf] add SecureAgent and simplify URI resource processing (#8260)
This commit adds a new class `Tmf::SecureAgent` as a sub-class of
`Coap::CoapSecure`. It also simplifies the handling of TMF URI
resources by secure agent (similar model as in `Tmf::Agent` added
in #8233.
2022-10-10 12:40:26 -07:00
Jonathan Hui 09e06c6eff [dns-types] verify pointer refers to prior occurrence (#8262) 2022-10-10 11:45:39 -07:00
Abtin Keshavarzian e387505d4f [link-metrics] simplify handling of Type IDs (#8246)
This commit simplifies the handling of Type IDs in `LinkMetrics`
modules.
2022-10-10 10:54:19 -07:00
Abtin Keshavarzian 4a0d069ee8 [log] fix incorrect format strings (#8255) 2022-10-07 21:51:06 -07:00
Marek Porwisz b0266bc00e [ip6] fix packets not being forwarded outside of Thread (#8102)
Two changes made together broke fragmented packets handling: Some time
ago forwarding packets outside of thread was limited to 1280 bytes
Recently forwarding IP packet fragments was disabled.  This makes it
not forward packet fragments nor fully assembled packets.  According
to later change author this was to prevent packets from being handled
twice.

To fix this, forwarding of IP fragments was restored and instead
forwarding of reassembled frames was disabled regardless of the frame
size. This approach should save the need of fragmenting already
reassembled packets to fit into the
OPENTHREAD_CONFIG_IP6_MAX_DATAGRAM_LENGTH.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2022-10-07 17:50:39 -07:00
Abtin Keshavarzian 2b726ef29f [border-agent] fix logging of RelayTx URI (#8254) 2022-10-07 14:02:51 -07:00
Abtin Keshavarzian 812c36f658 [tmf] new model for handling TMF URI resources (#8233)
This commit updates and simplifies the handling of TMF URI resources.
The new model centralizes the processing and dispatching of URI
handlers in `Tmf::Agent`. It should help reduce memory (RAM and
code) use as well.

- A new enumeration `Uri` type is defined specifying all the TMF
  URIs along with functions to map between `Uri` and the related
  URI path string.
- We use binary search in a sorted table to match a path string
  (e.g., from a received CoAP message) to its corresponding URI.
- `Coap` class is updated to allow sub-classes to register an
   optional `ResourceHandler` to handle URI resources.
- `Tmf::Agent` uses the new `ResourceHandler` to process the TMF URI
  resources and invoke the related handlers on the proper module
  (e.g., passing `kUriAddressQuery` to `AddressResolver` module,
  `kUriActiveSet` to `MeshCoP::ActiveDatasetManager`, etc).
- The TMF handlers are defined as `HandleTmf<Uri>()` template method
  specializations which are defined on the proper module.
- Most URI handlers can be processed at any time but some perform
  additional checks, e.g., `kUriAddressSolicit` is passed to
  `Mle::MleRouter` which checks that device role is leader before
  processing the request.
2022-10-06 18:32:22 -07:00
Abtin Keshavarzian c4b6206f16 [srp-client] new feature to allow lease and key lease per service (#8211)
This commit add a new feature in `Srp::Client` to allow user to
specify the lease and/or key lease intervals explicitly per service.
The lease intervals in a service can be left unspecified(set to zero)
in which case the default lease intervals will be used.

In an SRP Update message, the lease info is included in additional
section in an Update Lease Option record. Therefore the lease values
are applicable to the entire message and all its records. If we have
services with different lease intervals, they need to be registered
in separate messages. This commit updates `Srp::Client` to implement
such a mechanism. When preparing an SRP message, we first determine
the lease and key lease intervals and ensure the services using
matching intervals are included in the message.

This commit also updates and simplifies the "single service mode"
functionality to use the newly added mechanism for tracking which
services are included in the message.

This commit adds `test_srp_register_services_diff_lease` which covers
the behavior of the newly added mechanisms.
2022-10-06 18:31:25 -07:00
Eduardo Montoya a34d1176b9 [thci] remove unneeded problematic command (#8235)
Listing the table of rules results in SSH disconnection under some
circumstances. Removing the command since it doesn't add any
functionality.
2022-10-06 09:03:26 -07:00
Abtin Keshavarzian 4eb64510bf [test] update AdvanceTime() in unit tests to handle overflow (#8244) 2022-10-06 08:54:27 -07:00
Jonathan Hui 10de4c4f13 [fuzz] advance time before fuzz input enable to more services (#8243) 2022-10-06 08:54:00 -07:00
Abtin Keshavarzian 4f57b8d461 [meshcop] simplify energy scan client and server (#8230)
This commit updates `EnergyScanClient` and `EnergyScanServer`.
On server side, we prepare the report message after we parse the
request and directly append the results in the report message as
energy scans are performed. Client side is also updated to
correctly handle the case where the report message contains
greater number of results that can be supported on the client
based on its configuration.
2022-10-06 08:53:17 -07:00
Abtin Keshavarzian d3e00fbd28 [dns] allow partial read of TXT data and add config for max size in CLI (#8232)
This commit updates `Dns::Client` so that when reading service info
`otDnsServiceInfo` if the received TXT data does not fit in the given
buffer, it is read partially. A new field `mTxtDataTruncated` is added
in `otDnsServiceInfo` to indicate that TXT data was not fully read.

This commit also updates `dns` related commands in CLI so to output
the partially read TXT data and add a new config specifying the max
TXT data size used by CLI.
2022-10-05 15:10:28 -07:00
Jonathan Hui c5b4cd7bbc [doxygen] change inout to in,out (#8231) 2022-10-04 12:45:18 -07:00
Abtin Keshavarzian 61d9e72c18 [cli] update sub-modules to use Process<Cmd("cmd")> method (#8224)
This commit updates CLI `SrpServer`, `CoapSecure`, `UdpExample`, and
`TcpExample` to use the template `Process<Cmd("cmd")>` model. This
helps make them similar to other CLI modules.
2022-10-03 09:32:02 -07:00
Abtin Keshavarzian 7e8b482e3c [timer] add template TimerMilliIn to simplify handler functions (#8221)
This class adds a template sub-classes of `TimerMilli/Micro` which
allows us to directly specify an `Owner` for timer along with handler
callback as a member method of `Owner`. This helps simplify the
use of `Timer` in core module.
2022-09-30 11:32:56 -07:00
Jonathan Hui b3620ae51a [fuzz] add set -euxo pipefail to build script (#8222) 2022-09-30 11:24:20 -07:00
Suvesh Pratapa 6b712bd270 [cmake] allow configuring OPENTHREAD_CONFIG_MLE_MAX_CHILDREN with a CMake option (#8216)
This can help us configure this value during build time for OTBR
projects or other projects using CMake.
2022-09-30 09:50:12 -07:00
Abtin Keshavarzian bd8513b904 [ip6] define Ip6::NetifIdentifier mirroring otNetifIdentifier (#8219) 2022-09-30 08:36:48 -07:00
Song GUO 7954c34231 [nat64] support using IPv4 DNS server addresses in CLI (#8212)
Similar to TCP/UDP/PING commands, this command will print "Synthesized
IPv6 DNS server address:" when an IPv4 address is received.
2022-09-30 08:29:44 -07:00
Jonathan Hui f6df50cde6 [fuzz] declare otPlatLog as weak (#8220) 2022-09-29 20:59:32 -07:00
hemanth-silabs 081567fda6 [crypto] update the signature algorithm used for 3.2.0 mbedTLS (#8215)
`mbedtls_ssl_conf_sig_hashes` was deprecated in 3.2.0, and we
attempted to move over to the new recommended function. That new
function expects `MBEDTLS_TLS1_3_SIG_` type arguments.
2022-09-29 15:38:25 -07:00
Abtin Keshavarzian ba3d188db7 [srp-client] update "single service mode" to handle many removes (#8207)
This commit fixes the "single service mode" behavior to handle
if there are many simultaneous service removes. It also updates the
test to cover this situation.
2022-09-29 15:37:26 -07:00
Song GUO 06a6de24fa [nat64] add functional tests (#8161)
The test includes:
- Counters (protocol & error (4to6 no mapping, other errors are not
  expected))
- ICMP ping Connectivity
- UDP connectivity
2022-09-29 10:54:49 -07:00
Song GUO fc8949afb5 [nat64] fix typo: synthersize -> synthesize (#8213) 2022-09-29 10:51:06 -07:00
Tobías Lifschitz 12a1e618b2 [cli] print missing mac counters (#8210)
Co-authored-by: Tobias <tlifschitz@maper.com.ar>
2022-09-28 14:04:14 -07:00
Abtin Keshavarzian 32a17d8abe [test] update SRP unit test to prepare service entries in all cases (#8208) 2022-09-27 20:35:16 -07:00
Abtin Keshavarzian 02690328a8 [srp-server] lease info for a deleted service or host entry (#8206)
This commit updates the `Srp::Server` to allow lease info (in
particular the key-lease) to be retrieved for a deleted service or
host entry.
2022-09-27 09:43:20 -07:00
Abtin Keshavarzian 384dcbf631 [srp-server] update the default min/max lease/key-lease intervals (#8205)
This commit updates the default `LeaseConfig` intervals used by
`Srp::Server` to accept any requested lease time between 30 seconds
and 27 hours and any requested key lease time between 30 seconds and
189 hours.
2022-09-27 09:40:18 -07:00
Kangping ecdd5312a3 [posix] fix OT_DAEMON flag definitions (#8203)
We have to add the `OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE` definition
to `ot-config` because OpenThread core libraries will set config file
to "openthrad-core-posix-config.h" which depends on
`OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE` to correctly enable
PLATFORM_NETIF and PLATFORM_UDP features. Otherwise, OpenThread core
and posix libraries will use different feature definitions.
2022-09-27 08:58:23 -07:00
Jonathan Hui e64ba13faa [address-cache] increase default to 32 (#8204)
To reduce likelihood of cache miss and associated costs.
2022-09-26 12:58:52 -07:00
Jiachen Dong bcf9d8058e [harness-simulation] add the usage of the CLI command nodeidfilter (#8196) 2022-09-23 12:20:05 -07:00
Abtin Keshavarzian 5f7f48be9b [equatable] update Equatable to ensure CRTP-style use (#8199)
This commit updates `Equatable<Type>` to ensure CRTP-style use.
2022-09-23 09:05:32 -07:00
Abtin Keshavarzian 1942a79d75 [clearable] update Clearable to ensure CRTP-style use (#8198)
This commit updates `Clearable<Type>::Clear()` method to perform
`static_cast<Type *>(this)`. This ensures CRTP-style use and also
allows the `Clearable` to be used for types that may not be a
standard layout type (and/or more generally in cases where empty
base optimization may not be applied).
2022-09-23 09:04:24 -07:00
Abtin Keshavarzian 322671e682 [routing-manager] remove old deprecating prefix on multiple xpanid change (#8151)
This commit updates `RoutingManager` to ensure to unpublish the old
local on-link prefix being deprecated on ext PAN ID change if the ext
PAN ID happens to change again before the previous deprecating prefix
is expired. Note that the code supports retaining one old deprecating
prefix entry since back-to-back ext pan ID change is not expected as
a typical use-case. This commit also updates `test_routing_manager`
to cover and test this scenario.
2022-09-23 09:02:37 -07:00
Mason Tran cc8e4cce15 [cmake] add interface libraries ot-config-(ftd|mtd|radio) (#8190)
This allows for more granular control of any configuration which
might need to be incorporated in the core library build.
2022-09-22 23:20:35 -07:00
Abtin Keshavarzian da45d327c7 [routing-manager] allow old deprecating PIOs when checking RA is from router (#8193)
This commit updates `IsReceivedRouterAdvertFromManager()` which checks
if a received RA message was prepared by the `RoutingManager module
itself to allow deprecating PIOs in the RA message. These will handle
the case when old on-link prefix(es) (e.g., on extended PAN ID change)
are being deprecated.
2022-09-22 13:37:42 -07:00
Jiachen Dong fe655f4ef1 [thci] make OpenThreadTHCI compatible with Thread reference 20200818 (#8195) 2022-09-22 11:37:30 -07:00
Abtin Keshavarzian 8988bd84c3 [mle] add RouterTable::LogRouteTable() (#8189)
This commit updates the logging format of the route table. It adds
`LogRouteTable()` method in `RouterTable`.
2022-09-22 11:33:46 -07:00
Abtin Keshavarzian 13df0374d1 [routing-manager] fix prefix comparison in EvaluateOnLinkPrefix() (#8192)
This commit fixes `EvaluateOnLinkPrefix()` to use local on-link
prefix (instead of OMR prefix).
2022-09-21 14:11:22 -07:00
Mason Tran 32d7405174 [examples] make built-in otPlatCalloc and otPlatFree definitions weak (#8188)
This will allow platforms to define their own `otPlatCalloc` and
`otPlatFree` functions which may not map directly to `calloc()`
and `free()`
2022-09-21 11:11:37 -07:00
Abtin Keshavarzian 5a627ba0fd [test] add unit test test_srp_server (#8163)
This commit adds a unit test for `Srp::Server` (which also covers
`Srp::Client`) building a foundation for writing tests covering edge
cases of SRP server and its interaction with platform "update handler"
callback and SRP client.

For example, the test validates behavior of SRP sever, when
"update handler" accepts, rejects, or ignores (waits for timeout)
the received SRP updates. The test also validates that all heap
allocated objects (used by  SRP sever) are properly freed under
different scenarios (validating that there is no heap object leak).
2022-09-21 11:06:23 -07:00
Abtin Keshavarzian 615e951ca9 [srp-server] add AutoEnableMode to give control to BR (#8129)
This commit adds new APIs and mechanisms to support `AutoEnableMode`
in SRP server. This mode allows us to delegate the control of SRP
server (when it is enabled or disabled) to the Border Routing
Manager.

Under this mode, SRP sever is auto-enabled if/when `RoutingManager` is
done with the initial prefix and route setup, i.e., when the OMR and
on-link prefixes are determined, advertised in the emitted Router
Advert message on infrastructure side and published in the Thread
Network Data. This ensures that bi-directional connectivity is set up
before allowing service registration and discovery to start. The SRP
server is auto-disabled if/when BR is stopped, for example, when the
infrastructure network interface is brought down or when the BR gets
detached.

This commit also adds CLI commands for the new APIs and adds a
test-case in `test_routing_manager` to test and validate the newly
added mechanism.
2022-09-20 22:04:58 -07:00
Abtin Keshavarzian af1fd05f0b [gh-action] add new case to run unit test with toranj config (#8164)
This commit adds a new case under GitHub `toranj.yml` workflow to
build and run all unit test using the toranj OT configuration.
2022-09-20 18:21:13 -07:00
Abtin Keshavarzian 92f18c5c53 [cmake] add separate tcplp libraries for ftd and mtd (#8175)
This commit adds separate `tpclp-ftd` and `tcplp-mtd` libraries.
Each library is then `target_link_libraries()` with the related
`openthread-ftd/mtd`. This should help avoid situation where both
`openthread-ftd` and `openthread-mtd` are included as dependency
and linked and address linker failures under certain versions of
`clang`.
2022-09-20 15:43:19 -07:00
Abtin Keshavarzian bacf8d625f [routing-manager] add Nat64PrefixManager nested class. (#8178)
This commit adds `Nat64PrefixManager` class in `RoutingManager` which
contains the NAT64 related logic including generation of local NAT64
prefix, discovery of infra interface prefix, maintaining the
discovered prefix lifetime, and selection of the NAT64 prefix to
publish in Network Data. This class encapsulates all variables and
methods related to NAT64.
2022-09-19 11:01:44 -07:00
Jiachen Dong 6df8627135 [harness-simulation] update deviceInputFields.xml automatically (#8177)
This commit automatically updates the device fields in
deviceInputFields.xml, eliminating the need to update them manually.
2022-09-19 10:59:15 -07:00
Jiachen Dong 7b44e089a7 [harness-simulation] change config format from JSON to YAML (#8176)
This commit changes the format of the configuration file from JSON to
YAML, as YAML is designed for human interaction and better suitable
for configuration than JSON.
2022-09-19 10:58:08 -07:00
Sam Kumar 9d76424c3c [cli-tcp] use TCP Circular Send Buffer in TCP CLI tool and test (#7867) 2022-09-19 10:30:48 -07:00
Sam Kumar 19f9ba20a3 [tcp] implement TCP Circular Send Buffer (#7867) 2022-09-19 10:30:48 -07:00
Sam Kumar 5b430bf80b [tcp] suppress clang-tidy for re-declared TCPlp functions (#7867) 2022-09-19 10:30:48 -07:00
Jonathan Hui 2cab708443 [cc2538] move to openthread/ot-cc2538 (#8169) 2022-09-16 09:03:28 -07:00
Simon Lin 3a64f399bf [thci] wait for connection reset in powerDown (#8166)
This commit fixes `powerDown` to wait for connection reset after
issuing `reset` command.
2022-09-16 08:31:27 -07:00
Simon Lin 0756d1ea8f [dtls] fix DTLS connection issues (#8168)
This commit fixes two DTLS session issues on Posix:
- Fix the issue that UDP connect would cause the kernel socket to bind
  to an address that might be different from the address used by the
  Commissioner.
- Set the socket address to avoid kernel selecting an incorrect source
  address.
2022-09-15 20:55:01 -07:00
Jonathan Hui b5ea9c8106 [github-actions] use concurrency feature to cancel oustanding jobs (#8154) 2022-09-15 12:06:45 -07:00
Simon Lin b11121b7b5 [thci] fix mdns_query incorrect ip6tables rules (#8159)
This commit fixes the bug that `mdns_query` inserts `ip6tables` rules
in an incorrect order.  It also uses `ip6tables -F INPUT` to flush the
`INPUT` chain after mDNS query is done.
2022-09-15 08:52:41 -07:00
Song GUO 6973a1b067 [nat64] implement functions for NAT64 on the client side (#8126)
This commit adds the ability for accepting an IPv4 address for {ping,
tcp, udp} CLI commands.
2022-09-15 08:43:36 -07:00
Simon Lin a7e0516fb2 [thci] allow custom otbr-agent log dumping command via Param9 (#8137)
This commit allows THCI to use custom command to dump `otbr-agent`
logs via `Param9`.
2022-09-14 23:03:34 -07:00
canisLupus1313 bf2e1c39bc [cmake] add files allowing direct integration to Zephyr's west (#8143)
This commit adds CmakeLists and west config in order to be able to
directly integrate the openthread with zephyr build system.
2022-09-14 22:50:04 -07:00
Jiachen Dong a0c4ede86d [harness-simulation] add support for RF enclosure simulation (#8092)
This commit adds support for RF enclosure simulation. It can pass
Leader 9.2.9, Router 9.2.9 and Router 9.2.10 in Thread Test Harness
v56.0 now.
2022-09-14 14:31:06 -07:00
Eduardo Montoya 436bde84f5 [cli] document the ping async option (#8158) 2022-09-14 11:40:57 -07:00
Jonathan Hui 1fad9f7626 [github-actions] use external repo for arm build check (#8153)
Also remove autotools build checks.
2022-09-14 11:39:28 -07:00
Song GUO b66d521d1d [nat64] implement CLI functions for NAT64 (#8058)
This commit introduces `nat64` command and 4 new subcommands
(`configuredcidr`, `configuredprefix`, `mappings`, `counters`)

nat64 cidr -- Get the configured CIDR for NAT64 translator.
nat64 mappings -- Get the mappings of NAT64 translator.
nat64 counters -- Get the packet counters and error counters of NAT64
                  translator.

This commit also introduces related API for the above commands, and
`otIp4AddressToString` & `otIp4CidrToString` for the CLI to format the
IPv4 address and CIDR.
2022-09-13 09:39:50 -07:00
Abtin Keshavarzian 531339b65d [link-metrics] simplify preparation of MLE Data Request (#8142)
This commit simplifies the preparation of MLE Data Request message
which include a Link Metrics Query TLV and its sub-TLVs.
2022-09-13 08:44:45 -07:00
Sam Kumar dd02babfeb [tcplp] add test for contiguify functionality (#7868) 2022-09-12 21:54:33 -07:00
Abtin Keshavarzian f4c76f11fc [config] include misc.h in srp_client.h (#8146)
This ensures that `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is
defined in `config/srp_client.h` and can be safely used for defining
`OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_HOST_ADDRESSES`.
2022-09-12 21:28:35 -07:00
Jonathan Hui e9877198c4 [fuzz] enable SRP server in fuzz targets (#8145) 2022-09-12 21:23:31 -07:00
Jonathan Hui 945edf1eb6 [fuzz] bump Thread version to 1.3 (#8145) 2022-09-12 21:23:31 -07:00
Abtin Keshavarzian 2ad5515be2 [routing-manager] deprecate previous local on-link prefix on xpanid change (#8112)
This commit updates `RoutingManager` to deprecate a previously
advertised local on-link prefix when extended PAN ID gets changed.
The local on-link prefix is derived from Thread network extended PAN
ID.  On extended PAN ID change, we continue to include the the old
prefix (if it was being advertised) in the emitted RAs as PIO (with
zero preferred lifetime) and continue to publish it in Network Data
up to its lifetime. This ensures that any device on infrastructure
link side that may be using an IPv6 address based on this old prefix
can continue to communicate with the Thread mesh devices.

This commit also adds a test-case in `test_routing_manager` to
validate the behavior of the newly added mechanism when ext PAN ID
changes while the local on-link is being advertised and also while
it was being deprecated.
2022-09-12 21:23:03 -07:00
Abtin Keshavarzian 1861291a62 [routing-manager] add RsSender nested class (#8124)
This commit adds `RsSender` class in `RoutingManager` which contains
the logic related to the transmission of Router Solicitation
(RS) messages to discover other routers. This class encapsulates all
variables, constants, and methods related to the RS transmission
mechanism(number of RS messages in a cycle, time intervals, etc).
2022-09-12 13:00:48 -07:00
Eduardo Montoya 865727adc8 [tcp] extend test to cover otTcpStopListening API (#8133)
Make sure `otTcpStopListening` is verified.
2022-09-09 20:20:28 -07:00
Jiachen Dong 4311d1931a [harness-simulation] add multiple-version support (#8075)
This commit adds multiple-version support, and uses a unified
configuration file to specify all the parameters.
2022-09-09 13:32:17 -07:00
Abtin Keshavarzian 2a27a15c1a [srp-server] log the content of processed SRP update message (#8131)
This commit updates the `Srp::Server` to log the processed info in a
received SRP Update message, such as host name, lease times, host
addresses, all services (and sub-types) being added or removed. The
info is logged before invoking the "update handler" and/or committing
the info into existing data. This change can help with debugging
issues.
2022-09-09 08:42:47 -07:00
Abtin Keshavarzian ccf8ea6923 [srp-client] update document about selected preferred server (#8125)
This commit updates `otSrpClientEnableAutoStartMode` documentation
to describe how the preferred server is determined from Network Data
entries (different Network Data entry categories, their order of
preference, and how to handle when there are multiple options within
the same category).
2022-09-06 15:27:22 -07:00
Jonathan Hui 1929c7c187 [github-actions] add gcc-12 to build matrix (#8118) 2022-09-06 11:19:09 -07:00
Jonathan Hui f88f954289 [ncp] fix init order to resolve compiler warning (#8118) 2022-09-06 11:19:09 -07:00
Jonathan Hui ae4c28c5ae [core] do not use FreeMessageOnError() on nonnull pointer (#8118) 2022-09-06 11:19:09 -07:00
Abtin Keshavarzian a53715b231 [link-metrics] simplify processing of SeriesFlags (#8116)
This commit updates `SeriesFlags` definition to map to the public
`otLinkMetricsSeriesFlags` struct and adds helper methods to convert
to or set it from a `uint8_t` flags bitmask which is read or written
in the TLVs.
2022-09-06 08:50:17 -07:00
Abtin Keshavarzian f43b9f0332 [routing-manager] add ScheduleRoutingPolicyEvaluation() (#8115)
This commit adds a new method `ScheduleRoutingPolicyEvaluation()` in
`RoutingManager` which combines the logic from different related
methods. This helps simplify the code. The new method accept an enum
`SchduleMode` input which indicates the rule to use when determining
the next policy evaluation time, e.g., schedule it immediately, or
after a random delay, or after short random jitter time to reply to
a received RS, etc.
2022-09-06 08:49:27 -07:00
Abtin Keshavarzian 46c7dccfef [discover-scanner] invoke handler when scan is done from a tasklet (#8111)
This commit updates `DiscoverScanner` so when scan operation is
finished it uses a `Tasklet` to clear the state and invoke the
callback. This allows users to safely call OT APIs from the
callback.
2022-09-06 08:46:27 -07:00
Abtin Keshavarzian 5d50088da9 [routing-manager] rename published NAT64 prefix (#8113)
This commit renames the variable representing the NAT64 prefix
which is published in Network Data to `mPublishedNat64Prefix`.
2022-09-01 11:01:53 -07:00
Abtin Keshavarzian 6dca78e757 [link-metrics] add blocking CLI query command and enhance tests (#8108)
This commit updates CLI `linkmetrics query` command to allow it
to be used in blocking mode (wait for response to query). This
is then used in different tests to validate the `LinkMetrics`
module behavior. In particular, `v1_2_test_single_probe` and
`v1_2_LowPower_7_2_01_ForwardTrackingSeries` are updated to
validate that the received query report message is correctly
parsed.
2022-09-01 10:49:02 -07:00
Abtin Keshavarzian c3dd3ba8fb [mle] update DetachGracefully() to stop BR routing manager (#8105)
This commit updates `Mle::DetachGracefully()` to stop Border Router
`RoutingManager`. This ensures that BR will have the chance to send
a final Router Advertisement message desecrating/removing its
previously advertised on-link or route prefixes.
2022-09-01 08:19:57 -07:00
Simon Lin 30d65bca48 [thread-cert] import Crypto on demand (#8109)
This commit imports `Crypto` module only when it's used.

This helps thread-cert tests that do not use message factory to run
without having to install `Crypto` module.
2022-08-31 19:48:24 -07:00
Song GUO bce7c1ae1f [nat64] change BORDER_ROUTING_NAT64 to NAT64_BORDER_ROUTING (#8047)
We decided to rename BORDER_ROUTING_NAT64 to NAT64_BORDER_ROUTING so
the flag won't be confusing since we have NAT64_TRANSLATOR which does
not depends on the border routing manager.
2022-08-30 21:05:28 -07:00
rxwen 3d60038bcb [posix] make base class destructor virtual (#7220) 2022-08-30 11:04:21 -07:00
Abtin Keshavarzian d9fd256b47 [tlvs] rename method to ReadTlvValue() from ReadTlv() (#8100)
This commit renames the method from `ReadTlv()` to `ReadTlvValue()`
to emphasize that it read the TLV value only (unlike `FindTlv()` helper
methods which find and read the whole TLV).
2022-08-30 09:11:06 -07:00
Abtin Keshavarzian ba4389a44a [radio] define Radio::kInvalidRssi constant (#8097)
This commit harmonizes the constant used to indicate an "Invalid RSSI
value". It defines `Radio::kInvalidRssi` which is then used in all
core modules replacing `OT_RADIO_INVALID_RSSI` and similar constants
in `SubMac/Mac`.
2022-08-30 09:10:18 -07:00
Abtin Keshavarzian a6032491b8 [link-metrics] fix reading of Report sub-tlv from message (#8099) 2022-08-29 20:25:34 -07:00
Jonathan Hui 0988f460dc [github-actions] migrate to ubuntu 20.04 to 18.04 (#8061) 2022-08-29 10:51:35 -07:00
whd 9308db14c9 [otci] support ADB connection for OTCI (#8088) 2022-08-25 23:19:28 -07:00
Abtin Keshavarzian ba006225e0 [link-quality] helper fn to convert link margin, link quality, RSS (#8081)
This commit simplifies the helper functions that convert between
link margin, link quality and RSS (replacing the `static` methods
in `LinkQualityInfo`).
2022-08-25 14:10:29 -07:00
Abtin Keshavarzian 10c9a365f2 [link-metrics] simplify sending MLE Mgmt Request (#8073)
This commit adds `FwdProbingRegSubTlv` which is used to simplify
`SendMgmtRequestForwardTrackingSeries()` implementation. Similarly
`EnhAckConfigSubTlv` is updated and used to simplify method
`SendMgmtRequestEnhAckProbing()`.
2022-08-25 11:17:56 -07:00
Sarah cd83fc1477 [docs] CLI Dataset (#7944) 2022-08-25 11:15:37 -07:00
Abtin Keshavarzian 958eb5c5bf [srp-server] update validation of instance and service names (#8080)
This commit updates `ProcessServiceDiscoveryInstructions()` method
to use `Dns::Name::IsSubDomainOf()` to validate the relation between
service instance name and the base service name.
2022-08-25 11:11:35 -07:00
Abtin Keshavarzian d72c10eed3 [routing-manager] advert local on-link prefix if same as discovered prefix (#8079)
This commit updates the `RoutingManager` such that if we see that that
current favored discovered on-link prefix (from processed RAs from
other router) matches our local on-link prefix, we start/continue
advertising it as well. The local on-link prefix is derived from
extended PAN ID and therefore is the same for all BRs on the same
Thread mesh. Having multiple BRs advertise the same on-link prefix
adds redundancy (in case one BR goes offline).
2022-08-25 11:09:42 -07:00
Abtin Keshavarzian 989a56e96d [link-metrics] update the scaling of link margin and RSSI metrics (#8078)
This commit updates the scaling of the link margin and RSSI metrics.
The metric values are scaled when appended in the message (in a
Report sub-TLV) or when they are read back from received message. The
stored value in `MetricsValues` are changed to be always the actual
metric value (not the scaled value). This ensures that the value are
stored in proper int type (e.g., RSSI is `int8` vs the scaled value
which is `[0,255]`). Methods are added to perform the scaling which
now rounds to closest integer ensuring the reverse scaling gives back
the original value. Unit test is added to validate the scaling
methods.
2022-08-25 11:08:44 -07:00
Abtin Keshavarzian cba1bebf1f [child-table] check neighbor is in ChildTable before cast as Child (#8071)
This commit adds a check `Get<ChildTable>().Contains(Neighbor &)`
to ensure that the neighbor is from the child table before casting
the neighbor entry to `Child`. This adds safety and protection against
potential corner-case where we have a neighbor entry which is
`Parent` or `ParentCandidate` that is a REED.
2022-08-24 23:35:21 -07:00
Jonathan Hui d7cbc17961 [posix] initialize hints in InfraNetif::DiscoverNat64Prefix (#8070) 2022-08-24 22:15:07 -07:00
Jiachen Dong 0f10480ed6 [harness-simulation] fix build_docker_image.sh error (#8072) 2022-08-24 10:53:11 -07:00
Abtin Keshavarzian e51941177f [mle] add ParentCandidate class (#8069)
This commit adds `ParentCandidate` in `Mle` class (as a sub-class of
`Parent`) and moves all member properties related to parent candidate
to this new class.
2022-08-24 10:46:14 -07:00
Abtin Keshavarzian 9699d319af [takelet] add template TaskeltIn to simplify handler functions (#8064)
This class adds a template sub-class of `Tasklet` which allows
us to directly specify an `Owner` of tasklet along with handler
callback as a member method of `Owner`. This helps simplify the
use of `Tasklet` in core module.
2022-08-24 10:44:48 -07:00
Sarah 5516024905 [docs] CLI child commands (#8041) 2022-08-23 17:33:14 -07:00
Eduardo Montoya 130cfd790c [thci] remove unused methods (#7704)
`setActiveDataset` and `setCommisionerMode` have been removed from
the `iThci` abstract class in the latest harness release.
2022-08-23 16:30:10 -07:00
Abtin Keshavarzian d17bde5b2d [mle] move simple RLOC to Router ID conversion functions to mle_types.hpp (#8060)
This commit moves simple `static` member methods from `Mle` class to
`mle_types.hpp` (under `Mle` namespace).
2022-08-23 16:14:09 -07:00
Abtin Keshavarzian 2c3a10d67a [mac] add ComputeLinkMargin() (#8063)
This commit adds a helper method in `Mac` to compute link margin
from a given received signal strength (in dBm) using the radio
noise floor.
2022-08-23 14:37:21 -07:00
Abtin Keshavarzian 9d70832b85 [link-metrics] simplify HandleReport() (#8054)
This commit updates `LinkMetrics::HandleReport()` method:
- Fixes issue where `Status` sub-TLV would not be read.
- Uses `Tlv` helper method to read the sub-TLVs.
- Reads `ReportSubTlv` directly from message and uses its methods
  to get the metrics values.
- Fixes issue where we would not skip over unknown sub-TLVs
  correctly.
2022-08-23 14:34:09 -07:00
Yi 3d146f3f60 [nat64] disable discovering NAT64 AIL prefix for OpenWRT (#8065) 2022-08-23 08:32:56 -07:00
canisLupus1313 85fb24aedf [mesh-forwarder] fix random ieee frame version 2015 while attaching (#8067)
This commit fixes random 2015 frame version issue while attaching to
REED. the problem was caused by unconditionally casting Router structure
to Child structure and making out of original structure memory access.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2022-08-23 07:05:04 -07:00
Jiachen Dong 0b8e9745e5 [thci] add support for OTBR simulations (#8015)
It can run all Thread 1.2 test cases with simulations now except those
requiring multiple versions support. It has been tested with the DUT
being a role of Router, Leader, Border Router, BR_1 and BR_2.
2022-08-22 21:32:45 -07:00
Abtin Keshavarzian 142b8cf58c [core] add generic three-way comparison function (#8050)
This commit adds a generic `ThreeWayCompare()` function. It also
renames header to `num_utils.hpp` from `min_max.hpp`.
2022-08-22 19:52:02 -07:00
Abtin Keshavarzian 188ec0d476 [link-metrics] define StatusSubTlv to simplify appending/parsing it (#8051)
Status sub-TLV has a single `uint8_t` status value so we can use
declare it as `UintTlvInfo<SubTlv::kStatus, uint8_t>` and then use
helper `Append<StatusSubTlv>` and `Read<StatusSubTlv>` to append
and read it.
2022-08-22 19:26:25 -07:00
Abtin Keshavarzian 570e30522f [address-resolver] simplify EntryInfo and Iterator (#8055) 2022-08-22 17:47:07 -07:00
whd 8942e7f895 [multicast-routing] block egress multicast packets from LLA (#8059)
According to the Spec, egress packets from LLA should not be
forwarded. Linux kernel doesn't automatically block such forwarding
so that we need to check this before adding the MFC entry.
2022-08-22 16:34:52 -07:00
Jonathan Hui 370d4dc0b5 [docs] update Thread version (#8053) 2022-08-22 16:30:36 -07:00
Abtin Keshavarzian b8b88d9492 [mle] track LeaderCost in Parent class (#8052) 2022-08-22 16:30:17 -07:00
Abtin Keshavarzian 96bba3659c [topology] add Router::GetTwoWayLinkQuality() method (#8049)
This commits add `GetTwoWayLinkQuality()` method to `Router` class
which returns the minimum of router's Link Quality In and Out
values. It also adds `GetLinkQualityIn()` to `Neighbor`. These
are used in `Mle` and `MeshForwarder`.
2022-08-22 16:22:31 -07:00
Abtin Keshavarzian fdd0afacc5 [link-metrics] simplify AddReport() (#8042)
This commit simplifies the `LinkMetrics::AddReport()` method so that
when preparing the MLE Link Metrics Report TLV (and its sub-TLVs) we
determine the TLV length after all sub-TLVs are appended to the
message from the number of written bytes in the message (difference
between `aMessage.GetLength()` and initial offset of the TLV). This
allows to simplify methods `AppendReportSubTlvToMessage()` and
`AppendStatusSubTlvToMessage()` as well.
2022-08-22 16:19:18 -07:00
Yi e50be395e4 [nat64] extend wait time between test cases and verify netdata stabilized (#8057)
This commit extend the wait time after disabling border routing and a
new case is added to verify that the netdata is stable again.
2022-08-22 16:14:07 -07:00
Kangping d48799dddf [border-agent] update logging for filtered messages (#8045)
Update border agent logging for filtered messages to debug level to
avoid confusion, because it's actually not a error case.
2022-08-20 08:05:59 -07:00
Abtin Keshavarzian a5eb1c9401 [link-metrics] add link_metrics_types.hpp (#8040)
This commit adds a new header files `link_metrics_types.hpp` which
includes all `LinkMetrics` related types and constants. The related
type definition are moved to this header from `link_metrics.hpp` and
`link_metrics_tlvs.hpp` (which now contains the TLV definitions only).

This commit also moves the more complex method implementations to the
`cpp` file.
2022-08-19 11:13:15 -07:00
Sam Kumar 829632e33e [tcp] implement otTcpReceiveContiguify (#7634) 2022-08-19 10:12:40 -07:00
Sam Kumar 0126c5f44b [tcp] modify cbuf to be able to use all bytes provided by the user (#7634) 2022-08-19 10:12:40 -07:00
Abtin Keshavarzian a0718d90b1 [mle] define DetachGraecfuly variables as private (#8044)
This commit changes the definitions (member variables, constants, and
methods) related to graceful detach mechanism to be `private` instead
of `protected` since they are only accessed/used by the `Mle` and not
by its sub-class `MleRouter`.
2022-08-18 23:01:26 -07:00
Abtin Keshavarzian 4dd9fd0c9e [link-metrics] fix integer conversions & use of u8 for offset (#8043)
This commit addresses integer conversion warnings in `LinkMetrics`.
In particular it updates `ReadTypeIdFlagsFromMessage()` to use
`uint16_t` as offset value (instead of `uint8_t`).
2022-08-18 23:00:51 -07:00
Abtin Keshavarzian 969d511d04 [routing-manager] allow domain prefix to be considered as OMR (#8014)
This commit updates the `RoutingManager` to allow domain prefix from
Network Data to also be considered during OMR selection. In
particular:
- `IsValidOmrPrefix(config)` now accepts prefixes with `mDp` flag.
- `OmrPrefix` now tracks whether the prefix is domain prefix.
- When appending RIO in RA message, the domain prefix is always
  excluded (independent of whether or not it is the current favored
  OMR prefix).

This commit also updates the `test_routing_manager` unit test to add
a test case checking behavior of `RoutingManager` when a domain prefix
is selected as the favored OMR.
2022-08-18 22:41:49 -07:00
Abtin Keshavarzian c2b6621d9f [ip6] add MessageOrigin to indicate origin or IPv6 message (#8036)
This commit adds a new enum `Ip6::MessageOrigin` which indicates the
origin of the message: From Thread Netif or from host. In case the
message is originating from host, it also indicates whether or not it
is allowed to pass back the message to the host.
2022-08-18 22:32:10 -07:00
Song GUO e84f05c641 [nat64] implement nat64 translator (ot::Nat64::Translator) (#7836)
This commit:

- implements the core logic for translating packets for NAT64,
  including the public APIs exposed to platform daemons.

- includes changes for POSIX platform, use `OT_POSIX_NAT64_CIDR`,
  `OPENTHREAD_POSIX_CONFIG_NAT64_CIDR` for setting the CIDR for NAT64
  during build time.

- exposes `otNat64Send(otInstance *aInstance, otMessage *aMessage)`
  and `void otNat64SetReceiveIp4Callback(otInstance *aInstance,
  otNat64ReceiveIp4Callback aCallback, void *aContext)`.
2022-08-18 22:28:26 -07:00
whd 20aee3fa70 [multicast-routing] don't add MFC entries using mesh local as the source address (#8025)
According to Thread Spec, PBBR should not forward a multicast packet
from Thread interface to Backbone interface when the source address is
Mesh-Local.
2022-08-17 22:59:50 -07:00
Abtin Keshavarzian 897a29565e [api] harmonize nullptr assert check of pointer input parameters (#8031)
This commit harmonizes and simplifies the code related to asserting
that the OT API pointer parameters are valid and not `nullptr`.
`OPENTHREAD_CONFIG_ASSERT_CHECK_API_POINTER_PARAM_FOR_NULL` is added
which when used performs assert check on all pointer inputs to APIs.
This is either done within `AsCoreType()` when the pointer is
converted to its related core type, or by a direct call to newly added
macro `AssertPointerIsNotNull()`.

Since enabling assert checks on every API parameter can increase code
size, this config is disabled by default and it is recommended to use
it during debugging only.
2022-08-17 20:22:19 -07:00
Abtin Keshavarzian cb91e43322 [mle] add Parent class (tracking CSL accuracy info) (#8029)
This commit adds `Parent` class as a sub-class of `Router` and moves
the CSL accuracy definitions in `Parent` class (from `Router`) since
we need to track CSL info only for the parent and not other entries
in the router table. This helps reduce the memory/RAM used by router
table.
2022-08-17 19:21:19 -07:00
Abtin Keshavarzian 1d10948069 [router-table] simplify Allocate() and random selection of ID (#8032)
This commit updates `RouterTable::Allocate()` to use Reservoir
sampling algorithm to randomly select a router ID while iterating
through the list of available IDs.
2022-08-17 15:36:10 -07:00
Abtin Keshavarzian 061d22ba8e [ip6] simplify Ip6::HandleDatagram() - remove netif local var (#8035)
This commit updates `Ip6::HandleDatagram()` and removes the local
`netif` variable and directly uses `ThreadNetif` instead. Note that
the input parameter `aNetif` is either `nullptr` or points to
`ThreadNetif`, and in both cases the local variable `netif` will be
set to point to `ThreadNetif`.
2022-08-17 14:32:18 -07:00
Abtin Keshavarzian 2d4896f675 [ip6] remove extra param from Ip6::HandleExtensionHeaders() (#8035)
This commit updates `Ip6::HandleExtensionHeaders()` removing
`aIsOutbound` input and instead using `(aNetif == nullptr)` to
determine this.
2022-08-17 14:32:18 -07:00
Abtin Keshavarzian 7f73cd42a4 [link-metrics] fix the endian-ness of mPduCountValue (#8039)
This commit updates `LinkMetrics::AppendReport()` to ensure
the `values.mPduCountValue` (which is a `uint32_t`) is stored in
the host MCU encoding and not in big-endian encoding.

This was originally added in #7046 as a fix (basically saving the
value in local variable in the encoding we expect to later include
in the Report TLV), however #8006 updates the `ReportSubTlv` methods
to do the encoding change in the `Get/SetMetricsValue32()` (similar
to other OT `Tlv` definitions).
2022-08-17 12:00:27 -07:00
Abtin Keshavarzian 1b5298eb76 [csl] add CslAccuracy type (#8024)
The CSL accuracy is represented as two parameters: clock accuracy in
ppm, and uncertainty in units of 10 microseconds. These two parameters
are often used together. This commit adds a new class `CslAccuracy`
encapsulating both. This new type is used in `Mac` and `Mle` methods
allowing us to pass both in one object.

This commit also adds `Mle::RxMessage::ReadCslClockAccuracyTlv()` to
read and parse the CSL Accuracy TLV value from a given received MLE
message.
2022-08-16 22:19:14 -07:00
Simon Lin f790edd5e2 [github-actions] upgrade pyshark to 0.4.6 (#8030) 2022-08-16 16:23:43 -07:00
Abtin Keshavarzian 8161a90a0c [thread] add version consts & use uint16_t for Neighbor::mVersion (#8027)
This commit adds `thread/version.hpp` which defile Thread Version
constants. It also changes the `mVersion` in `Neighbor` class to
use `uint16_t` to track the version. This help harmonize it with
the MLE Version TLV and and version in `Settings`. Due to memory
alignment of existing member variables the change (from `u8` to
`u16`) does not increase the memory requirement for child or router
table.
2022-08-16 16:22:35 -07:00
Abtin Keshavarzian bbac0e7980 [ip6] update HandlePayload() (avoid msg clone if not needed) (#8023)
This commit adds a smaller enhancement in `Ip6::HandlePayload()`. If
support for TCP `OPENTHREAD_CONFIG_TCP_ENABLE` is not enabled, we
exit early from this method before potentially creating a clone of
the message (to free later).
2022-08-16 15:55:48 -07:00
Abtin Keshavarzian 47e5277659 [mle] define ParentSearch class (#8022)
This commit adds `Mle::ParentSearch` class which encapsulates all
definitions (variables, constants, and methods) related to "Parent
Search" feature.
2022-08-16 15:55:09 -07:00
Jonathan Hui 4c8ae758fd [routing-manager] fix call to StartRoutingPolicyEvaluationJitter() (#8034) 2022-08-16 15:54:23 -07:00
Abtin Keshavarzian 51c58d9080 [slaac] only allow SLAAC for prefixes with 64-bit length (#8021)
This commit updates `Slaac` module to only allow prefixes with
64-bit length.
2022-08-16 13:21:51 -07:00
Zhangwx 7c648559da [bbr] reduce the default reregisteration delay (#7996)
After BBR restarting, in order to receive the packets from multicast
group, the devices, which have registered multicast group addresses to
that BBR, needs to re-register these groups. In current logic, the
default max reregistration delay is too large (1200 seconds).
2022-08-16 13:20:47 -07:00
Simon Lin 92a5bd5451 [routing-manager] increase routing policy evaluation jitters (#7982)
This commit increase the routing policy evaluation jitter from 1
second to 2~4 seconds to avoid adding on-link prefix when the AIL GUA
prefix is unavailable for a very short duration (usually during GUA
prefix renewing).
2022-08-16 13:19:34 -07:00
Simon Lin 1bc309452f [thci] send mdns queries without dig (#7954)
Some mDNS implementations do not respond to mDNS queries sent by
`dig`.
2022-08-16 13:18:55 -07:00
Eduardo Montoya 01dd49286e [doc] fix RCP building information for nRF52840 (#8020) 2022-08-12 16:07:08 -07:00
Abtin Keshavarzian f33a586530 [mle] new API to trigger search for better parent (#8018)
This commit adds `otThreadSearchForBetterParent()` to start the
process on a child to search for a better parent while staying
attached to its current parent. This commit also adds a related CLI
command `parent search`.
2022-08-12 16:05:53 -07:00
Abtin Keshavarzian d1d8c6fecd [mle] add method to get parent info (#8019)
This commit moves the code for getting the parent info from the
`thread_api.cpp` to `Mle` class `GetParentInfo()` method. It also
updates the `Router::Info::SetFrom()` to populate the `mVersion` and
the newly added CSL related fields. This allows us to re-use the
same code for both router or parent info.
2022-08-12 11:26:47 -07:00
Abtin Keshavarzian 3aa4060018 [routing-manager] accept any ULA/GUA with 64-bit len as OMR prefix (#8016)
This commit updates `IsValidOmrPrefix()` to accept any ULA/GUA
prefix with 64-bit length as OMR prefix.
2022-08-12 11:23:38 -07:00
Abtin Keshavarzian d06f96a50f [routing-manager] add RaInfo tracking all RA related info (#8013)
This commit adds a new struct `RaInfo` in `RoutingManager` which
tracks info about emitted RA messages: Number of RAs sent, last tx
time, header to use and whether the header is discovered from
receiving RAs from the host itself. This helps encapsulate all
related info in one data structure.
2022-08-12 11:22:46 -07:00
Abtin Keshavarzian fda4549df7 [core] add new generic Min(), Max() and Clamp() functions (#8017)
This commit adds generic helper functions:

- `Min()` to get the minimum of two values,
- `Max()` to get the maximum of two values, and
- `Clamp()` to clamp a value to a given closed range from a minimum
   up to a maximum value. It also adds functions
- `ClampToUint8()` and `ClampToUint16()` to clamp a `uint` value to
   a smaller bit-size (`uint8_t` or `uint16_t`) range.
2022-08-12 09:22:18 -07:00
Laukik Hase 82088fe24d [meshcop] update deprecated functions for Mbed TLS v3.2.1 (#7977)
- Updated the following deprecated APIs with their respective alternatives
  - `mbedtls_ssl_conf_min_version` => `mbedtls_ssl_conf_min_tls_version`
  - `mbedtls_ssl_conf_max_version` => `mbedtls_ssl_conf_min_tls_version`
  - `mbedtls_ssl_conf_sig_hashes` => `mbedtls_ssl_conf_sig_algs`
- Updated the parameter data-type for `mbedtls_ssl_conf_sig_algs`
  (list of allowed signature algorithms) from `int` to `uint16_t`
- Added macros for backward compatibility
2022-08-12 09:15:04 -07:00
Yi 80565c58a9 [nat64] fetch NAT64 prefix from infrastructure interface and advertise it to netdata (#7619)
This commit fetches the NAT64 prefix on infrastructure interface and
advertise it to Network Data at medium preference.

- Use `getaddrinfo_a()` function to asynchronously lookup the ipv6
  address of the special domain `ipv4only.arpa`. The infrastructure
  NAT64 prefix is extracted from the domain answer.

- `mInfraIfNat64PrefixStaleTimer` is scheduled to monitor the presence
  and change of infrastructure NAT64 prefix.

- `EvaluateNat64Prefix` evaluates whether to advertise the
  infrastructure prefix or the local ULA prefix or neither. When there
  is a new infrastructure prefix, it will withdraw the legacy one and
  add the new one. When the infrastructure prefix no longer exists, it
  will withdraw the legacy one and add the local ULA prefix. When the
  infrastructure prefix presents again, it will add the infrastructure
  prefix and withdraw the local ULA prefix.

New tests are added to test the scenarios when infrastructure NAT64
prefix exists.  `DNS64` on OTBR is turned on to enable `bind9` with
NAT64 prefix on infrastructure interface for these tests. `bind9` is
explicitly turned off when testing local ULA prefix.  Since bind9 is
conflict with other components like dnssd, all nat64 tests are moved
under /nat64 directory and configured separately.

The case that two or more BRs have same infrastructure NAT64 prefix is
not covered by this commit and will be followed up later.
2022-08-12 07:37:05 -07:00
Abtin Keshavarzian 034fc826f3 [routing-manager] use Ip6::Prefix::IsUniqeLocal() to check OMR prefix (#8012)
This commit updates `IsValidOmrPrefix()` to use `IsUniqeLocal()`
method of `Ip6::Prefix`. This relaxes the check to allow any ULA
prefix and not necessarily with 64 bits prefix length.
2022-08-11 11:16:46 -07:00
Abtin Keshavarzian a1e2698401 [ip6-address] move more complex Prefix methods to cpp file (#8011)
This commit moves more complex methods of `Ip6::Prefix` class to the
`cpp` file. It also simplifies the `IsLinkLocal()` implementation. It
also updates unit test `test_ip_address` to validate `IsLinkLocal()`,
`IsMulticast()`, and `IsUniqueLocal()` methods.
2022-08-11 11:15:11 -07:00
Abtin Keshavarzian ea1b2292be [mle] add TlvList to track list of TLV types (#8008)
This commit adds `Mle::TlvList` type which represents a list of MLE
TLV types. It provides helper methods to `Add()` TLVs to the list
ensuring that any TLV type is included only once. The `TlvList` is
used when parsing "TLV Request TLV" or preparing which TLVs to
include in an MLE message.
2022-08-11 11:14:09 -07:00
Simon Lin 3120efb486 [thci] restore BBR config for 1.2 BR_1/BR_2 roles (#7997)
BBR related configurations was previously removed for Thread 1.3 BRs.
However, when running 1.2 test case for a Thread 1.3 BR, these
configurations are still necessary.

This commit restores BBR dataset configurations for 1.2 BR_1/BR_2
roles.
2022-08-11 11:08:48 -07:00
Simon Lin f4d93d8fcf [thci] enhance mdns_query to use ip6tables to filter mDNS responses (#8000) 2022-08-11 10:24:52 -07:00
whd df2c11a6cb [tests] add test for Advertising Proxy to publish zero or multiple host addrs (#8003) 2022-08-10 21:24:44 -07:00
Sarah c336a1899f [docs] CLI bbr (#7986) 2022-08-10 17:12:05 -07:00
Abtin Keshavarzian 82ce9dd4c4 [csl] update CSL Channel TLV process to allow for unspecified case (#8005)
This commit updates how unspecified CSL channel is conveyed in MLE
messages. Special value of zero in CSL Channel TLV is used to
indicate that the CSL channel is unspecified. The exclusion of the
TLV keeps the CSL channel as before (no change to the previously
set CSL channel).
2022-08-10 15:00:48 -07:00
Abtin Keshavarzian 967d89cd1a [link-metrics] fix u32 endian-ness in ReportSubTlv (#8006) 2022-08-10 12:11:39 -07:00
Abtin Keshavarzian 9f451a2b32 [mle] fix processing of CSL TLVs (#8004)
This commit contains fixes and enhancements related to processing
of CSL Channel TLV and CSL Clock Accuracy TLV in MLE messages:

- Updates/adds `IsValid()` method to check if TLV is well-formed.
  In particular, we check the TLV length to be at least the
  expecte length (but can be larger) to allow for future changes
  to the TLV format (adding new fields while remaining backward
  compatible).

- Ensure to verify that the read TLV is valid before using its
  content.

 - Fix processing of Accuracy TLV in `HandleChildUpdateResponse()`
   (where we could use incorrect values if TLV was not present).
2022-08-10 10:28:32 -07:00
Abtin Keshavarzian 3a31a5f368 [mle] add array bound check to avoid overflow in HandleDataRequest() (#8002) 2022-08-10 10:26:41 -07:00
Abtin Keshavarzian 3c38af22b4 [mle] helper method appending TLV Request TLV (#8001)
This commit contains smaller enhancements in MLE:

- We use `static const` to define array of TLVs to request.
- Rename the const arrays to `kTlvs`.
- Adds template `AppendTlvRequestTlv()`.
- Adds template `SendDataRequest()`.
2022-08-10 10:22:51 -07:00
Jiachen Dong ba14836b68 [thci] enhance SSH connection (#7981)
Now It connects to OpenThread FTD simulations via SSH without PTY and
runs in non-blocking mode.
2022-08-09 09:21:52 -07:00
Simon Lin 919157d0a6 [thci] generate more logs (#7975) 2022-08-09 09:19:20 -07:00
Jiachen Dong 0a41196540 [thci] add SSH keepalive (#7999)
Add SSH keepalive to avoid disconnection after idle for a long time.
2022-08-08 18:18:21 -07:00
Eduardo Montoya 4ce6a4708d [api] allow CSL receiver to gather parent CSL capabilities (#7991)
This commit extends the Thread API to allow a CSL Receiver application
to adjust its CSL parameters depending on the parent capabilities.

Specifically, it might decide to switch to polling operation instead
of CSL synchronization when the attached parent does not support CSL
Transmitter role (Thread Version 2) or it advertises poor CSL accuracy
or uncertainty.
2022-08-08 11:42:39 -07:00
Eduardo Montoya 5700f90590 [message] document buffer size needs (#7998)
With changes in #7554 the `Metadata` stuct size in `Message` increased,
leading to unsufficient message buffer size when the maximum number
of children is configured, due to the variable size of `ChildMask`.

Furthermore, enabling CoAP Blockwise option also extends the message
buffer size requirements.

This commit documents those cases and makes it clearer
for users how to overcome the possible building issues.
2022-08-08 11:06:59 -07:00
Steven Cooreman 0b41ae0a30 [crypto] allow selecting randomized ECDSA instead of deterministic (#7894)
There is no hard dependency in the Thread specification which requires
the use of deterministic signatures. On the contrary, looking at the
tinycrypt implementation, that one issues randomized ECDSA signatures
and seems to be quite happy with that.

This change does not change the default behaviour, which is to use
deterministic ECDSA when using the default MbedTLS backend. It does
however make it possible for platforms which have qualified hardware
entropy to select 'plain' ECDSA instead, which gives both a performance
and code size improvement on those platforms.
2022-08-08 10:27:12 -07:00
Abtin Keshavarzian cbbed06931 [mesh-forwarder] add Mac::Addresses (src and dst address) (#7990)
This commit adds a new struct `Mac::Addresses` which represents two
MAC addresses corresponding to source and destination. This type
is then used in `MeshForwarder` and `Lowpan` methods allowing us
to pass both source and destination addresses as one parameter.
2022-08-08 09:26:16 -07:00
Abtin Keshavarzian c28496dbd8 [routing-manager] add LocalOnLinkPrefix class (#7989)
This commit simplifies `RoutingManager` by adding a nested class
`LocalOnLinkPrefix` which encapsulates the local on-link prefix
related info and functionality. It tracks the state of the prefix,
i.e. whether we are advertising, deprecating or not including it. It
provides a method to append it as a PIO in an RA message and uses a
timer to keep track of the prefix's lifetime (since the last time it
was advertised in an RA message).

This commit also updated the `test_routing_manager` unit test to add
`TestLocalOnLinkPrefixDeprecation()` checking the deprecation and
expiration of local on-link prefix.
2022-08-08 09:24:10 -07:00
Jiachen Dong 62fcf85106 [thci] change implementation of sniffer simulation from SSH to gRPC (#7983)
The sniffer simulation now supports node filter functionality
(equivalent to RF enclosure in the real world).
2022-08-08 09:19:07 -07:00
whd 24fd146e10 [otci] wait for 2 seconds before retrying a command (#7995)
After a factoryreset the `ot-ctl` may fail to connect to the socket
for ~10 seconds. In such a situation, if OTCI sends a new command,
`execute_command` will receive an exception and will retry the same
command for several times. Such retries will immediately fail because
`ot-ctl` connection is still down and there's no time gap between two
retries.  Hence we should add some wait time before retrying so that
it gives `ot-ctl` some time to recover the connection.
2022-08-08 09:14:33 -07:00
Abtin Keshavarzian b2f8c4adba [cmake] enhance OT CMake config options (allow on/off/unspecified) (#7979)
This commit enhances OT CMake config options allowing them to use 3
values of "on", "off", and unspecified (empty string).

With this change is an `OT_{FEATURE}` option is set to "off", it is
explicitly disabled (`-DOPENTHREAD_CONFIG_{FEATURE}=0` is added which
defines the corresponding OT config as zero). This changes the CMake OT
option behavior from before where "off" was treated as unspecified.

If `OT_{FEATURE}` is left unspecified (or set to empty string), then
the related OT config is not defined by CMake build allowing it to be
to be determined by other means, e.g., a project specific config
header or default config specified in `src/core/config` header files).

This commit adds a CMake macro `ot_option()` to help simplify defining
CMake OT config options. This macro also help emit status messages
indicating the value of each OT config.
2022-08-05 19:56:53 -07:00
Simon Lin 2615d10db8 [border-agent] refine meshcop service state bitmap checks (#7950) 2022-08-04 21:18:19 -07:00
Abtin Keshavarzian cc72e29c88 [lowpan] update ComputeIid() and simplify CompressIid() (#7973)
This commit contains smaller enhancements and fixes in `Lowpan`
related to IID calculation and compression:

- It updates `ComputeIid()` to return `Iid` only.
- `ComputeIid()` now uses the newly added `ApplyPrefix()` which
  ensures the prefix bits are set in IID (if prefix len > 64).
- `CompressIid()` methods are simplified to use `IsLocator()`
   method to determine if the IID matches the locator pattern.
2022-08-04 20:19:56 -07:00
Abtin Keshavarzian 21c5bf7025 [ip6] add ApplyPrefix() to Ip6::InterfaceIdentifier (#7973)
This commit adds a new method `InterfaceIdentifier::ApplyPrefix()`
which applies a given prefix to an IID. This is applicable only when
the prefix length is longer than 64 bit. In this case, only the bits
in the IID up the prefix length are changed to match the prefix and
the remaining bits are left unchanged. This commit also updates the
unit test to validate the behavior of the new method.
2022-08-04 20:19:56 -07:00
Abtin Keshavarzian 3b0738542c [lowpan] update Context and add FindContext() methods (#7971)
This commit contains smaller enhancements in `Lowpan` related to
`Context`. It adds a new member variable `mIsValid` to this struct
which indicates whether we have a valid context. It also adds new
methods `FindContextForId()` and `FindContextToCompressAddress()`.
These methods will either retrieve a related context or `Clear()`
it (to indicate that there is no valid context and also set it ID
to zero which is the default used in lowpan compression).
2022-08-04 07:29:12 -07:00
Abtin Keshavarzian 4116b30c58 [config] add border_routing.h and border_agent.h (#7968)
This commit adds `border_routing.h` and `border_agent.h` header
files for OT configuration related to Border Routing Manager and
Border Agent (removing the definitions from `border_router.h`).
2022-08-04 07:27:10 -07:00
Sarah 9a104a814c [docs] CLI channel (#7957) 2022-08-02 12:54:10 -07:00
Abtin Keshavarzian c096c0e9ca [mesh-forwarder] use FrameBuidler in PrepareDataFrame() (#7964)
This commit updates `MeshForwarder::PrepareDataFrame()` to use
`FrameBuilder` to prepare the frame. It also updates `Lowpan`
fragment header definitions and adds `FirstFrag` and `NextFrag`
nested types. The unit test `test_lowpan` is also updated to
use the new types.
2022-08-02 12:43:51 -07:00
Abtin Keshavarzian e3f157402c [frame-builder] add Insert(), Remove() and other helper methods (#7964)
This commit adds `Insert()` and `Remove()` methods in `FrameBuilder`.
`Insert` can be used to insert new content in the frame at a given
offset moving any previously written content forward. `Remove()` can
be used to remove previously appended content from the frame moving
any content after the removed bytes backward. This commit also adds
`GetRemainingLength()` to get the remaining length (number of bytes
that can be appended) in the frame buffer, and `SetMaxLength()`. Unit
test `test_frame_builder` is also updated to validate all the newly
added methods.
2022-08-02 12:43:51 -07:00
Jonathan Hui 7af484f49f [docker] upgrade pip before installing cmake (#7970) 2022-08-01 21:48:36 -07:00
Jonathan Hui 184aef663a [github-actions] remove clang-6,7,8 from build check (#7969) 2022-08-01 18:48:08 -07:00
Abtin Keshavarzian 600ae09994 [test] update RoutingManager unit test to check default-route (#7940)
This commit updates `test_routing_manager` unit test to validate the
behavior of `RoutingMangaer` related to default route prefix (when AIL
routers advertise default route in RA header or as `::/0` prefix in an
RIO).
2022-08-01 10:44:32 -07:00
Abtin Keshavarzian 4e8eeccfe8 [test] update RoutingManager unit test adding new helper methods (#7951)
This commit updates `test_routing_manager` unit test and adds a new
set of helper methods to simplify the implementation of test-case:

- `VerifyOmrPrefixInNetData()` to check OMR prefix in Network Data.
- `VerifyExternalRoutesInNetData()` to check external route prefixes
   in Network Data.
- `VerifyPrefixTable()` to check the on-link and route prefixes in
  discovered prefix table.
- Different flavors of `SendRouterAdvert()` to send RA with different
  PIOs, RIOs, and default route info (in header).

This commit also breaks the test-cases into multiple functions each
covering specific aspect.
2022-07-28 17:26:49 -07:00
Abtin Keshavarzian 747a0a8069 [mle] fix incorrect StatusTlv when processing Child Update Response (#7956)
This commit fixes `MleRouter::HandleChildUpdateResponse()` to use the
MLE `StatusTlv` instead of `ThreadStatusTlv` when parsing a received
MLE Child Update Response (from a child).
2022-07-28 16:46:54 -07:00
Jonathan Hui 0b1e922a1d [mle] send Link Request immediately if router id was previously allocated (#7947)
After upgrading to a router, the device will wait until it receives a
Route TLV from a neighboring node indicating that the new Router ID
has been allocated. In normal cases, this is not an issue since the
Leader will disseminate a new Router ID Sequence after allocating a
new Router ID. However, in some scenarios, a device may request the
same Router ID that was previously allocated and significantly delay
establishing links with neighboring routers. With this commit, a
device will immediately send a Link Request if the Router ID was
previously allocated.
2022-07-28 07:27:57 -07:00
Abtin Keshavarzian b6ac79f61a [test] fix test_mle_msg_key_seq_jump (#7952)
This commit updates `test_mle_msg_key_seq_jump` to increase the wait
time after key index change for MLE advertisement transmissions. The
MLE advertisement uses trickle timer with max interval of 32 seconds.
Based on this the max interval between two consecutive advertisement
transmissions can be 1.5 times the trickle timer max interval or 48
seconds. The test uses 52 sec as wait time which includes a 4 sec
additional guard time to account for any action and/or message
exchanges after rx of an advertisement. This change should help
address the occasional failures of this test.
2022-07-27 18:58:47 -07:00
Abtin Keshavarzian 1c9373bb0c [mesh-forwarder] allow limiting max num of frames in direct tx queue (#7908)
This commit adds a new feature in `MeshForwarder` to specify a max
limit for the number of frames in tx queue marked for direct
transmission. `OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE`
specifies the maximum number. If set to zero then this behavior is
disabled, i.e., no check is performed on tx queue length.

This commit also adds a new message action log "Dropping (dir queue
full)" which indicates when a message is being dropped due to the
newly added check.
2022-07-27 13:39:51 -07:00
Abtin Keshavarzian c96bf599b7 [toranj] relax test-017-parent-reset-child-recovery pass condition (#7939)
This commit relaxes the pass condition for `test-017` which checks
that after a parent is reset it uses "MLE Child Update Request" to
recover its previous children. This is indirectly validated by
monitoring number of state/role changes on the children. With the
recent change which increases the number of MLE Parent Requests, the
window of time where parent is detached is increased and if during
this time a child tries to send to the parent it can detect that
parent is reset and detach itself causing the test to fail. This
commit relaxes the pass condition to at least one child recovering
using "Child Update" mechanism.
2022-07-27 07:21:44 -07:00
Abtin Keshavarzian 925b12cc08 [routing-manager] rename DiscoveredPrefixTable::Entry method to SetFrom() (#7949)
This commit renames the `DiscoveredPrefixTable::Entry` method to
`SetFrom()` from `InitFrom()` to make it clear that this method can
be used on an existing entry to update it.
2022-07-26 20:53:31 -07:00
Abtin Keshavarzian 12d35f3dfa [routing-manager] ensure to clear the prefix for default route (#7948)
This commit fixes the method setting the prefix table entry from
RA header as a default route by clearing `mPrefix` variable so
to set it as `::/0`.
2022-07-26 20:52:53 -07:00
Jonathan Hui 32ac6ddfad [bootstrap] apply shfmt diffs (#7946) 2022-07-26 14:51:14 -07:00
Abtin Keshavarzian 209716aa19 [routing-manager] enhance selection of prefixes to advertise as RIO (#7936)
This commit updated how `RoutingManager` selects the set of prefixes
to advertise as RIO in emitted RA messages from the BR.  The related
code is now moved to `SendRouterAdvertisement()` method (instead of
previously being in `EvaluateOmrPrefix()`). Since the array for
storing the advertised prefixes has a limited size (configurable
through an OT build-time setting), we add more important prefixes
first in the array to ensure that they are advertised in the RA
message. The following order is used: (1) Local OMR prefix (if
added in Network Data), (2) currently favored OMR prefix, (3) any
other OMR prefixes from Network Data, (4) any other on-mesh prefix
(excluding Domain Prefix) from Network Data.
2022-07-26 12:41:07 -07:00
Abtin Keshavarzian 5755797937 [routing-manager] fix DiscoveredPrefixTable::Entry leak (#7945)
This commit fixes an issue with the potential overwriting of `mNext`
when existing entry in the list is updated (avoid calling `Clear()`).
It also updates `test_routing_manager` to check such a situation
and ensure that the fix is addressing the issue.
2022-07-26 12:24:35 -07:00
Thomas 47b42bb8d9 [ncp] fixes -Werror=missing-field-initializers (#7942)
The uninitialized fields cause compile errors on some systems, this
commit fixes this.
2022-07-26 11:17:36 -07:00
Abtin Keshavarzian a282aa9f9b [core] adding FrameBuilder for constructing frames (#7935)
This commit adds a new class `FrameBuilder` which helps with
construction of frames in a given buffer. It provides helper methods
to append different items to the frame, e.g., bytes from a buffer or
`Message`, a `uint8`, `uint16` or `uint32` value assuming big or
little endian encoding, or a given object. It also provides methods
to overwrite previously appended content in the frame at a given
offset. This class is used in `Lowpan` (replacing `BufferWriter`)
which helps simplify the code. This commit also updates `Appender` to
use the `FrameBuilder` and adds a new unit test for `FrameBuidler`.
2022-07-25 19:59:55 -07:00
Abtin Keshavarzian 5bc71b2a4f [message] allow msg pool using external heap (#7933)
This commit updates the code to allow the config combination of
`OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE` along using external heap
`OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE`. This commit updates `Message`
`GetFreeBufferCount()` and `GetTotalBufferCount()` methods to return
special value `0xffff` under this config combo indicating the numbers
cannot be estimated.

This commit also updates `check-simulation-build-autotools` to add
such a build config so to be covered as part OT CI tests.
2022-07-22 15:43:48 -07:00
Abtin Keshavarzian 390efb4c38 [srp-client] add random short delay before sending update message (#7863)
This commit updates the `Srp::Client` to add a randomly chosen short
delay before delay wait time before sending an update message. This
replaces the current model which was adding a fixed short delay.
Selecting the delay randomly helps in situations where some common
event triggers multiple SRP clients on Thread mesh to send an SRP
update(e.g., new OMR prefix causing new addresses, or a server entry
change on Thread Network Data).
2022-07-22 11:16:46 -07:00
Luis Ubieda 1f2a315acf [cmake] update option to enable CoAP Observe through CMake (#7932)
Change the definition of OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE
through target_compile_detinifions().

Signed-off-by: Luis Ubieda <luisubiedas@gmail.com>
2022-07-21 22:25:08 -07:00
Jiachen Dong 12933d3f86 [harness] add functionality to discover and control simulations (#7901)
It can run all the Thread 1.1 test cases with simulations as a role of
Router now except those requiring RF enclosure.
2022-07-21 21:49:34 -07:00
Abtin Keshavarzian 19ca3a0a3c [test] add unit test test_routing_manager (#7927)
This commit adds a unit test for `RoutingManager` which builds a
foundation for writing test cases covering different behaviors of
`RoutingManager`, e.g., validating emitted router advertisements,
sending custom RA messages from different routers on AIL, adding or
removing entries in Network Data while monitoring the behavior of
`RoutingManager`.
2022-07-21 21:43:11 -07:00
Abtin Keshavarzian 96819f934a [routing-manager] new API to get currently favored OMR prefix (#7913)
This commit updates `RoutingManager` to remember the currently favored
OMR prefix (which can be an OMR prefix discovered from Network Data
or device's local OMR prefix). It adds a new public API to retrieve
this prefix and adds a related CLI sub-command.
2022-07-21 21:32:52 -07:00
Abtin Keshavarzian 19181047fd [routing-manager] advertise all on-mesh prefixes as RIOs in emitted RAs (#7900)
This commit changes `RoutingManager` so to include all on-mesh
prefixes from Thread Network Data excluding domain prefix as Route
Info Option in the emitted Router Advertisement messages.
2022-07-21 14:26:21 -07:00
Jonathan Hui 6809b33f31 [github-actions] update to macos-12 (#7930)
macos-10.15 is deprecated.
2022-07-21 13:08:26 -07:00
Yi bec3a5edb0 [nat64] fix build options for NAT64 tests (#7929)
This commit fixes the build options for NAT64 tests. A new option was
added in ot-br-posix recently.
2022-07-21 07:22:27 -07:00
Eduardo Montoya 424005f695 [csl] test resync after parent is down for a long period (#7915)
Add test steps to verify that a CSL Receiver is able to re-establish
CSL synchronization after its peer has been absent for a long period.
2022-07-20 15:11:34 -07:00
Abtin Keshavarzian 7b60716713 [csl] ensure SubMacis informed when CSL support changes (#7918)
This commit changes `Mac::UpdateCsl()` to ensure we inform `SubMac`
and disable CSL when CSL support changes (e.g., device gets
detached). This ensures that `SubMac` internal variables (CSL period,
channel) are updated on a detach and if the device later attaches
again, we detect the change in CSL configuration and trigger the tx
of MLE Child Update Request.
2022-07-20 15:11:34 -07:00
Paweł Wańczyk ed0334f626 [routing-table] do not reset LastHeard timestamp when removing router link (#7879) 2022-07-20 15:09:28 -07:00
Abtin Keshavarzian f98f89adfe [core] replace uses of OT_ERROR_{} with kError{} in core modules (#7919) 2022-07-19 21:45:55 -07:00
Robert Quattlebaum 8095a086d7 [bootstrap] Explicitly use arm-none-eabi-gcc from armmbed (#7917)
The bootstrap script taps `armmbed/formulae`, and then tries
to install `arm-none-eabi-gcc` from that tap. However, if the
user has already tapped a different tap that offers
`arm-none-eabi-gcc`, then the install will fail.

This change removes the ambiguity of the install by specifying
the tap to use.
2022-07-19 14:35:19 -07:00
Sarah c73db3ff2f [docs] add NAT64 to Doxygen (#7916)
I added the group definition under IPv6 Networking.
2022-07-19 13:21:20 -07:00
Simon Lin e538aad095 [thci] find border agents with non link-local addresses (#7853)
Thread BR may advertise IPv6 GUA rather than LLA. For example, Avahi
stops publishing LLA when any GUA is found on the network interface.

This commit enhances mdns_query to find border agents with
non-link-local addresses.
2022-07-19 09:12:17 -07:00
Simon Lin 6242a1e68e [thci] allow to specify custom commands (#7912)
This commit uses `Param9` to specify custom commands for Thread BR
THCI to control `otbr-agent`.
2022-07-19 08:51:20 -07:00
Yi 095f530bd7 [nat64] run nat64 ci tests as an independent job (#7885)
This commit changes the NAT64 CI tests to be ran as an independent
job. A new /nat64 folder is added and it would make it easier to
configure new NAT64 tests in the future.
2022-07-18 14:15:00 -07:00
Eduardo Montoya a68cd059cc [csl] update CSL information in radio when parent changes (#7911)
Cover the case of parent change while the CSL child is still attached.
2022-07-18 14:12:20 -07:00
Abtin Keshavarzian ec96609070 [test] fix "unused result warning" in newly updated unit tests (#7905) 2022-07-18 14:10:54 -07:00
Sarah 78f8437c3b [docs] update CLI comments (#7902) 2022-07-16 18:41:13 -07:00
Yakun Xu 793483da0d [size-report] fix markdown viewer (#7906) 2022-07-16 08:19:14 -07:00
Song GUO 03c9b9389d [nat64] add functions for processing IPv4 packets (#7824)
With NAT64, we need to handle the IPv4 packets inside the border
router functions in OpenThread core.

This commit introduces a few new classes for NAT64:
- Add `Ip4::Cidr` (for specifying CIDR block of translated packets)
- Updated Ip4 address format -- use a union of (m8[4], m16[2], m32)
  instead of 4 bytes.
- Extend `Checksum` for supporting ICMP in Ip4 (and TCP4 / UDP4) and
  IPv4 header.
2022-07-15 10:54:20 -07:00
Abtin Keshavarzian 13416b15fb [core] adding FrameData class for parsing frames (#7892)
This commit adds a new class `FrameData` which is a sub-class of
`Data` (acts as a wrapper over a buffer pointer and a length). It is
used in `MeshForwarder` and `Lowpan` to simplify the method calls
(can pass `FrameData` instance instead of pointer and length). It
also provides helper methods for parsing the frame content (e.g.,
reading `uint16/32` value assuming big or little endian encoding).
When read successfully, the `FrameData` is updated to skip over the
read content. These methods help simplify `Lowpan` parsing and
decompression code. In particular the `Lowpan` methods now directly
update the passed-in `FrameData` to skip over the parsed header
portion (instead of returning the parsed header length).
2022-07-14 17:04:47 -07:00
Zhanglong Xia 366786dbed [posix] add a vendor interface for the radio spinel layer (#7884)
This commit adds a vendor interface for developers to implement
the bus interface by themselves.
2022-07-14 13:10:51 -07:00
Abtin Keshavarzian 0ec9612379 [docs] add plat-infra-if and api-border-routing doxygen groups (#7898) 2022-07-13 19:59:47 -07:00
Eduardo Montoya 648770a8ad [cli] fix endif comment (#7896) 2022-07-13 08:11:27 -07:00
Abtin Keshavarzian 78e3b28127 [routing-manager] fix typos in method/variable names (#7895) 2022-07-12 10:51:12 -07:00
Abtin Keshavarzian 158e59f267 [tmf] update IsTmfMessage() method (#7875)
This commit updates `Tmf::IsTmfMessage()` method to check source and
destination addresses. This change helps make this method more
generic(allow it to be used for both rx/tx messages). This commit
also simplifies the implementation (avoid using complex expression
containing multiple `&&` and `||`).
2022-07-12 10:15:34 -07:00
Abtin Keshavarzian eca7a63adc [toranj] make test-017 more robust (#7888)
This commit updates `test-017-parent-reset-child-recovery.py` to make
it more robust by increasing the wait time for children to be
recovered after parent/leader reset. This is related to the increase
in data poll period of sleepy children to 10 sec which was done
previously to accommodate for the increased start-up time of leader
(due to change in number of MLE Parent Requests).
2022-07-11 11:59:34 -07:00
Abtin Keshavarzian 6e0eb8addf [mesh-forwarder] simplify CheckReachability() and Icmp::SendError() (#7887)
A new flavor of `Icmp::SendError()` is added which allows the caller
to provide the parsed `Ip6::Headers` of the error-causing message
instead the full `Message` instance. Note that the implementation of
`SendError()` only includes the IPv6 header of the error-causing
message in the payload of the ICMPv6 error message.

`MeshForwarder::CheckReachability()` method is updated to use the
recently added `Ip6::Headers` to parse the IPv6 headers from the
received frame. With the changes in this commit, we no longer need to
allocate a temporary `Message` which was used for reading the
decompressed IPv6 header and also to pass to `Icmp::SendError()` in
case of "destination unreachable" error.
2022-07-11 11:59:06 -07:00
Abtin Keshavarzian 5876ff79ae [routing-manager] add public API to get discovered prefix table (#7877)
This commit adds new public OT APIs to iterate over the Border Router
discovered prefix table from received Router Advertisement messages.
It also adds new CLI command to output the prefix table. The new APIs
are primary intended for testing.
2022-07-11 11:58:27 -07:00
Abtin Keshavarzian 75ecf8d260 [api] add border_routing.h header for otBorderRouting APIs (#7877)
This commit adds `<openthread/border_routing.h`> header and moves
all the `otBorderRouting` APIs (which are related to Border Routing
Manager) into this header. It also adds a note that these APIs are
available when `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is enabled.
It also adds `border_routing_api.cpp` source file for the API
implementation.
2022-07-11 11:58:27 -07:00
3438 changed files with 347292 additions and 518671 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
@@ -55,11 +55,11 @@ DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
IncludeCategories:
- Regex: '^<openthread/.*/'
Priority: 4
- Regex: '^<openthread/'
+23
View File
@@ -0,0 +1,23 @@
---
Checks: >
-*,
bugprone-argument-comment,
bugprone-too-small-loop-variable,
google-explicit-constructor,
google-readability-casting,
misc-unused-using-decls,
modernize-loop-convert,
modernize-use-bool-literals,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,
readability-avoid-const-params-in-decls,
readability-else-after-return,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-redundant-control-flow,
readability-redundant-member-init,
readability-simplify-boolean-expr,
readability-static-accessed-through-instance
WarningsAsErrors: '*'
HeaderFilterRegex: '(examples|include|src).*(?<!third_party.*repo)'
+10
View File
@@ -0,0 +1,10 @@
have_fun: false
code_review:
disable: false
comment_severity_threshold: MEDIUM
max_review_comments: -1
pull_request_opened:
help: false
summary: true
code_review: true
include_drafts: true
-18
View File
@@ -18,21 +18,3 @@
*.png binary !eol
*.jpg binary !eol
*.gif binary !eol
# Files normalized to always keep Unix line endings
.default-version eol=lf
bootstrap* eol=lf
config.guess eol=lf
config.status eol=lf
configure eol=lf
libtool eol=lf
libtoolize eol=lf
autoreconf eol=lf
mkversion eol=lf
*.sh eol=lf
*-sh eol=lf
*.m4 eol=lf
configure.ac eol=lf
Makefile.am eol=lf
Makefile.in eol=lf
Makefile eol=lf
+39
View File
@@ -0,0 +1,39 @@
#
# Copyright (c) 2022, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
version: 2
updates:
- package-ecosystem: "github-actions"
if: github.repository == "openthread/openthread"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "github-actions"
rebase-strategy: "disabled"
open-pull-requests-limit: 1
+202 -128
View File
@@ -28,61 +28,111 @@
name: Build
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
pretty:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-format-9 clang-tidy-9 shellcheck
python3 -m pip install yapf==0.31.0
sudo apt-get update
sudo apt-get --no-install-recommends install -y shellcheck iwyu
sudo bash script/install-llvm.sh
python3 -m pip install yapf==0.43.0
sudo snap install shfmt
npm install prettier@2.0.4
- name: Check
run: |
script/make-pretty check
script/check-iwyu-public-header
markdown-lint-check:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
use-verbose-mode: 'yes'
max-depth: 3
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
cmake-version:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Run linkspector
uses: umbrelladocs/action-linkspector@652f85bc57bb1e7d4327260decc10aa68f7694c3 # v1.4.0
with:
submodules: true
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_on_error: true
cmake-presets:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo pip3 install --system -U cmake==3.10.3
sudo apt-get --no-install-recommends install -y build-essential ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
cmake --preset simulation
cmake --build --preset simulation
ctest --preset simulation
cmake-version:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y build-essential ninja-build libreadline-dev libncurses-dev
sudo apt-get remove cmake
sudo apt-get purge --auto-remove cmake
wget http://www.cmake.org/files/v3.10/cmake-3.10.3.tar.gz
tar xf cmake-3.10.3.tar.gz
cd cmake-3.10.3
./configure
sudo make install
cmake --version | grep 3.10.3
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
OT_NODE_TYPE=rcp ./script/test build
package:
name: package-${{ matrix.compiler }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
@@ -97,53 +147,63 @@ jobs:
CC: ${{ matrix.compiler_c }}
CXX: ${{ matrix.compiler_cpp }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Package
run: |
script/test package
scan-build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-tools-9 ninja-build
sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-tools-14 ninja-build
- name: Run
run: |
script/check-scan-build
mbedtls3-build:
runs-on: ubuntu-18.04
mbedtls2-build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
rm -rf third_party/mbedtls/repo
- uses: actions/checkout@v2
with:
repository: ARMmbed/mbedtls
ref: v3.1.0
path: third_party/mbedtls/repo
cd third_party/mbedtls/repo && git fetch --tags && git checkout tags/v2.28.8
- name: Build
run: |
./script/test build
OT_OPTIONS='-DCMAKE_POLICY_VERSION_MINIMUM=3.5' ./script/test build
arm-gcc:
name: arm-gcc-${{ matrix.gcc_ver }}
runs-on: ubuntu-18.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
@@ -163,42 +223,66 @@ jobs:
- gcc_ver: 9
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-9-2019-q4-major
- gcc_ver: 10
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-10.3-2021.10
- gcc_ver: 11
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz
gcc_extract_dir: arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi
- gcc_ver: 12
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz
gcc_extract_dir: arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi
- gcc_ver: 13
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi.tar.xz
gcc_extract_dir: arm-gnu-toolchain-13.3.rel1-x86_64-arm-none-eabi
- gcc_ver: 14
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi.tar.xz
gcc_extract_dir: arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
cd /tmp
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y lib32z1 ninja-build gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
wget --tries 4 --no-check-certificate --quiet ${{ matrix.gcc_download_url }} -O gcc-arm.tar.bz2
tar xjf gcc-arm.tar.bz2
# use the minimal required cmake version
sudo pip3 install --system -U cmake==3.10.3
cmake --version | grep 3.10.3
sudo apt-get update
sudo apt-get --no-install-recommends install -y build-essential lib32z1 ninja-build gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
wget --tries 4 --no-check-certificate --quiet ${{ matrix.gcc_download_url }} -O gcc-arm
tar xf gcc-arm
- name: Build
env:
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
export PATH=/tmp/${{ matrix.gcc_extract_dir }}/bin:$PATH
script/check-arm-build
gcc:
name: gcc-${{ matrix.gcc_ver }}
runs-on: ubuntu-18.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
gcc_ver: [5, 6, 7, 8, 9, 10, 11]
gcc_ver: [9, 10, 11, 12]
env:
CC: gcc-${{ matrix.gcc_ver }}
CXX: g++-${{ matrix.gcc_ver }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get update
case ${{ matrix.gcc_ver }} in
11)
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
@@ -212,85 +296,52 @@ jobs:
clang:
name: clang-${{ matrix.clang_ver }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
clang_ver: ["6.0", "7", "8", "9", "10", "11", "12", "13"]
clang_ver: ["17", "18", "19"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/*
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main
# 13
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main' | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
script/check-simulation-build
script/check-posix-build
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
clang-m32:
name: clang-m32-${{ matrix.clang_ver }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
clang_ver: ["6.0", "7", "8", "9", "10", "11", "12", "13"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
CFLAGS: -m32 -Wconversion
CXXFLAGS: -m32 -Wconversion
LDFLAGS: -m32
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
submodules: recursive
- name: Bootstrap
run: |
sudo dpkg --add-architecture i386
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main
# 13
deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main
deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main' | sudo tee -a /etc/apt/sources.list
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh ${{ matrix.clang_ver }}
sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} ninja-build
sudo apt-get --no-install-recommends install -y g++-multilib libreadline-dev:i386 libncurses-dev:i386
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
script/check-simulation-build
script/check-posix-build
gn:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build
cd /tmp
wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
unzip -o gn.zip
chmod a+x gn && mkdir -p bin && mv -f gn bin/
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build gn
- name: Build
run: |
export PATH=/tmp/bin:$PATH
script/check-gn-build
macos:
@@ -303,32 +354,55 @@ jobs:
CXX: clang++
- CC: gcc
CXX: g++
runs-on: macos-10.15
runs-on: macos-14
env:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
rm -f '/usr/local/bin/2to3'
brew update
brew install automake m4 ninja
[ ${{ matrix.CC }} != clang ] || brew install llvm
wget --tries 4 https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip
unzip ninja-mac.zip && mv ninja /usr/local/bin/.
- name: Build
run: |
export PATH=$(brew --prefix m4)/bin:$PATH
script/check-posix-build
script/check-simulation-build
android:
runs-on: ubuntu-20.04
android-ndk:
name: android-ndk
runs-on: ubuntu-24.04
container:
image: openthread/environment
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Install unzip
run: apt update && apt install -y unzip
- name: Setup NDK
id: setup-ndk
uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410 # v1.5.0
with:
ndk-version: r25c
local-cache: true
- name: Build
env:
NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
docker run --rm -v $PWD:/build/openthread openthread/android-trusty /build/openthread/script/check-android-build
rm -rf build/ && OT_CMAKE_NINJA_TARGET="ot-daemon ot-ctl" script/cmake-build android-ndk
rm -rf build/ && OT_CMAKE_NINJA_TARGET="ot-cli" script/cmake-build android-ndk
+86
View File
@@ -0,0 +1,86 @@
#
# Copyright (c) 2022, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Initialize CodeQL
uses: github/codeql-action/init@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
- run: |
./script/test build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
with:
category: "/language:${{matrix.language}}"
+121 -52
View File
@@ -28,70 +28,139 @@
name: Docker
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
env:
DOCKERHUB_REPO: openthread/environment
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
buildx:
name: buildx-${{ matrix.docker_name }}
runs-on: ubuntu-20.04
build:
strategy:
fail-fast: false
matrix:
include:
- docker_name: environment
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=openthread/${{ matrix.docker_name }}
DOCKER_FILE=etc/docker/${{ matrix.docker_name }}/Dockerfile
DOCKER_PLATFORMS=linux/amd64
VERSION=latest
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg OT_GIT_REF=${{ github.sha }} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file ${DOCKER_FILE} .
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
${{ env.DOCKERHUB_REPO }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to DockerHub
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push by digest
if: success()
id: build
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
file: etc/docker/environment/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }}",push-by-digest=true,name-canonical=true
push: ${{ github.repository == 'openthread/openthread' && github.event_name != 'pull_request' }}
- name: Docker Buildx (push)
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Export digest
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Inspect Image
if: always() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
- name: Upload digest
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
merge:
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Download digests
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
${{ env.DOCKERHUB_REPO }}
tags: |
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }}
+59 -21
View File
@@ -27,25 +27,63 @@
#
name: CIFuzz
on: [pull_request]
on:
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
Fuzzing:
runs-on: ubuntu-20.04
steps:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
fuzz-seconds: 1800
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure()
with:
name: artifacts
path: ./out/artifacts
Fuzzing:
runs-on: ubuntu-24.04
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined]
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
language: 'c++'
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
language: 'c++'
fuzz-seconds: 1800
sanitizer: ${{ matrix.sanitizer }}
output-sarif: true
- name: Upload Crash
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
- name: Upload Sarif
if: always() && steps.build.outcome == 'success'
uses: github/codeql-action/upload-sarif@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
with:
sarif_file: cifuzz-sarif/results.sarif
checkout_path: cifuzz-sarif
+35 -12
View File
@@ -28,23 +28,46 @@
name: Makefile Check
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
makefile-check:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Check
run: |
script/check-core-makefiles
header-guard-check:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Check
run: |
script/check-header-guards
+74
View File
@@ -0,0 +1,74 @@
#
# Copyright (c) 2026, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
name: Nexus
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
nexus-tests:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo add-apt-repository -y ppa:wireshark-dev/stable
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -y ninja-build tshark
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build Nexus
run: |
mkdir -p build/nexus
top_builddir=build/nexus ./tests/nexus/build.sh
- name: Run Nexus Tests
run: |
top_builddir=build/nexus ./tests/nexus/run_nexus_tests.sh
+87 -58
View File
@@ -28,25 +28,31 @@
name: Border Router
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
backbone-router:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 0
TEST_TIMEOUT: 1800
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.3
THREAD_VERSION: 1.4
INTER_OP: 1
COVERAGE: 1
MULTIPLY: 1
@@ -56,19 +62,21 @@ jobs:
# packet verification can't handle it because of the order of context ID
# of OMR prefix and Domain prefix is not deterministic.
BORDER_ROUTING: 0
DISCOVERY_PROXY: 0
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
submodules: recursive
- name: Build OTBR Docker
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
./script/test build_otbr_docker
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build socat lcov
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build lcov
sudo bash script/install_socat
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
@@ -80,31 +88,33 @@ jobs:
run: |
export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
echo "CI_ENV=${CI_ENV}"
sudo -E ./script/test cert_suite ./tests/scripts/thread-cert/backbone/*.py || (sudo chmod a+r *.log *.json *.pcap && false)
- uses: actions/upload-artifact@v2
sudo -E ./script/test cert_suite ./tests/scripts/thread-cert/backbone/*.py || (sudo chmod a+r ot_testing/* && false)
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-1-3-backbone-docker
path: /tmp/coverage/
- uses: actions/upload-artifact@v2
retention-days: 1
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: thread-1-3-backbone-results
path: |
*.pcap
*.json
*.log
coredump_*
otbr-agent_*
ot_testing/*.pcap
ot_testing/*.json
ot_testing/*.log
ot_testing/coredump_*
ot_testing/otbr-agent_*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-1-3-backbone
path: tmp/coverage.info
retention-days: 1
thread-border-router:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
@@ -113,38 +123,52 @@ jobs:
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 1
nat64: 0
description: ""
- otbr_mdns: "mDNSResponder"
otbr_trel: 1
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 2
nat64: 0
description: ""
- otbr_mdns: "mDNSResponder"
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/MATN/*.py
packet_verification: 1
nat64: 0
description: "MATN"
- otbr_mdns: "mDNSResponder"
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/LowPower/*.py
packet_verification: 1
nat64: 0
description: "LowPower"
- otbr_mdns: "mDNSResponder"
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/internet/*.py
packet_verification: 1
nat64: 1
description: "internet access"
- otbr_mdns: "avahi"
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 1
nat64: 0
description: ""
- otbr_mdns: "avahi"
otbr_trel: 1
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
packet_verification: 2
description: ""
packet_verification: 1
nat64: 0
use_core_firewall: 1
description: "core-firewall"
name: BR ${{ matrix.description }} (${{ matrix.otbr_mdns }}, TREL=${{matrix.otbr_trel}})
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 0
TEST_TIMEOUT: 1800
PACKET_VERIFICATION: ${{ matrix.packet_verification }}
THREAD_VERSION: 1.3
THREAD_VERSION: 1.4
INTER_OP: 1
COVERAGE: 1
MULTIPLY: 1
@@ -152,19 +176,27 @@ jobs:
PYTHONUNBUFFERED: 1
VERBOSE: 1
BORDER_ROUTING: 1
NAT64: ${{ matrix.nat64 }}
MAX_JOBS: 3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Set firewall environment variables
if: ${{ matrix.use_core_firewall }}
run: |
echo "FIREWALL=0" >> $GITHUB_ENV
- name: Build OTBR Docker
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
TREL: ${{ matrix.otbr_trel }}
run: |
./script/test build_otbr_docker
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build socat lcov
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build lcov
sudo bash script/install_socat
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
@@ -176,60 +208,57 @@ jobs:
run: |
export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
echo "CI_ENV=${CI_ENV}"
sudo -E ./script/test cert_suite ${{ matrix.cert_scripts }} || (sudo chmod a+r *.log *.json *.pcap && false)
- uses: actions/upload-artifact@v2
sudo -E ./script/test cert_suite ${{ matrix.cert_scripts }} || (sudo chmod a+r ot_testing/* && false)
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-border-router-docker
name: cov-br-docker-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
path: /tmp/coverage/
- uses: actions/upload-artifact@v2
retention-days: 1
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: thread-border-router-results
name: br-results-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
path: |
*.pcap
*.json
*.log
coredump_*
otbr-agent_*
ot_testing/*.pcap
ot_testing/*.json
ot_testing/*.log
ot_testing/coredump_*
ot_testing/otbr-agent_*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-border-router
name: cov-br-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs:
- backbone-router
- thread-border-router
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
continue-on-error: true
run: |
script/test combine_coverage
- name: Upload Coverage
continue-on-error: true
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
delete-coverage-artifacts:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@1-glob-support
with:
name: cov-*
useGlob: true
+38 -18
View File
@@ -28,45 +28,65 @@
name: OTCI
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
cli-sim:
name: cli-sim VIRTUAL_TIME=${{ matrix.virtual_time }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
virtual_time: [0, 1]
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: ${{ matrix.virtual_time }}
OT_VT_USE_UNIX_SOCKET: ${{ matrix.virtual_time }}
REAL_DEVICE: 0
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
python3 -m pip install pytype adb-shell
- name: Style check
run: |
PYTHONPATH=./tests/scripts/thread-cert pytype tools/otci
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation THREAD_VERSION=1.3 DUA=1 MLR=1 BACKBONE_ROUTER=1 CSL_RECEIVER=1
./script/cmake-build simulation -DOT_THREAD_VERSION=1.4 -DOT_DUA=ON -DOT_MLR=ON -DOT_BACKBONE_ROUTER=ON \
-DOT_CSL_RECEIVER=ON -DOT_SIMULATION_VIRTUAL_TIME=${VIRTUAL_TIME}
- name: Install OTCI Python Library
run: |
(cd tools/otci && python3 setup.py install --user)
(cd tools/otci && python3 -m pip install .)
- name: Run
run: |
export PYTHONPATH=./tests/scripts/thread-cert/
export OT_CLI=./output/simulation/bin/ot-cli-ftd
export OT_CLI=./build/simulation/examples/apps/cli/ot-cli-ftd
python3 tools/otci/tests/test_otci.py
+78 -49
View File
@@ -28,7 +28,17 @@
name: OTNS
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
env:
COVERAGE: 1
@@ -36,35 +46,36 @@ env:
VIRTUAL_TIME: 1
VIRTUAL_TIME_UART: 1
MAX_NETWORK_SIZE: 999
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
unittests:
name: Unittests
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
go-version: '1.14'
- name: Set up Python 3.6
uses: actions/setup-python@v1
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
python-version: 3.6
submodules: recursive
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: "1.23"
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build
./bootstrap
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build
- name: Run
run: |
export OT_DIR=$PWD
@@ -73,7 +84,7 @@ jobs:
cd /tmp/otns
./script/test py-unittests
)
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: unittests-pcaps
@@ -83,28 +94,30 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-otns-unittests
path: tmp/coverage.info
retention-days: 1
examples:
name: Examples
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
go-version: '1.14'
- name: Set up Python 3.6
uses: actions/setup-python@v1
submodules: recursive
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
python-version: 3.6
go-version: "1.23"
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build
./bootstrap
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build
- name: Run
run: |
export OT_DIR=$PWD
@@ -113,7 +126,7 @@ jobs:
cd /tmp/otns
./script/test py-examples
)
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: examples-pcaps
@@ -123,14 +136,14 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-otns-examples
path: tmp/coverage.info
stress-tests:
name: Stress ${{ matrix.suite }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
@@ -150,19 +163,25 @@ jobs:
env:
STRESS_LEVEL: ${{ matrix.stress_level }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
go-version: '1.14'
- name: Set up Python 3.6
uses: actions/setup-python@v1
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
python-version: 3.6
submodules: recursive
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version: "1.23"
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build
./bootstrap
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build
- name: Run
run: |
export OT_DIR=$PWD
@@ -171,7 +190,7 @@ jobs:
cd /tmp/otns
./script/test stress-tests ${{ matrix.suite }}
)
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: stress-tests-${{ matrix.suite }}-pcaps
@@ -181,25 +200,35 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-otns-stress-tests-${{ matrix.suite }}
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs:
- unittests
- examples
- stress-tests
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Upload Coverage
run: |
script/test upload_codecov
+155 -95
View File
@@ -28,40 +28,62 @@
name: POSIX
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
expects-linux:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
env:
CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
sudo bash script/install_socat
pip install bleak 'cryptography==43.0.0'
- name: Run RCP Mode
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
OT_OPTIONS='-DOT_READLINE=OFF -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED' VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test build expect
- name: Run ot-fct
run: |
OT_CMAKE_NINJA_TARGET="ot-fct" script/cmake-build posix
tests/scripts/expect/ot-fct.exp
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_RCP=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED_RCP == '1' }}
with:
name: core-expect-rcp
@@ -70,19 +92,21 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-expects-linux-1
path: tmp/coverage.info
retention-days: 1
- name: Run TUN Mode
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get install --no-install-recommends -y dnsmasq bind9-host ntp
sudo systemctl start dnsmasq ntp
host ipv6.google.com 127.0.0.1
echo 'listen-address=::1' | sudo tee /etc/dnsmasq.conf
sudo apt-get update
echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
sudo systemctl restart dnsmasq
sudo apt-get install --no-install-recommends -y bind9-host ntp
sudo bash script/install_socat
sudo systemctl restart ntp
sudo socat 'UDP6-LISTEN:53,fork,reuseaddr,bind=[::1]' UDP:127.0.0.53:53 &
socat 'TCP6-LISTEN:2000,fork,reuseaddr' TCP:127.0.0.53:53 &
host ipv6.google.com 127.0.0.53
host ipv6.google.com ::1
ulimit -c unlimited
./script/test prepare_coredump_upload
@@ -93,13 +117,13 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_TUN=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED_TUN == '1' }}
with:
name: core-expect-linux
path: |
./ot-core-dump/*
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: syslog-expect-linux
@@ -107,81 +131,60 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-expects-linux-2
path: tmp/coverage.info
retention-days: 1
thread-cert:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
COVERAGE: 1
PYTHONUNBUFFERED: 1
READLINE: readline
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
VIRTUAL_TIME_UART: 1
OT_VT_USE_UNIX_SOCKET: 1
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y libreadline6-dev python3-setuptools python3-wheel lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
make -f src/posix/Makefile-posix
OT_NODE_TYPE=rcp ./script/test build
- name: Run
run: |
VERBOSE=1 OT_CLI_PATH="$PWD/output/posix/bin/ot-cli -v" RADIO_DEVICE="$PWD/output/simulation/bin/ot-rcp" make -f src/posix/Makefile-posix check
- uses: actions/upload-artifact@v2
MAX_JOBS=$(getconf _NPROCESSORS_ONLN) ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: thread-cert
path: build/posix/tests/scripts/thread-cert
path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-cert
path: tmp/coverage.info
ncp-rcp-migrate:
runs-on: ubuntu-20.04
env:
COVERAGE: 1
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y expect lcov
- name: Build
run: |
./bootstrap
script/check-ncp-rcp-migrate build
- name: Run
run: |
script/check-ncp-rcp-migrate check
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
with:
name: cov-ncp-rcp-migrate
path: tmp/coverage.info
pty-linux:
name: pty-linux OT_DAEMON=${{ matrix.OT_DAEMON }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
@@ -191,11 +194,19 @@ jobs:
OT_DAEMON: ${{ matrix.OT_DAEMON }}
OT_READLINE: 'readline'
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y socat expect lcov net-tools ninja-build
sudo apt-get update
sudo apt-get --no-install-recommends install -y expect lcov libreadline-dev net-tools ninja-build
sudo bash script/install_socat
cd /tmp
wget https://github.com/obgm/libcoap/archive/bsd-licensed.tar.gz
tar xvf bsd-licensed.tar.gz
@@ -219,14 +230,38 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-pty-linux-${{ matrix.DAEMON }}
name: cov-pty-linux-${{ matrix.OT_DAEMON }}
path: tmp/coverage.info
retention-days: 1
infra-if-index-changed-linux:
name: infra-if-index-changed-linux
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y net-tools ninja-build
- name: Build
run: |
script/check-infra-if-index-changed build
- name: Run
run: |
script/check-infra-if-index-changed check
pty-macos:
name: pty-macos OT_DAEMON=${{ matrix.OT_DAEMON }}
runs-on: macos-10.15
runs-on: macos-14
strategy:
fail-fast: false
matrix:
@@ -235,12 +270,29 @@ jobs:
OT_DAEMON: ${{ matrix.OT_DAEMON }}
OT_READLINE: 'off'
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
rm -f '/usr/local/bin/2to3'
rm -f /usr/local/bin/2to3
rm -f /usr/local/bin/2to3-3.11
rm -f /usr/local/bin/idle3
rm -f /usr/local/bin/idle3.11
rm -f /usr/local/bin/pydoc3
rm -f /usr/local/bin/pydoc3.11
rm -f /usr/local/bin/python3
rm -f /usr/local/bin/python3.11
rm -f /usr/local/bin/python3-config
rm -f /usr/local/bin/python3.11-config
brew update
brew install ninja socat
brew install ninja
sudo bash script/install_socat
- name: Build
run: |
script/check-posix-pty build
@@ -249,14 +301,22 @@ jobs:
script/check-posix-pty check
rcp-stack-reset:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
sudo bash script/install_socat
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
- name: Build
run: |
@@ -267,42 +327,42 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-rcp-stack-reset
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs:
- expects-linux
- ncp-rcp-migrate
- pty-linux
- thread-cert
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
delete-coverage-artifacts:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@1-glob-support
with:
name: cov-*
useGlob: true
+100
View File
@@ -0,0 +1,100 @@
#
# Copyright (c) 2022, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecards supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '33 12 * * 0'
push:
branches: [ "main" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecards analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read
steps:
- name: "Checkout code"
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecards on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v2.1.27
with:
sarif_file: results.sarif
+205 -120
View File
@@ -28,60 +28,50 @@
name: Simulation 1.1
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
distcheck:
runs-on: ubuntu-20.04
env:
CC: clang
CXX: clang++
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y llvm-runtime python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Run
run: |
export ASAN_SYMBOLIZER_PATH=`which llvm-symbolizer`
export ASAN_OPTIONS=symbolize=1
export DISTCHECK_CONFIGURE_FLAGS= CPPFLAGS=-DOPENTHREAD_SIMULATION_VIRTUAL_TIME=1
export DISTCHECK_BUILD=1
./bootstrap
VERBOSE=1 make -f examples/Makefile-simulation distcheck
packet-verification:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
PACKET_VERIFICATION: 1
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
MULTIPLY: 3
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
@@ -92,7 +82,7 @@ jobs:
- name: Run
run: |
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: packet-verification-pcaps
@@ -102,13 +92,14 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-packet-verification
path: tmp/coverage.info
retention-days: 1
cli-ftd:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
@@ -117,38 +108,49 @@ jobs:
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
./script/test build
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- uses: actions/upload-artifact@v2
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: cli-ftd-thread-cert
path: build/simulation/tests/scripts/thread-cert
path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-cli-ftd
path: tmp/coverage.info
retention-days: 1
cli-mtd:
name: cli-mtd MESSAGE_USE_HEAP=${{ matrix.message_use_heap }}
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
@@ -162,38 +164,49 @@ jobs:
THREAD_VERSION: 1.1
USE_MTD: 1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
MESSAGE_USE_HEAP: ${{ matrix.message_use_heap }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
./script/test build
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- uses: actions/upload-artifact@v2
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: cli-mtd-thread-cert
path: build/simulation/tests/scripts/thread-cert
path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-cli-mtd-${{ matrix.message_use_heap }}
path: tmp/coverage.info
retention-days: 1
cli-time-sync:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
@@ -201,48 +214,71 @@ jobs:
COVERAGE: 1
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
TIME_SYNC: 1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
OT_OPTIONS="-DOT_TIME_SYNC=ON" ./script/test build
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- uses: actions/upload-artifact@v2
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: cli-time-sync-thread-cert
path: build/simulation/tests/scripts/thread-cert
path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-cli-time-sync
path: tmp/coverage.info
retention-days: 1
expects:
runs-on: ubuntu-18.04
runs-on: ubuntu-24.04
env:
CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
THREAD_VERSION: 1.1
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
sudo bash script/install_socat
pip install bleak 'cryptography==43.0.0'
- name: Run
run: |
ulimit -c unlimited
@@ -254,7 +290,7 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_CLI=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED_CLI == '1' }}
with:
name: core-expect-cli
@@ -263,37 +299,48 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-expects
path: tmp/coverage.info
retention-days: 1
ot-commissioner:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
THREAD_VERSION: 1.1
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo rm /etc/apt/sources.list.d/*
sudo apt-get update
sudo apt-get install -y avahi-daemon avahi-utils lcov
script/git-tool clone https://github.com/openthread/ot-commissioner.git /tmp/ot-commissioner --depth 1 --branch main
- name: Build
run: |
cd /tmp/ot-commissioner
script/bootstrap.sh
cmake -GNinja \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOT_COMM_COVERAGE=ON \
-DOT_COMM_CCM=OFF \
cmake -GNinja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOT_COMM_COVERAGE=ON \
-DOT_COMM_CCM=OFF \
-S . -B build
cmake --build build
sudo cmake --install build
@@ -306,47 +353,85 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-ot-commissioner
path: tmp/coverage.info
retention-days: 1
multiple-instance:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
env:
COVERAGE: 1
MULTIPLE_INSTANCE: 1
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
CXXFLAGS: "-DOPENTHREAD_CONFIG_LOG_PREPEND_UPTIME=0"
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel lcov
sudo apt-get --no-install-recommends install -y lcov ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
OT_OPTIONS="-DOT_MULTIPLE_INSTANCE=ON" ./script/test build
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- uses: actions/upload-artifact@v2
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: multiple-instance-thread-cert
name: ot_testing
path: build/simulation/tests/scripts/thread-cert
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-multiple-instance
path: tmp/coverage.info
retention-days: 1
simulation-local-host:
runs-on: ubuntu-24.04
env:
COVERAGE: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
- name: Run
run: |
./script/check-simulation-local-host
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-simulation-local-host
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs:
@@ -357,31 +442,31 @@ jobs:
- expects
- ot-commissioner
- multiple-instance
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
delete-coverage-artifacts:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@1-glob-support
with:
name: cov-*
useGlob: true
-338
View File
@@ -1,338 +0,0 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
name: Simulation 1.3
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
thread-1-3:
name: thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}
runs-on: ubuntu-20.04
env:
CFLAGS: -${{ matrix.arch }}
CXXFLAGS: -${{ matrix.arch }}
LDFLAGS: -${{ matrix.arch }}
COVERAGE: 1
THREAD_VERSION: 1.3
VIRTUAL_TIME: 1
INTER_OP: 1
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cxx }}
strategy:
fail-fast: false
matrix:
compiler: [{c: "gcc", cxx: "g++", gcov: "gcc"}, { c: "clang-10", cxx: "clang++-10", gcov: "llvm"}]
arch: ["m32", "m64"]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-10 clang++-10 ninja-build python3-setuptools python3-wheel llvm lcov
sudo apt-get --no-install-recommends install -y g++-multilib libreadline-dev:i386 libncurses-dev:i386
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
./script/test unit
./script/test cert_suite tests/scripts/thread-cert/v1_2_*
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}-pcaps
path: "*.pcap"
- uses: actions/upload-artifact@v2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-thread-1-3
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage "${{ matrix.compiler.gcov }}"
- uses: actions/upload-artifact@v2
with:
name: cov-thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}
path: tmp/coverage.info
packet-verification-low-power:
runs-on: ubuntu-20.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
COVERAGE: 1
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.3
MAC_FILTER: 1
INTER_OP: 1
INTER_OP_BBR: 0
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Get Thread-Wireshark
run: |
./script/test get_thread_wireshark
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
for i in {1..10}
do
./script/test cert_suite ./tests/scripts/thread-cert/v1_2_LowPower*.py
done
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: packet-verification-low-power-pcaps
path: |
*.pcap
*.json
- uses: actions/upload-artifact@v2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-low-power
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
with:
name: cov-packet-verification-low-power
path: tmp/coverage.info
packet-verification-1-1-on-1-3:
runs-on: ubuntu-20.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.3
MULTIPLY: 3
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Get Thread-Wireshark
run: |
./script/test get_thread_wireshark
- name: Run
run: |
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: packet-verification-1.1-on-1.3-pcaps
path: |
*.pcap
*.json
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
with:
name: cov-packet-verification-1-1-on-1-3
path: tmp/coverage.info
expects:
runs-on: ubuntu-20.04
env:
COVERAGE: 1
THREAD_VERSION: 1.3
VIRTUAL_TIME: 0
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
- name: Run RCP Mode
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
OT_OPTIONS=-DOT_READLINE=OFF OT_NODE_TYPE=rcp ./script/test build expect
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-expect-1-3
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
with:
name: cov-expects
path: tmp/coverage.info
thread-1-3-posix:
runs-on: ubuntu-20.04
env:
COVERAGE: 1
PYTHONUNBUFFERED: 1
READLINE: readline
THREAD_VERSION: 1.3
OT_NODE_TYPE: rcp
USE_MTD: 1
VIRTUAL_TIME: 1
INTER_OP: 1
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y libreadline6-dev g++-multilib ninja-build python3-setuptools python3-wheel llvm lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
./script/test cert tests/scripts/thread-cert/v1_2_LowPower_5_3_01_SSEDAttachment.py
./script/test cert tests/scripts/thread-cert/v1_2_LowPower_6_1_07_PreferringARouterOverAReed.py
./script/test cert tests/scripts/thread-cert/v1_2_router_5_1_1.py
./script/test cert tests/scripts/thread-cert/v1_2_test_csl_transmission.py
./script/test cert tests/scripts/thread-cert/v1_2_test_enhanced_frame_pending.py
./script/test cert tests/scripts/thread-cert/v1_2_test_parent_selection.py
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: thread-1-3-posix-pcaps
path: "*.pcap"
- uses: actions/upload-artifact@v2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-thread-1-3-posix
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
with:
name: cov-thread-1-3-posix
path: tmp/coverage.info
upload-coverage:
needs:
- thread-1-3
- packet-verification-low-power
- packet-verification-1-1-on-1-3
- expects
- thread-1-3-posix
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
with:
path: coverage/
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@v2
with:
files: final.info
fail_ci_if_error: true
delete-coverage-artifacts:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@1-glob-support
with:
name: cov-*
useGlob: true
+458
View File
@@ -0,0 +1,458 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
name: Simulation 1.4
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
thread-1-4:
name: thread-1-4-${{ matrix.compiler.c }}-${{ matrix.arch }}
runs-on: ubuntu-22.04
env:
CFLAGS: -${{ matrix.arch }}
CXXFLAGS: -${{ matrix.arch }}
LDFLAGS: -${{ matrix.arch }}
COVERAGE: 1
THREAD_VERSION: 1.4
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
INTER_OP: 1
INTER_OP_BBR: 1
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cxx }}
strategy:
fail-fast: false
matrix:
compiler: [{c: "gcc", cxx: "g++", gcov: "gcc"}, { c: "clang", cxx: "clang++", gcov: "llvm"}]
arch: ["m32", "m64"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build llvm lcov
sudo apt-get --no-install-recommends install -y g++-multilib libreadline-dev:i386 libncurses-dev:i386
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
./script/test unit
./script/test cert_suite tests/scripts/thread-cert/v1_2_*
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: thread-1-4-${{ matrix.compiler.c }}-${{ matrix.arch }}-pcaps
path: "*.pcap"
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-thread-1-4
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage "${{ matrix.compiler.gcov }}"
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-1-4-${{ matrix.compiler.c }}-${{ matrix.arch }}
path: tmp/coverage.info
retention-days: 1
packet-verification-low-power:
runs-on: ubuntu-24.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
TEST_TIMEOUT: 300
OT_VT_USE_UNIX_SOCKET: 1
COVERAGE: 1
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.4
MAC_FILTER: 1
INTER_OP: 1
INTER_OP_BBR: 0
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Build with OT_CSL_RECEIVER_LOCAL_TIME_SYNC
run: |
OT_BUILDDIR="${PWD}/build_csl_receiver_local_time_sync" OT_OPTIONS="-DOT_CSL_RECEIVER_LOCAL_TIME_SYNC=ON" ./script/test build
- name: Get Thread-Wireshark
run: |
./script/test get_thread_wireshark
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
for i in {1..10}
do
./script/test cert_suite ./tests/scripts/thread-cert/v1_2_LowPower*.py
done
- name: Run with OT_CSL_RECEIVER_LOCAL_TIME_SYNC
run: |
OT_BUILDDIR="${PWD}/build_csl_receiver_local_time_sync" ./script/test cert_suite ./tests/scripts/thread-cert/v1_2_LowPower*.py
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: packet-verification-low-power-pcaps
path: |
*.pcap
*.json
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-low-power
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-packet-verification-low-power
path: tmp/coverage.info
retention-days: 1
packet-verification-1-1-on-1-4:
runs-on: ubuntu-24.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
OT_VT_USE_UNIX_SOCKET: 1
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.4
INTER_OP_BBR: 1
MULTIPLY: 3
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Get Thread-Wireshark
run: |
./script/test get_thread_wireshark
- name: Run
run: |
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: packet-verification-1.1-on-1.4-pcaps
path: |
*.pcap
*.json
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-packet-verification-1-1-on-1-4
path: tmp/coverage.info
retention-days: 1
channel-manager-csl:
runs-on: ubuntu-24.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
THREAD_VERSION: 1.4
VIRTUAL_TIME: 1
OT_VT_USE_UNIX_SOCKET: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
OT_OPTIONS="-DOT_CHANNEL_MANAGER_CSL=ON" ./script/test build
- name: Run
run: |
ulimit -c unlimited
./script/test cert_suite ./tests/scripts/thread-cert/addon_test_channel_manager_autocsl*.py
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: channel-manager-csl
path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-channel-manager-csl
path: tmp/coverage.info
retention-days: 1
expects:
runs-on: ubuntu-24.04
env:
COVERAGE: 1
THREAD_VERSION: 1.4
VIRTUAL_TIME: 0
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov
sudo bash script/install_socat
pip install bleak 'cryptography==43.0.0'
- name: Run RCP Mode
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
OT_OPTIONS=-DOT_READLINE=OFF OT_NODE_TYPE=rcp ./script/test build expect
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-expect-1-4
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-expects
path: tmp/coverage.info
retention-days: 1
thread-1-4-posix:
runs-on: ubuntu-24.04
env:
COVERAGE: 1
PYTHONUNBUFFERED: 1
READLINE: readline
THREAD_VERSION: 1.4
OT_NODE_TYPE: rcp
USE_MTD: 1
VIRTUAL_TIME: 1
OT_VT_USE_UNIX_SOCKET: 1
INTER_OP: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y libreadline6-dev ninja-build llvm lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Run
run: |
ulimit -c unlimited
./script/test prepare_coredump_upload
./script/test cert tests/scripts/thread-cert/v1_2_LowPower_5_3_01_SSEDAttachment.py
./script/test cert tests/scripts/thread-cert/v1_2_LowPower_6_1_07_PreferringARouterOverAReed.py
./script/test cert tests/scripts/thread-cert/v1_2_router_5_1_1.py
./script/test cert tests/scripts/thread-cert/v1_2_test_csl_transmission.py
./script/test cert tests/scripts/thread-cert/v1_2_test_enhanced_frame_pending.py
./script/test cert tests/scripts/thread-cert/v1_2_test_parent_selection.py
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() }}
with:
name: thread-1-4-posix-pcaps
path: "*.pcap"
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-thread-1-4-posix
path: |
./ot-core-dump/*
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-thread-1-4-posix
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs:
- thread-1-4
- packet-verification-low-power
- packet-verification-1-1-on-1-4
- expects
- thread-1-4-posix
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
+79 -24
View File
@@ -28,37 +28,92 @@
name: Size
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request_target:
branches:
- 'main'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
size-check:
runs-on: ubuntu-24.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
size-report:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
if: "github.event_name == 'push'"
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Fetch Pull Request ref
if: ${{ github.event_name == 'pull_request_target' }}
run: |
python3 -m pip install --upgrade setuptools wheel
python3 -m pip install mdv
git fetch --depth 2 origin pull/${{ github.event.pull_request.number }}/merge
echo "OT_SHA_NEW=$(git rev-parse FETCH_HEAD)" >> $GITHUB_ENV
- name: Run
env:
OT_BASE_BRANCH: "${{ github.base_ref }}"
SIZE_REPORT_URL: "https://openthread-size-report.glitch.me/size-report/1354027"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
PR_NUMBER: "${{ github.event.pull_request.number }}"
run: |
export PATH=$PATH:$HOME/.local/bin
if [ ${{ github.event_name }} == pull_request ]; then
curl -s --retry 5 "${SIZE_REPORT_URL}/bash" >size-report
chmod a+x size-report
export OT_SIZE_REPORTER=./size-report
fi
./script/check-size
cat /tmp/ot-size-report/report_pr >> $GITHUB_STEP_SUMMARY
- name: Upload report
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: report_pr
path: /tmp/ot-size-report/report_pr
size-report:
needs:
- size-check
permissions:
pull-requests: write
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-24.04
steps:
- name: Download report
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: report_pr
path: /tmp/ot-size-report
- name: Post Report
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
id: post-report
with:
script: |
const fs = require('fs')
const report = fs.readFileSync('/tmp/ot-size-report/report_pr', 'utf8');
const params = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report,
}
const response = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const kMagicHeader = '<!-- Size Report of **OpenThread** -->'
const comment = response.data.find(comment => comment.body.startsWith(kMagicHeader))
if (comment) {
params.comment_id = comment.id;
await github.rest.issues.updateComment(params)
} else {
await github.rest.issues.createComment(params)
}
+188 -77
View File
@@ -28,84 +28,89 @@
name: Toranj
on: [push, pull_request]
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
toranj-ncp:
name: toranj-ncp-${{ matrix.TORANJ_RADIO }}
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
TORANJ_RADIO: ['15.4', 'trel', 'multi']
env:
COVERAGE: 1
TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Bootstrap
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev
sudo apt-get --no-install-recommends install -y autoconf-archive
sudo apt-get --no-install-recommends install -y bsdtar
sudo apt-get --no-install-recommends install -y libtool
sudo apt-get --no-install-recommends install -y libglib2.0-dev
sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev
sudo apt-get --no-install-recommends install -y lcov
script/git-tool clone --depth=1 --branch=master https://github.com/openthread/wpantund.git
cd wpantund
./bootstrap.sh
./configure
sudo make -j2
sudo make install
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
- name: Generate Coverage
if: "matrix.TORANJ_RADIO != 'multi'"
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
if: "matrix.TORANJ_RADIO != 'multi'"
with:
name: cov-toranj-ncp-${{ matrix.TORANJ_RADIO }}
path: tmp/coverage.info
toranj-cli:
name: toranj-cli-${{ matrix.TORANJ_RADIO }}
runs-on: ubuntu-18.04
strategy:
matrix:
TORANJ_RADIO: ['15.4']
env:
COVERAGE: 1
TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }}
TORANJ_CLI: 1
TORANJ_NCP : 1
TORANJ_EVENT_NAME: ${{ github.event_name }}
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y lcov
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
toranj-cli:
name: toranj-cli-${{ matrix.TORANJ_RADIO }}
runs-on: ubuntu-24.04
strategy:
matrix:
TORANJ_RADIO: ['15.4', 'trel', 'multi']
env:
COVERAGE: 1
TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }}
TORANJ_CLI: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
env:
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build & Run
run: |
@@ -114,41 +119,147 @@ jobs:
if: "matrix.TORANJ_RADIO != 'multi'"
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: "matrix.TORANJ_RADIO != 'multi'"
with:
name: cov-toranj-cli-${{ matrix.TORANJ_RADIO }}
path: tmp/coverage.info
retention-days: 1
toranj-unittest:
name: toranj-unittest
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.12'
cache: pip
- name: Bootstrap
env:
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build
- name: Build & Run
run: |
./tests/toranj/build.sh all
ninja test
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
# Validate posix builds with different radio configs
git clean -dfx
./tests/toranj/build.sh ncp-15.4
git clean -dfx
./tests/toranj/build.sh ncp-trel
git clean -dfx
./tests/toranj/build.sh ncp-15.4+trel
git clean -dfx
./tests/toranj/build.sh posix-15.4
git clean -dfx
./tests/toranj/build.sh posix-15.4+trel
git clean -dfx
./tests/toranj/build.sh posix-trel
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
# Log levels
git clean -dfx
./tests/toranj/build.sh --log-level DEBG all
git clean -dfx
./tests/toranj/build.sh --log-level INFO all
git clean -dfx
./tests/toranj/build.sh --log-level NOTE all
git clean -dfx
./tests/toranj/build.sh --log-level WARN all
git clean -dfx
./tests/toranj/build.sh --log-level CRIT all
git clean -dfx
./tests/toranj/build.sh --log-level NONE all
#- - - - - - - - - - - - - - - - - - - - - - - - - - -
git clean -dfx
./tests/toranj/build.sh --enable-plat-key-ref all
toranj-macos:
name: toranj-macos
runs-on: macos-14
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
env:
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
brew update
brew install ninja
- name: Build & Run
run: |
./tests/toranj/build.sh posix-15.4
nexus:
name: nexus
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
env:
PR_BODY: "${{ github.event.pull_request.body }}"
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov
- name: Build & Run
run: |
./tests/nexus/build.sh
ctest -L core --output-on-failure
git clean -dfx
./tests/nexus/build.sh trel
ctest -L trel --output-on-failure
upload-coverage:
needs:
- toranj-ncp
- toranj-cli
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
delete-coverage-artifacts:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- uses: geekyeggo/delete-artifact@1-glob-support
with:
name: cov-*
useGlob: true
+136
View File
@@ -0,0 +1,136 @@
#
# Copyright (c) 2023, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
name: Unit
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
tcplp-buffering:
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Build
run: make -C third_party/tcplp/lib/test/
- name: Run
run: third_party/tcplp/lib/test/test_all
unit-tests:
runs-on: ubuntu-22.04
env:
COVERAGE: 1
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build lcov libgtest-dev libgmock-dev
- name: Build Simulation
run: ./script/cmake-build simulation -DOT_BUILD_GTEST=ON -DOT_BORDER_ROUTING=ON -DOT_BORDER_ROUTING_DHCP6_PD=ON
- name: Test Simulation
run: cd build/simulation && ninja test
- name: Build Multipan Simulation
run: ./script/cmake-build simulation -DOT_BUILD_GTEST=ON -DOT_MULTIPAN_RCP=ON -DOT_FTD=OFF -DOT_MTD=OFF
- name: Test Multipan Simulation
run: cd build/simulation && ninja test
- name: Build NCP Simulation
run: ./script/cmake-build simulation -DOT_BUILD_GTEST=OFF -DOT_MTD=OFF -DOT_RCP=OFF -DOT_APP_CLI=OFF -DOT_APP_RCP=OFF \
-DOT_BORDER_ROUTING=ON -DOT_NCP_INFRA_IF=ON -DOT_SRP_SERVER=ON -DOT_NCP_DNSSD=ON -DOT_PLATFORM_DNSSD=ON -DOT_NCP_CLI_STREAM=ON
- name: Test NCP Simulation
run: cd build/simulation && ninja test
- name: Build POSIX
run: ./script/cmake-build posix
- name: Test POSIX
run: cd build/posix && ninja test
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: cov-unit-tests
path: tmp/coverage.info
retention-days: 1
upload-coverage:
needs: unit-tests
runs-on: ubuntu-24.04
steps:
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
path: coverage/
pattern: cov-*
merge-multiple: true
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: final.info
fail_ci_if_error: true
+19 -12
View File
@@ -28,23 +28,30 @@
name: API Version
on: [pull_request]
on:
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
cancel-in-progress: true
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
cancel-previous-runs:
runs-on: ubuntu-20.04
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/main'"
api-version:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
submodules: true
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: recursive
- name: Check
run: |
script/check-api-version
+25 -34
View File
@@ -1,65 +1,41 @@
*.a
*.a.*
*.bak
*.db
*.flash
*.gcda
*.gcno
*.log
*.o
*.lo
*.la
*.ninja*
*.opendb
*.orig
*.pcap
*.pyc
*.suo
*.swn
*.swo
*.swp
*.trs
*.user
*.bak
*.map
*~
.deps
.dirstamp
.DS_Store
.local-version
.libs
.vagrant
aclocal.m4
autom4te.cache
build
CMakeCache.txt
CMakeFiles
cmake_install.cmake
configure
config.log
config.status
doc/Doxyfile
doc/html
etc/cmake/openthread-config-generic.h
include/openthread-config.h
include/openthread-config.h.in
include/openthread-config-generic.h
include/openthread-config-generic.h.in
include/stamp-h1
ipch
libtool
Makefile
Makefile.in
output
third_party/nlbuild-autotools/repo/third_party/autoconf/compile
third_party/nlbuild-autotools/repo/third_party/autoconf/depcomp
third_party/nlbuild-autotools/repo/third_party/autoconf/ltmain.sh
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/libtool.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltoptions.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltsugar.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltversion.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/lt~obsolete.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/missing
/tmp/
# OT exectuables
ot-cli-ftd
ot-cli-mtd
ot-cli-radio
ot-ncp-ftd
ot-ncp-mtd
ot-rcp
# IDE / editor files
.idea/**
.vscode/**
@@ -68,3 +44,18 @@ cmake-build-*/**
# Python bytecodes
__pycache__
# Python environments
.venv
venv/
# Unit test files
CTestTestfile.cmake
ot-test-*
ot_testing/
Testing/
tests/nexus/nexus_*
# Misc
DartConfiguration.tcl
third_party/mbedtls/openthread-mbedtls-config.h
+3
View File
@@ -0,0 +1,3 @@
[submodule "third_party/mbedtls/repo"]
path = third_party/mbedtls/repo
url = https://github.com/Mbed-TLS/mbedtls.git
+1 -1
View File
@@ -1,3 +1,3 @@
buildconfig = "//third_party/build_gn/BUILDCONFIG.gn"
buildconfig = "//etc/gn/BUILDCONFIG.gn"
check_system_includes = true
-37
View File
@@ -1,37 +0,0 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
extraction:
cpp:
prepare:
packages:
- cmake
- ninja-build
index:
build_command:
- THREAD_VERSION=1.2 NODE_MODE=rcp OT_NATIVE_IP=1 ./script/test build
-630
View File
@@ -1,630 +0,0 @@
#
# Copyright (c) 2018, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
LOCAL_PATH := $(call my-dir)
ifeq ($(OPENTHREAD_ENABLE_ANDROID_MK),1)
OPENTHREAD_DEFAULT_VERSION := $(shell cat $(LOCAL_PATH)/.default-version)
OPENTHREAD_SOURCE_VERSION := $(shell git -C $(LOCAL_PATH) describe --always --match "[0-9].*" 2> /dev/null)
OPENTHREAD_PROJECT_CFLAGS ?= \
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \
$(NULL)
OPENTHREAD_PUBLIC_CFLAGS := \
-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \
-DOPENTHREAD_CONFIG_DTLS_ENABLE=1 \
-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1 \
-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1 \
-DOPENTHREAD_CONFIG_JOINER_ENABLE=1 \
-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1 \
-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1 \
-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_PLATFORM_POSIX=1 \
-DOPENTHREAD_POSIX_CONFIG_RCP_PTY_ENABLE=1 \
-DOPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1 \
$(NULL)
OPENTHREAD_PRIVATE_CFLAGS := \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DPACKAGE=\"openthread\" \
-DPACKAGE_BUGREPORT=\"openthread-devel@googlegroups.com\" \
-DPACKAGE_NAME=\"OPENTHREAD\" \
-DPACKAGE_STRING=\"OPENTHREAD\ $(OPENTHREAD_DEFAULT_VERSION)\" \
-DPACKAGE_TARNAME=\"openthread\" \
-DPACKAGE_URL=\"http://github.com/openthread/openthread\" \
-DPACKAGE_VERSION=\"$(OPENTHREAD_SOURCE_VERSION)\" \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
-DVERSION=\"$(OPENTHREAD_DEFAULT_VERSION)\" \
$(NULL)
# Enable required features for on-device tests.
ifeq ($(TARGET_BUILD_VARIANT),eng)
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \
$(NULL)
endif
ifeq ($(USE_OTBR_DAEMON), 1)
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1 \
-DOPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1 \
-DOPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE=1 \
$(NULL)
else
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1
endif
ifeq ($(USE_OT_RCP_BUS), spi)
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_RCP_BUS=OT_POSIX_RCP_BUS_SPI
else
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_RCP_BUS=OT_POSIX_RCP_BUS_UART
endif
# Enable all optional features for CI tests.
ifeq ($(TARGET_PRODUCT),generic)
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1 \
-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=0 \
-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1 \
$(NULL)
endif
include $(CLEAR_VARS)
LOCAL_MODULE := spi-hdlc-adapter
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := tools/spi-hdlc-adapter/spi-hdlc-adapter.c
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := ot-core
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/ncp \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(LOCAL_PATH)/third_party/mbedtls/repo/library \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_EXPORT_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(NULL)
LOCAL_CPPFLAGS := \
-std=c++11 \
-Wno-error=non-virtual-dtor \
-pedantic-errors \
$(NULL)
ifeq ($(ANDROID_NDK),1)
LOCAL_SHARED_LIBRARIES := libcutils
LOCAL_CFLAGS += \
-DOPENTHREAD_ENABLE_ANDROID_NDK=1 \
-Wno-sign-compare \
$(NULL)
endif
LOCAL_SRC_FILES := \
src/core/api/backbone_router_api.cpp \
src/core/api/backbone_router_ftd_api.cpp \
src/core/api/border_agent_api.cpp \
src/core/api/border_router_api.cpp \
src/core/api/channel_manager_api.cpp \
src/core/api/channel_monitor_api.cpp \
src/core/api/child_supervision_api.cpp \
src/core/api/coap_api.cpp \
src/core/api/coap_secure_api.cpp \
src/core/api/commissioner_api.cpp \
src/core/api/crypto_api.cpp \
src/core/api/dataset_api.cpp \
src/core/api/dataset_ftd_api.cpp \
src/core/api/dataset_updater_api.cpp \
src/core/api/diags_api.cpp \
src/core/api/dns_api.cpp \
src/core/api/dns_server_api.cpp \
src/core/api/error_api.cpp \
src/core/api/heap_api.cpp \
src/core/api/history_tracker_api.cpp \
src/core/api/icmp6_api.cpp \
src/core/api/instance_api.cpp \
src/core/api/ip6_api.cpp \
src/core/api/jam_detection_api.cpp \
src/core/api/joiner_api.cpp \
src/core/api/link_api.cpp \
src/core/api/link_metrics_api.cpp \
src/core/api/link_raw_api.cpp \
src/core/api/logging_api.cpp \
src/core/api/message_api.cpp \
src/core/api/multi_radio_api.cpp \
src/core/api/netdata_api.cpp \
src/core/api/netdata_publisher_api.cpp \
src/core/api/netdiag_api.cpp \
src/core/api/network_time_api.cpp \
src/core/api/ping_sender_api.cpp \
src/core/api/random_crypto_api.cpp \
src/core/api/random_noncrypto_api.cpp \
src/core/api/server_api.cpp \
src/core/api/sntp_api.cpp \
src/core/api/srp_client_api.cpp \
src/core/api/srp_client_buffers_api.cpp \
src/core/api/srp_server_api.cpp \
src/core/api/tasklet_api.cpp \
src/core/api/tcp_api.cpp \
src/core/api/thread_api.cpp \
src/core/api/thread_ftd_api.cpp \
src/core/api/trel_api.cpp \
src/core/api/udp_api.cpp \
src/core/backbone_router/backbone_tmf.cpp \
src/core/backbone_router/bbr_leader.cpp \
src/core/backbone_router/bbr_local.cpp \
src/core/backbone_router/bbr_manager.cpp \
src/core/backbone_router/multicast_listeners_table.cpp \
src/core/backbone_router/ndproxy_table.cpp \
src/core/border_router/infra_if.cpp \
src/core/border_router/routing_manager.cpp \
src/core/coap/coap.cpp \
src/core/coap/coap_message.cpp \
src/core/coap/coap_secure.cpp \
src/core/common/appender.cpp \
src/core/common/binary_search.cpp \
src/core/common/crc16.cpp \
src/core/common/data.cpp \
src/core/common/error.cpp \
src/core/common/heap.cpp \
src/core/common/heap_data.cpp \
src/core/common/heap_string.cpp \
src/core/common/instance.cpp \
src/core/common/log.cpp \
src/core/common/message.cpp \
src/core/common/notifier.cpp \
src/core/common/random.cpp \
src/core/common/settings.cpp \
src/core/common/string.cpp \
src/core/common/tasklet.cpp \
src/core/common/time_ticker.cpp \
src/core/common/timer.cpp \
src/core/common/tlvs.cpp \
src/core/common/trickle_timer.cpp \
src/core/common/uptime.cpp \
src/core/crypto/aes_ccm.cpp \
src/core/crypto/aes_ecb.cpp \
src/core/crypto/crypto_platform.cpp \
src/core/crypto/ecdsa.cpp \
src/core/crypto/ecdsa_tinycrypt.cpp \
src/core/crypto/hkdf_sha256.cpp \
src/core/crypto/hmac_sha256.cpp \
src/core/crypto/mbedtls.cpp \
src/core/crypto/pbkdf2_cmac.cpp \
src/core/crypto/sha256.cpp \
src/core/crypto/storage.cpp \
src/core/diags/factory_diags.cpp \
src/core/mac/channel_mask.cpp \
src/core/mac/data_poll_handler.cpp \
src/core/mac/data_poll_sender.cpp \
src/core/mac/link_raw.cpp \
src/core/mac/mac.cpp \
src/core/mac/mac_filter.cpp \
src/core/mac/mac_frame.cpp \
src/core/mac/mac_links.cpp \
src/core/mac/mac_types.cpp \
src/core/mac/sub_mac.cpp \
src/core/mac/sub_mac_callbacks.cpp \
src/core/meshcop/announce_begin_client.cpp \
src/core/meshcop/border_agent.cpp \
src/core/meshcop/commissioner.cpp \
src/core/meshcop/dataset.cpp \
src/core/meshcop/dataset_local.cpp \
src/core/meshcop/dataset_manager.cpp \
src/core/meshcop/dataset_manager_ftd.cpp \
src/core/meshcop/dataset_updater.cpp \
src/core/meshcop/dtls.cpp \
src/core/meshcop/energy_scan_client.cpp \
src/core/meshcop/extended_panid.cpp \
src/core/meshcop/joiner.cpp \
src/core/meshcop/joiner_router.cpp \
src/core/meshcop/meshcop.cpp \
src/core/meshcop/meshcop_leader.cpp \
src/core/meshcop/meshcop_tlvs.cpp \
src/core/meshcop/network_name.cpp \
src/core/meshcop/panid_query_client.cpp \
src/core/meshcop/timestamp.cpp \
src/core/net/checksum.cpp \
src/core/net/dhcp6_client.cpp \
src/core/net/dhcp6_server.cpp \
src/core/net/dns_client.cpp \
src/core/net/dns_dso.cpp \
src/core/net/dns_types.cpp \
src/core/net/dnssd_server.cpp \
src/core/net/icmp6.cpp \
src/core/net/ip4_address.cpp \
src/core/net/ip6.cpp \
src/core/net/ip6_address.cpp \
src/core/net/ip6_filter.cpp \
src/core/net/ip6_headers.cpp \
src/core/net/ip6_mpl.cpp \
src/core/net/nd6.cpp \
src/core/net/nd_agent.cpp \
src/core/net/netif.cpp \
src/core/net/sntp_client.cpp \
src/core/net/socket.cpp \
src/core/net/srp_client.cpp \
src/core/net/srp_server.cpp \
src/core/net/tcp6.cpp \
src/core/net/udp6.cpp \
src/core/radio/radio.cpp \
src/core/radio/radio_callbacks.cpp \
src/core/radio/radio_platform.cpp \
src/core/radio/trel_interface.cpp \
src/core/radio/trel_link.cpp \
src/core/radio/trel_packet.cpp \
src/core/thread/address_resolver.cpp \
src/core/thread/announce_begin_server.cpp \
src/core/thread/announce_sender.cpp \
src/core/thread/anycast_locator.cpp \
src/core/thread/child_table.cpp \
src/core/thread/csl_tx_scheduler.cpp \
src/core/thread/discover_scanner.cpp \
src/core/thread/dua_manager.cpp \
src/core/thread/energy_scan_server.cpp \
src/core/thread/indirect_sender.cpp \
src/core/thread/key_manager.cpp \
src/core/thread/link_metrics.cpp \
src/core/thread/link_quality.cpp \
src/core/thread/lowpan.cpp \
src/core/thread/mesh_forwarder.cpp \
src/core/thread/mesh_forwarder_ftd.cpp \
src/core/thread/mesh_forwarder_mtd.cpp \
src/core/thread/mle.cpp \
src/core/thread/mle_router.cpp \
src/core/thread/mle_types.cpp \
src/core/thread/mlr_manager.cpp \
src/core/thread/neighbor_table.cpp \
src/core/thread/network_data.cpp \
src/core/thread/network_data_leader.cpp \
src/core/thread/network_data_leader_ftd.cpp \
src/core/thread/network_data_local.cpp \
src/core/thread/network_data_notifier.cpp \
src/core/thread/network_data_publisher.cpp \
src/core/thread/network_data_service.cpp \
src/core/thread/network_data_tlvs.cpp \
src/core/thread/network_data_types.cpp \
src/core/thread/network_diagnostic.cpp \
src/core/thread/panid_query_server.cpp \
src/core/thread/radio_selector.cpp \
src/core/thread/router_table.cpp \
src/core/thread/src_match_controller.cpp \
src/core/thread/thread_netif.cpp \
src/core/thread/time_sync_service.cpp \
src/core/thread/tmf.cpp \
src/core/thread/topology.cpp \
src/core/thread/uri_paths.cpp \
src/core/utils/channel_manager.cpp \
src/core/utils/channel_monitor.cpp \
src/core/utils/child_supervision.cpp \
src/core/utils/flash.cpp \
src/core/utils/heap.cpp \
src/core/utils/history_tracker.cpp \
src/core/utils/jam_detector.cpp \
src/core/utils/otns.cpp \
src/core/utils/parse_cmdline.cpp \
src/core/utils/ping_sender.cpp \
src/core/utils/slaac_address.cpp \
src/core/utils/srp_client_buffers.cpp \
src/lib/hdlc/hdlc.cpp \
src/lib/platform/exit_code.c \
src/lib/spinel/spinel.c \
src/lib/spinel/spinel_decoder.cpp \
src/lib/spinel/spinel_encoder.cpp \
src/lib/url/url.cpp \
src/posix/platform/alarm.cpp \
src/posix/platform/backbone.cpp \
src/posix/platform/daemon.cpp \
src/posix/platform/entropy.cpp \
src/posix/platform/firewall.cpp \
src/posix/platform/hdlc_interface.cpp \
src/posix/platform/infra_if.cpp \
src/posix/platform/logging.cpp \
src/posix/platform/mainloop.cpp \
src/posix/platform/memory.cpp \
src/posix/platform/misc.cpp \
src/posix/platform/multicast_routing.cpp \
src/posix/platform/netif.cpp \
src/posix/platform/radio.cpp \
src/posix/platform/radio_url.cpp \
src/posix/platform/settings.cpp \
src/posix/platform/spi_interface.cpp \
src/posix/platform/system.cpp \
src/posix/platform/trel.cpp \
src/posix/platform/udp.cpp \
src/posix/platform/utils.cpp \
third_party/mbedtls/repo/library/aes.c \
third_party/mbedtls/repo/library/aesni.c \
third_party/mbedtls/repo/library/arc4.c \
third_party/mbedtls/repo/library/aria.c \
third_party/mbedtls/repo/library/asn1parse.c \
third_party/mbedtls/repo/library/asn1write.c \
third_party/mbedtls/repo/library/base64.c \
third_party/mbedtls/repo/library/bignum.c \
third_party/mbedtls/repo/library/blowfish.c \
third_party/mbedtls/repo/library/camellia.c \
third_party/mbedtls/repo/library/ccm.c \
third_party/mbedtls/repo/library/certs.c \
third_party/mbedtls/repo/library/chacha20.c \
third_party/mbedtls/repo/library/chachapoly.c \
third_party/mbedtls/repo/library/cipher.c \
third_party/mbedtls/repo/library/cipher_wrap.c \
third_party/mbedtls/repo/library/cmac.c \
third_party/mbedtls/repo/library/constant_time.c \
third_party/mbedtls/repo/library/ctr_drbg.c \
third_party/mbedtls/repo/library/debug.c \
third_party/mbedtls/repo/library/des.c \
third_party/mbedtls/repo/library/dhm.c \
third_party/mbedtls/repo/library/ecdh.c \
third_party/mbedtls/repo/library/ecdsa.c \
third_party/mbedtls/repo/library/ecjpake.c \
third_party/mbedtls/repo/library/ecp.c \
third_party/mbedtls/repo/library/ecp_curves.c \
third_party/mbedtls/repo/library/entropy.c \
third_party/mbedtls/repo/library/entropy_poll.c \
third_party/mbedtls/repo/library/error.c \
third_party/mbedtls/repo/library/gcm.c \
third_party/mbedtls/repo/library/havege.c \
third_party/mbedtls/repo/library/hkdf.c \
third_party/mbedtls/repo/library/hmac_drbg.c \
third_party/mbedtls/repo/library/md.c \
third_party/mbedtls/repo/library/md2.c \
third_party/mbedtls/repo/library/md4.c \
third_party/mbedtls/repo/library/md5.c \
third_party/mbedtls/repo/library/memory_buffer_alloc.c \
third_party/mbedtls/repo/library/net_sockets.c \
third_party/mbedtls/repo/library/nist_kw.c \
third_party/mbedtls/repo/library/oid.c \
third_party/mbedtls/repo/library/padlock.c \
third_party/mbedtls/repo/library/pem.c \
third_party/mbedtls/repo/library/pk.c \
third_party/mbedtls/repo/library/pk_wrap.c \
third_party/mbedtls/repo/library/pkcs11.c \
third_party/mbedtls/repo/library/pkcs12.c \
third_party/mbedtls/repo/library/pkcs5.c \
third_party/mbedtls/repo/library/pkparse.c \
third_party/mbedtls/repo/library/pkwrite.c \
third_party/mbedtls/repo/library/platform.c \
third_party/mbedtls/repo/library/platform_util.c \
third_party/mbedtls/repo/library/poly1305.c \
third_party/mbedtls/repo/library/psa_crypto.c \
third_party/mbedtls/repo/library/psa_crypto_driver_wrappers.c \
third_party/mbedtls/repo/library/psa_crypto_se.c \
third_party/mbedtls/repo/library/psa_crypto_slot_management.c \
third_party/mbedtls/repo/library/psa_crypto_storage.c \
third_party/mbedtls/repo/library/psa_its_file.c \
third_party/mbedtls/repo/library/ripemd160.c \
third_party/mbedtls/repo/library/rsa.c \
third_party/mbedtls/repo/library/rsa_internal.c \
third_party/mbedtls/repo/library/sha1.c \
third_party/mbedtls/repo/library/sha256.c \
third_party/mbedtls/repo/library/sha512.c \
third_party/mbedtls/repo/library/ssl_cache.c \
third_party/mbedtls/repo/library/ssl_ciphersuites.c \
third_party/mbedtls/repo/library/ssl_cli.c \
third_party/mbedtls/repo/library/ssl_cookie.c \
third_party/mbedtls/repo/library/ssl_msg.c \
third_party/mbedtls/repo/library/ssl_srv.c \
third_party/mbedtls/repo/library/ssl_ticket.c \
third_party/mbedtls/repo/library/ssl_tls.c \
third_party/mbedtls/repo/library/ssl_tls13_keys.c \
third_party/mbedtls/repo/library/threading.c \
third_party/mbedtls/repo/library/timing.c \
third_party/mbedtls/repo/library/version.c \
third_party/mbedtls/repo/library/version_features.c \
third_party/mbedtls/repo/library/x509.c \
third_party/mbedtls/repo/library/x509_create.c \
third_party/mbedtls/repo/library/x509_crl.c \
third_party/mbedtls/repo/library/x509_crt.c \
third_party/mbedtls/repo/library/x509_csr.c \
third_party/mbedtls/repo/library/x509write_crt.c \
third_party/mbedtls/repo/library/x509write_csr.c \
third_party/mbedtls/repo/library/xtea.c \
third_party/tcplp/bsdtcp/tcp_usrreq.c \
third_party/tcplp/bsdtcp/tcp_subr.c \
third_party/tcplp/bsdtcp/tcp_output.c \
third_party/tcplp/bsdtcp/cc/cc_newreno.c \
third_party/tcplp/bsdtcp/tcp_reass.c \
third_party/tcplp/bsdtcp/tcp_timewait.c \
third_party/tcplp/bsdtcp/tcp_sack.c \
third_party/tcplp/bsdtcp/tcp_input.c \
third_party/tcplp/bsdtcp/tcp_timer.c \
third_party/tcplp/lib/bitmap.c \
third_party/tcplp/lib/cbuf.c \
third_party/tcplp/lib/lbuf.c \
$(OPENTHREAD_PROJECT_SRC_FILES) \
$(NULL)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libopenthread-cli
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_SRC_FILES := \
src/cli/cli.cpp \
src/cli/cli_coap.cpp \
src/cli/cli_coap_secure.cpp \
src/cli/cli_commissioner.cpp \
src/cli/cli_dataset.cpp \
src/cli/cli_history.cpp \
src/cli/cli_joiner.cpp \
src/cli/cli_network_data.cpp \
src/cli/cli_output.cpp \
src/cli/cli_srp_client.cpp \
src/cli/cli_srp_server.cpp \
src/cli/cli_tcp.cpp \
src/cli/cli_udp.cpp \
$(NULL)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ot-cli
LOCAL_MODULE_TAGS := eng
ifneq ($(ANDROID_NDK),1)
LOCAL_SHARED_LIBRARIES := libcutils
endif
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_LDLIBS := \
-lrt \
-lutil
LOCAL_SRC_FILES := \
src/posix/cli_readline.cpp \
src/posix/cli_stdio.cpp \
src/posix/main.c \
$(NULL)
LOCAL_STATIC_LIBRARIES = libopenthread-cli ot-core
include $(BUILD_EXECUTABLE)
ifeq ($(USE_OTBR_DAEMON), 1)
include $(CLEAR_VARS)
LOCAL_MODULE := ot-ctl
LOCAL_MODULE_TAGS := eng
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src/ \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(NULL)
LOCAL_SRC_FILES := src/posix/client.cpp
include $(BUILD_EXECUTABLE)
endif # ($(USE_OTBR_DAEMON), 1)
ifneq ($(OPENTHREAD_PROJECT_ANDROID_MK),)
include $(OPENTHREAD_PROJECT_ANDROID_MK)
endif
endif # ($(OPENTHREAD_ENABLE_ANDROID_MK),1)
+6
View File
@@ -38,6 +38,7 @@ config("openthread_config") {
include_dirs += [
"${root_gen_dir}/include",
"include",
"src/include",
]
}
@@ -100,6 +101,11 @@ group("libopenthread-spinel-rcp") {
deps = [ "src/lib/spinel:libopenthread-spinel-rcp" ]
}
group("libopenthread-radio-spinel") {
public_deps = [ "src/lib/spinel:spinel-api" ]
deps = [ "src/lib/spinel:libopenthread-radio-spinel" ]
}
if (current_os == "fuchsia") {
group("lib-ot-core") {
public_deps = [
+38 -66
View File
@@ -33,6 +33,7 @@ file(READ .default-version OT_DEFAULT_VERSION)
string(STRIP ${OT_DEFAULT_VERSION} OT_DEFAULT_VERSION)
project(openthread VERSION ${OT_DEFAULT_VERSION})
include(CTest)
option(OT_BUILD_EXECUTABLES "Build executables" ON)
option(OT_COVERAGE "enable coverage" OFF)
@@ -40,8 +41,12 @@ set(OT_EXTERNAL_MBEDTLS "" CACHE STRING "Specify external mbedtls library")
option(OT_MBEDTLS_THREADING "enable mbedtls threading" OFF)
add_library(ot-config INTERFACE)
add_library(ot-config-ftd INTERFACE)
add_library(ot-config-mtd INTERFACE)
add_library(ot-config-radio INTERFACE)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99)
message(STATUS "OpenThread Source Directory: ${PROJECT_SOURCE_DIR}")
@@ -50,6 +55,7 @@ target_include_directories(ot-config INTERFACE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/core
${PROJECT_SOURCE_DIR}/src/include
)
include(TestBigEndian)
@@ -86,8 +92,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
endif()
set(OT_CFLAGS
$<$<COMPILE_LANGUAGE:C>:${OT_CFLAGS} -Wall -Wextra -Wshadow>
$<$<COMPILE_LANGUAGE:CXX>:${OT_CFLAGS} -Wall -Wextra -Wshadow -Wno-c++14-compat -fno-exceptions>
$<$<COMPILE_LANGUAGE:C>:${OT_CFLAGS} -Wall -Wformat-nonliteral -Wextra -Wshadow>
$<$<COMPILE_LANGUAGE:CXX>:${OT_CFLAGS} -Wall -Wformat-nonliteral -Wextra -Wshadow -Wno-c++14-compat -fno-exceptions>
$<$<CXX_COMPILER_ID:Clang>:-Wc99-extensions>
)
endif()
@@ -102,66 +109,11 @@ if(OT_PACKAGE_VERSION STREQUAL "")
endif()
message(STATUS "Package Version: ${OT_PACKAGE_VERSION}")
set(OT_THREAD_VERSION "1.3" CACHE STRING "Thread version chosen by the user at configure time")
set_property(CACHE OT_THREAD_VERSION PROPERTY STRINGS "1.1" "1.2" "1.3")
if(${OT_THREAD_VERSION} EQUAL "1.1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_1")
elseif(${OT_THREAD_VERSION} EQUAL "1.2")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2")
elseif(${OT_THREAD_VERSION} EQUAL "1.3")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3")
else()
message(FATAL_ERROR "Thread version unknown: ${OT_THREAD_VERSION}")
endif()
# Deprecated
set(OT_CONFIG "" CACHE STRING "OpenThread config header file (deprecated, use `OT_PROJECT_CONFIG` or `OT_PLATFORM_CONFIG` instead")
set(OT_PLATFORM "NO" CACHE STRING "Target platform chosen by the user at configure time")
ot_get_platforms(OT_PLATFORMS)
set_property(CACHE OT_PLATFORM PROPERTY STRINGS ${OT_PLATFORMS})
if(NOT OT_PLATFORM IN_LIST OT_PLATFORMS)
message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}")
endif()
set(OT_LOG_LEVEL "" CACHE STRING "set OpenThread log level")
set(OT_LOG_LEVEL_VALUES
"NONE"
"CRIT"
"WARN"
"NOTE"
"INFO"
"DEBG"
)
set_property(CACHE OT_LOG_LEVEL PROPERTY STRINGS ${OT_LOG_LEVEL_VALUES})
if(OT_LOG_LEVEL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_${OT_LOG_LEVEL}")
endif()
set(OT_LOG_OUTPUT_VALUES
"APP"
"DEBUG_UART"
"NONE"
"PLATFORM_DEFINED"
)
if(OT_REFERENCE_DEVICE AND NOT OT_PLATFORM STREQUAL "posix")
set(OT_LOG_OUTPUT "APP" CACHE STRING "Set log output to application for reference device")
else()
set(OT_LOG_OUTPUT "" CACHE STRING "Where log output goes to")
endif()
set_property(CACHE OT_LOG_OUTPUT PROPERTY STRINGS ${OT_LOG_OUTPUT_VALUES})
if(OT_LOG_OUTPUT)
if(NOT OT_LOG_OUTPUT IN_LIST OT_LOG_OUTPUT_VALUES)
message(FATAL_ERROR "Log output unknown: ${OT_LOG_OUTPUT}")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_${OT_LOG_OUTPUT}")
message(STATUS "Log output: ${OT_LOG_OUTPUT}")
endif()
# OT_CONFIG allows users to specify the path to a customized OpenThread
# config header file. The default value of this parameter is empty string.
# When not specified by user (value is ""), a platform cmake file may
# choose to change this variable to provide its own OpenThread config header
# file instead.
set(OT_CONFIG "" CACHE STRING "OpenThread project-specific config header file chosen by user at configure time")
set(OT_PROJECT_CONFIG "" CACHE STRING "OpenThread project-specific config header file")
set(OT_PLATFORM_CONFIG "" CACHE STRING "OpenThread platform-specific config header file")
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_BINARY_DIR}/etc/cmake)
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/etc/cmake)
@@ -169,17 +121,40 @@ list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include)
if(OT_PLATFORM STREQUAL "posix")
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/src/posix/platform)
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=1)
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform")
elseif(OT_PLATFORM STREQUAL "external")
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
# skip in this case
elseif(OT_PLATFORM STREQUAL "nexus")
if (OT_APP_CLI OR OT_APP_NCP OR OT_APP_RCP)
message(FATAL_ERROR "no app (cli/ncp/rcp) should be enabled with nexus simulation platform")
endif()
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=1)
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
else()
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=0)
target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_NEXUS=0)
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM})
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}")
endif()
if(OT_CONFIG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_FILE=\"${OT_CONFIG}\"")
message(STATUS "OpenThread Config File: \"${OT_CONFIG}\"")
message(WARNING "OT_CONFIG is deprecated - use `OT_PROJECT_CONFIG` and `OT_PLATFORM_CONFIG` instead")
message(STATUS "OT_CONFIG=\"${OT_CONFIG}\"")
endif()
if (OT_PROJECT_CONFIG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_PROJECT_CONFIG}\"")
message(STATUS "OT_PROJECT_CONFIG=\"${OT_PROJECT_CONFIG}\"")
endif()
if (OT_PLATFORM_CONFIG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_PLATFORM_CORE_CONFIG_FILE=\"${OT_PLATFORM_CONFIG}\"")
message(STATUS "OT_PLATFORM_CONFIG=\"${OT_PLATFORM_CONFIG}\"")
endif()
target_compile_definitions(ot-config INTERFACE ${OT_PLATFORM_DEFINES})
@@ -201,11 +176,8 @@ endif()
add_subdirectory(src)
add_subdirectory(third_party EXCLUDE_FROM_ALL)
if(OT_PLATFORM STREQUAL "simulation")
enable_testing()
endif()
add_subdirectory(tests)
add_subdirectory(tools)
add_custom_target(print-ot-config ALL
COMMAND ${CMAKE_COMMAND}
+96
View File
@@ -0,0 +1,96 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "simulation",
"displayName": "Simulation Configure",
"description": "Simulation platform build in 'build/simulation' folder",
"binaryDir": "${sourceDir}/build/simulation",
"inherits": "common",
"cacheVariables": {
"OT_DNS_CLIENT_OVER_TCP": "ON",
"OT_DNS_DSO": "ON",
"OT_LINK_RAW": "ON",
"OT_PLATFORM": "simulation",
"OT_UDP_FORWARD": "ON"
}
},
{
"name": "common",
"displayName": "Common Config",
"description": "Common configuration",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"OT_ANYCAST_LOCATOR": "ON",
"OT_BLE_TCAT": "ON",
"OT_BORDER_AGENT": "ON",
"OT_BORDER_AGENT_EPSKC": "ON",
"OT_BORDER_AGENT_ID": "ON",
"OT_BORDER_ROUTER": "ON",
"OT_CHANNEL_MANAGER": "ON",
"OT_CHANNEL_MONITOR": "ON",
"OT_COAP": "ON",
"OT_COAPS": "ON",
"OT_COAP_BLOCK": "ON",
"OT_COAP_OBSERVE": "ON",
"OT_COMMISSIONER": "ON",
"OT_COMPILE_WARNING_AS_ERROR": "ON",
"OT_COVERAGE": "ON",
"OT_DATASET_UPDATER": "ON",
"OT_DHCP6_CLIENT": "ON",
"OT_DHCP6_SERVER": "ON",
"OT_DIAGNOSTIC": "ON",
"OT_DNSSD_SERVER": "ON",
"OT_DNS_CLIENT": "ON",
"OT_ECDSA": "ON",
"OT_HISTORY_TRACKER": "ON",
"OT_IP6_FRAGM": "ON",
"OT_JAM_DETECTION": "ON",
"OT_JOINER": "ON",
"OT_LOG_LEVEL_DYNAMIC": "ON",
"OT_MAC_FILTER": "ON",
"OT_NEIGHBOR_DISCOVERY_AGENT": "ON",
"OT_NETDATA_PUBLISHER": "ON",
"OT_NETDIAG_CLIENT": "ON",
"OT_PING_SENDER": "ON",
"OT_RCP_RESTORATION_MAX_COUNT": "2",
"OT_RCP_TX_WAIT_TIME_SECS": "5",
"OT_REFERENCE_DEVICE": "ON",
"OT_SERVICE": "ON",
"OT_SLAAC": "ON",
"OT_SNTP_CLIENT": "ON",
"OT_SRP_CLIENT": "ON",
"OT_SRP_SERVER": "ON",
"OT_SRP_SERVER_FAST_START_MODE": "ON",
"OT_UPTIME": "ON"
}
}
],
"buildPresets": [
{
"name": "simulation",
"displayName": "Simulation Build",
"configurePreset": "simulation"
}
],
"testPresets": [
{
"name": "simulation",
"displayName": "Simulation Test",
"configurePreset": "simulation",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
}
]
}
+57 -20
View File
@@ -2,45 +2,82 @@
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
Examples of behavior that contributes to a positive environment for our community include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior by participants include:
Examples of unacceptable behavior include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Publishing others' private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
## Enforcement Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at openthread-conduct@google.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at openthread-conduct@google.com. All complaints will be reviewed and investigated promptly and fairly.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of actions.
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][mozilla coc].
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][faq]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[mozilla coc]: https://github.com/mozilla/diversity
[faq]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
+1 -1
View File
@@ -109,7 +109,7 @@ This will open up a text editor where you can specify which commits to squash.
#### Coding Conventions and Style
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v19](https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.7) for C/C++ and [yapf v0.43.0](https://github.com/google/yapf) for Python.
As part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks.
+129
View File
@@ -0,0 +1,129 @@
# OpenThread (`openthread`) GEMINI.md
## Project Overview
OpenThread is an open-source implementation of the Thread networking protocol, released by Google. It is designed to be OS and platform-agnostic, with a small memory footprint, making it highly portable. It supports both system-on-chip (SoC) and network co-processor (NCP) designs and is a Thread Certified Component.
The project is primarily written in C and C++, with Python used for scripting and tooling. It uses a variety of build systems, including CMake and GN, and is actively maintained with a strong emphasis on code quality and style, enforced through continuous integration.
## Building and Running
The project uses both CMake and GN as build systems. A collection of scripts in the `script/` directory simplifies the build and test process.
### Prerequisites
- **Compilers:** `gcc` and `clang`
- **Build tools:** `make`, `ninja-build`
- **Other tools:** `python3`, `yapf` (v0.43.0), `clang-format` (v19), `pylint`, `shellcheck`, `iwyu`
A bootstrap script is provided to install the required tools:
```bash
./script/bootstrap
```
### Building with CMake
The project provides CMake presets for easier configuration.
**Configure:**
```bash
cmake --preset simulation
```
**Build:**
```bash
cmake --build --preset simulation
```
### Building with Scripts
The `script/` directory contains several scripts for building the project for different configurations:
- **Simulation Build:**
```bash
script/check-simulation-build
```
- **POSIX Build:**
```bash
script/check-posix-build
```
- **ARM Build:**
```bash
script/check-arm-build
```
- **GN Build:**
```bash
script/check-gn-build
```
## Testing
The project uses CTest for testing.
To run the tests after building with the simulation preset:
```bash
ctest --preset simulation
```
### Nexus Tests
Nexus is a test framework that allows simulating multiple OpenThread nodes within a single process, enabling faster and more scalable network simulations.
**Build Nexus tests:**
```bash
top_builddir=nexus_test ./tests/nexus/build.sh
```
**Run all Nexus tests:**
```bash
top_builddir=nexus_test ./tests/nexus/run_nexus_tests.sh
```
**Run a specific Nexus test:**
```bash
top_builddir=nexus_test ./tests/nexus/run_nexus_tests.sh <test_name>
```
For more details, see [tests/nexus/README.md](tests/nexus/README.md).
## Development Conventions
### Code Style
The project has a strict coding style, which is enforced by the `script/make-pretty` script. Before submitting a pull request, ensure your code is formatted correctly.
**Check code style:**
```bash
script/make-pretty check
```
**Format code:**
```bash
script/make-pretty
```
Key style points:
- **Indentation:** 4 spaces.
- **Naming:**
- `UpperCamelCase` for types (classes, structs, enums), methods, functions.
- `lowerCamelCase` for variables.
- `g` prefix for globals, `s` for statics, `m` for members, `a` for arguments.
- **Comments:** Doxygen is used for API documentation.
For more details, see the [STYLE_GUIDE.md](STYLE_GUIDE.md).
### Commits and Pull Requests
The project follows the "Fork-and-Pull" model. All contributions must be accompanied by a Contributor License Agreement (CLA). Pull requests are tested using GitHub Actions, and all checks must pass before merging.
For more details, see the [CONTRIBUTING.md](CONTRIBUTING.md).
-189
View File
@@ -1,189 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
AM_MAKEFLAGS = --no-print-directory
AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-address-sanitizer \
--enable-cli \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--enable-radio-cli \
--with-examples=simulation \
$(NULL)
SUBDIRS = \
include \
third_party \
src \
examples \
tests \
tools \
doc \
$(NULL)
EXTRA_DIST = \
.default-version \
bootstrap \
etc \
README.md \
NOTICE \
CONTRIBUTING.md \
LICENSE \
$(NULL)
BUILT_SOURCES = \
.local-version \
$(NULL)
dist_doc_DATA = \
$(NULL)
DISTCLEANFILES = \
.local-version \
$(NULL)
# Ignore the pseudo flash files on Posix platform during diskcheck
distcleancheck_listfiles = \
$(AM_V_at)find . -type f -name "*flash"
#
# Package version files:
#
# .default-version - The default package version. This file is ALWAYS checked
# in and should always represent the current baseline
# version of the package.
#
# .dist-version - The distributed package version. This file is NEVER
# checked in within the upstream repository, is auto-
# generated, and is only found in the package distribution.
#
# .local-version - The current source code controlled package version. This
# file is NEVER checked in within the upstream repository,
# is auto-generated, and can always be found in both the
# build tree and distribution.
#
# When present, the .local-version file is preferred first, the
# .dist-version second, and the .default-version last.
#
VERSION_FILE := $(if $(wildcard $(builddir)/.local-version),$(builddir)/.local-version,$(if $(wildcard $(srcdir)/.dist-version),$(srcdir)/.dist-version,$(srcdir)/.default-version))
#
# Override autotool's default notion of the package version variables.
# This ensures that when we create a source distribution that the
# version is always the current version, not the version when the
# package was bootstrapped.
#
OPENTHREAD_VERSION ?= $(shell cat $(VERSION_FILE) 2> /dev/null)
PACKAGE_VERSION = $(OPENTHREAD_VERSION)
VERSION = $(PACKAGE_VERSION)
distdir = $(PACKAGE)-$(shell \
if [ "$(origin OPENTHREAD_VERSION)" != "file" ]; then \
echo "$(OPENTHREAD_VERSION)" ; \
else \
$(abs_top_nlbuild_autotools_dir)/scripts/mkversion \
-b "$(OPENTHREAD_VERSION)" "$(top_srcdir)"; \
fi )
#
# check-file-.local-version
#
# Speculatively regenerate .local-version and check to see if it needs
# to be updated.
#
# If OPENTHREAD_VERSION has been supplied anywhere other than in this file
# (which is implicitly the contents of .local-version), then use that;
# otherwise, attempt to generate it from the SCM system.
#
# This is called from $(call check-file,.local-version).
#
define check-file-.local-version
if [ "$(origin OPENTHREAD_VERSION)" != "file" ]; then \
echo "$(OPENTHREAD_VERSION)" > "$(2)"; \
else \
$(abs_top_nlbuild_autotools_dir)/scripts/mkversion \
-b "$(OPENTHREAD_VERSION)" "$(top_srcdir)" \
> "$(2)"; \
fi
endef
#
# check-file-.dist-version
#
# Speculatively regenerate .dist-version and check to see if it needs
# to be updated.
#
# This is called from $(call check-file,.dist-version).
#
define check-file-.dist-version
cat "$(1)" > "$(2)"
endef
#
# A convenience target to allow package users to easily rerun the
# package configuration according to the current configuration.
#
.PHONY: reconfigure
reconfigure: $(builddir)/config.status
$(AM_V_at)$(<) --recheck
#
# Version file regeneration rules.
#
.PHONY: force
$(builddir)/.local-version: $(srcdir)/.default-version force
$(distdir)/.dist-version: $(builddir)/.local-version force
$(distdir)/.dist-version $(builddir)/.local-version:
$(call check-file,$(@F))
dist distcheck: $(BUILT_SOURCES)
dist-hook: $(distdir)/.dist-version
#
# Top-level convenience target for making a documentation-only
# distribution whose results appear at the top level of the build tree
# in the same fashion that the distribution would be for 'make dist'.
#
.PHONY: docdist
docdist: $(BUILT_SOURCES)
$(MAKE) -C doc docdistdir=$(abs_builddir) $(@)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+4 -4
View File
@@ -1,5 +1,5 @@
OpenThread is an open source implementation of the Thread 1.2.0 Final Specification.
The Thread 1.2.0 Final Specification is promulgated by the Thread Group. The Thread
OpenThread is an open source implementation of the Thread 1.4.0 Final Specification.
The Thread 1.4.0 Final Specification is promulgated by the Thread Group. The Thread
Group is a non-profit organization formed for the purposes of defining one or
more specifications, best practices, reference architectures, implementation
guidelines and certification programs to promote the availability of compliant
@@ -7,10 +7,10 @@ implementations of the Thread protocol. Information on becoming a Member, includ
information about the benefits thereof, can be found at http://threadgroup.org.
OpenThread is not affiliated with or endorsed by the Thread Group. Implementation
of this OpenThread code does not assure compliance with the Thread 1.2.0 Final
of this OpenThread code does not assure compliance with the Thread 1.4.0 Final
Specification and does not convey the right to identify any final product as Thread
certified. Members of the Thread Group may hold patents and other intellectual
property rights relating to the Thread 1.2.0 Final Specification, ownership and
property rights relating to the Thread 1.4.0 Final Specification, ownership and
licenses of which are subject to the Thread Groups IP Policies, and not this license.
The included copyright to the OpenThread code is subject to the license in the
+5 -17
View File
@@ -1,4 +1,4 @@
[![OpenThread][ot-logo]][ot-repo] [![Build][ot-gh-action-build-svg]][ot-gh-action-build] [![Simulation][ot-gh-action-simulation-svg]][ot-gh-action-simulation] [![Docker][ot-gh-action-docker-svg]][ot-gh-action-docker] [![Language grade: C/C++][ot-lgtm-svg]][ot-lgtm] [![Coverage Status][ot-codecov-svg]][ot-codecov]
[![OpenThread][ot-logo]][ot-repo] [![Ask DeepWiki][deep-wiki-svg]][deep-wiki]
---
@@ -10,26 +10,18 @@ OpenThread released by Google is... <a href="https://www.threadgroup.org/What-is
**...OS and platform agnostic**, with a narrow platform abstraction layer and a small memory footprint, making it highly portable. It supports both system-on-chip (SoC) and network co-processor (NCP) designs.
**...a Thread Certified Component**, implementing all features defined in the [Thread 1.2 specification](https://www.threadgroup.org/support#specifications), including all Thread networking layers (IPv6, 6LoWPAN, IEEE 802.15.4 with MAC security, Mesh Link Establishment, Mesh Routing) and device roles, as well as [Border Router](https://github.com/openthread/ot-br-posix) support.
**...a Thread Certified Component**, implementing all features defined in the [Thread 1.4.0 specification](https://www.threadgroup.org/support#specifications), including all Thread networking layers (IPv6, 6LoWPAN, IEEE 802.15.4 with MAC security, Mesh Link Establishment, Mesh Routing) and device roles, as well as [Border Router](https://github.com/openthread/ot-br-posix) support.
More information about Thread can be found at [threadgroup.org](http://threadgroup.org/). Thread is a registered trademark of the Thread Group, Inc.
[ot-repo]: https://github.com/openthread/openthread
[ot-logo]: https://github.com/openthread/openthread/raw/main/doc/images/openthread_logo.png
[ot-gh-action-build]: https://github.com/openthread/openthread/actions?query=workflow%3ABuild+branch%3Amain+event%3Apush
[ot-gh-action-build-svg]: https://github.com/openthread/openthread/workflows/Build/badge.svg?branch=main&event=push
[ot-gh-action-simulation]: https://github.com/openthread/openthread/actions?query=workflow%3ASimulation+branch%3Amain+event%3Apush
[ot-gh-action-simulation-svg]: https://github.com/openthread/openthread/workflows/Simulation/badge.svg?branch=main&event=push
[ot-gh-action-docker]: https://github.com/openthread/openthread/actions?query=workflow%3ADocker+branch%3Amain+event%3Apush
[ot-gh-action-docker-svg]: https://github.com/openthread/openthread/workflows/Docker/badge.svg?branch=main&event=push
[ot-lgtm]: https://lgtm.com/projects/g/openthread/openthread/context:cpp
[ot-lgtm-svg]: https://img.shields.io/lgtm/grade/cpp/g/openthread/openthread.svg?logo=lgtm&logoWidth=18
[ot-codecov]: https://codecov.io/gh/openthread/openthread
[ot-codecov-svg]: https://codecov.io/gh/openthread/openthread/branch/main/graph/badge.svg
[deep-wiki]: https://deepwiki.com/openthread/openthread
[deep-wiki-svg]: https://deepwiki.com/badge.svg
# Who supports OpenThread?
<a href="https://www.arm.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-arm.png" alt="ARM" width="200px"></a><a href="https://www.cascoda.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-cascoda.png" alt="Cascoda" width="200px"></a><a href="https://www.espressif.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-espressif-github.png" alt="Espressif" width="200px"></a><a href="https://www.google.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-google.png" alt="Google" width="200px"></a><a href="https://www.infineon.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-infineon.png" alt="Infineon" width="200px"></a><a href="http://www.nordicsemi.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nordic.png" alt="Nordic" width="200px"></a><a href="http://www.nxp.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nxp.png" alt="NXP" width="200px"></a><a href="http://www.qorvo.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-qorvo.png" alt="Qorvo" width="200px"></a><a href="https://www.qualcomm.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-qc.png" alt="Qualcomm" width="200px"></a><a href="https://www.samsung.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-samsung.png" alt="Samsung" width="200px"></a><a href="https://www.silabs.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-silabs.png" alt="Silicon Labs" width="200px"></a><a href="https://www.st.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-stm.png" alt="STMicroelectronics" width="200px"></a><a href="https://www.synopsys.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-synopsys.png" alt="Synopsys" width="200px"></a><a href="https://www.telink-semi.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-telink-github.png" alt="Telink Semiconductor" width="200px"></a><a href="https://www.ti.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-ti.png" alt="Texas Instruments" width="200px"></a><a href="https://www.zephyrproject.org/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-zephyr.png" alt="Zephyr Project" width="200px"></a>
<a href="https://www.amazon.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-amazon.png" alt="Amazon" width="200px"></a><a href="https://www.aqara.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-aqara.png" alt="Aqara" width="200px"></a><a href="https://www.arm.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-arm.png" alt="ARM" width="200px"></a><a href="https://www.bekencorp.com/en"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-beken.png" alt="Beken" width="200px"></a><a href="https://www.cascoda.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-cascoda.png" alt="Cascoda" width="200px"></a><a href="https://www.eero.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-eero.png" alt="Eero" width="200px"></a><a href="https://www.espressif.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-espressif-github.png" alt="Espressif" width="200px"></a><a href="https://www.google.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-google.png" alt="Google" width="200px"></a><a href="https://www.infineon.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-infineon.png" alt="Infineon" width="200px"></a><a href="https://mmbnetworks.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-mmb-networks.png" alt="MMB Networks" width="200px"></a><a href="https://www.nabucasa.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nabu-casa.png" alt="Nabu Casa" width="200px"></a><a href="https://www.nanoleaf.me/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nanoleaf.png" alt="Nanoleaf" width="200px"></a><a href="http://www.nordicsemi.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nordic.png" alt="Nordic" width="200px"></a><a href="http://www.nxp.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-nxp.png" alt="NXP" width="200px"></a><a href="http://www.qorvo.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-qorvo.png" alt="Qorvo" width="200px"></a><a href="https://www.qualcomm.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-qc.png" alt="Qualcomm" width="200px"></a><a href="https://www.samsung.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-samsung.png" alt="Samsung" width="200px"></a><a href="https://www.silabs.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-silabs.png" alt="Silicon Labs" width="200px"></a><a href="https://www.st.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-stm.png" alt="STMicroelectronics" width="200px"></a><a href="https://www.synopsys.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-synopsys.png" alt="Synopsys" width="200px"></a><a href="https://www.telink-semi.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-telink-github.png" alt="Telink Semiconductor" width="200px"></a><a href="https://www.ti.com/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-ti.png" alt="Texas Instruments" width="200px"></a><a href="https://www.zephyrproject.org/"><img src="https://github.com/openthread/openthread/raw/main/doc/images/ot-contrib-zephyr.png" alt="Zephyr Project" width="200px"></a>
# Getting started
@@ -54,10 +46,6 @@ We would love for you to contribute to OpenThread and help make it even better t
Contributors are required to abide by our [Code of Conduct](https://github.com/openthread/openthread/blob/main/CODE_OF_CONDUCT.md) and [Coding Conventions and Style Guide](https://github.com/openthread/openthread/blob/main/STYLE_GUIDE.md).
# Versioning
OpenThread follows the [Semantic Versioning guidelines](http://semver.org/) for release cycle transparency and to maintain backwards compatibility. OpenThread's versioning is independent of the Thread protocol specification version but will clearly indicate which version of the specification it currently supports.
# License
OpenThread is released under the [BSD 3-Clause license](https://github.com/openthread/openthread/blob/main/LICENSE). See the [`LICENSE`](https://github.com/openthread/openthread/blob/main/LICENSE) file for more information.
+1
View File
@@ -0,0 +1 @@
To report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). We use g.co/vulnz for our intake, and do coordination and disclosure here on GitHub (including using GitHub Security Advisory). The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
+1 -1
View File
@@ -116,7 +116,7 @@
- OpenThread uses `script/make-pretty` to reformat code and enforce code format and style. `script/make-pretty check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
- `script/make-pretty` requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
- `script/make-pretty` requires [clang-format v19](https://github.com/llvm/llvm-project/releases/tag/llvmorg-19.1.7) for C/C++ and [yapf v0.43.0](https://github.com/google/yapf) for Python.
### File Names
-45
View File
@@ -1,45 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Description:
# This file is a trampoline script to the nlbuild-autotools
# bootstrap script and augments it by providing the path to the
# nlbuild-autotools repository for this project.
#
# Set this to the relative location of nlbuild-autotools to this script
nlbuild_autotools_stem="third_party/nlbuild-autotools/repo"
abs_srcdir=$(cd "$(dirname "${0}")" && pwd)
# filter out knowning information from stderr which is causing GitHub annotation check warnings.
(cd "$abs_srcdir" && exec "$abs_srcdir/$nlbuild_autotools_stem/scripts/bootstrap" -I "$abs_srcdir/$nlbuild_autotools_stem" "${@}") 2> \
>(grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/missing'" \
| grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/compile'" \
| grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/depcomp'" 1>&2)
-1107
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1144,7 +1144,7 @@ HTML_STYLESHEET =
# defined cascading style sheet that is included after the standard style sheets
# created by doxygen. Using this option one can overrule certain style aspects.
# This is preferred over using HTML_STYLESHEET since it does not replace the
# standard style sheet and is therefor more robust against future updates.
# standard style sheet and is therefore more robust against future updates.
# Doxygen will copy the style sheet file to the output directory. For an example
# see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -2026,10 +2026,10 @@ PREDEFINED = __attribute__(x)=
# definition found in the source code.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_AS_DEFINED =
EXPAND_AS_DEFINED = OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK
# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
# remove all refrences to function-like macros that are alone on a line, have an
# remove all references to function-like macros that are alone on a line, have an
# all uppercase name, and do not end with a semicolon. Such function macros are
# typically used for boiler-plate code, and will confuse the parser if not
# removed.
-128
View File
@@ -1,128 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
EXTRA_DIST = \
$(srcdir)/Doxyfile.in \
$(srcdir)/header.html \
$(srcdir)/images/Open-Thread-Logo-200x42.png \
$(srcdir)/images/openthread_logo.png \
$(srcdir)/images/ot-contrib-arm.png \
$(srcdir)/images/ot-contrib-cascoda.png \
$(srcdir)/images/ot-contrib-google.png \
$(srcdir)/images/ot-contrib-nordic.png \
$(srcdir)/images/ot-contrib-nxp.png \
$(srcdir)/images/ot-contrib-qc.png \
$(srcdir)/images/ot-contrib-qorvo.png \
$(srcdir)/images/ot-contrib-samsung.png \
$(srcdir)/images/ot-contrib-silabs.png \
$(srcdir)/images/ot-contrib-stm.png \
$(srcdir)/images/ot-contrib-synopsys.png \
$(srcdir)/images/ot-contrib-ti.png \
$(srcdir)/images/ot-contrib-zephyr.png \
$(srcdir)/ot_api_doc.h \
$(NULL)
#
# Override autotool's default notion of the package version variables.
# This ensures that when we create a doc distribution that the
# version is always the current version, not the version when the
# package was bootstrapped.
#
PACKAGE_VERSION = $(shell cat $(top_builddir)/.local-version)
VERSION = $(PACKAGE_VERSION)
docdistdir ?= .
openthread_docdist_alias = \
$(PACKAGE_TARNAME)-docs
openthread_docdist_name = \
$(openthread_docdist_alias)-$(VERSION)
openthread_docdist_archive = \
$(docdistdir)/$(openthread_docdist_name).tar.gz
CLEANFILES = \
Doxyfile \
$(openthread_docdist_archive) \
$(NULL)
if OPENTHREAD_BUILD_DOCS
openthreaddir = $(includedir)/openthread
dist_openthread_HEADERS = ot_api_doc.h
all-local: html/index.html
#
# We choose to manually transform Doxyfile.in into Doxyfile here in
# the makefile rather than in the configure script so that we can take
# advantage of live, at build time (rather than at configure time),
# updating of the package version number.
#
Doxyfile: $(srcdir)/Doxyfile.in Makefile
$(AM_V_GEN)$(SED) \
-e "s,\@DOXYGEN_USE_DOT\@,$(DOXYGEN_USE_DOT),g" \
-e "s,\@PACKAGE_NAME\@,$(PACKAGE_NAME),g" \
-e "s,\@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g" \
-e "s,\@PERL\@,$(PERL),g" \
-e "s,\@abs_builddir\@,$(abs_builddir),g" \
-e "s,\@abs_srcdir\@,$(abs_srcdir),g" \
-e "s,\@abs_top_builddir\@,$(abs_top_builddir),g" \
-e "s,\@abs_top_srcdir\@,$(abs_top_srcdir),g" \
< "$(srcdir)/Doxyfile.in" > "$(@)"
html/index.html: Doxyfile
$(AM_V_GEN)$(DOXYGEN) $(<)
#
# Addition rules and commands to create a documentation-only
# distribution of openthread
#
$(openthread_docdist_name): html/index.html
$(AM_V_at)rm -f -r $(@)
$(call create-directory)
$(AM_V_at)cp -R html $(@)
$(openthread_docdist_archive): $(openthread_docdist_name)
$(AM_V_at)echo " TAR $(@)"
$(AM_V_at)tardir="$(<)" && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c > "$(@)" && rm -rf $(<)
docdist $(openthread_docdist_alias): $(openthread_docdist_archive)
clean-local:
$(AM_V_at)rm -f -r html
endif # OPENTHREAD_BUILD_DOCS
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

+115 -75
View File
@@ -33,151 +33,191 @@
*/
/**
* @defgroup api API
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
* Important note: The OpenThread stack is not re-entrant. All OpenThread public APIs, platform APIs, and callbacks
* MUST be invoked from the same OS context (e.g., the same thread/process or the same task in an RTOS).
* Any exceptions to this rule, where an API can be called from a different context, will be explicitly documented
* in that API's reference. Failure to follow this rule can lead to undefined and unexpected behaviors.
*
* @defgroup api-error Error
*
* @defgroup api-execution Execution
* If an API call returns an error status (any value other than success), the caller MUST assume any of the output
* parameters passed to the API may have been modified and are in an indeterminate state. Assuming that an output
* parameter remains unchanged upon error is invalid. If an API deviates from this default behavior (e.g., by
* guaranteeing parameters are untouched on error), it will be explicitly documented. Otherwise, developers
* MUST NOT make this assumption.
*
* @{
*
* @defgroup api-instance Instance
* @defgroup api-tasklets Tasklets
* @defgroup api-error Error
*
* @defgroup api-execution Execution
*
* @{
*
* @defgroup api-instance Instance
* @defgroup api-tasklets Tasklets
*
* @}
*
* @defgroup api-net IPv6 Networking
* @defgroup api-net IPv6 Networking
* @{
*
* @defgroup api-dns DNSv6
* @defgroup api-dnssd-server DNS-SD Server
* @defgroup api-icmp6 ICMPv6
* @defgroup api-ip6 IPv6
* @defgroup api-srp SRP
* @defgroup api-ping-sender Ping Sender
* @defgroup api-ble-secure BLE Secure
* @defgroup api-dns DNS
* @defgroup api-dnssd-server DNS-SD Server
* @defgroup api-icmp6 ICMPv6
* @defgroup api-ip6 IPv6
* @defgroup api-mdns Multicast DNS
* @defgroup api-nat64 NAT64
* @defgroup api-srp SRP
* @defgroup api-ping-sender Ping Sender
*
* @defgroup api-tcp-group TCP
* @defgroup api-tcp-group TCP
*
* @{
*
* @defgroup api-tcp TCP
* @defgroup api-tcp-ext TCP Abstractions
* @defgroup api-tcp TCP
* @defgroup api-tcp-ext TCP Abstractions
*
* @}
*
* @defgroup api-udp-group UDP
* @defgroup api-udp-group UDP
*
* @{
*
* @defgroup api-udp UDP
* @defgroup api-udp-forward UDP Forward
* @defgroup api-udp UDP
* @defgroup api-udp-forward UDP Forward
*
* @}
*
* @}
*
* @defgroup api-link Link
* @defgroup api-link Link
*
* @{
*
* @defgroup api-link-link Link
* @defgroup api-link-metrics Link Metrics
* @defgroup api-link-raw Raw Link
* @defgroup api-link-link Link
* @defgroup api-link-metrics Link Metrics
* @defgroup api-link-raw Raw Link
*
* @}
*
* @defgroup api-message Message
* @defgroup api-message Message
*
* @defgroup api-multi-radio Multi Radio Link
* @defgroup api-trel TREL - Thread Stack
* @defgroup api-multi-radio Multi Radio Link
* @defgroup api-trel TREL - Thread Stack
*
* @defgroup api-thread Thread
* @defgroup api-thread Thread
*
* @{
*
* @defgroup api-backbone-router Backbone Router
* @defgroup api-border-agent Border Agent
* @defgroup api-border-router Border Router
* @defgroup api-commissioner Commissioner
* @defgroup api-thread-general General
* @defgroup api-backbone-router Backbone Router
* @defgroup api-border-agent Border Agent
* @defgroup api-border-agent-tracker Border Agent Tracker
* @defgroup api-border-agent-txt-data Border Agent TXT Data Parser
* @defgroup api-border-router Border Router
* @defgroup api-border-routing Border Routing Manager
* @defgroup api-multi-ail-detection Border Router Multi AIL Detection
* @defgroup api-commissioner Commissioner
* @defgroup api-thread-general General
* @brief This module includes functions for all Thread roles.
* @defgroup api-joiner Joiner
* @defgroup api-operational-dataset Operational Dataset
* @defgroup api-thread-router Router/Leader
* @defgroup api-joiner Joiner
* @defgroup api-operational-dataset Operational Dataset
* @brief Includes functions for the Operational Dataset API.
* @defgroup api-thread-router Router/Leader
* @brief This module includes functions for Thread Routers and Leaders.
* @defgroup api-server Server
* @defgroup api-seeker Seeker
* @defgroup api-server Server
* @defgroup api-steering-data Steering Data
*
* @}
*
* @defgroup api-addons Add-Ons
* @defgroup api-addons Add-Ons
*
* @{
*
* @defgroup api-channel-manager Channel Manager
* @defgroup api-channel-monitor Channel Monitoring
* @defgroup api-child-supervision Child Supervision
* @defgroup api-coap-group CoAP
* @defgroup api-channel-manager Channel Manager
* @defgroup api-channel-monitor Channel Monitoring
* @defgroup api-child-supervision Child Supervision
* @defgroup api-coap-group CoAP
*
* @{
*
* @defgroup api-coap CoAP
* @defgroup api-coap-secure CoAP Secure
* @defgroup api-coap CoAP
* @defgroup api-coap-secure CoAP Secure
*
* @}
*
* @defgroup api-cli Command Line Interface
* @defgroup api-crypto Crypto - Thread Stack
* @defgroup api-factory-diagnostics Factory Diagnostics - Thread Stack
* @defgroup api-heap Heap
* @defgroup api-history-tracker History Tracker
* @defgroup api-jam-detection Jam Detection
* @defgroup api-logging Logging - Thread Stack
* @defgroup api-ncp Network Co-Processor
* @defgroup api-network-time Network Time Synchronization
* @defgroup api-random-group Random Number Generator
* @defgroup api-cli Command Line Interface
* @defgroup api-crypto Crypto - Thread Stack
* @defgroup api-factory-diagnostics Factory Diagnostics - Thread Stack
* @defgroup api-heap Heap
* @defgroup api-history-tracker History Tracker
* @defgroup api-jam-detection Jam Detection
* @defgroup api-logging Logging - Thread Stack
* @defgroup api-mesh-diag Mesh Diagnostics
* @defgroup api-ncp Network Co-Processor
* @defgroup api-network-time Network Time Synchronization
* @defgroup api-radio Radio Statistics
* @defgroup api-random-group Random Number Generator
*
* @{
*
* @defgroup api-random-crypto RNG Cryptographic
* @defgroup api-random-non-crypto RNG Non-cryptographic
* @defgroup api-random-crypto RNG Cryptographic
* @defgroup api-random-non-crypto RNG Non-cryptographic
*
* @}
*
* @defgroup api-sntp SNTP
* @defgroup api-sntp SNTP
* @defgroup api-verhoeff-checksum Verhoeff Checksum
*
* @}
*
* @defgroup api-provisional Provisional
* @brief
* This module includes the OpenThread provisional APIs. These APIs are not stable and users should use them with
* caution.
*
* @{
*
* @defgroup api-provisional-link Link
* @defgroup api-provisional-p2p Peer-to-Peer
*
* @}
*
* @}
*
*/
/**
* @defgroup platform Platform Abstraction
* @defgroup platform Platform Abstraction
* @brief
* This module includes the platform abstraction used by the OpenThread stack.
*
* @{
*
* @defgroup plat-alarm Alarm
* @defgroup plat-crypto Crypto - Platform
* @defgroup plat-entropy Entropy
* @defgroup plat-factory-diagnostics Factory Diagnostics - Platform
* @defgroup plat-logging Logging - Platform
* @defgroup plat-memory Memory
* @defgroup plat-messagepool Message Pool
* @defgroup plat-misc Miscellaneous
* @defgroup plat-otns Network Simulator
* @defgroup plat-radio Radio
* @defgroup plat-settings Settings
* @defgroup plat-spi-slave SPI Slave
* @defgroup plat-time Time Service
* @defgroup plat-toolchain Toolchain
* @defgroup plat-trel TREL - Platform
* @defgroup plat-alarm Alarm
* @defgroup plat-ble BLE
* @defgroup plat-crypto Crypto - Platform
* @defgroup plat-dns DNS - Platform
* @defgroup plat-dns-sd DNS-SD (mDNS)
* @defgroup plat-entropy Entropy
* @defgroup plat-factory-diagnostics Factory Diagnostics - Platform
* @defgroup plat-infra-if Infrastructure Interface
* @defgroup plat-logging Logging - Platform
* @defgroup plat-memory Memory
* @defgroup plat-messagepool Message Pool
* @defgroup plat-misc Miscellaneous
* @defgroup plat-mdns Multicast DNS
* @defgroup plat-multipan Multipan
* @defgroup plat-otns Network Simulator
* @defgroup plat-radio Radio
* @defgroup plat-settings Settings
* @defgroup plat-spi-slave SPI Slave
* @defgroup plat-time Time Service
* @defgroup plat-toolchain Toolchain
* @defgroup plat-trel TREL - Platform
*
* @}
*
*/
+92
View File
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2023, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file defines the Doxygen group structure for OpenThread documentation.
*/
/**
* @defgroup config Config Variables
* @brief
* This module lists all OpenThread configuration variables.
*
* @{
*
* @defgroup config-announce-sender Announce Sender
* @defgroup config-backbone-router Backbone Router Services
* @defgroup config-border-agent Border Agent
* @defgroup config-border-router Border Router
* @defgroup config-border-routing Border Routing Manager
* @defgroup config-channel-manager Channel Manager
* @defgroup config-channel-monitor Channel Monitor
* @defgroup config-child-supervision Child Supervision
* @defgroup config-coap CoAP
* @defgroup config-commissioner Commissioner
* @defgroup config-crypto Crypto Backend Library
* @defgroup config-dataset-updater Dataset Updater
* @defgroup config-dhcpv6-client DHCPv6 Client
* @defgroup config-dhcpv6-server DHCPv6 Server
* @defgroup config-diag DIAG Service
* @defgroup config-dns-client DNS Client
* @defgroup config-dns-dso DNS Stateful Operations
* @defgroup config-dnssd-server DNS-SD Server
* @defgroup config-history-tracker History Tracker
* @defgroup config-ip6 IP6 Service
* @defgroup config-joiner Joiner
* @defgroup config-link-metrics-manager Link Metrics Manager
* @defgroup config-link-quality Link Quality
* @defgroup config-link-raw Link Raw Service
* @defgroup config-logging Logging Service
* @defgroup config-mac MAC
* @defgroup config-mesh-diag Mesh Diagnostic
* @defgroup config-mesh-forwarder Mesh Forwarder
* @defgroup config-misc Miscellaneous Constants
* @defgroup config-mle MLE Service
* @defgroup config-mdns Multicast DNS
* @defgroup config-nat64 NAT64
* @defgroup config-netdata-publisher Network Data Publisher
* @defgroup config-network-diagnostic Network Diagnostics
* @defgroup config-p2p Peer-to-Peer
* @defgroup config-parent-search Parent Search
* @defgroup config-ping-sender Ping Sender
* @defgroup config-platform Platform Specific Services
* @defgroup config-power-calibration Power Calibration
* @defgroup config-radio-link Radio Links
* @defgroup config-secure-transport Secure Transport
* @defgroup config-sntp-client SNTP Client
* @defgroup config-srp-client SRP Client
* @defgroup config-srp-server SRP Server
* @defgroup config-time-sync Time Sync Service
* @defgroup config-tmf Thread Management Framework Service
* @defgroup config-trel TREL
* @defgroup config-wakeup Wake-up
*
* @}
*/
-16
View File
@@ -26,22 +26,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
# Get a list of the available platforms and output as a list to the 'arg_platforms' argument
function(ot_get_platforms arg_platforms)
list(APPEND result "NO" "posix" "external")
set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms")
file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*")
foreach(platform IN LISTS platforms)
if(IS_DIRECTORY "${platforms_dir}/${platform}")
list(APPEND result "${platform}")
endif()
endforeach()
list(REMOVE_ITEM result utils)
list(SORT result)
set(${arg_platforms} "${result}" PARENT_SCOPE)
endfunction()
function(ot_git_version git_version)
execute_process(
COMMAND git describe --dirty --always
+333 -341
View File
@@ -34,61 +34,338 @@ option(OT_FTD "enable FTD" ON)
option(OT_MTD "enable MTD" ON)
option(OT_RCP "enable RCP" ON)
option(OT_ANYCAST_LOCATOR "enable anycast locator support")
if(OT_ANYCAST_LOCATOR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE=1")
option(OT_LINKER_MAP "generate .map files for example apps" ON)
message(STATUS OT_APP_CLI=${OT_APP_CLI})
message(STATUS OT_APP_NCP=${OT_APP_NCP})
message(STATUS OT_APP_RCP=${OT_APP_RCP})
message(STATUS OT_FTD=${OT_FTD})
message(STATUS OT_MTD=${OT_MTD})
message(STATUS OT_RCP=${OT_RCP})
set(OT_CONFIG_VALUES
""
"ON"
"OFF"
)
macro(ot_option name ot_config description)
# Declare an (ON/OFF/unspecified) OT cmake config with `name`
# mapping to OPENTHREAD_CONFIG `ot_config`. Parameter
# `description` provides the help string for this OT cmake
# config. There is an optional last parameter which if provided
# determines the default value for the cmake config. If not
# provided empty string is used which will be treated as "not
# specified". In this case, the variable `name` would still be
# false but the related OPENTHREAD_CONFIG is not added in
# `ot-config`.
if (${ARGC} GREATER 3)
set(${name} ${ARGN} CACHE STRING "enable ${description}")
else()
set(${name} "" CACHE STRING "enable ${description}")
endif()
set_property(CACHE ${name} PROPERTY STRINGS ${OT_CONFIG_VALUES})
string(COMPARE EQUAL "${${name}}" "" is_empty)
if (is_empty)
message(STATUS "${name}=\"\"")
elseif (${name})
message(STATUS "${name}=ON --> ${ot_config}=1")
target_compile_definitions(ot-config INTERFACE "${ot_config}=1")
else()
message(STATUS "${name}=OFF --> ${ot_config}=0")
target_compile_definitions(ot-config INTERFACE "${ot_config}=0")
endif()
endmacro()
macro(ot_string_option name ot_config description)
# Declare a string OT cmake config with `name` mapping to
# OPENTHREAD_CONFIG `ot_config`. Parameter `description` provides
# the help string for this OT cmake config. There is an optional
# last parameter which if provided determines the default value
# for the cmake config. If not provided empty string is used
# which will be treated as "not specified".
if (${ARGC} GREATER 3)
set(${name} ${ARGN} CACHE STRING "${description}")
else()
set(${name} "" CACHE STRING "${description}")
endif()
set_property(CACHE ${name} PROPERTY STRINGS "")
string(COMPARE EQUAL "${${name}}" "" is_empty)
if (is_empty)
message(STATUS "${name}=\"\"")
else()
message(STATUS "${name}=\"${${name}}\" --> ${ot_config}=\"${${name}}\"")
target_compile_definitions(ot-config INTERFACE "${ot_config}=\"${${name}}\"")
endif()
endmacro()
macro(ot_int_option name ot_config description)
# Declares a integer-value OT cmake config with `name` mapping to
# OPENTHREAD_CONFIG `ot_config`. There is an optional last
# parameter which if provided determines the default value for
# the cmake config. If not provided empty string is used which
# will be treated as "not specified".
if (${ARGC} GREATER 3)
set(${name} ${ARGN} CACHE STRING "${description}")
else()
set(${name} "" CACHE STRING "${description}")
endif()
set_property(CACHE ${name} PROPERTY STRINGS "")
string(COMPARE EQUAL "${${name}}" "" is_empty)
if (is_empty)
message(STATUS "${name}=\"\"")
elseif("${${name}}" MATCHES "^[0-9]+$")
message(STATUS "${name}=\"${${name}}\" --> ${ot_config}=${${name}}")
target_compile_definitions(ot-config INTERFACE "${ot_config}=${${name}}")
else()
message(FATAL_ERROR "${name}=\"${${name}}\" - invalid value, must be integer")
endif()
endmacro()
macro(ot_multi_option name values ot_config ot_value_prefix description)
# Declares a multi-value OT cmake config with `name` with valid
# values from `values` list mapping to OPENTHREAD_CONFIG
# `ot_config`. The `ot_value_prefix` is the prefix string to
# construct the OPENTHREAD_CONFIG value. There is an optional
# last parameter which if provided determines the default value
# for the cmake config. If not provided empty string is used
# which will be treated as "not specified".
if (${ARGC} GREATER 5)
set(${name} ${ARGN} CACHE STRING "${description}")
else()
set(${name} "" CACHE STRING "${description}")
endif()
set_property(CACHE ${name} PROPERTY STRINGS "${${values}}")
string(COMPARE EQUAL "${${name}}" "" is_empty)
if (is_empty)
message(STATUS "${name}=\"\"")
else()
list(FIND ${values} "${${name}}" ot_index)
if(ot_index EQUAL -1)
message(FATAL_ERROR "${name}=\"${${name}}\" - unknown value, valid values " "${${values}}")
else()
message(STATUS "${name}=\"${${name}}\" --> ${ot_config}=${ot_value_prefix}${${name}}")
target_compile_definitions(ot-config INTERFACE "${ot_config}=${ot_value_prefix}${${name}}")
endif()
endif()
endmacro()
message(STATUS "- - - - - - - - - - - - - - - - ")
message(STATUS "OpenThread ON/OFF/Unspecified Configs")
ot_option(OT_15_4 OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE "802.15.4 radio link")
ot_option(OT_ANDROID_NDK OPENTHREAD_CONFIG_ANDROID_NDK_ENABLE "enable android NDK")
ot_option(OT_ANYCAST_LOCATOR OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE "anycast locator")
ot_option(OT_ASSERT OPENTHREAD_CONFIG_ASSERT_ENABLE "assert function OT_ASSERT()")
ot_option(OT_BACKBONE_ROUTER OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE "backbone router functionality")
ot_option(OT_BACKBONE_ROUTER_DUA_NDPROXYING OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE "BBR DUA ND Proxy")
ot_option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE "BBR MR")
ot_option(OT_BLE_TCAT OPENTHREAD_CONFIG_BLE_TCAT_ENABLE "Ble based thread commissioning")
ot_option(OT_BORDER_ADMITTER OPENTHREAD_CONFIG_BORDER_AGENT_ADMITTER_ENABLE "border agent admitter")
ot_option(OT_BORDER_AGENT OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE "border agent")
ot_option(OT_BORDER_AGENT_EPSKC OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE "border agent ephemeral PSKc")
ot_option(OT_BORDER_AGENT_ID OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE "create and save border agent ID")
ot_option(OT_BORDER_AGENT_MESHCOP_SERVICE OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_ENABLE "border agent meshcop service")
ot_option(OT_BORDER_AGENT_TRACKER OPENTHREAD_CONFIG_BORDER_AGENT_TRACKER_ENABLE "border agent tracker")
ot_option(OT_BORDER_AGENT_TXT_DATA_PARSER OPENTHREAD_CONFIG_BORDER_AGENT_TXT_DATA_PARSER_ENABLE "border agent TXT data parser")
ot_option(OT_BORDER_ROUTER OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE "border router")
ot_option(OT_BORDER_ROUTING OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE "border routing")
ot_option(OT_BORDER_ROUTING_DHCP6_PD OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE "dhcpv6 pd support in border routing")
ot_option(OT_BORDER_ROUTING_DHCP6_PD_CLIENT OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE "dhcp6 pd client")
ot_option(OT_BORDER_ROUTING_COUNTERS OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE "border routing counters")
ot_option(OT_BORDER_ROUTING_MULTI_AIL_DETECTION OPENTHREAD_CONFIG_BORDER_ROUTING_MULTI_AIL_DETECTION_ENABLE "multiple AIL detection for border routers")
ot_option(OT_CHANNEL_MANAGER OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE "channel manager")
ot_option(OT_CHANNEL_MANAGER_CSL OPENTHREAD_CONFIG_CHANNEL_MANAGER_CSL_CHANNEL_SELECT_ENABLE "channel manager for csl channel")
ot_option(OT_CHANNEL_MONITOR OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE "channel monitor")
ot_option(OT_CHANNEL_MONITOR_AUTO_START OPENTHREAD_CONFIG_CHANNEL_MONITOR_AUTO_START_ENABLE "start channel monitor with interface")
ot_option(OT_COAP OPENTHREAD_CONFIG_COAP_API_ENABLE "coap api")
ot_option(OT_COAP_BLOCK OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE "coap block-wise transfer (RFC7959)")
ot_option(OT_COAP_OBSERVE OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE "coap observe (RFC7641)")
ot_option(OT_COAPS OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE "secure coap")
ot_option(OT_COMMISSIONER OPENTHREAD_CONFIG_COMMISSIONER_ENABLE "commissioner")
ot_option(OT_CSL_AUTO_SYNC OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE "data polling based on csl")
ot_option(OT_CSL_DEBUG OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE "csl debug")
ot_option(OT_CSL_RECEIVER OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE "csl receiver")
ot_option(OT_CSL_RECEIVER_LOCAL_TIME_SYNC OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_LOCAL_TIME_SYNC "use local time for csl elapsed sync time")
ot_option(OT_DATASET_UPDATER OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE "dataset updater")
ot_option(OT_DEVICE_PROP_LEADER_WEIGHT OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE "device prop for leader weight")
ot_option(OT_DHCP6_CLIENT OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE "DHCP6 client")
ot_option(OT_DHCP6_SERVER OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE "DHCP6 server")
ot_option(OT_DIAGNOSTIC OPENTHREAD_CONFIG_DIAG_ENABLE "diagnostic")
ot_option(OT_DNS_CLIENT OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE "DNS client")
ot_option(OT_DNS_CLIENT_BIND_UDP_THREAD_NETIF OPENTHREAD_CONFIG_DNS_CLIENT_BIND_UDP_TO_THREAD_NETIF "bind DNS client socket to Thread netif")
ot_option(OT_DNS_CLIENT_OVER_TCP OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE "Enable dns query over tcp")
ot_option(OT_DNS_DSO OPENTHREAD_CONFIG_DNS_DSO_ENABLE "DNS Stateful Operations (DSO)")
ot_option(OT_DNS_UPSTREAM_QUERY OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE "Allow sending DNS queries to upstream")
ot_option(OT_DNSSD_DISCOVERY_PROXY OPENTHREAD_CONFIG_DNSSD_DISCOVERY_PROXY_ENABLE "DNS-SD discovery proxy")
ot_option(OT_DNSSD_SERVER OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE "DNS-SD server")
ot_option(OT_DUA OPENTHREAD_CONFIG_DUA_ENABLE "Domain Unicast Address (DUA)")
ot_option(OT_DYNAMIC_STORE_FRAME_AHEAD_COUNTER OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE "dynamic store frame ahead counter")
ot_option(OT_ECDSA OPENTHREAD_CONFIG_ECDSA_ENABLE "ECDSA")
ot_option(OT_EXTERNAL_HEAP OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE "external heap")
ot_option(OT_FIREWALL OPENTHREAD_POSIX_CONFIG_FIREWALL_ENABLE "firewall")
ot_option(OT_HISTORY_TRACKER OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE "history tracker")
ot_option(OT_IP6_FRAGM OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE "ipv6 fragmentation")
ot_option(OT_JAM_DETECTION OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE "jam detection")
ot_option(OT_JOINER OPENTHREAD_CONFIG_JOINER_ENABLE "joiner")
ot_option(OT_LINK_METRICS_INITIATOR OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE "link metrics initiator")
ot_option(OT_LINK_METRICS_MANAGER OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE "link metrics manager")
ot_option(OT_LINK_METRICS_SUBJECT OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE "link metrics subject")
ot_option(OT_LINK_RAW OPENTHREAD_CONFIG_LINK_RAW_ENABLE "link raw service")
ot_option(OT_LOG_LEVEL_DYNAMIC OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE "dynamic log level control")
ot_option(OT_MAC_FILTER OPENTHREAD_CONFIG_MAC_FILTER_ENABLE "mac filter")
ot_option(OT_MDNS OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE "multicast DNS (mDNS)")
ot_option(OT_MDNS_VERBOSE OPENTHREAD_CONFIG_MULTICAST_DNS_VERBOSE_LOGGING_ENABLE "mDNS verbose logging")
ot_option(OT_MDNS_VERBOSE_STATE OPENTHREAD_CONFIG_MULTICAST_DEFAULT_DNS_VERBOSE_LOGGING_STATE "mDNS verbose state on start")
ot_option(OT_MESH_DIAG OPENTHREAD_CONFIG_MESH_DIAG_ENABLE "mesh diag")
ot_option(OT_MESSAGE_USE_HEAP OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE "heap allocator for message buffers")
ot_option(OT_MLE_LONG_ROUTES OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE "MLE long routes extension (experimental)")
ot_option(OT_MLR OPENTHREAD_CONFIG_MLR_ENABLE "Multicast Listener Registration (MLR)")
ot_option(OT_MULTIPAN_RCP OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE "enable multi-PAN RCP")
ot_option(OT_MULTIPLE_INSTANCE OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE "multiple instances")
ot_option(OT_NAT64_BORDER_ROUTING OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE "border routing NAT64")
ot_option(OT_NAT64_TRANSLATOR OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE "NAT64 translator support")
ot_option(OT_NEIGHBOR_DISCOVERY_AGENT OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE "neighbor discovery agent")
ot_option(OT_NETDATA_PUBLISHER OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE "Network Data publisher")
ot_option(OT_NETDIAG_CLIENT OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE "Network Diagnostic client")
ot_option(OT_NETDIAG_VENDOR_INFO OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE "Allow setting vendor info at runtime")
ot_option(OT_OPERATIONAL_DATASET_AUTO_INIT OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT "operational dataset auto init")
ot_option(OT_OTNS OPENTHREAD_CONFIG_OTNS_ENABLE "OTNS")
ot_option(OT_P2P OPENTHREAD_CONFIG_P2P_ENABLE "peer to peer")
ot_option(OT_PING_SENDER OPENTHREAD_CONFIG_PING_SENDER_ENABLE "ping sender" ${OT_APP_CLI})
ot_option(OT_PLATFORM_BOOTLOADER_MODE OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE "platform bootloader mode")
ot_option(OT_PLATFORM_DNSSD OPENTHREAD_CONFIG_PLATFORM_DNSSD_ENABLE "platform dnssd")
ot_option(OT_PLATFORM_KEY_REF OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE "platform key reference secure storage")
ot_option(OT_PLATFORM_LOG_CRASH_DUMP OPENTHREAD_CONFIG_PLATFORM_LOG_CRASH_DUMP_ENABLE "platform log crash dump")
ot_option(OT_PLATFORM_NETIF OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE "platform netif")
ot_option(OT_PLATFORM_POWER_CALIBRATION OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE "power calibration")
ot_option(OT_PLATFORM_UDP OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE "platform UDP")
ot_option(OT_REFERENCE_DEVICE OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE "test harness reference device")
ot_option(OT_SEEKER OPENTHREAD_CONFIG_SEEKER_ENABLE "seeker")
ot_option(OT_SERVICE OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE "Network Data service")
ot_option(OT_SETTINGS_RAM OPENTHREAD_SETTINGS_RAM "volatile-only storage of settings")
ot_option(OT_SLAAC OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE "SLAAC address")
ot_option(OT_SNTP_CLIENT OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE "SNTP client")
ot_option(OT_SRP_ADV_PROXY OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE "SRP advertising proxy")
ot_option(OT_SRP_CLIENT OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE "SRP client")
ot_option(OT_SRP_SERVER OPENTHREAD_CONFIG_SRP_SERVER_ENABLE "SRP server")
ot_option(OT_SRP_SERVER_FAST_START_MODE OPENTHREAD_CONFIG_SRP_SERVER_FAST_START_MODE_ENABLE "SRP server fast start")
ot_option(OT_STEERING_DATA OPENTHREAD_CONFIG_MESHCOP_STEERING_DATA_API_ENABLE "MeshCoP Steering Data APIs")
ot_option(OT_TCP OPENTHREAD_CONFIG_TCP_ENABLE "TCP")
ot_option(OT_TIME_SYNC OPENTHREAD_CONFIG_TIME_SYNC_ENABLE "time synchronization service")
ot_option(OT_TREL OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE "TREL radio link for Thread over Infrastructure feature")
ot_option(OT_TREL_MANAGE_DNSSD OPENTHREAD_CONFIG_TREL_MANAGE_DNSSD_ENABLE "TREL to manage DNSSD and peer discovery")
ot_option(OT_TX_BEACON_PAYLOAD OPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE "tx beacon payload")
ot_option(OT_TX_QUEUE_STATS OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE "tx queue statistics")
ot_option(OT_UDP_FORWARD OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE "UDP forward")
ot_option(OT_UPTIME OPENTHREAD_CONFIG_UPTIME_ENABLE "uptime")
ot_option(OT_VERHOEFF_CHECKSUM OPENTHREAD_CONFIG_VERHOEFF_CHECKSUM_ENABLE "verhoeff checksum")
ot_option(OT_WAKEUP_COORDINATOR OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE "wake-up coordinator")
ot_option(OT_WAKEUP_END_DEVICE OPENTHREAD_CONFIG_WAKEUP_END_DEVICE_ENABLE "wake-up end device")
ot_option(OT_SPINEL_CP_RESET_FAIL_CALLBACK_ENABLE OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE "CP reset failure callback")
option(OT_DOC "build OpenThread documentation")
message(STATUS "- - - - - - - - - - - - - - - - ")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Get a list of the available platforms and output as a list to the 'arg_platforms' argument
function(ot_get_platforms arg_platforms)
list(APPEND result "NO" "posix" "external" "nexus")
set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms")
file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*")
foreach(platform IN LISTS platforms)
if(IS_DIRECTORY "${platforms_dir}/${platform}")
list(APPEND result "${platform}")
endif()
endforeach()
list(REMOVE_ITEM result utils)
list(SORT result)
set(${arg_platforms} "${result}" PARENT_SCOPE)
endfunction()
ot_get_platforms(OT_PLATFORM_VALUES)
set(OT_PLATFORM "NO" CACHE STRING "Target platform chosen by the user at configure time")
set_property(CACHE OT_PLATFORM PROPERTY STRINGS "${OT_PLATFORM_VALUES}")
message(STATUS "OT_PLATFORM=\"${OT_PLATFORM}\"")
list(FIND OT_PLATFORM_VALUES "${OT_PLATFORM}" ot_index)
if(ot_index EQUAL -1)
message(FATAL_ERROR "Invalid value for OT_PLATFORM - valid values are:" "${OT_PLATFORM_VALUES}")
endif()
option(OT_ASSERT "enable assert function OT_ASSERT()" ON)
if(OT_ASSERT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set(OT_CRYPTO_LIB_VALUES "MBEDTLS" "PSA" "PLATFORM")
ot_multi_option(OT_CRYPTO_LIB OT_CRYPTO_LIB_VALUES OPENTHREAD_CONFIG_CRYPTO_LIB OPENTHREAD_CONFIG_CRYPTO_LIB_ "set Crypto backend library")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set(OT_THREAD_VERSION_VALUES "1.1" "1.2" "1.3" "1.3.1" "1.4")
set(OT_THREAD_VERSION "1.4" CACHE STRING "set Thread version")
set_property(CACHE OT_THREAD_VERSION PROPERTY STRINGS "${OT_THREAD_VERSION_VALUES}")
list(FIND OT_THREAD_VERSION_VALUES "${OT_THREAD_VERSION}" ot_index)
if(ot_index EQUAL -1)
message(STATUS "OT_THREAD_VERSION=\"${OT_THREAD_VERSION}\"")
message(FATAL_ERROR "Invalid value for OT_THREAD_VERSION - valid values are: " "${OT_THREAD_VERSION_VALUES}")
endif()
set(OT_VERSION_SUFFIX_LIST "1_1" "1_2" "1_3" "1_3_1" "1_4")
list(GET OT_VERSION_SUFFIX_LIST ${ot_index} OT_VERSION_SUFFIX)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_${OT_VERSION_SUFFIX}")
message(STATUS "OT_THREAD_VERSION=\"${OT_THREAD_VERSION}\" -> OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_${OT_VERSION_SUFFIX}")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set(OT_LOG_LEVEL_VALUES "NONE" "CRIT" "WARN" "NOTE" "INFO" "DEBG")
ot_multi_option(OT_LOG_LEVEL OT_LOG_LEVEL_VALUES OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_ "set OpenThread log level")
option(OT_FULL_LOGS "enable full logs")
if(OT_FULL_LOGS)
if(NOT OT_LOG_LEVEL)
message(STATUS "OT_FULL_LOGS=ON --> Setting LOG_LEVEL to DEBG")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
endif()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(OT_REFERENCE_DEVICE AND NOT OT_PLATFORM STREQUAL "posix")
set(OT_DEFAULT_LOG_OUTPUT "APP")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=0")
set(OT_DEFAULT_LOG_OUTPUT "")
endif()
set(OT_LOG_OUTPUT_VALUES "APP" "DEBUG_UART" "NONE" "PLATFORM_DEFINED")
ot_multi_option(OT_LOG_OUTPUT OT_LOG_OUTPUT_VALUES OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_ "Set the log output" "${OT_DEFAULT_LOG_OUTPUT}")
option(OT_BACKBONE_ROUTER "enable backbone router functionality")
if(OT_BACKBONE_ROUTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1")
set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable DUA NDProxying by default")
set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING ON CACHE BOOL "Enable Multicast Routing by default")
endif()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
option(OT_BACKBONE_ROUTER_DUA_NDPROXYING "enable Backbone Router DUA ND Proxying functionality" OFF)
if(OT_BACKBONE_ROUTER_DUA_NDPROXYING)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=1")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=0")
endif()
ot_string_option(OT_VENDOR_NAME OPENTHREAD_CONFIG_NET_DIAG_VENDOR_NAME "set the vendor name config")
ot_string_option(OT_VENDOR_MODEL OPENTHREAD_CONFIG_NET_DIAG_VENDOR_MODEL "set the vendor model config")
ot_string_option(OT_VENDOR_SW_VERSION OPENTHREAD_CONFIG_NET_DIAG_VENDOR_SW_VERSION "set the vendor sw version config")
ot_string_option(OT_BORDER_AGENT_SERVICE_NAME OPENTHREAD_CONFIG_BORDER_AGENT_MESHCOP_SERVICE_BASE_NAME "set the border agent service base name")
option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING "enable Backbone Router Multicast Routing functionality" OFF)
if(OT_BACKBONE_ROUTER_MULTICAST_ROUTING)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=1")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=0")
endif()
set(OT_POWER_SUPPLY_VALUES "BATTERY" "EXTERNAL" "EXTERNAL_STABLE" "EXTERNAL_UNSTABLE")
ot_multi_option(OT_POWER_SUPPLY OT_POWER_SUPPLY_VALUES OPENTHREAD_CONFIG_DEVICE_POWER_SUPPLY OT_POWER_SUPPLY_ "set the device power supply config")
option(OT_BORDER_AGENT "enable border agent support")
if(OT_BORDER_AGENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1")
endif()
ot_int_option(OT_BORDER_ROUTING_DHCP6_PD_MIN_LIFETIME OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_MIN_LIFETIME "set minimum lifetime for dhcp6 pd in seconds")
ot_int_option(OT_LOG_MAX_SIZE OPENTHREAD_CONFIG_LOG_MAX_SIZE "set maximum log string size")
ot_int_option(OT_MAC_CSL_REQUEST_AHEAD_US OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US "set time ahead to deliver CSL frame from MAC to SubMac in microseconds")
ot_int_option(OT_MLE_MAX_CHILDREN OPENTHREAD_CONFIG_MLE_MAX_CHILDREN "set maximum number of children")
ot_int_option(OT_RCP_RESTORATION_MAX_COUNT OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT "set max RCP restoration count")
ot_int_option(OT_RCP_TIME_SYNC_INTERVAL OPENTHREAD_SPINEL_CONFIG_RCP_TIME_SYNC_INTERVAL "set host-RCP time sync interval in microseconds")
ot_int_option(OT_RCP_TX_WAIT_TIME_SECS OPENTHREAD_SPINEL_CONFIG_RCP_TX_WAIT_TIME_SECS "set RCP TX wait TIME in seconds")
option(OT_BORDER_ROUTER "enable border router support")
if(OT_BORDER_ROUTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1")
endif()
option(OT_BORDER_ROUTING "enable border routing support")
if(OT_BORDER_ROUTING)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1")
endif()
option(OT_BORDER_ROUTING_NAT64 "enable border routing NAT64 support")
if(OT_BORDER_ROUTING_NAT64)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE=1")
endif()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(NOT OT_EXTERNAL_MBEDTLS)
set(OT_MBEDTLS mbedtls)
set(OT_MBEDTLS mbedtls mbedcrypto)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=1")
else()
set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS})
@@ -102,307 +379,22 @@ else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=0")
endif()
option(OT_CHANNEL_MANAGER "enable channel manager support")
if(OT_CHANNEL_MANAGER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1")
endif()
option(OT_CHANNEL_MONITOR "enable channel monitor support")
if(OT_CHANNEL_MONITOR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1")
endif()
option(OT_CHILD_SUPERVISION "enable child supervision support")
if(OT_CHILD_SUPERVISION)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1")
endif()
option(OT_COAP "enable coap api support")
if(OT_COAP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_API_ENABLE=1")
endif()
option(OT_COAPS "enable secure coap api support")
if(OT_COAPS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1")
endif()
option(OT_COAP_BLOCK "enable coap block-wise transfer (RFC7959) api support")
if(OT_COAP_BLOCK)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE=1")
endif()
option(OT_COAP_OBSERVE "enable coap observe (RFC7641) api support")
if(OT_COAP_OBSERVE)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1")
endif()
option(OT_COMMISSIONER "enable commissioner support")
if(OT_COMMISSIONER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1")
endif()
option(OT_CSL_RECEIVER "enable csl receiver")
if(OT_CSL_RECEIVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1")
endif()
option(OT_CSL_AUTO_SYNC "enable data polling based on csl config" ${OT_CSL_RECEIVER})
if(OT_CSL_AUTO_SYNC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=0")
endif()
option(OT_CSL_DEBUG "enable csl debug")
if(OT_CSL_DEBUG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE=1")
endif()
option(OT_DATASET_UPDATER "enable dataset updater support")
if(OT_DATASET_UPDATER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1")
endif()
option(OT_DHCP6_CLIENT "enable DHCP6 client support")
if(OT_DHCP6_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1")
endif()
option(OT_DHCP6_SERVER "enable DHCP6 server support")
if(OT_DHCP6_SERVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1")
endif()
option(OT_DIAGNOSTIC "enable diagnostic support")
if(OT_DIAGNOSTIC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DIAG_ENABLE=1")
endif()
option(OT_DNS_CLIENT "enable DNS client support")
if(OT_DNS_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1")
endif()
option(OT_DNS_DSO "enable DNS Stateful Operations (DSO) support")
if(OT_DNS_DSO)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_DSO_ENABLE=1")
endif()
option(OT_DNSSD_SERVER "enable DNS-SD server support")
if(OT_DNSSD_SERVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1")
endif()
option(OT_DOC "Build OpenThread documentation")
option(OT_ECDSA "enable ECDSA support")
if(OT_ECDSA)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ECDSA_ENABLE=1")
endif()
option(OT_SRP_CLIENT "enable SRP client support")
if (OT_SRP_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1")
endif()
option(OT_DUA "enable Domain Unicast Address feature for Thread 1.2")
if(OT_DUA)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DUA_ENABLE=1")
endif()
option(OT_MESSAGE_USE_HEAP "enable heap allocator for message buffers")
if(OT_MESSAGE_USE_HEAP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1")
endif()
option(OT_MLR "enable Multicast Listener Registration feature for Thread 1.2")
if(OT_MLR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLR_ENABLE=1")
endif()
option(OT_EXTERNAL_HEAP "enable external heap support")
if(OT_EXTERNAL_HEAP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1")
endif()
option(OT_HISTORY_TRACKER "enable history tracker support")
if(OT_HISTORY_TRACKER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1")
endif()
option(OT_IP6_FRAGM "enable ipv6 fragmentation support")
if(OT_IP6_FRAGM)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1")
endif()
option(OT_JAM_DETECTION "enable jam detection support")
if(OT_JAM_DETECTION)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1")
endif()
option(OT_JOINER "enable joiner support")
if(OT_JOINER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JOINER_ENABLE=1")
endif()
option(OT_LEGACY "enable legacy network support")
if(OT_LEGACY)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LEGACY_ENABLE=1")
endif()
option(OT_LINK_RAW "enable link raw service")
if(OT_LINK_RAW)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1")
endif()
option(OT_LINK_METRICS_INITIATOR "enable link metrics initiator")
if (OT_LINK_METRICS_INITIATOR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1")
endif()
option(OT_LINK_METRICS_SUBJECT "enable link metrics subject")
if (OT_LINK_METRICS_SUBJECT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=1")
endif()
option(OT_LOG_LEVEL_DYNAMIC "enable dynamic log level control")
if(OT_LOG_LEVEL_DYNAMIC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1")
endif()
option(OT_MAC_FILTER "enable mac filter support")
if(OT_MAC_FILTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1")
endif()
option(OT_MLE_LONG_ROUTES "enable MLE long routes extension (experimental, breaks Thread conformance)")
if(OT_MLE_LONG_ROUTES)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1")
endif()
option(OT_MTD_NETDIAG "enable TMF network diagnostics on MTDs")
if(OT_MTD_NETDIAG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1")
endif()
option(OT_MULTIPLE_INSTANCE "enable multiple instances")
if(OT_MULTIPLE_INSTANCE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1")
endif()
option(OT_NEIGHBOR_DISCOVERY_AGENT "enable neighbor discovery agent support")
if(OT_NEIGHBOR_DISCOVERY_AGENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE=1")
endif()
option(OT_NETDATA_PUBLISHER "enable Thread Network Data publisher")
if(OT_NETDATA_PUBLISHER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1")
endif()
option(OT_PING_SENDER "enable ping sender support" ${OT_APP_CLI})
if(OT_PING_SENDER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PING_SENDER_ENABLE=1")
endif()
option(OT_PLATFORM_NETIF "enable platform netif support")
if(OT_PLATFORM_NETIF)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1")
endif()
option(OT_PLATFORM_UDP "enable platform UDP support")
if(OT_PLATFORM_UDP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1")
endif()
if(OT_POSIX_SETTINGS_PATH)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH=${OT_POSIX_SETTINGS_PATH}")
endif()
option(OT_REFERENCE_DEVICE "enable Thread Test Harness reference device support")
if(OT_REFERENCE_DEVICE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1")
endif()
#-----------------------------------------------------------------------------------------------------------------------
# Check removed/replaced options
option(OT_SERVICE "enable support for injecting Service entries into the Thread Network Data")
if(OT_SERVICE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1")
endif()
option(OT_SETTINGS_RAM "enable volatile-only storage of settings")
if(OT_SETTINGS_RAM)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SETTINGS_RAM=1")
endif()
option(OT_SLAAC "enable support for adding of auto-configured SLAAC addresses by OpenThread")
if(OT_SLAAC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1")
endif()
option(OT_SNTP_CLIENT "enable SNTP Client support")
if(OT_SNTP_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1")
endif()
option(OT_SRP_SERVER "enable SRP server")
if (OT_SRP_SERVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1")
endif()
option(OT_TIME_SYNC "enable the time synchronization service feature")
if(OT_TIME_SYNC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1")
endif()
option(OT_TREL "enable TREL radio link for Thread over Infrastructure feature")
if (OT_TREL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1")
endif()
option(OT_TX_BEACON_PAYLOAD "enable Thread beacon payload in outgoing beacons")
if (OT_TX_BEACON_PAYLOAD)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1")
endif()
option(OT_UDP_FORWARD "enable UDP forward support")
if(OT_UDP_FORWARD)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1")
endif()
option(OT_UPTIME "enable support for tracking OpenThread instance's uptime")
if(OT_UPTIME)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UPTIME_ENABLE=1")
endif()
option(OT_FIREWALL "enable firewall")
if (OT_FIREWALL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_POSIX_CONFIG_FIREWALL_ENABLE=1")
endif()
option(OT_FULL_LOGS "enable full logs")
if(OT_FULL_LOGS)
if(NOT OT_LOG_LEVEL)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
macro(ot_removed_option name error)
# This macro checks for a remove option and emits an error
# if the option is set.
get_property(is_set CACHE ${name} PROPERTY VALUE SET)
if (is_set)
message(FATAL_ERROR "Removed option ${name} is set - ${error}")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
endif()
endmacro()
option(OT_OTNS "enable OTNS support")
if(OT_OTNS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_OTNS_ENABLE=1")
endif()
set(OT_RCP_RESTORATION_MAX_COUNT "0" CACHE STRING "set max RCP restoration count")
if(OT_RCP_RESTORATION_MAX_COUNT MATCHES "^[0-9]+$")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}")
else()
message(FATAL_ERROR "Invalid max RCP restoration count: ${OT_RCP_RESTORATION_MAX_COUNT}")
endif()
option(OT_EXCLUDE_TCPLP_LIB "exclude TCPlp library from build")
# Checks
if(OT_PLATFORM_UDP AND OT_UDP_FORWARD)
message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive")
endif()
ot_removed_option(OT_MTD_NETDIAG "- Use OT_NETDIAG_CLIENT instead - note that server function is always supported")
ot_removed_option(OT_EXCLUDE_TCPLP_LIB "- Use OT_TCP instead, OT_EXCLUDE_TCPLP_LIB is deprecated")
ot_removed_option(OT_POSIX_CONFIG_RCP_BUS "- Use OT_POSIX_RCP_HDLC_BUS, OT_POSIX_RCP_SPI_BUS or OT_POSIX_RCP_VENDOR_BUS instead, OT_POSIX_CONFIG_RCP_BUS is deprecated")
-32
View File
@@ -1,32 +0,0 @@
VERSION=0.1
all: arm32v7_linux x86_linux simulation
arm32v7_linux: arm32v7_ubuntu_wpantund
docker build -t openthread/wpantund_arm32v7_linux arm32v7_ubuntu_wpantund && \
docker push openthread/wpantund_arm32v7_linux && \
docker tag openthread/wpantund_arm32v7_linux openthread/wpantund_arm32v7_linux:$(VERSION) && \
docker push openthread/wpantund_arm32v7_linux:$(VERSION)
x86_linux: x86_ubuntu_wpantund
docker build -t openthread/wpantund_amd64_linux x86_ubuntu_wpantund && \
docker push openthread/wpantund_amd64_linux && \
docker tag openthread/wpantund_amd64_linux openthread/wpantund_amd64_linux:$(VERSION) && \
docker push openthread/wpantund_amd64_linux:$(VERSION)
simulation: ot_simulation
docker build -t openthread/simulation ot_sim && \
docker push openthread/simulation && \
docker tag openthread/simulation openthread/simulation:$(VERSION) && \
docker push openthread/simulation:$(VERSION)
publish_manifest:
docker manifest create openthread/wpantund openthread/wpantund_arm32v7_linux openthread/wpantund_amd64_linux
docker manifest annotate openthread/wpantund openthread/wpantund_arm32v7_linux --os linux --arch arm --variant 7
docker manifest annotate openthread/wpantund openthread/wpantund_amd64_linux --os linux --arch amd64
docker manifest push --purge openthread/wpantund
docker manifest create openthread/wpantund:$(VERSION) openthread/wpantund_arm32v7_linux:$(VERSION) openthread/wpantund_amd64_linux:$(VERSION)
docker manifest annotate openthread/wpantund:$(VERSION) openthread/wpantund_arm32v7_linux:$(VERSION) --os linux --arch arm --variant 7
docker manifest annotate openthread/wpantund:$(VERSION) openthread/wpantund_amd64_linux:$(VERSION) --os linux --arch amd64
docker manifest push --purge openthread/wpantund:$(VERSION)
-105
View File
@@ -1,105 +0,0 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# Ubuntu 14.04 with tools required to run OpenThread Android check
#
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
ENV ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
ENV OPT_BIN=/opt/bin
ENV PATH=$OPT_BIN:$PATH
ENV ANDROID_NDK_PATH=/opt/ndk-bundle
WORKDIR /build
RUN apt-get -y update && apt-get --no-install-recommends install -y \
gcc-multilib \
g++-multilib \
git \
make \
python \
unzip \
wget
RUN wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip \
&& unzip android-ndk-r17c-linux-x86_64.zip > /dev/null \
&& mv android-ndk-r17c $ANDROID_NDK_PATH \
&& rm android-ndk-r17c-linux-x86_64.zip
# Android build system
RUN mkdir build && cd build && git init && git pull --depth 1 https://android.googlesource.com/platform/build 2db32730e79cafcf13e1f898a7bee7f82b0449d6
RUN ln -s build/core/main.mk Makefile
RUN mkdir /opt/bin
# Workarounds for java checking
RUN printf '#!/bin/sh\n\
echo java version \\"1.6\\"'\
> $OPT_BIN/java \
&& printf '#!/bin/sh\n\
echo javac \\"1.6\\"'\
> $OPT_BIN/javac \
&& chmod a+x $OPT_BIN/java $OPT_BIN/javac \
&& mkdir -p /usr/lib/jvm/java-6-openjdk-amd64/lib/ \
&& touch /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
# Files for building ndk
# The default libstdc++.so does not contain full stl implementation, see https://developer.android.com/ndk/guides/cpp-support
RUN mkdir -p system/core/include/arch/linux-arm \
&& touch system/core/include/arch/linux-arm/AndroidConfig.h \
&& mkdir -p system/core/include/arch/linux-x86 \
&& touch system/core/include/arch/linux-x86/AndroidConfig.h \
&& mkdir -p bionic/libc/ \
&& cp -r "$ANDROID_NDK_PATH"/sysroot/usr/include bionic/libc/include \
&& mv bionic/libc/include/arm-linux-androideabi/asm bionic/libc/include/asm \
&& mkdir -p out/target/product/generic/obj/ \
&& cp -r "$ANDROID_NDK_PATH"/platforms/android-27/arch-arm/usr/lib out/target/product/generic/obj/ \
&& mkdir -p bionic/libstdc++ \
&& cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/include bionic/libstdc++ \
&& cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/* bionic/libstdc++/include \
&& cp "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so out/target/product/generic/obj/lib/libstdc++.so \
&& printf "TARGET_PRODUCT := generic\n\
TARGET_BUILD_VARIANT := eng\n\
TARGET_BUILD_TYPE := release\n\
TARGET_TOOLS_PREFIX := $ANDROID_NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"\
> buildspec.mk
RUN rm -rf "$ANDROID_NDK_PATH"/platforms
RUN rm -rf "$ANDROID_NDK_PATH"/prebuilt
RUN rm -rf "$ANDROID_NDK_PATH"/shader-tools
RUN rm -rf "$ANDROID_NDK_PATH"/sources
RUN rm -rf "$ANDROID_NDK_PATH"/sysroot
RUN rm -rf "$ANDROID_NDK_PATH"/simpleperf
RUN cd "$ANDROID_NDK_PATH"/toolchains && rm -rf aarch64-linux-android-4.9 llvm mips64el-linux-android-4.9 mipsel-linux-android-4.9 x86-4.9 x86_64-4.9
RUN apt-get purge -y unzip wget git && apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*
CMD ["bash"]
+11 -3
View File
@@ -1,14 +1,21 @@
# Ubuntu image with tools required to build OpenThread
FROM ubuntu:18.04
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=en_US.UTF-8
ENV INSTALL_FORMAT_TOOLS=0
# Resolves issue with installing libc-bin
RUN rm /var/lib/dpkg/info/libc-bin.* \
&& apt-get clean -y \
&& apt-get update -y \
&& apt-get install --no-install-recommends -y libc-bin
RUN set -x \
&& apt-get update -y \
&& apt-get install -y locales \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& apt-get --no-install-recommends install -fy \
bzip2 \
git \
ninja-build \
python3 \
@@ -20,6 +27,7 @@ RUN set -x \
inetutils-ping \
ca-certificates \
&& update-ca-certificates \
&& python3 -m pip install -U pip \
&& python3 -m pip install -U cmake \
&& python3 -m pip install wheel
+45
View File
@@ -0,0 +1,45 @@
# Copyright (c) 2025, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE]
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
if (target_os == "") {
target_os = host_os
}
if (target_cpu == "") {
target_cpu = host_cpu
}
if (current_cpu == "") {
current_cpu = target_cpu
}
if (current_os == "") {
current_os = target_os
}
declare_args() {
use_clang = false
}
set_default_toolchain("//etc/gn/toolchain")
+11 -2
View File
@@ -81,9 +81,15 @@ if (openthread_enable_core_config_args) {
# Enable backbone router functionality
openthread_config_backbone_router_enable = false
# Enable BLE based commissioning functionality
openthread_config_ble_tcat_enable = false
# Enable border agent support
openthread_config_border_agent_enable = false
# Enable border agent ID
openthread_config_border_agent_id_enable = false
# Enable border router support
openthread_config_border_router_enable = false
@@ -174,8 +180,8 @@ if (openthread_enable_core_config_args) {
# Enable MLE long routes extension (experimental, breaks Thread conformance]
openthread_config_mle_long_routes_enable = false
# Enable TMF network diagnostics on MTDs
openthread_config_tmf_network_diag_mtd_enable = false
# Enable TMF network diagnostics client
openthread_config_tmf_netdiag_client_enable = false
# Enable multiple instances
openthread_config_multiple_instance_enable = false
@@ -207,6 +213,9 @@ if (openthread_enable_core_config_args) {
# Enable SRP Server support
openthread_config_srp_server_enable = false
# Enable support for TCP
openthread_config_tcp_enable = true
# Enable ping sender support
openthread_config_ping_sender = false
+114
View File
@@ -0,0 +1,114 @@
# Copyright (c) 2025, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE]
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
toolchain("toolchain") {
diagnostic_cflags = [
"-Werror",
"-Wall",
"-Wextra",
"-Wundef",
"-Wformat-nonliteral",
]
if (use_clang) {
cc = "clang"
cxx = "clang++"
} else {
cc = "gcc"
cxx = "g++"
}
cflags = string_join(" ", diagnostic_cflags)
tool("cc") {
depfile = "{{output}}.d"
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} $cflags {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CC {{output}}"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
]
}
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} $cflags {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
depsformat = "gcc"
description = "CXX {{output}}"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
]
}
tool("alink") {
rspfile = "{{output}}.rsp"
command = "rm -f {{output}} && ar rcs {{output}} @$rspfile"
description = "AR {{target_output_name}}{{output_extension}}"
rspfile_content = "{{inputs}}"
outputs = [
"{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
]
default_output_extension = ".a"
output_prefix = "lib"
}
tool("solink") {
soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
sofile = "{{output_dir}}/$soname"
rspfile = soname + ".rsp"
command = "$cxx -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
description = "SOLINK $soname"
# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
default_output_extension = ".so"
# Use this for {{output_dir}} expansions unless a target manually overrides
# it (in which case {{output_dir}} will be what the target specifies).
default_output_dir = "{{root_out_dir}}"
outputs = [
sofile,
]
link_output = sofile
depend_output = sofile
output_prefix = "lib"
}
tool("link") {
outfile = "{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
command = "$cxx {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
description = "LINK $outfile"
default_output_dir = "{{root_out_dir}}"
rspfile_content = "{{inputs}}"
outputs = [
outfile,
]
}
tool("stamp") {
command = "touch {{output}}"
description = "STAMP {{output}}"
}
tool("copy") {
command = "cp -af {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
-309
View File
@@ -1,309 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = arm-none-eabi-as
CPP = arm-none-eabi-cpp
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
--enable-cli \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--with-examples=cc2538 \
$(NULL)
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CC2538_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-cc2538-config.h\"'
CC2538_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-cc2538-config-check.h\"'
CC2538_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/cc2538/
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(CC2538_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
# Optional CC2592 options, first and foremost, whether to enable support for it
# at all.
ifeq ($(CC2592),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_WITH_CC2592=1
# If the PA_EN is on another port C pin, specify it with CC2592_PA_PIN.
ifneq ($(CC2592_PA_EN),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_PA_EN_PIN=$(CC2592_PA_EN)
endif
# If the LNA_EN is on another port C pin, specify it with CC2592_LNA_PIN.
ifneq ($(CC2592_LNA_EN),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_LNA_EN_PIN=$(CC2592_LNA_EN)
endif
# If we're not using HGM, set CC2538_USE_HGM to 0.
ifeq ($(CC2592_USE_HGM),0)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_USE_HGM=0
else # CC2592_USE_HGM=1
# HGM in use, if not on port D, specify the port here (A, B or C) with CC2592_HGM_PORT.
ifneq ($(CC2592_HGM_PORT),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_PORT=GPIO_$(CC2592_HGM_PORT)_BASE
endif
# If HGM is not at pin 2, specify which pin here with CC2592_HGM_PIN.
ifneq ($(CC2592_HGM_PIN),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_PIN=$(CC2592_HGM_PIN)
endif
# If we want it off by default, specify CC2592_HGM_DEFAULT_STATE=0
ifeq ($(CC2592_HGM_DEFAULT_STATE),0)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE=false
endif
endif # CC2592_USE_HGM
endif # CC2592
ifneq ($(CC2538_RECEIVE_SENSITIVITY),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY=$(CC2538_RECEIVE_SENSITIVITY)
endif
ifneq ($(CC2538_RSSI_OFFSET),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RSSI_OFFSET=$(CC2538_RSSI_OFFSET)
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-nostartfiles \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = cc2538
ARCHS = cortex-m3
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# cortex-m3
#
cortex-m3_target_ABI = cortex-m3
cortex-m3_target_CPPFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
cortex-m3_target_CFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
cortex-m3_target_CXXFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
cortex-m3_target_LDFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
-352
View File
@@ -1,352 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Don't allow this top-level makefile's targets to be built in parallel.
.NOTPARALLEL:
COVERAGE ?= 0
DEBUG ?= 0
# Enable most features by default to cover most code
ANYCAST_LOCATOR ?= 1
BORDER_AGENT ?= 1
BORDER_ROUTER ?= 1
COAP ?= 1
COAP_BLOCK ?= 1
COAP_OBSERVE ?= 1
COAPS ?= 1
COMMISSIONER ?= 1
CHANNEL_MANAGER ?= 1
CHANNEL_MONITOR ?= 1
CHILD_SUPERVISION ?= 1
DATASET_UPDATER ?= 1
DHCP6_CLIENT ?= 1
DHCP6_SERVER ?= 1
DIAGNOSTIC ?= 1
DNS_CLIENT ?= 1
DNS_DSO ?= 1
DNSSD_SERVER ?= 1
ECDSA ?= 1
HISTORY_TRACKER ?= 1
IP6_FRAGM ?= 1
JAM_DETECTION ?= 1
JOINER ?= 1
LEGACY ?= 1
LINK_RAW ?= 1
MAC_FILTER ?= 1
MTD_NETDIAG ?= 1
NEIGHBOR_DISCOVERY_AGENT ?= 1
NETDATA_PUBLISHER ?= 1
PING_SENDER ?= 1
REFERENCE_DEVICE ?= 1
SERVICE ?= 1
SNTP_CLIENT ?= 1
SRP_CLIENT ?= 1
SRP_SERVER ?= 1
UDP_FORWARD ?= 1
COMMONCFLAGS := \
-g \
$(NULL)
# If the user has asserted COVERAGE, alter the configuration options
# accordingly.
configure_OPTIONS = \
--enable-cli \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--with-examples=simulation \
$(NULL)
# Platform specific switches
ifneq ($(DEBUG),1)
COMMONCFLAGS += \
-O2 \
$(NULL)
endif
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1
endif # NCP_SPI == 1
ifeq ($(OTNS),1)
VIRTUAL_TIME ?= 1
endif
ifeq ($(VIRTUAL_TIME),1)
COMMONCFLAGS += -DOPENTHREAD_SIMULATION_VIRTUAL_TIME=1
endif
ifeq ($(VIRTUAL_TIME_UART),1)
COMMONCFLAGS += -DOPENTHREAD_SIMULATION_VIRTUAL_TIME_UART=1
endif
ifneq ($(MAX_NETWORK_SIZE),)
COMMONCFLAGS += -DOPENTHREAD_SIMULATION_MAX_NETWORK_SIZE=$(MAX_NETWORK_SIZE)
endif
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-simulation-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/simulation/
COMMONCFLAGS += \
-D$(CONFIG_FILE) \
-I$(CONFIG_FILE_PATH) \
CPPFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(NULL)
ECHO := @echo
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
LN_S := ln -s
MAKE := make
MKDIR_P := mkdir -p
RM_F := rm -f
BuildJobs ?= 10
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = simulation
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <target>
#
# Configure OpenThread for the specified target.
#
# target - The target to configure.
#
define configure-target
$(ECHO) " CONFIG $(1)..."
(cd $(BuildPath)/$(1) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
--prefix=/ \
--exec-prefix=/$(1) \
$(configure_OPTIONS))
endef # configure-target
#
# build-target <target>
#
# Build the OpenThread intermediate build products for the specified
# target.
#
# target - The target to build.
#
define build-target
$(ECHO) " BUILD $(1)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
all
endef # build-target
#
# check-target <target>
#
# Check (run unit tests) OpenThread for the specified target.
#
# target - The target to check.
#
define check-target
$(ECHO) " CHECK $(1)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
check
endef # check-target
#
# distcheck-target <target>
#
# Check (run unit tests) OpenThread for the specified target.
#
# target - The target to distcheck.
#
define distcheck-target
$(ECHO) " DISTCHECK $(1)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
distcheck
endef # distcheck-target
#
# coverage-target <target>
#
# Generate code coverage from unit tests for OpenThread for the
# specified target.
#
# target - The target to generate code coverage for.
#
define coverage-target
$(ECHO) " COVERAGE $(1)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
coverage
endef # coverage-target
#
# stage-target <target>
#
# Stage (install) the OpenThread final build products for the specified
# target.
#
# target - The target to stage.
#
define stage-target
$(ECHO) " STAGE $(1)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(1) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-target
#
# TARGET_template <target>
#
# Define macros, targets and rules to configure, build, and stage
# OpenThread for a single target.
#
# target - The target to instantiate the template for.
#
define TARGET_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
CHECK_TARGETS += check-$(1)
DISTCHECK_TARGETS += distcheck-$(1)
COVERAGE_TARGETS += coverage-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(1)
DIRECTORIES += $(BuildPath)/$(1)
configure-$(1): $(BuildPath)/$(1)/config.status
$(BuildPath)/$(1)/config.status: | $(BuildPath)/$(1)
$$(call configure-target,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-target,$(1))
check-$(1): do-build-$(1)
check-$(1):
+$$(call check-target,$(1))
distcheck-$(1): do-build-$(1)
distcheck-$(1):
+$$(call distcheck-target,$(1))
coverage-$(1): do-build-$(1)
coverage-$(1):
+$$(call coverage-target,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-target,$(1))
$(1): stage-$(1)
endef # TARGET_template
.DEFAULT_GOAL := all
all: stage
# Instantiate an target-specific build template for the target.
$(eval $(call TARGET_template,$(TargetTuple)))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
check: $(CHECK_TARGETS)
distcheck: $(DISTCHECK_TARGETS)
coverage: $(COVERAGE_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "target:"
$(ECHO) ""
$(ECHO) " $(TargetTuple)"
$(ECHO) ""
-50
View File
@@ -1,50 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
platforms \
apps \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
platforms \
$(NULL)
if OPENTHREAD_ENABLE_EXAMPLES
SUBDIRS += \
apps \
$(NULL)
endif
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
-73
View File
@@ -1,73 +0,0 @@
# Common switches
OpenThread allows you to [configure](https://openthread.io/guides/build#configuration) the stack for different functionality and behavior. This configuration is based on changing compile-time constants during the build process using common switches listed in `/examples/common-switches.mk`.
This page lists the available common switches with description. Unless stated otherwise, the switches are set to 0 by default. For build command examples, see [build examples](https://openthread.io/guides/build#build_examples).
| Makefile switch | CMake switch | Description |
| --- | --- | --- |
| ANYCAST_LOCATOR | OT_ANYCAST_LOCATOR | Enables anycast locator functionality. |
| BACKBONE_ROUTER | OT_BACKBONE_ROUTER | Enables Backbone Router functionality for Thread 1.2. |
| BIG_ENDIAN | OT_BIG_ENDIAN | Allows the host platform to use big-endian byte order. |
| BORDER_AGENT | OT_BORDER_AGENT | Enables support for border agent. In most cases, enable this switch if you are building On-mesh Commissioner or Border Router with External Commissioning support. |
| BORDER_ROUTER | OT_BORDER_ROUTER | Enables support for Border Router. This switch is usually combined with the BORDER_AGENT and UDP_FORWARD (or PLATFORM_UDP in case of RCP design) switches to build Border Router device. |
| BORDER_ROUTING | OT_BORDER_ROUTING | Enables bi-directional border routing between Thread and Infrastructure networks for Border Router. |
| BORDER_ROUTING_NAT64 | OT_BORDER_ROUTING_NAT64 | Enables NAT64 border routing support for Border Router. |
| BUILTIN_MBEDTLS_MANAGEMENT | OT_BUILTIN_MBEDTLS_MANAGEMENT | Enables the built-in mbedTLS management. Enable this switch if the external mbedTLS is used, but mbedTLS memory allocation and debug config should be managed internally by OpenThread. |
| CHANNEL_MANAGER | OT_CHANNEL_MANAGER | Enables support for channel manager. Enable this switch on devices that are supposed to request a Thread network channel change. This switch should be used only with an FTD build. |
| CHANNEL_MONITOR | OT_CHANNEL_MONITOR | Enables support for channel monitor. Enable this switch on devices that are supposed to determine the cleaner channels. |
| CHILD_SUPERVISION | OT_CHILD_SUPERVISION | Enables support for [child supervision](https://openthread.io/guides/build/features/child-supervision). Enable this switch on a parent or child node with custom OpenThread application that manages the supervision, checks timeout intervals, and verifies connectivity between parent and child. |
| COAP | OT_COAP | Enables support for the CoAP API. Enable this switch if you want to control Constrained Application Protocol communication. |
| COAP_OBSERVE | OT_COAP_OBSERVE | Enables support for CoAP Observe (RFC7641) API. |
| COAPS | OT_COAPS | Enables support for the secure CoAP API. Enable this switch if you want to control Constrained Application Protocol Secure (CoAP over DTLS) communication. |
| COMMISSIONER | OT_COMMISSIONER | Enables support for Commissioner. Enable this switch on device that is able to perform Commissioner role. |
| COVERAGE | OT_COVERAGE | Enables the generation of code-coverage instances. |
| CSL_RECEIVER | OT_CSL_RECEIVER | Enables CSL receiver feature for Thread 1.2. |
| DEBUG | not implemented | Allows building debug instance. Code optimization is disabled. |
| DHCP6_CLIENT | OT_DHCP6_CLIENT | Enables support for the DHCP6 client. The device is able to act as typical DHCP client. Enable this switch on a device that is supposed to request networking parameters from the DHCP server. |
| DHCP6_SERVER | OT_DHCP6_SERVER | Enables support for the DHCP6 server. The device is able to act as typical DHCP server. Enable this switch on a device that is supposed to provide networking parameters to devices with DHCP_CLIENT switch enabled. |
| DIAGNOSTIC | OT_DIAGNOSTIC | Enables diagnostic support. Enable this switch on a device that is tested in the factory production stage. |
| DISABLE_BUILTIN_MBEDTLS | not implemented | Disables OpenThread's mbedTLS build. Enable this switch if you do not want to use the built-in mbedTLS and you do not want to manage mbedTLS internally. Enabling this switch will disable support for such features as memory allocation and debug. |
| DISABLE_DOC | not implemented | Disables building of the documentation. |
| DISABLE_EXECUTABLE | not implemented | Disables building of executables. |
| DISABLE_TOOLS | not implemented | Disables building of tools. |
| DEBUG_UART | not implemented | Enables the Debug UART platform feature. |
| DEBUG_UART_LOG | not implemented | Enables the log output for the debug UART. Requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled. |
| DNS_CLIENT | OT_DNS_CLIENT | Enables support for DNS client. Enable this switch on a device that sends a DNS query for AAAA (IPv6) record. |
| DNS_DSO | OT_DNS_DSO | Enables support for DNS Stateful Operations (DSO). |
| DNSSD_SERVER | OT_DNSSD_SERVER | Enables support for DNS-SD server. DNS-SD server use service information from local SRP server to resolve DNS-SD query questions. |
| DUA | OT_DUA | Enables the Domain Unicast Address feature for Thread 1.2. |
| DYNAMIC_LOG_LEVEL | not implemented | Enables the dynamic log level feature. Enable this switch if OpenThread log level is required to be set at runtime. See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| ECDSA | OT_ECDSA | Enables support for Elliptic Curve Digital Signature Algorithm. Enable this switch if ECDSA digital signature is used by application. |
| EXCLUDE_TCPLP_LIB | OT_EXCLUDE_TCPLP_LIB | Exclude TCPlp library from the build. |
| EXTERNAL_HEAP | OT_EXTERNAL_HEAP | Enables support for external heap. Enable this switch if the platform uses its own heap. Make sure to specify the external heap Calloc and Free functions to be used by the OpenThread stack. |
| FULL_LOGS | OT_FULL_LOGS | Enables all log levels and regions. This switch sets the log level to OT_LOG_LEVEL_DEBG and turns on all region flags. See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| HISTORY_TRACKER | OT_HISTORY_TRACKER | Enables support for History Tracker. |
| IP6_FRAGM | OT_IP6_FRAGM | Enables support for IPv6 fragmentation. |
| JAM_DETECTION | OT_JAM_DETECTION | Enables support for [Jam Detection](https://openthread.io/guides/build/features/jam-detection). Enable this switch if a device requires the ability to detect signal jamming on a specific channel. |
| JOINER | OT_JOINER | Enables [support for Joiner](https://openthread.io/reference/group/api-joiner). Enable this switch on a device that has to be commissioned to join the network. |
| LEGACY | OT_LEGACY | Enables support for legacy network. |
| LINK_RAW | OT_LINK_RAW | Enables the Link Raw service. |
| LOG_OUTPUT | not implemented | Defines if the LOG output is to be created and where it goes. There are several options available: `NONE`, `DEBUG_UART`, `APP`, `PLATFORM_DEFINED` (default). See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| MAC_FILTER | OT_MAC_FILTER | Enables support for the MAC filter. |
| MLE_LONG_ROUTES | OT_MLE_LONG_ROUTES | Enables the MLE long routes extension. **Note: Enabling this feature breaks conformance to the Thread Specification.** |
| MLR | OT_MLR | Enables Multicast Listener Registration feature for Thread 1.2. |
| MTD_NETDIAG | OT_MTD_NETDIAG | Enables the TMF network diagnostics on MTDs. |
| MULTIPLE_INSTANCE | OT_MULTIPLE_INSTANCE | Enables multiple OpenThread instances. |
| NETDATA_PUBLISHER | OT_NETDATA_PUBLISHER | Enables support for Thread Network Data publisher. |
| PING_SENDER | OT_PING_SENDER | Enables support for ping sender. |
| OTNS | OT_OTNS | Enables support for [OpenThread Network Simulator](https://github.com/openthread/ot-ns). Enable this switch if you are building OpenThread for OpenThread Network Simulator. |
| PLATFORM_UDP | OT_PLATFORM_UDP | Enables platform UDP support. |
| REFERENCE_DEVICE | OT_REFERENCE_DEVICE | Enables support for Thread Test Harness reference device. Enable this switch on the reference device during certification. |
| SERVICE | OT_SERVICE | Enables support for injecting Service entries into the Thread Network Data. |
| SETTINGS_RAM | OT_SETTINGS_RAM | Enables volatile-only storage of settings. |
| SLAAC | OT_SLAAC | Enables support for adding auto-configured SLAAC addresses by OpenThread. This feature is enabled by default. |
| SNTP_CLIENT | OT_SNTP_CLIENT | Enables support for SNTP Client. |
| SPINEL_ENCRYPTER_LIBS | not implemented | Specifies library files (absolute paths) for implementing the NCP Spinel Encrypter. |
| SRP_CLIENT | OT_SRP_CLIENT | Enable support for SRP client. |
| SRP_SERVER | OT_SRP_SERVER | Enable support for SRP server. |
| THREAD_VERSION | OT_THREAD_VERSION | Enables the chosen Thread version (1.1 / 1.2 (default)). For example, set to `1.1` for Thread 1.1. |
| TIME_SYNC | OT_TIME_SYNC | Enables the time synchronization service feature. **Note: Enabling this feature breaks conformance to the Thread Specification.** | |
| TREL | OT_TREL | Enables TREL radio link for Thread over Infrastructure feature. |
| UDP_FORWARD | OT_UDP_FORWARD | Enables support for UDP forward. | Enable this switch on the Border Router device (running on the NCP design) with External Commissioning support to service Thread Commissioner packets on the NCP side. |
| UPTIME | OT_UPTIME | Enables support for tracking OpenThread instance's uptime. |
-57
View File
@@ -1,57 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
cli \
ncp \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
$(NULL)
if OPENTHREAD_ENABLE_EXECUTABLE
if OPENTHREAD_ENABLE_CLI
SUBDIRS += cli
endif
if OPENTHREAD_ENABLE_NCP
SUBDIRS += ncp
else
if OPENTHREAD_ENABLE_RADIO_ONLY
SUBDIRS += ncp
endif
endif
endif
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+35
View File
@@ -0,0 +1,35 @@
# Copyright (c) 2026, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
static_library("cli_uart") {
sources = [ "cli_uart.cpp" ]
include_dirs = [ "../../platforms" ]
deps = [
"../../../src/cli:cli_config",
"../../../src/core:libopenthread_core_headers",
]
}
-167
View File
@@ -1,167 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/Makefile.platform.am
bin_PROGRAMS = \
$(NULL)
CPPFLAGS_COMMON += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/examples/platforms \
$(NULL)
LDADD_COMMON += \
$(top_builddir)/third_party/tcplp/libtcplp.a \
$(NULL)
LDFLAGS_COMMON += \
$(NULL)
LIBTOOLFLAGS_COMMON += \
$(NULL)
SOURCES_COMMON += \
cli_uart.cpp \
main.c \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_COMMON += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_FTD
bin_PROGRAMS += \
ot-cli-ftd \
$(NULL)
endif
ot_cli_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_cli_ftd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(NULL)
ot_cli_ftd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_cli_ftd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_cli_ftd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_MTD
bin_PROGRAMS += \
ot-cli-mtd \
$(NULL)
endif
ot_cli_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_cli_mtd_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-mtd.a \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(NULL)
ot_cli_mtd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_cli_mtd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_cli_mtd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_RADIO_CLI
bin_PROGRAMS += \
ot-cli-radio \
$(NULL)
endif
ot_cli_radio_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_cli_radio_LDADD = \
$(top_builddir)/src/cli/libopenthread-cli-radio.a \
$(top_builddir)/src/core/libopenthread-radio-cli.a \
$(LDADD_COMMON) \
$(top_builddir)/src/core/libopenthread-radio-cli.a \
$(LDADD_COMMON) \
$(NULL)
ot_cli_radio_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_cli_radio_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_cli_radio_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_LINKER_MAP
ot_cli_ftd_LDFLAGS += -Wl,-Map=ot-cli-ftd.map
ot_cli_mtd_LDFLAGS += -Wl,-Map=ot-cli-mtd.map
ot_cli_radio_LDFLAGS += -Wl,-Map=ot-cli-radio.map
endif
if OPENTHREAD_BUILD_COVERAGE
CPPFLAGS_COMMON += \
-DOPENTHREAD_ENABLE_COVERAGE \
$(NULL)
CLEANFILES = $(wildcard *.gcda *.gcno)
endif # OPENTHREAD_BUILD_COVERAGE
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+3 -4
View File
@@ -6,8 +6,7 @@ This example application exposes OpenThread configuration and management APIs vi
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-simulation
$ ./script/cmake-build simulation
```
## 2. Start node 1
@@ -15,7 +14,7 @@ $ make -f examples/Makefile-simulation
Spawn the process:
```bash
$ cd <path-to-openthread>/output/<platform>/bin
$ cd <path-to-openthread>/build/simulation/examples/apps/cli
$ ./ot-cli-ftd 1
```
@@ -78,7 +77,7 @@ Done
Spawn the process:
```bash
$ cd <path-to-openthread>/output/<platform>/bin
$ cd <path-to-openthread>/build/simulation/examples/apps/cli
$ ./ot-cli-ftd 2
```
+8 -16
View File
@@ -29,11 +29,10 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <openthread-system.h>
#include <openthread/cli.h>
#include <openthread/logging.h>
#include <openthread/platform/debug_uart.h>
#include "cli/cli_config.h"
#include "common/code_utils.hpp"
@@ -49,7 +48,6 @@
* @def OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
*
* The size of CLI UART RX buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_CLI_UART_RX_BUFFER_SIZE
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
@@ -63,7 +61,6 @@
* @def OPENTHREAD_CONFIG_CLI_TX_BUFFER_SIZE
*
* The size of CLI message buffer in bytes.
*
*/
#ifndef OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE
#define OPENTHREAD_CONFIG_CLI_UART_TX_BUFFER_SIZE 1024
@@ -106,7 +103,6 @@ uint16_t sSendLength;
/**
* Macro to acquire an exclusive lock of uart cli output
* Default implementation does nothing
*
*/
#ifndef OT_CLI_UART_OUTPUT_LOCK
#define OT_CLI_UART_OUTPUT_LOCK() \
@@ -118,7 +114,6 @@ uint16_t sSendLength;
/**
* Macro to release the exclusive lock of uart cli output
* Default implementation does nothing
*
*/
#ifndef OT_CLI_UART_OUTPUT_UNLOCK
#define OT_CLI_UART_OUTPUT_UNLOCK() \
@@ -137,7 +132,7 @@ static void ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength)
static const char sEraseString[] = {'\b', ' ', '\b'};
static const char CRNL[] = {'\r', '\n'};
static uint8_t sLastChar = '\0';
const uint8_t * end;
const uint8_t *end;
end = aBuf + aBufLength;
@@ -225,7 +220,7 @@ static void Send(void)
{
#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
/* duplicate the output to the debug uart */
otSysDebugUart_write_bytes(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength);
otPlatDebugUart_write_bytes(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength);
#endif
IgnoreError(otPlatUartSend(reinterpret_cast<uint8_t *>(sTxBuffer + sTxHead), sSendLength));
}
@@ -294,6 +289,9 @@ static int Output(const char *aBuf, uint16_t aBufLength)
return sent;
}
static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments)
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments)
{
OT_UNUSED_VARIABLE(aContext);
@@ -368,15 +366,9 @@ exit:
return rval;
}
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
ReceiveTask(aBuf, aBufLength);
}
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { ReceiveTask(aBuf, aBufLength); }
void otPlatUartSendDone(void)
{
SendDoneTask();
}
void otPlatUartSendDone(void) { SendDoneTask(); }
extern "C" void otAppCliInit(otInstance *aInstance)
{
+16
View File
@@ -33,6 +33,13 @@ add_executable(ot-cli-ftd
target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-cli-ftd
PRIVATE
OPENTHREAD_FTD=1
OPENTHREAD_MTD=0
OPENTHREAD_RADIO=0
)
if(NOT DEFINED OT_PLATFORM_LIB_FTD)
set(OT_PLATFORM_LIB_FTD ${OT_PLATFORM_LIB})
endif()
@@ -44,8 +51,17 @@ target_link_libraries(ot-cli-ftd PRIVATE
${OT_PLATFORM_LIB_FTD}
openthread-cli-ftd
${OT_MBEDTLS}
ot-config-ftd
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-map,ot-cli-ftd.map)
else()
target_link_libraries(ot-cli-ftd PRIVATE -Wl,-Map=ot-cli-ftd.map)
endif()
endif()
install(TARGETS ot-cli-ftd
DESTINATION bin)
+52 -30
View File
@@ -27,13 +27,18 @@
*/
#include <assert.h>
#ifdef __linux__
#include <signal.h>
#include <sys/prctl.h>
#endif
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/cli.h>
#include <openthread/diag.h>
#include <openthread/tasklet.h>
#include <openthread/platform/logging.h>
#include <openthread/platform/misc.h>
#include "openthread-system.h"
#include "cli/cli_config.h"
@@ -42,32 +47,20 @@
#include "lib/platform/reset_util.h"
/**
* This function initializes the CLI app.
* Initializes the CLI app.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
extern void otAppCliInit(otInstance *aInstance);
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
return calloc(aNum, aSize);
}
OT_TOOL_WEAK void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); }
void otPlatFree(void *aPtr)
{
free(aPtr);
}
OT_TOOL_WEAK void otPlatFree(void *aPtr) { free(aPtr); }
#endif
void otTaskletsSignalPending(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
static void ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
static otError ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
{
OT_UNUSED_VARIABLE(aContext);
OT_UNUSED_VARIABLE(aArgsLength);
@@ -75,13 +68,49 @@ static void ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
exit(EXIT_SUCCESS);
}
static const otCliCommand kCommands[] = {{"exit", ProcessExit}};
#if OPENTHREAD_EXAMPLES_SIMULATION
extern otError ProcessNodeIdFilter(void *aContext, uint8_t aArgsLength, char *aArgs[]);
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
extern otError ProcessTrelTest(void *aContext, uint8_t aArgsLength, char *aArgs[]);
#endif
#endif
static const otCliCommand kCommands[] = {
{"exit", ProcessExit},
#if OPENTHREAD_EXAMPLES_SIMULATION
/*
* The CLI command `nodeidfilter` only works for simulation in real time.
*
* It can be used either as an allow list or a deny list. Once the filter is cleared, the first `nodeidfilter allow`
* or `nodeidfilter deny` will determine whether it is set up as an allow or deny list. Subsequent calls should
* use the same sub-command to add new node IDs, e.g., if we first call `nodeidfilter allow` (which sets the filter
* up as an allow list), a subsequent `nodeidfilter deny` will result in `InvalidState` error.
*
* The usage of the command `nodeidfilter`:
* - `nodeidfilter deny <nodeid>` : It denies the connection to a specified node (use as deny-list).
* - `nodeidfilter allow <nodeid> : It allows the connection to a specified node (use as allow-list).
* - `nodeidfilter clear` : It restores the filter state to default.
* - `nodeidfilter` : Outputs filter mode (allow-list or deny-list) and filtered node IDs.
*/
{"nodeidfilter", ProcessNodeIdFilter},
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
{"treltest", ProcessTrelTest},
#endif
#endif
};
#endif // OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
int main(int argc, char *argv[])
{
otInstance *instance;
#ifdef __linux__
// Ensure we terminate this process if the
// parent process dies.
prctl(PR_SET_PDEATHSIG, SIGHUP);
#endif
OT_SETUP_RESET_JUMP(argv);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
@@ -111,7 +140,11 @@ pseudo_reset:
otAppCliInit(instance);
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance);
IgnoreError(otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance));
#endif
#if OPENTHREAD_CONFIG_PLATFORM_LOG_CRASH_DUMP_ENABLE
IgnoreError(otPlatLogCrashDump());
#endif
while (!otSysPseudoResetWasRequested())
@@ -129,14 +162,3 @@ pseudo_reset:
return 0;
}
#if OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_APP
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
va_list ap;
va_start(ap, aFormat);
otCliPlatLogv(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
#endif
+16
View File
@@ -33,6 +33,13 @@ add_executable(ot-cli-mtd
target_include_directories(ot-cli-mtd PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-cli-mtd
PRIVATE
OPENTHREAD_FTD=0
OPENTHREAD_MTD=1
OPENTHREAD_RADIO=0
)
if(NOT DEFINED OT_PLATFORM_LIB_MTD)
set(OT_PLATFORM_LIB_MTD ${OT_PLATFORM_LIB})
endif()
@@ -44,8 +51,17 @@ target_link_libraries(ot-cli-mtd PRIVATE
${OT_PLATFORM_LIB_MTD}
openthread-cli-mtd
${OT_MBEDTLS}
ot-config-mtd
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-map,ot-cli-mtd.map)
else()
target_link_libraries(ot-cli-mtd PRIVATE -Wl,-Map=ot-cli-mtd.map)
endif()
endif()
install(TARGETS ot-cli-mtd
DESTINATION bin)
+16
View File
@@ -33,6 +33,13 @@ add_executable(ot-cli-radio
target_include_directories(ot-cli-radio PRIVATE ${COMMON_INCLUDES})
target_compile_definitions(ot-cli-radio
PRIVATE
OPENTHREAD_FTD=0
OPENTHREAD_MTD=0
OPENTHREAD_RADIO=1
)
if(NOT DEFINED OT_PLATFORM_LIB_RCP)
set(OT_PLATFORM_LIB_RCP ${OT_PLATFORM_LIB})
endif()
@@ -48,9 +55,18 @@ target_link_libraries(ot-cli-radio PRIVATE
${OT_PLATFORM_LIB_RCP}
openthread-cli-radio
${OT_MBEDTLS_RCP}
ot-config-radio
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-cli-radio PRIVATE -Wl,-map,ot-cli-radio.map)
else()
target_link_libraries(ot-cli-radio PRIVATE -Wl,-Map=ot-cli-radio.map)
endif()
endif()
install(TARGETS ot-cli-radio
DESTINATION bin
)
-200
View File
@@ -1,200 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
include $(top_srcdir)/examples/platforms/Makefile.platform.am
bin_PROGRAMS = \
$(NULL)
CPPFLAGS_COMMON += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/examples/platforms \
$(NULL)
LDADD_COMMON += \
$(top_builddir)/third_party/tcplp/libtcplp.a \
$(NULL)
LDFLAGS_COMMON += \
$(NULL)
LIBTOOLFLAGS_COMMON += \
$(NULL)
SOURCES_COMMON += \
main.c \
ncp.c \
$(NULL)
LDADD_MBEDTLS = \
$(NULL)
LDADD_MBEDTLS_RADIO = \
$(NULL)
LDADD_DIAG = \
$(NULL)
if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_MBEDTLS += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
LDADD_MBEDTLS_RADIO += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto-radio.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
LDADD_COMMON += \
$(OPENTHREAD_NCP_SPINEL_ENCRYPTER_LIBS) \
$(NULL)
endif # OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
if OPENTHREAD_ENABLE_NCP
if OPENTHREAD_ENABLE_FTD
bin_PROGRAMS += \
ot-ncp-ftd \
$(NULL)
endif
endif
ot_ncp_ftd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_ncp_ftd_LDADD = \
$(top_builddir)/src/ncp/libopenthread-ncp-ftd.a \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS) \
$(LDADD_DIAG) \
$(top_builddir)/src/core/libopenthread-ftd.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS) \
$(LDADD_DIAG) \
$(NULL)
ot_ncp_ftd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_ncp_ftd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_ncp_ftd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_NCP
if OPENTHREAD_ENABLE_MTD
bin_PROGRAMS += \
ot-ncp-mtd \
$(NULL)
endif
endif
ot_ncp_mtd_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_ncp_mtd_LDADD = \
$(top_builddir)/src/ncp/libopenthread-ncp-mtd.a \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS) \
$(LDADD_DIAG) \
$(top_builddir)/src/core/libopenthread-mtd.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS) \
$(LDADD_DIAG) \
$(NULL)
ot_ncp_mtd_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_ncp_mtd_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_ncp_mtd_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_RADIO_ONLY
bin_PROGRAMS += \
ot-rcp \
$(NULL)
endif
ot_rcp_CPPFLAGS = \
$(CPPFLAGS_COMMON) \
$(NULL)
ot_rcp_LDADD = \
$(top_builddir)/src/ncp/libopenthread-rcp.a \
$(top_builddir)/src/core/libopenthread-radio.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS_RADIO) \
$(top_builddir)/src/core/libopenthread-radio.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS_RADIO) \
$(NULL)
ot_rcp_LDFLAGS = \
$(LDFLAGS_COMMON) \
$(NULL)
ot_rcp_LIBTOOLFLAGS = \
$(LIBTOOLFLAGS_COMMON) \
$(NULL)
ot_rcp_SOURCES = \
$(SOURCES_COMMON) \
$(NULL)
if OPENTHREAD_ENABLE_LINKER_MAP
ot_ncp_ftd_LDFLAGS += -Wl,-Map=ot-ncp-ftd.map
ot_ncp_mtd_LDFLAGS += -Wl,-Map=ot-ncp-mtd.map
ot_rcp_LDFLAGS += -Wl,-Map=ot-rcp.map
endif
if OPENTHREAD_BUILD_COVERAGE
CPPFLAGS_COMMON += \
-DOPENTHREAD_ENABLE_COVERAGE \
$(NULL)
CLEANFILES = $(wildcard *.gcda *.gcno)
endif # OPENTHREAD_BUILD_COVERAGE
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+9
View File
@@ -44,7 +44,16 @@ target_link_libraries(ot-ncp-ftd PRIVATE
${OT_PLATFORM_LIB_FTD}
openthread-ncp-ftd
${OT_MBEDTLS}
ot-config-ftd
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-map,ot-ncp-ftd.map)
else()
target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-Map=ot-ncp-ftd.map)
endif()
endif()
install(TARGETS ot-ncp-ftd DESTINATION bin)
+43 -18
View File
@@ -27,6 +27,11 @@
*/
#include <assert.h>
#ifdef __linux__
#include <signal.h>
#include <sys/prctl.h>
#endif
#include <openthread-core-config.h>
#include <openthread/config.h>
@@ -37,38 +42,45 @@
#include "openthread-system.h"
#include "lib/platform/reset_util.h"
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
#if OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE == 0
#error "Support for multiple OpenThread static instance is disabled."
#endif
#define ENDPOINT_CT OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_NUM
#else
#define ENDPOINT_CT 1
#endif /* OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE */
/**
* This function initializes the NCP app.
* Initializes the NCP app.
*
* @param[in] aInstance The OpenThread instance structure.
*
*/
extern void otAppNcpInit(otInstance *aInstance);
extern void otAppNcpInitMulti(otInstance **aInstances, uint8_t count);
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
return calloc(aNum, aSize);
}
OT_TOOL_WEAK void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); }
void otPlatFree(void *aPtr)
{
free(aPtr);
}
OT_TOOL_WEAK void otPlatFree(void *aPtr) { free(aPtr); }
#endif
void otTaskletsSignalPending(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
int main(int argc, char *argv[])
{
otInstance *instance;
OT_SETUP_RESET_JUMP(argv);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#ifdef __linux__
// Ensure we terminate this process if the
// parent process dies.
prctl(PR_SET_PDEATHSIG, SIGHUP);
#endif
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
otInstance *instances[ENDPOINT_CT] = {NULL};
#elif OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
size_t otInstanceBufferLength = 0;
uint8_t *otInstanceBuffer = NULL;
#endif
@@ -77,7 +89,16 @@ pseudo_reset:
otSysInit(argc, argv);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
for (int i = 0; i < ENDPOINT_CT; i++)
{
instances[i] = otInstanceInitMultiple(i);
assert(instances[i]);
}
instance = instances[0];
#elif OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
// Call to query the buffer size
(void)otInstanceInit(NULL, &otInstanceBufferLength);
@@ -92,7 +113,11 @@ pseudo_reset:
#endif
assert(instance);
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
otAppNcpInitMulti(instances, ENDPOINT_CT);
#else
otAppNcpInit(instance);
#endif
while (!otSysPseudoResetWasRequested())
{
@@ -101,7 +126,7 @@ pseudo_reset:
}
otInstanceFinalize(instance);
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && !OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
free(otInstanceBuffer);
#endif
+9
View File
@@ -44,7 +44,16 @@ target_link_libraries(ot-ncp-mtd PRIVATE
${OT_PLATFORM_LIB_MTD}
openthread-ncp-mtd
${OT_MBEDTLS}
ot-config-mtd
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-map,ot-ncp-mtd.map)
else()
target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-Map=ot-ncp-mtd.map)
endif()
endif()
install(TARGETS ot-ncp-mtd DESTINATION bin)
+15 -8
View File
@@ -37,15 +37,9 @@
#if !OPENTHREAD_CONFIG_NCP_SPI_ENABLE
#include "utils/uart.h"
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
otNcpHdlcReceive(aBuf, aBufLength);
}
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { otNcpHdlcReceive(aBuf, aBufLength); }
void otPlatUartSendDone(void)
{
otNcpHdlcSendDone();
}
void otPlatUartSendDone(void) { otNcpHdlcSendDone(); }
#endif
#if !OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
@@ -67,4 +61,17 @@ void otAppNcpInit(otInstance *aInstance)
otNcpHdlcInit(aInstance, NcpSend);
#endif
}
#if OPENTHREAD_CONFIG_MULTIPAN_RCP_ENABLE
void otAppNcpInitMulti(otInstance **aInstances, uint8_t aCount)
{
#if OPENTHREAD_CONFIG_NCP_SPI_ENABLE
#error Multipan support not implemented for SPI
#else
IgnoreError(otPlatUartEnable());
otNcpHdlcInitMulti(aInstances, aCount, NcpSend);
#endif
}
#endif
#endif // !OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
+9
View File
@@ -43,7 +43,16 @@ target_link_libraries(ot-rcp PRIVATE
openthread-radio
${OT_PLATFORM_LIB_RCP}
openthread-rcp
ot-config-radio
ot-config
)
if(OT_LINKER_MAP)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
target_link_libraries(ot-rcp PRIVATE -Wl,-map,ot-rcp.map)
else()
target_link_libraries(ot-rcp PRIVATE -Wl,-Map=ot-rcp.map)
endif()
endif()
install(TARGETS ot-rcp DESTINATION bin)
-394
View File
@@ -1,394 +0,0 @@
#
# Copyright (c) 2016-2017, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# OpenThread Features (Makefile default configuration).
ANYCAST_LOCATOR ?= 0
BACKBONE_ROUTER ?= 0
BIG_ENDIAN ?= 0
BORDER_AGENT ?= 0
BORDER_ROUTER ?= 0
BORDER_ROUTING ?= 0
BORDER_ROUTING_NAT64 ?= 0
COAP ?= 0
COAP_BLOCK ?= 0
COAP_OBSERVE ?= 0
COAPS ?= 0
COMMISSIONER ?= 0
COVERAGE ?= 0
CHANNEL_MANAGER ?= 0
CHANNEL_MONITOR ?= 0
CHILD_SUPERVISION ?= 0
DATASET_UPDATER ?= 0
DEBUG ?= 0
DHCP6_CLIENT ?= 0
DHCP6_SERVER ?= 0
DIAGNOSTIC ?= 0
DISABLE_DOC ?= 0
DISABLE_TOOLS ?= 0
DNS_CLIENT ?= 0
DNS_DSO ?= 0
DNSSD_SERVER ?= 0
DUA ?= 0
DYNAMIC_LOG_LEVEL ?= 0
ECDSA ?= 0
EXTERNAL_HEAP ?= 0
HISTORY_TRACKER ?= 0
IP6_FRAGM ?= 0
JAM_DETECTION ?= 0
JOINER ?= 0
LEGACY ?= 0
ifeq ($(REFERENCE_DEVICE),1)
LOG_OUTPUT ?= APP
endif
LINK_RAW ?= 0
MAC_FILTER ?= 0
MESSAGE_USE_HEAP ?= 0
MLE_LONG_ROUTES ?= 0
MLR ?= 0
MTD_NETDIAG ?= 0
MULTIPLE_INSTANCE ?= 0
NEIGHBOR_DISCOVERY_AGENT ?= 0
NETDATA_PUBLISHER ?= 0
OTNS ?= 0
PING_SENDER ?= 1
PLATFORM_UDP ?= 0
REFERENCE_DEVICE ?= 0
SERVICE ?= 0
SETTINGS_RAM ?= 0
# SLAAC is enabled by default
SLAAC ?= 1
SNTP_CLIENT ?= 0
SRP_CLIENT ?= 0
SRP_SERVER ?= 0
THREAD_VERSION ?= 1.3
TIME_SYNC ?= 0
TREL ?= 0
UDP_FORWARD ?= 0
UPTIME ?= 0
RCP_RESTORATION_MAX_COUNT ?= 0
ifeq ($(ANYCAST_LOCATOR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE=1
endif
ifeq ($(BACKBONE_ROUTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1
endif
ifeq ($(BIG_ENDIAN),1)
COMMONCFLAGS += -DBYTE_ORDER_BIG_ENDIAN=1
endif
ifeq ($(BORDER_AGENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1
endif
ifeq ($(BORDER_ROUTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1
endif
ifeq ($(BORDER_ROUTING),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1
endif
ifeq ($(BORDER_ROUTING_NAT64),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE=1
endif
ifeq ($(COAP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_API_ENABLE=1
endif
ifeq ($(COAPS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1
endif
ifeq ($(COAP_BLOCK),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE=1
endif
ifeq ($(COAP_OBSERVE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1
endif
ifeq ($(COMMISSIONER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1
endif
ifeq ($(COVERAGE),1)
configure_OPTIONS += --enable-coverage
endif
ifeq ($(CHANNEL_MANAGER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1
endif
ifeq ($(CHANNEL_MONITOR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1
endif
ifeq ($(CHILD_SUPERVISION),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1
endif
ifeq ($(CSL_RECEIVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1
endif
ifeq ($(CSL_AUTO_SYNC),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1
else ifeq ($(CSL_AUTO_SYNC),0)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=0
endif
ifeq ($(CSL_DEBUG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE=1
endif
ifeq ($(DATASET_UPDATER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1
endif
ifeq ($(DEBUG),1)
configure_OPTIONS += --enable-debug --disable-optimization
endif
ifeq ($(DHCP6_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1
endif
ifeq ($(DHCP6_SERVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1
endif
ifeq ($(DIAGNOSTIC),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DIAG_ENABLE=1
endif
ifeq ($(DISABLE_DOC),1)
configure_OPTIONS += --disable-docs
endif
ifeq ($(DISABLE_TOOLS),1)
configure_OPTIONS += --disable-tools
endif
ifeq ($(DNS_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1
endif
ifeq ($(DNS_DSO),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNS_DSO_ENABLE=1
endif
ifeq ($(DNSSD_SERVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1
endif
ifeq ($(DUA),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DUA_ENABLE=1
endif
ifeq ($(DYNAMIC_LOG_LEVEL),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1
endif
ifeq ($(ECDSA),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_ECDSA_ENABLE=1
endif
ifeq ($(EXTERNAL_HEAP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1
endif
ifeq ($(HISTORY_TRACKER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1
endif
ifeq ($(IP6_FRAGM),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1
endif
ifeq ($(JAM_DETECTION),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1
endif
ifeq ($(JOINER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_JOINER_ENABLE=1
endif
ifeq ($(LEGACY),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LEGACY_ENABLE=1
endif
ifeq ($(LINK_RAW),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1
endif
ifeq ($(LINK_METRICS_INITIATOR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1
endif
ifeq ($(LINK_METRICS_SUBJECT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=1
endif
ifneq ($(LOG_OUTPUT),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_$(LOG_OUTPUT)
endif
ifeq ($(MAC_FILTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1
endif
ifeq ($(MESSAGE_USE_HEAP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1
endif
# Enable MLE long routes extension (experimental, breaks Thread conformance)
ifeq ($(MLE_LONG_ROUTES),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1
endif
ifeq ($(MLR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLR_ENABLE=1
endif
ifeq ($(MTD_NETDIAG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1
endif
ifeq ($(MULTIPLE_INSTANCE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1
endif
ifeq ($(NEIGHBOR_DISCOVERY_AGENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE=1
endif
ifeq ($(NETDATA_PUBLISHER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1
endif
ifeq ($(PING_SENDER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1
endif
ifeq ($(PLATFORM_UDP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1
endif
# Enable features only required for reference device during certification.
ifeq ($(REFERENCE_DEVICE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1
endif
ifeq ($(SERVICE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1
endif
ifeq ($(SLAAC),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1
endif
ifeq ($(SNTP_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1
endif
ifeq ($(SRP_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1
endif
ifeq ($(SRP_SERVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1
endif
ifeq ($(THREAD_VERSION),1.1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=2
else ifeq ($(THREAD_VERSION),1.2)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=3
else ifeq ($(THREAD_VERSION),1.3)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=4
endif
ifeq ($(TIME_SYNC),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1 -DOPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT=1
endif
ifeq ($(TREL),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1
endif
ifeq ($(UDP_FORWARD),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1
endif
ifeq ($(UPTIME),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_UPTIME_ENABLE=1
endif
ifeq ($(DISABLE_BUILTIN_MBEDTLS),1)
configure_OPTIONS += --disable-builtin-mbedtls
endif
ifneq ($(BUILTIN_MBEDTLS_MANAGEMENT),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=$(BUILTIN_MBEDTLS_MANAGEMENT)
endif
ifeq ($(DISABLE_EXECUTABLE),1)
configure_OPTIONS += --enable-executable=no
endif
ifeq ($(DEBUG_UART),1)
CFLAGS += -DOPENTHREAD_CONFIG_ENABLE_DEBUG_UART=1
CXXFLAGS += -DOPENTHREAD_CONFIG_ENABLE_DEBUG_UART=1
endif
ifeq ($(DEBUG_UART_LOG),1)
CFLAGS += -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART
CXXFLAGS += -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART
endif
ifeq ($(SETTINGS_RAM),1)
COMMONCFLAGS += -DOPENTHREAD_SETTINGS_RAM=1
endif
ifeq ($(OTNS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_OTNS_ENABLE=1
endif
ifneq ($(SPINEL_ENCRYPTER_LIBS),)
configure_OPTIONS += --with-ncp-spinel-encrypter-libs=$(SPINEL_ENCRYPTER_LIBS)
endif
COMMONCFLAGS += -DOPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${RCP_RESTORATION_MAX_COUNT}
ifeq ($(FULL_LOGS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG -DOPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1
endif
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2023, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* This header file defines the OpenThread core configuration example for an Border Router. This is intended for use
* in `script/check-size`.
*/
#ifndef OT_CORE_CONFIG_CHECK_SIZE_BR_H_
#define OT_CORE_CONFIG_CHECK_SIZE_BR_H_
#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_4
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 1
#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_ADMITTER_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 1
#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 1
#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 1
#define OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 1
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 1
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 1
#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1
#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 1
#define OPENTHREAD_CONFIG_JOINER_ENABLE 1
#define OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE 1
#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 1
#define OPENTHREAD_CONFIG_MESH_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
#define OPENTHREAD_CONFIG_MULTICAST_DNS_ENABLE 1
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1
#define OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE 1
#define OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE 1
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE 1
#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 1
#define OPENTHREAD_CONFIG_UPTIME_ENABLE 1
// Enable mock platform APIs
#define OPENTHREAD_CONFIG_DNS_DSO_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTING_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_MOCK_PLAT_APIS_ENABLE 1
#define OPENTHREAD_CONFIG_MULTICAST_DNS_MOCK_PLAT_APIS_ENABLE 1
#endif // OT_CORE_CONFIG_CHECK_SIZE_BR_H_
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2023, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* This header file defines the OpenThread core configuration example for an FTD device (not acting as BR). This is
* intended for use in `script/check-size`.
*/
#ifndef OT_CORE_CONFIG_CHECK_SIZE_FTD_H_
#define OT_CORE_CONFIG_CHECK_SIZE_FTD_H_
#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_4
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 1
#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 0
#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 1
#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 1
#define OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 0
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1
#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 1
#define OPENTHREAD_CONFIG_JOINER_ENABLE 1
#define OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE 1
#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 1
#define OPENTHREAD_CONFIG_MESH_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE 0
#define OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE 0
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE 0
#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 1
#define OPENTHREAD_CONFIG_UPTIME_ENABLE 1
#endif // OT_CORE_CONFIG_CHECK_SIZE_FTD_H_
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2023, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* This header file defines the OpenThread core configuration example for an MTD/SED device. This is intended for use
* in `script/check-size`.
*/
#ifndef OT_CORE_CONFIG_CHECK_SIZE_MTD_H_
#define OT_CORE_CONFIG_CHECK_SIZE_MTD_H_
#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_4
#define OPENTHREAD_CONFIG_ASSERT_ENABLE 1
#define OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 0
#define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 0
#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 0
#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0
#define OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE 0
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 0
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1
#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 0
#define OPENTHREAD_CONFIG_JOINER_ENABLE 1
#define OPENTHREAD_CONFIG_LINK_METRICS_MANAGER_ENABLE 0
#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_INFO
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 1
#define OPENTHREAD_CONFIG_MESH_DIAG_ENABLE 0
#define OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE 0
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 0
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 0
#define OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE 0
#define OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE 0
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
#define OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0
#define OPENTHREAD_CONFIG_TIME_SYNC_ENABLE 0
#define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0
#define OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE 0
#define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE 0
#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 1
#define OPENTHREAD_CONFIG_UPTIME_ENABLE 1
#endif // OT_CORE_CONFIG_CHECK_SIZE_MTD_H_
-71
View File
@@ -1,71 +0,0 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
EXTRA_DIST = \
cc1352 \
cc2652 \
efr32 \
gp712 \
k32w \
kw41z \
nrf528xx \
qpg6095 \
qpg6100 \
qpg7015m \
samr21 \
$(NULL)
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
cc2538 \
simulation \
utils \
$(NULL)
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
utils \
$(NULL)
if OPENTHREAD_PLATFORM_CC2538
SUBDIRS += cc2538
endif
if OPENTHREAD_PLATFORM_SIMULATION
SUBDIRS += simulation
endif
noinst_HEADERS = \
openthread-system.h \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
-50
View File
@@ -1,50 +0,0 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# This utility Makefile is included by the application Makefile.am as follows:
#
# include $(top_srcdir)/examples/platforms/Makefile.platform.am
#
# It will automatically set required flags and libraries to link based on
# the selected platform and feature options set via configure.
#
CPPFLAGS_COMMON = $(NULL)
LDADD_COMMON = $(NULL)
LDFLAGS_COMMON = $(NULL)
SOURCES_COMMON = $(NULL)
LIBTOOLFLAGS_COMMON = --preserve-dup-deps
if OPENTHREAD_EXAMPLES_CC2538
include $(top_srcdir)/examples/platforms/cc2538/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_SIMULATION
include $(top_srcdir)/examples/platforms/simulation/Makefile.platform.am
endif
-1
View File
@@ -1 +0,0 @@
The OpenThread on CC1352 example has moved to https://github.com/openthread/ot-cc13x2-cc26x2
-79
View File
@@ -1,79 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set(OT_PLATFORM_LIB "openthread-cc2538" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "openthread-core-cc2538-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-cc2538-config-check.h\""
"OPENTHREAD_CONFIG_NCP_HDLC_ENABLE=1"
)
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-cc2538
alarm.c
diag.c
entropy.c
flash.c
misc.c
radio.c
startup-gcc.c
system.c
logging.c
uart.c
$<TARGET_OBJECTS:openthread-platform-utils>
)
target_link_libraries(openthread-cc2538
PRIVATE
ot-config
PUBLIC
-T${PROJECT_SOURCE_DIR}/examples/platforms/cc2538/cc2538.ld
-Wl,--gc-sections -Wl,-Map=$<TARGET_PROPERTY:NAME>.map
)
target_compile_definitions(openthread-cc2538
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-cc2538 PRIVATE
${OT_CFLAGS}
)
target_include_directories(openthread-cc2538 PRIVATE
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms
${PROJECT_SOURCE_DIR}/src/core
)
-69
View File
@@ -1,69 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Do not enable -Wcast-align for this platform
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
lib_LIBRARIES = libopenthread-cc2538.a
libopenthread_cc2538_a_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/examples/platforms \
-I$(top_srcdir)/src/core \
$(NULL)
PLATFORM_SOURCES = \
alarm.c \
cc2538-reg.h \
diag.c \
entropy.c \
flash.c \
misc.c \
openthread-core-cc2538-config.h \
openthread-core-cc2538-config-check.h \
platform-cc2538.h \
radio.c \
rom-utility.h \
startup-gcc.c \
system.c \
logging.c \
uart.c \
$(NULL)
libopenthread_cc2538_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_cc2538_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
@@ -1,39 +0,0 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# cc2538 platform-specific Makefile
#
LDADD_COMMON += \
$(top_builddir)/examples/platforms/cc2538/libopenthread-cc2538.a \
$(NULL)
LDFLAGS_COMMON += \
-T $(top_srcdir)/examples/platforms/cc2538/cc2538.ld \
$(NULL)
-112
View File
@@ -1,112 +0,0 @@
# OpenThread on CC2538 Example
This directory contains example platform drivers for the [Texas Instruments CC2538][cc2538].
[cc2538]: http://www.ti.com/product/CC2538
The example platform drivers are intended to present the minimal code necessary to support OpenThread. As a result, the example platform drivers do not necessarily highlight the platform's full capabilities.
## Toolchain
Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
```bash
$ cd <path-to-openthread>
$ ./script/bootstrap
```
## Building
In a Bash terminal, follow these instructions to build the cc2538 examples.
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-cc2538
```
### CC2592 support
If your board has a CC2592 range extender front-end IC connected to the CC2538 (e.g. the CC2538-CC2592 EM reference design), you need to initialise this part before reception of radio traffic will work.
Support is enabled in OpenThread by building with `CC2592=1`:
```bash
$ make -f examples/Makefile-cc2538 CC2592=1
```
The default settings should work for any design following the integration advice given in TI's application report ["AN130 - Using CC2592 Front End With CC2538"](http://www.ti.com/lit/pdf/swra447).
Additional settings can be customised:
- `CC2592_PA_EN`: This specifies which pin (on port C of the CC2538) connects to the CC2592's `PA_EN` pin. The default is `3` (PC3).
- `CC2592_LNA_EN`: This specifies which pin (on port C of the CC2538) connects to the CC2592's `LNA_EN` pin. The default is `2` (PC2).
- `CC2592_USE_HGM`: This defines whether the HGM pin of the CC2592 is under GPIO control or not. If not, it is assumed that the HGM pin is tied to a power rail.
- `CC2592_HGM_PORT`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO port, you may specify that port (`A`, `B` or `C`) here.
- `CC2592_HGM_PORT`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO port, you may specify that port (`A`, `B` or `C`) here. Default is `D`.
- `CC2592_HGM_PIN`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO pin, you can specify the pin here. Default is `2`.
- `CC2592_HGM_DEFAULT_STATE`: By default, HGM is enabled at power-on, but you may want to have it default to off, specify `CC2592_HGM_DEFAULT_STATE=0` to do so.
- `CC2538_RECEIVE_SENSITIVITY`: If you have tied the HGM pin to a power rail, this allows you to calibrate the RSSI values according to the new receive sensitivity. This has no effect if `CC2592_USE_HGM=1` (the default).
- `CC2538_RSSI_OFFSET`: If you have tied the HGM pin to a power rail, this allows you to calibrate the RSSI values according to the new RSSI offset. This has no effect if `CC2592_USE_HGM=1` (the default).
## Flash Binaries
If the build completed successfully, the `elf` files may be found in `<path-to-openthread>/output/cc2538/bin`.
To flash the images with [Flash Programmer 2][ti-flash-programmer-2], the files must have the `*.elf` extension.
```bash
$ cd <path-to-openthread>/output/cc2538/bin
$ cp ot-cli ot-cli.elf
```
To load the images with the [serial bootloader][ti-cc2538-bootloader], the images must be converted to `bin`. This is done using `arm-none-eabi-objcopy`
```bash
$ cd <path-to-openthread>/output/cc2538/bin
$ arm-none-eabi-objcopy -O binary ot-cli ot-cli.bin
```
The [cc2538-bsl.py script][cc2538-bsl-tool] provides a convenient method for flashing a CC2538 via the UART. To enter the bootloader backdoor for flashing, hold down SELECT for CC2538DK (corresponds to logic '0') while you press the Reset button.
[ti-flash-programmer-2]: http://www.ti.com/tool/flash-programmer
[ti-cc2538-bootloader]: http://www.ti.com/lit/an/swra466a/swra466a.pdf
[cc2538-bsl-tool]: https://github.com/JelmerT/cc2538-bsl
## Interact
1. Open terminal to `/dev/ttyUSB1` (serial port settings: 115200 8-N-1).
2. Type `help` for list of commands.
```bash
> help
help
channel
childtimeout
contextreusedelay
extaddr
extpanid
ipaddr
keysequence
leaderweight
mode
netdata register
networkidtimeout
networkkey
networkname
panid
ping
prefix
releaserouterid
rloc16
route
routerupgradethreshold
scan
start
state
stop
```
-148
View File
@@ -1,148 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements the OpenThread platform abstraction for the alarm.
*
*/
#include <stdbool.h>
#include <stdint.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
#include "platform-cc2538.h"
enum
{
kSystemClock = 32000000, ///< MHz
kTicksPerSec = 1000, ///< Ticks per second
};
static uint32_t sCounter = 0;
static uint32_t sAlarmT0 = 0;
static uint32_t sAlarmDt = 0;
static bool sIsRunning = false;
static uint8_t sTimersIsRunning = 0;
static uint32_t sTimersExpireAt[OT_CC2538_TIMERS_COUNT];
extern void cc2538EnergyScanTimerHandler(void);
void cc2538SetTimer(otCC2538Timer aTimer, uint32_t aDelay)
{
sTimersIsRunning |= (1 << aTimer);
sTimersExpireAt[aTimer] = sCounter + aDelay;
}
void cc2538AlarmInit(void)
{
HWREG(NVIC_ST_RELOAD) = kSystemClock / kTicksPerSec;
HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_INTEN | NVIC_ST_CTRL_ENABLE;
}
uint32_t otPlatAlarmMilliGetNow(void)
{
return sCounter;
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
{
OT_UNUSED_VARIABLE(aInstance);
sAlarmT0 = t0;
sAlarmDt = dt;
sIsRunning = true;
}
void otPlatAlarmMilliStop(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
sIsRunning = false;
}
void cc2538AlarmProcess(otInstance *aInstance)
{
uint32_t expires;
bool fire = false;
if (sTimersIsRunning)
{
if ((int32_t)(sTimersExpireAt[OT_CC2538_TIMER_ENERGY_SCAN] - sCounter) < 0)
{
sTimersIsRunning &= ~(1 << OT_CC2538_TIMER_ENERGY_SCAN);
cc2538EnergyScanTimerHandler();
}
}
if (sIsRunning)
{
expires = sAlarmT0 + sAlarmDt;
if (sAlarmT0 <= sCounter)
{
if (expires >= sAlarmT0 && expires <= sCounter)
{
fire = true;
}
}
else
{
if (expires >= sAlarmT0 || expires <= sCounter)
{
fire = true;
}
}
if (fire)
{
sIsRunning = false;
#if OPENTHREAD_CONFIG_DIAG_ENABLE
if (otPlatDiagModeGet())
{
otPlatDiagAlarmFired(aInstance);
}
else
#endif
{
otPlatAlarmMilliFired(aInstance);
}
}
}
}
void SysTick_Handler()
{
sCounter++;
}
@@ -1,42 +0,0 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)
set(COMMON_C_FLAGS "-mthumb -fno-builtin -Wall -fdata-sections -ffunction-sections -mabi=aapcs -mcpu=cortex-m3 -mfloat-abi=soft")
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -nostartfiles")
-326
View File
@@ -1,326 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes CC2538 register definitions.
*
*/
#ifndef CC2538_REG_H_
#define CC2538_REG_H_
#include <stdint.h>
// clang-format off
#define HWREG(x) (*((volatile uint32_t *)(x)))
/*!
* For registers that are arrays of 32-bit integers.
*
* @param reg Register address
* @param idx Register array index
*/
#define HWREG_ARR(reg, idx) HWREG((reg) + ((idx) << 2))
#define NVIC_ST_CTRL 0xE000E010 // SysTick Control and Status
#define NVIC_ST_RELOAD 0xE000E014 // SysTick Reload Value Register
#define NVIC_EN0 0xE000E100 // Interrupt 0-31 Set Enable
#define NVIC_ST_CTRL_COUNT 0x00010000 // Count Flag
#define NVIC_ST_CTRL_CLK_SRC 0x00000004 // Clock Source
#define NVIC_ST_CTRL_INTEN 0x00000002 // Interrupt Enable
#define NVIC_ST_CTRL_ENABLE 0x00000001 // Enable
#define RFCORE_XREG_SRCMATCH_EN 0x00000001 // SRCMATCH.SRC_MATCH_EN(1)
#define RFCORE_XREG_SRCMATCH_AUTOPEND 0x00000002 // SRCMATCH.AUTOPEND(1)
#define RFCORE_XREG_SRCMATCH_PEND_DATAREQ_ONLY 0x00000004 // SRCMATCH.PEND_DATAREQ_ONLY(1)
#define RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE 3 // Num of register for source match enable status
#define RFCORE_XREG_SRCMATCH_SHORT_ENTRIES 24 // 24 short address entries in maximum
#define RFCORE_XREG_SRCMATCH_EXT_ENTRIES 12 // 12 extended address entries in maximum
#define RFCORE_XREG_SRCMATCH_SHORT_ENTRY_OFFSET 4 // address offset for one short address entry
#define RFCORE_XREG_SRCMATCH_EXT_ENTRY_OFFSET 8 // address offset for one extended address entry
#define INT_UART0 21 // UART0 Rx and Tx
#define IEEE_EUI64 0x00280028 // Address of IEEE EUI-64 address
#define RFCORE_FFSM_SRCADDRESS_TABLE 0x40088400 // Source Address Table
#define RFCORE_FFSM_SRCEXTPENDEN0 0x40088590 // Enable/Disable automatic pending per extended address
#define RFCORE_FFSM_SRCSHORTPENDEN0 0x4008859C // Enable/Disable automatic pending per short address
#define RFCORE_FFSM_EXT_ADDR0 0x400885A8 // Local address information
#define RFCORE_FFSM_PAN_ID0 0x400885C8 // Local address information
#define RFCORE_FFSM_PAN_ID1 0x400885CC // Local address information
#define RFCORE_FFSM_SHORT_ADDR0 0x400885D0 // Local address information
#define RFCORE_FFSM_SHORT_ADDR1 0x400885D4 // Local address information
#define RFCORE_XREG_FRMFILT0 0x40088600 // The frame filtering function
#define RFCORE_XREG_SRCMATCH 0x40088608 // Source address matching and pending bits
#define RFCORE_XREG_SRCSHORTEN0 0x4008860C // Short address matching
#define RFCORE_XREG_SRCEXTEN0 0x40088618 // Extended address matching
#define RFCORE_XREG_FRMCTRL0 0x40088624 // Frame handling
#define RFCORE_XREG_FRMCTRL1 0x40088628 // Frame handling
#define RFCORE_XREG_RXENABLE 0x4008862C // RX enabling
#define RFCORE_XREG_FREQCTRL 0x4008863C // Controls the RF frequency
#define RFCORE_XREG_TXPOWER 0x40088640 // Controls the output power
#define RFCORE_XREG_FSMSTAT0 0x40088648 // Radio finite state machine status
#define RFCORE_XREG_FSMSTAT1 0x4008864C // Radio status register
#define RFCORE_XREG_FIFOPCTRL 0x40088650 // FIFOP threshold
#define RFCORE_XREG_CCACTRL0 0x40088658 // CCA threshold
#define RFCORE_XREG_RSSI 0x40088660 // RSSI status register
#define RFCORE_XREG_RSSISTAT 0x40088664 // RSSI valid status register
#define RFCORE_XREG_AGCCTRL1 0x400886C8 // AGC reference level
#define RFCORE_XREG_RFC_OBS_CTRL 0x400887AC // RF Core observable output
#define RFCORE_XREG_TXFILTCFG 0x400887E8 // TX filter configuration
#define RFCORE_XREG_RFRND 0x4008869C // Random data
#define RFCORE_SFR_RFDATA 0x40088828 // The TX FIFO and RX FIFO
#define RFCORE_SFR_RFERRF 0x4008882C // RF error interrupt flags
#define RFCORE_SFR_RFIRQF0 0x40088834 // RF interrupt flags
#define RFCORE_SFR_RFST 0x40088838 // RF CSMA-CA/strobe processor
#define CCTEST_OBSSEL 0x44010014 // CCTEST observable output route
#define RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN 0x00000001 // Enables frame filtering
#define RFCORE_XREG_FRMCTRL0_AUTOACK 0x00000020
#define RFCORE_XREG_FRMCTRL0_ENERGY_SCAN 0x00000010
#define RFCORE_XREG_FRMCTRL0_AUTOCRC 0x00000040
#define RFCORE_XREG_FRMCTRL0_INFINITY_RX 0x00000008
#define RFCORE_XREG_FRMCTRL1_PENDING_OR 0x00000004
#define RFCORE_XREG_RFRND_IRND 0x00000001
#define RFCORE_XREG_FSMSTAT0_STATE_MASK 0x0000003F
#define RFCORE_XREG_FSMSTAT0_CAL_DONE 0x00000080
#define RFCORE_XREG_FSMSTAT0_CAL_RUN 0x00000040
#define RFCORE_XREG_FSMSTAT0_STATE_IDLE 0x00000000
#define RFCORE_XREG_FSMSTAT0_STATE_RX_CAL 0x00000002
#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT0 0x00000003
#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT1 0x00000004
#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT2 0x00000005
#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT3 0x00000006
#define RFCORE_XREG_FSMSTAT0_STATE_RX0 0x00000007
#define RFCORE_XREG_FSMSTAT0_STATE_RX1 0x00000008
#define RFCORE_XREG_FSMSTAT0_STATE_RX2 0x00000009
#define RFCORE_XREG_FSMSTAT0_STATE_RX3 0x0000000A
#define RFCORE_XREG_FSMSTAT0_STATE_RX4 0x0000000B
#define RFCORE_XREG_FSMSTAT0_STATE_RX5 0x0000000C
#define RFCORE_XREG_FSMSTAT0_STATE_RX6 0x0000000D
#define RFCORE_XREG_FSMSTAT0_STATE_RX_WAIT 0x0000000E
#define RFCORE_XREG_FSMSTAT0_STATE_RX_FRST 0x00000010
#define RFCORE_XREG_FSMSTAT0_STATE_RX_OVER 0x00000011
#define RFCORE_XREG_FSMSTAT0_STATE_TX_CAL 0x00000020
#define RFCORE_XREG_FSMSTAT0_STATE_TX0 0x00000022
#define RFCORE_XREG_FSMSTAT0_STATE_TX1 0x00000023
#define RFCORE_XREG_FSMSTAT0_STATE_TX2 0x00000024
#define RFCORE_XREG_FSMSTAT0_STATE_TX3 0x00000025
#define RFCORE_XREG_FSMSTAT0_STATE_TX4 0x00000026
#define RFCORE_XREG_FSMSTAT0_STATE_TX_FINAL 0x00000027
#define RFCORE_XREG_FSMSTAT0_STATE_RXTX_TRANS 0x00000028
#define RFCORE_XREG_FSMSTAT0_STATE_ACK_CAL 0x00000030
#define RFCORE_XREG_FSMSTAT0_STATE_ACK0 0x00000031
#define RFCORE_XREG_FSMSTAT0_STATE_ACK1 0x00000032
#define RFCORE_XREG_FSMSTAT0_STATE_ACK2 0x00000033
#define RFCORE_XREG_FSMSTAT0_STATE_ACK3 0x00000034
#define RFCORE_XREG_FSMSTAT0_STATE_ACK4 0x00000035
#define RFCORE_XREG_FSMSTAT0_STATE_ACK5 0x00000036
#define RFCORE_XREG_FSMSTAT0_STATE_ACK_DELAY 0x00000037
#define RFCORE_XREG_FSMSTAT0_STATE_TX_UNDER 0x00000038
#define RFCORE_XREG_FSMSTAT0_STATE_TX_DOWN0 0x0000001A
#define RFCORE_XREG_FSMSTAT0_STATE_TX_DOWN1 0x0000003A
#define RFCORE_XREG_FSMSTAT1_RX_ACTIVE 0x00000001
#define RFCORE_XREG_FSMSTAT1_TX_ACTIVE 0x00000002
#define RFCORE_XREG_FSMSTAT1_LOCK_STATUS 0x00000004
#define RFCORE_XREG_FSMSTAT1_SAMPLED_CCA 0x00000008
#define RFCORE_XREG_FSMSTAT1_CCA 0x00000010 // Clear channel assessment
#define RFCORE_XREG_FSMSTAT1_SFD 0x00000020
#define RFCORE_XREG_FSMSTAT1_FIFOP 0x00000040
#define RFCORE_XREG_FSMSTAT1_FIFO 0x00000080
#define RFCORE_XREG_RSSISTAT_RSSI_VALID 0x00000001 // RSSI value is valid.
#define RFCORE_XREG_RFC_OBS_POL_INV 0x00000040 // Invert polarity of OBS signal
#define RFCORE_XREG_RFC_OBS_MUX_ZERO 0x00000000 // Observable = constant zero
#define RFCORE_XREG_RFC_OBS_MUX_ONE 0x00000001 // Observable = constant one
#define RFCORE_XREG_RFC_OBS_MUX_SNIFF_DATA 0x00000008 // RFC sniff data
#define RFCORE_XREG_RFC_OBS_MUX_SNIFF_CLK 0x00000009 // RFC sniff clock
#define RFCORE_XREG_RFC_OBS_MUX_RSSI_VALID 0x0000000c // RSSI valid
#define RFCORE_XREG_RFC_OBS_MUX_DEMOD_CCA 0x0000000d // Clear channel assessment
#define RFCORE_XREG_RFC_OBS_MUX_SAMPLED_CCA 0x0000000e // Sampled CCA signal
#define RFCORE_XREG_RFC_OBS_MUX_SFD_SYNC 0x0000000f // SFD received or transmitted
#define RFCORE_XREG_RFC_OBS_MUX_TX_ACTIVE 0x00000010 // Transmitter is active
#define RFCORE_XREG_RFC_OBS_MUX_RX_ACTIVE 0x00000011 // Receiver is active
#define RFCORE_XREG_RFC_OBS_MUX_FFCTRL_FIFO 0x00000012 // One or more bytes in FIFO
#define RFCORE_XREG_RFC_OBS_MUX_FFCTRL_FIFOP 0x00000013 // One or more frames in FIFO
#define RFCORE_XREG_RFC_OBS_MUX_PACKET_DONE 0x00000014 // Packet received
#define RFCORE_XREG_RFC_OBS_MUX_RFC_XOR_RAND_IQ 0x00000016 // RAND I ^ RAND Q
#define RFCORE_XREG_RFC_OBS_MUX_RFC_RAND_Q 0x00000017 // Random data from Q channel
#define RFCORE_XREG_RFC_OBS_MUX_RFC_RAND_I 0x00000018 // Random data from I channel
#define RFCORE_XREG_RFC_OBS_MUX_LOCK_STATUS 0x00000019 // PLL is in lock
#define RFCORE_XREG_RFC_OBS_MUX_PA_PD 0x00000028 // Power amp power down
#define RFCORE_XREG_RFC_OBS_MUX_LNA_PD 0x0000002a // LNA power down
#define RFCORE_SFR_RFERRF_NLOCK 0x00000001 // Failed to achieve PLL lock.
#define RFCORE_SFR_RFERRF_RXABO 0x00000002 // RX Aborted.
#define RFCORE_SFR_RFERRF_RXOVERF 0x00000004 // RX FIFO overflowed.
#define RFCORE_SFR_RFERRF_RXUNDERF 0x00000008 // RX FIFO underflowed.
#define RFCORE_SFR_RFERRF_TXOVERF 0x00000010 // TX FIFO overflowed.
#define RFCORE_SFR_RFERRF_TXUNDERF 0x00000020 // TX FIFO underflowed.
#define RFCORE_SFR_RFERRF_STROBEERR 0x00000040 // Command Strobe Error.
#define RFCORE_SFR_RFST_INSTR_RXON 0xE3 // Instruction set RX on
#define RFCORE_SFR_RFST_INSTR_TXON 0xE9 // Instruction set TX on
#define RFCORE_SFR_RFST_INSTR_RFOFF 0xEF // Instruction set RF off
#define RFCORE_SFR_RFST_INSTR_FLUSHRX 0xED // Instruction set flush rx buffer
#define RFCORE_SFR_RFST_INSTR_FLUSHTX 0xEE // Instruction set flush tx buffer
#define CCTEST_OBSSEL_EN 0x00000080 // Enable the OBS output on this pin
#define CCTEST_OBSSEL_SEL_OBS0 0x00000000 // Route OBS0 to pin
#define CCTEST_OBSSEL_SEL_OBS1 0x00000001 // Route OBS1 to pin
#define CCTEST_OBSSEL_SEL_OBS2 0x00000002 // Route OBS2 to pin
#define ANA_REGS_BASE 0x400D6000 // ANA_REGS
#define ANA_REGS_O_IVCTRL 0x00000004 // Analog control register
#define SYS_CTRL_CLOCK_CTRL 0x400D2000 // The clock control register
#define SYS_CTRL_SYSDIV_32MHZ 0x00000000 // Sys_div for sysclk 32MHz
#define SYS_CTRL_CLOCK_CTRL_AMP_DET 0x00200000
#define SYS_CTRL_PWRDBG 0x400D2074
#define SYS_CTRL_PWRDBG_FORCE_WARM_RESET 0x00000008
#define SYS_CTRL_RCGCUART 0x400D2028
#define SYS_CTRL_SCGCUART 0x400D202C
#define SYS_CTRL_DCGCUART 0x400D2030
#define SYS_CTRL_I_MAP 0x400D2098
#define SYS_CTRL_RCGCRFC 0x400D20A8
#define SYS_CTRL_SCGCRFC 0x400D20AC
#define SYS_CTRL_DCGCRFC 0x400D20B0
#define SYS_CTRL_EMUOVR 0x400D20B4
#define SYS_CTRL_RCGCRFC_RFC0 0x00000001
#define SYS_CTRL_SCGCRFC_RFC0 0x00000001
#define SYS_CTRL_DCGCRFC_RFC0 0x00000001
#define SYS_CTRL_I_MAP_ALTMAP 0x00000001
#define SYS_CTRL_RCGCUART_UART0 0x00000001
#define SYS_CTRL_SCGCUART_UART0 0x00000001
#define SYS_CTRL_DCGCUART_UART0 0x00000001
#define SYS_CTRL_RCGCUART_UART1 0x00000002
#define SYS_CTRL_SCGCUART_UART1 0x00000002
#define SYS_CTRL_DCGCUART_UART1 0x00000002
#define IOC_PA0_SEL 0x400D4000 // Peripheral select control
#define IOC_PA1_SEL 0x400D4004 // Peripheral select control
#define IOC_PA2_SEL 0x400D4008
#define IOC_PA3_SEL 0x400D400C
#define IOC_UARTRXD_UART0 0x400D4100
#define IOC_UARTRXD_UART1 0x400D4108
#define IOC_PA0_OVER 0x400D4080
#define IOC_PA1_OVER 0x400D4084
#define IOC_PA2_OVER 0x400D4088
#define IOC_PA3_OVER 0x400D408C
#define IOC_MUX_OUT_SEL_UART0_TXD 0x00000000
#define IOC_MUX_OUT_SEL_UART1_TXD 0x00000002
#define IOC_OVERRIDE_OE 0x00000008 // PAD Config Override Output Enable
#define IOC_OVERRIDE_DIS 0x00000000 // PAD Config Override Disabled
#define IOC_PAD_IN_SEL_PA0 0x00000000 // PA0
#define IOC_PAD_IN_SEL_PA1 0x00000001 // PA1
#define IOC_PAD_IN_SEL_PA2 0x00000002 // PA2
#define IOC_PAD_IN_SEL_PA3 0x00000003 // PA3
#define UART0_BASE 0x4000C000
#define UART1_BASE 0x4000D000
#define GPIO_A_BASE 0x400D9000 // GPIO A
#define GPIO_B_BASE 0x400DA000 // GPIO B
#define GPIO_C_BASE 0x400DB000 // GPIO C
#define GPIO_D_BASE 0x400DC000 // GPIO D
#define GPIO_O_DIR 0x00000400
#define GPIO_O_AFSEL 0x00000420
#define GPIO_PIN(x) (1UL << x) // Arbitrary GPIO pin
#define GPIO_PIN_0 0x00000001 // GPIO pin 0
#define GPIO_PIN_1 0x00000002 // GPIO pin 1
#define GPIO_PIN_2 0x00000004 // GPIO pin 2
#define GPIO_PIN_3 0x00000008 // GPIO pin 3
#define GPIO_PIN_4 0x00000010 // GPIO pin 4
#define GPIO_PIN_5 0x00000020 // GPIO pin 5
#define GPIO_PIN_6 0x00000040 // GPIO pin 6
#define GPIO_PIN_7 0x00000080 // GPIO pin 7
#define UART_O_DR 0x00000000 // UART data
#define UART_O_FR 0x00000018 // UART flag
#define UART_O_IBRD 0x00000024
#define UART_O_FBRD 0x00000028
#define UART_O_LCRH 0x0000002C
#define UART_O_CTL 0x00000030 // UART control
#define UART_O_IM 0x00000038 // UART interrupt mask
#define UART_O_MIS 0x00000040 // UART masked interrupt status
#define UART_O_ICR 0x00000044 // UART interrupt clear
#define UART_O_CC 0x00000FC8 // UART clock configuration
#define UART_FR_RXFE 0x00000010 // UART receive FIFO empty
#define UART_FR_TXFF 0x00000020 // UART transmit FIFO full
#define UART_FR_RXFF 0x00000040 // UART receive FIFO full
#define UART_CONFIG_WLEN_8 0x00000060 // 8 bit data
#define UART_CONFIG_STOP_ONE 0x00000000 // One stop bit
#define UART_CONFIG_PAR_NONE 0x00000000 // No parity
#define UART_CTL_UARTEN 0x00000001 // UART enable
#define UART_CTL_TXE 0x00000100 // UART transmit enable
#define UART_CTL_RXE 0x00000200 // UART receive enable
#define UART_IM_RXIM 0x00000010 // UART receive interrupt mask
#define UART_IM_RTIM 0x00000040 // UART receive time-out interrupt
#define SOC_ADC_ADCCON1 0x400D7000 // ADC Control
#define SOC_ADC_RNDL 0x400D7014 // RNG low data
#define SOC_ADC_RNDH 0x400D7018 // RNG high data
#define SOC_ADC_ADCCON1_RCTRL0 0x00000004 // ADCCON1 RCTRL bit 0
#define SOC_ADC_ADCCON1_RCTRL1 0x00000008 // ADCCON1 RCTRL bit 1
#define FLASH_CTRL_FCTL 0x400D3008 // Flash control
#define FLASH_CTRL_DIECFG0 0x400D3014 // Flash information
// clang-format on
#endif
-138
View File
@@ -1,138 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* GCC linker script for CC2538.
*/
_512k_bytes = (512*1024);
_256k_bytes = (256*1024);
_128k_bytes = (128*1024);
_FLASH_page_size = 2048;
/*
* Change for your chip, default is 512k chips
*/
_FLASH_size_bytes = _512k_bytes;
_FLASH_n_pages = (_FLASH_size_bytes / _FLASH_page_size);
/* reduce the usable size by: the CCA + settings Page A & B, total 3 pages */
_FLASH_usable_size = (_FLASH_size_bytes - (3 * _FLASH_page_size));
_FLASH_start = 0x00200000;
_FLASH_end = (_FLASH_start + _FLASH_size_bytes);
/*
* The CCA (Customer Configuration Area) is always the last page.
* See: http://www.ti.com/lit/ug/swru319c/swru319c.pdf
* table 8-2 for more details.
*/
_FLASH_cca_page = (_FLASH_end - (1 * _FLASH_page_size));
/*
* OpenThread NV storage goes in the settings page.
* OpenThread requires at least 2 adjacent pages, call them A and B.
*/
_FLASH_settings_pageB = (_FLASH_end - (2 * _FLASH_page_size));
_FLASH_settings_pageA = (_FLASH_end - (3 * _FLASH_page_size));
MEMORY
{
/* would like to use SYMBOLS (from above)here but we cannot
* GCC version 4.9 does not support symbolic expressions here.
* But later versions do support the feature.
*/
FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 0x0007c000
FLASH_CCA (rx) : ORIGIN = 0x0027FFD4, LENGTH = 0x2c
SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
}
/*
* To safty check what would have been the SYMBOL values
* we use these ASSERTS to verify things are still good.
*/
ASSERT( _FLASH_start == 0x00200000, "invalid flash start address for cc2538")
ASSERT( _FLASH_cca_page == 0x0027f800, "invalid cca start address for cc2538")
ASSERT( _FLASH_usable_size == 0x0007e800, "Invalid usable size for this config")
ENTRY(flash_cca_lock_page)
SECTIONS
{
.text : ALIGN(4)
{
_text = .;
*(.vectors)
*(.text*)
*(.rodata*)
KEEP(*(.init))
KEEP(*(.fini))
_etext = .;
} > FLASH= 0
.init_array :
{
_init_array = .;
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array*))
_einit_array = .;
} > FLASH
.ARM.exidx : ALIGN(4)
{
*(.ARM.exidx*)
} > FLASH
.data : ALIGN(4)
{
_data = .;
*(.data*)
_edata = .;
} > SRAM AT > FLASH
_ldata = LOADADDR(.data);
.bss : ALIGN(4)
{
_bss = .;
*(.bss*)
*(COMMON)
_ebss = .;
} > SRAM
_heap = .;
end = .;
.stack : ALIGN(4)
{
*(.stack)
} > SRAM
.flashcca :
{
KEEP(*(.flash_cca))
} > FLASH_CCA
}
-80
View File
@@ -1,80 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/radio.h>
#include "platform-cc2538.h"
#if OPENTHREAD_CONFIG_DIAG_ENABLE
/**
* Diagnostics mode variables.
*
*/
static bool sDiagMode = false;
void otPlatDiagModeSet(bool aMode)
{
sDiagMode = aMode;
}
bool otPlatDiagModeGet()
{
return sDiagMode;
}
void otPlatDiagChannelSet(uint8_t aChannel)
{
OT_UNUSED_VARIABLE(aChannel);
}
void otPlatDiagTxPowerSet(int8_t aTxPower)
{
OT_UNUSED_VARIABLE(aTxPower);
}
void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
OT_UNUSED_VARIABLE(aInstance);
OT_UNUSED_VARIABLE(aFrame);
OT_UNUSED_VARIABLE(aError);
}
void otPlatDiagAlarmCallback(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
-112
View File
@@ -1,112 +0,0 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements an entropy source based on ADC.
*
*/
#include <openthread/platform/entropy.h>
#include <openthread/platform/radio.h>
#include "platform-cc2538.h"
#include "utils/code_utils.h"
static void generateRandom(uint8_t *aOutput, uint16_t aOutputLength)
{
uint32_t frmctrl0;
HWREG(SOC_ADC_ADCCON1) &= ~(SOC_ADC_ADCCON1_RCTRL1 | SOC_ADC_ADCCON1_RCTRL0);
HWREG(SYS_CTRL_RCGCRFC) = SYS_CTRL_RCGCRFC_RFC0;
while (HWREG(SYS_CTRL_RCGCRFC) != SYS_CTRL_RCGCRFC_RFC0)
;
frmctrl0 = HWREG(RFCORE_XREG_FRMCTRL0);
HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_INFINITY_RX;
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
while (!HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID)
;
for (uint16_t index = 0; index < aOutputLength; index++)
{
aOutput[index] = 0;
for (uint8_t offset = 0; offset < 8 * sizeof(uint8_t); offset++)
{
aOutput[index] <<= 1;
aOutput[index] |= (HWREG(RFCORE_XREG_RFRND) & RFCORE_XREG_RFRND_IRND);
}
}
HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RFOFF;
HWREG(RFCORE_XREG_FRMCTRL0) = frmctrl0;
}
void cc2538RandomInit(void)
{
uint16_t seed = 0;
while (seed == 0x0000 || seed == 0x8003)
{
generateRandom((uint8_t *)&seed, sizeof(seed));
}
HWREG(SOC_ADC_RNDL) = (seed >> 8) & 0xff;
HWREG(SOC_ADC_RNDL) = seed & 0xff;
}
otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
{
otError error = OT_ERROR_NONE;
uint8_t channel = 0;
otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
if (sInstance && otPlatRadioIsEnabled(sInstance))
{
channel = 11 + (HWREG(RFCORE_XREG_FREQCTRL) - 11) / 5;
otPlatRadioSleep(sInstance);
otPlatRadioDisable(sInstance);
}
generateRandom(aOutput, aOutputLength);
if (channel)
{
cc2538RadioInit();
otPlatRadioEnable(sInstance);
otPlatRadioReceive(sInstance, channel);
}
exit:
return error;
}
-101
View File
@@ -1,101 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "platform-cc2538.h"
#include "rom-utility.h"
#define FLASH_CTRL_FCTL_BUSY 0x00000080
#define FLASH_PAGE_SIZE 2048
#define FLASH_PAGE_NUM 2
#define FLASH_SWAP_SIZE (FLASH_PAGE_SIZE * (FLASH_PAGE_NUM / 2))
/* The linker script creates this external symbol */
extern uint8_t _FLASH_settings_pageA[];
/* Convert a settings offset to the physical address within the flash settings pages */
static uint32_t flashPhysAddr(uint8_t aSwapIndex, uint32_t aOffset)
{
uint32_t address = (uint32_t)(&_FLASH_settings_pageA[0]) + aOffset;
if (aSwapIndex)
{
address += FLASH_SWAP_SIZE;
}
return address;
}
void otPlatFlashInit(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
}
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
return FLASH_SWAP_SIZE;
}
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
{
OT_UNUSED_VARIABLE(aInstance);
ROM_PageErase(flashPhysAddr(aSwapIndex, 0), FLASH_PAGE_SIZE);
while (HWREG(FLASH_CTRL_FCTL) & FLASH_CTRL_FCTL_BUSY)
{
}
}
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
uint32_t *data = (uint32_t *)(aData);
for (uint32_t size = 0; size < aSize; size += sizeof(uint32_t), aOffset += sizeof(uint32_t), data++)
{
ROM_ProgramFlash(data, flashPhysAddr(aSwapIndex, aOffset), sizeof(uint32_t));
while (HWREG(FLASH_CTRL_FCTL) & FLASH_CTRL_FCTL_BUSY)
{
}
}
}
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, uint8_t *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
memcpy(aData, (void *)flashPhysAddr(aSwapIndex, aOffset), aSize);
}
-47
View File
@@ -1,47 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file logging.c
* Platform abstraction for the logging
*
*/
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/logging.h>
#include <openthread/platform/toolchain.h>
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
OT_UNUSED_VARIABLE(aFormat);
}
#endif
-49
View File
@@ -1,49 +0,0 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <openthread/platform/misc.h>
#include "platform-cc2538.h"
void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
HWREG(SYS_CTRL_PWRDBG) = SYS_CTRL_PWRDBG_FORCE_WARM_RESET;
}
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
// TODO: Write me!
return OT_PLAT_RESET_REASON_POWER_ON;
}
void otPlatWakeHost(void)
{
// TODO: implement an operation to wake the host from sleep state.
}

Some files were not shown because too many files have changed in this diff Show More