8589 Commits

Author SHA1 Message Date
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
90a84f6ee8 [posix] remove libanl (#11482) 2025-05-08 13:24:22 -07:00
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
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
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
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
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
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](c6295a65d1...0634a2670c)

---
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
4be7e8baa2 [tests] allow service bind9 stop to fail (#11438) 2025-04-23 10:05:30 -07:00
ffb8e4d7c8 [docs] use NULL in place of nullptr (#11435) 2025-04-23 08:19:27 -07:00
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
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
16bafadb59 [rcp] change default baud rate to 460800 (#11432) 2025-04-22 13:27:55 -07:00
08a8767fcd [posix] move SocketWithCloseExec() helper to common utils.hpp (#11427) 2025-04-22 07:43:07 -07:00
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
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
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
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](41dfa10bad...0aaccfd150)

---
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
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
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
b25d1af5f5 [posix] enhance otPlatAlarm implementation (#11424)
This commit enhances the posix `otPlatAlarm` implementation by:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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