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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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()`.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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).
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>
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.
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.
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.
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.
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.
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.