Commit Graph

9138 Commits

Author SHA1 Message Date
Ł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