Commit Graph

8875 Commits

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