Commit Graph

47 Commits

Author SHA1 Message Date
Jonathan Hui 136bdb6e2a [dua] remove OPENTHREAD_CONFIG_DUA_ENABLE build feature (#13165)
This commit completely removes the local Domain Unicast Address (DUA)
registration feature flag (OPENTHREAD_CONFIG_DUA_ENABLE) and all of
its associated implementation, public APIs, CLI commands, Spinel
property handlers, and certification tests.

Thread 1.2 FTD Border Router/Router DUA proxying features for MTD
children (OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE) are preserved and
updated to only compile/instantiate components when proxy DUA
features are active.

Detailed Changes:
- Remove default definition of OPENTHREAD_CONFIG_DUA_ENABLE from
  misc.h.
- Remove OT_DUA and openthread_config_dua_enable from CMake/GN
  configs.
- Remove otThreadSetFixedDuaInterfaceIdentifier and
  otThreadGetFixedDuaInterfaceIdentifier from
  include/openthread/thread.h
  and implementation src/core/api/thread_api.cpp.
- Remove CLI DUA interpreter from src/cli/cli.cpp.
- Remove SPINEL_CAP_DUA capability and SPINEL_PROP_THREAD_DUA_ID
  Spinel property handlers and dispatchers from NCP.
- Strip local DUA management features (conflict checking, SLAAC DUA
  interface identifiers, and dad info settings) from DuaManager, MLE,
  Address Resolver, and settings.
- Clean up Notifier, TimeTicker, and TMF dispatcher guards.
- Clean up -DOT_DUA=ON compilation flags across build/test scripts.
- Delete obsolete DUA certification tests:
  - v1_2_test_domain_unicast_address
  - v1_2_test_domain_unicast_address_registration
  - v1_2_test_dua_handle_address_error
2026-06-01 15:16:19 -07:00
Abtin Keshavarzian 2a2d4be953 [ip6] rename methods fully initializing an Ip6::Address/Prefix (#13169)
This commit renames several methods in `Ip6::Address`,
`Ip6::InterfaceIdentifier`, `Ip6::Prefix`, and `Ip4::Address` that
fully initialize the object from `Set...()` to `Init...()`.

This creates a clear semantic distinction in the API:
- `Init...()`: Fully (re-)initializing the object.
- `Set...()`: Modifies a specific property or a sub-component of
   the object (e.g., `SetPrefix()`,  `SetLocator()`,
   `SetSubnetId()`).

Some examples of renames include:
- `SetFromExtAddress()` -> `InitFromExtAddress()`
- `SetToLocator()` -> `InitAsLocator()`
- `SetToLinkLocalAddress()` -> `InitAsLinkLocalAddress()`
- `SetToRoutingLocator()` -> `InitAsRoutingLocator()`
- `SetToAnycastLocator()` -> `InitAsAnycastLocator()`
- `SetToIp4Mapped()` -> `InitAsIp4Mapped()`

All calls to these methods across the codebase have been updated
to reflect the new names.
2026-05-28 20:52:05 -07:00
Abtin Keshavarzian 3ce616d835 [netdiag] rename namespace NetworkDiagnostic to NetDiag (#13154)
This commit renames the `NetworkDiagnostic` namespace in `src/core/thread/`
and its related types to `NetDiag` for brevity. It updates the
corresponding filenames and header guards as well.
2026-05-26 20:19:48 -07:00
Jonathan Hui 5265a0bf48 [bbr] remove Backbone Router DUA ND Proxying feature (#13136)
This commit removes all code, configurations, APIs, and tests related
to the OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE feature.

Specifically, the following changes were made:
- Removed DUA ND Proxying Backbone Router configuration option and the
  related OPENTHREAD_CONFIG_NDPROXY_TABLE_ENTRY_NUM definition.
- Removed CLI commands: `bbr mgmt dua` and the proactive backbone
  notification fake command `/b/ba`.
- Removed NdProxyTable and bbr_manager DUA ND Proxying implementation.
- Removed public/internal APIs for ND Proxying and proactive backbone
  notifications.
- Deleted ndproxy_table source files and unit tests.
- Simplified CMake and GN build files to remove deleted targets.
2026-05-23 07:57:57 -07:00
Jonathan Hui 36b398ef61 [tmf] enforce link security for all TMF messages (#13048)
This commit updates Tmf::Agent::Filter to require link-layer security
for all incoming TMF requests.

Thread Management Framework (TMF) messages are used for network
management and configuration. The Thread specification requires that
all TMF messages be secured. While individual handlers often have
specific checks, enforcing this at the TMF Agent level provides a
consistent security layer for all TMF traffic.

For most TMF messages, security is provided by the Network Key. For
commissioning-related messages (like Joiner Entrust), security is
provided by the Key Encryption Key (KEK). In all cases, a valid TMF
message must have link-layer security enabled.

This change prevents unauthenticated attackers from sending unsecured
TMF messages to manipulate network state or configuration.
2026-05-05 15:22:45 -07:00
Abtin Keshavarzian 3559cbd55a [tmf] validate method as POST centrally in resource handlers (#12661)
This commit updates the central CoAP resource handlers in TMF agents
(`Agent::HandleResource`, `BackboneTmfAgent::HandleResource`, and
`Manager::CoapDtlsSession::HandleResource`) to verify that the
incoming request method is a POST request. If the URI is recognized
but the method is not POST, a `kCodeMethodNotAllowed` response is
now sent.

Since all TMF requests are now guaranteed to be POST requests before
reaching their specific handlers, the `IsPostRequest()` checks in
individual handlers are removed. Additionally, the
`IsConfirmablePostRequest()` and `IsNonConfirmablePostRequest()`
helper methods in `Coap::Message` are removed and their usages are
simplified to `IsConfirmable()` and `IsNonConfirmable()` in the
respective handlers.
2026-03-10 22:07:43 -05:00
Abtin Keshavarzian 75c554e9b1 [meshcop] integrate commissioner client classes (#12618)
This commit removes the standalone `AnnounceBeginClient`,
`EnergyScanClient`, and `PanIdQueryClient` classes, integrating their
methods and TMF message handlers directly into the
`MeshCoP::Commissioner` class.

Since these client classes contained minimal state and primarily
served as simple wrappers for sending specific requests and handling
callbacks, merging them into the main `Commissioner` class simplifies
the architecture, removes unnecessary auxiliary classes, and shrinks
the overall codebase size.
2026-03-05 10:37:35 -06:00
Abtin Keshavarzian f03cecdff6 [tmf] introduce specialized SendMessageTo() methods in Tmf::Agent (#12548)
This commit introduces new helper methods in the `Tmf::Agent` class
(`SendMessageTo()`, `SendMessageToRloc()`, `SendMessageToLeaderAloc()`,
and `SendMessageAllowMulticastLoop()`) to simplify the transmission of
TMF messages.

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

By incorporating these address resolution and message info preparation
steps directly into `Tmf::Agent`, this change significantly reduces
boilerplate code. All existing calls to `SendMessage()` have been
updated to use the new flavors.
2026-02-26 15:26:45 -06:00
Abtin Keshavarzian b0f6a855e0 [ip6] expose static multicast address getters and remove wrapper methods (#12416)
This commit updates `Ip6::Address` to expose `static` getter methods for
common multicast addresses (e.g., `GetLinkLocalAllNodesMulticast()`)
as public API.

Consequentially, the wrapper `SetTo...` and `Is...` methods for these
multicast addresses are removed. Callers are updated to use the
`static` getters directly. This change simplifies usage by allowing
direct access to the constant address instances, often eliminating
the need for local `Ip6::Address` variables.
2026-02-12 09:00:26 -06:00
Abtin Keshavarzian 66c7272eef [border-agent] implement Border Admitter (#12201)
This commit introduces the Border Agent Admitter feature , which
enhances Thread MeshCoP.

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

The implementation includes three main components:

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

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

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

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

This commit also introduces a suite of comprehensive tests for the
Border Admitter functionality under the `nexus` test framework. It
covers various scenarios including:
- Prime Admitter election and role management
- Enroller registration, keep-alive, and timeout interactions
- Handling of commissioner conflicts and petitioner retry mechanisms
- Support for multiple enroller sessions and combined steering data
- Forwarding of Joiner `RelayRx` and `UdpProxy` messages
- Joiner acceptance, release, and expiration tracking
2026-02-09 14:31:34 -08:00
Abtin Keshavarzian 558aea761f [coap] update Interceptor to use Msg (#12331)
This commit updates the `CoapBase::Interceptor` function pointer type
to accept `const Msg &` instead of separate `const Message &` and
`const Ip6::MessageInfo &` arguments. It also reorders the `void *`
to match other CoAP callbacks.

Implementations in `BackboneTmfAgent::Filter` and `Agent::Filter`
have been updated to match the new signature.
2026-01-26 10:33:00 -08:00
Abtin Keshavarzian 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
Abtin Keshavarzian 0c592029ba [history-tracker] add client/server for remote query (#11757)
This commit introduces a client/server mechanism to the History
Tracker module. This allows a device to query history information
from another device over the Thread network using TMF messages.

The new functionality is composed of three main parts:

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

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

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

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

The new feature can be enabled/disabled using two new configuration
flags:
- `OPENTHREAD_CONFIG_HISTORY_TRACKER_SERVER_ENABLE`
- `OPENTHREAD_CONFIG_HISTORY_TRACKER_CLIENT_ENABLE`
2025-12-09 10:34:06 -08:00
Esko Dijk e4479fb6b1 [tcat] add TCAT_ENABLE.req TMF command (#12013)
This adds support for the TMF command to enable TCAT remotely.  A test
is added that uses the 'UDP send' mechanism to send the new TMF
command to a target node.

Some fixes/additions to the test framework are made to support the new
test, including a new argument for udp_send() to send a specific byte
array and udp_rx() to receive data by a UDP client on a node.
2025-10-29 08:29:09 -07:00
Abtin Keshavarzian af6279f606 [border-agent] introduce BorderAgent namespace (#12002)
This change reorganizes the `BorderAgent` related classes into a new
`MeshCoP::BorderAgent` namespace to improve code structure and clarity.

The following changes are included:

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

All related calls and test files are updated to reflect these
changes.
2025-10-08 12:47:30 -07:00
Abtin Keshavarzian 0c1dfa0796 [mle] refactor MleRouter and Mle classes into a single Mle class (#11411)
This commit refactors the `Mle` modules and combines the `MleRouter`
and `Mle` classes into a single `Mle` class which now handles both
FTD and MTD functionalities.

The `MleRouter` and `Mle` classes were originally intended as
sub-classes, where the base class `Mle` would provide MTD and common
behaviors, and `MleRouter` would implement FTD-specific behaviors.
However, over the years and as new features were implemented, these
two classes became more intertwined, and the `Mle` class began to
include many FTD-related functions and interactions with `MleRouter`
private variables and methods.

This commit simplifies the code by combining the two into a single
class. The previous `mle_router.cpp` file is also renamed to
`mle_ftd.cpp` to indicate that it implements FTD-specific MLE
behaviors.
2025-04-18 14:28:47 -07:00
Abtin Keshavarzian 2ae1ce5293 [secure-transport] support multiple sessions on the same transport (#11092)
This commit updates `SecureTransport` to support multiple
`SecureSession`s on the same transport. The transport tracks a list
of sessions that it owns and manages. Two new callbacks are
introduced:

- `AcceptCallback`: Used to accept a new connection request, providing
  the `SecureSession` instance to use (passing ownership of the
  session to the transport).
- `RemoveSessionCallback`: Signals that a session is removed,
  releasing ownership of the session.

`BorderAgent`, `Tmf::SecureAgent`, and `ApplicationCoapSecure` are
updated to adopt the new model.

This commit also updates the Nexus `test_dtls`, adding
`TestDtlsMultiSession` to validate multiple session support
behavior.
2025-01-08 13:43:05 -08:00
Abtin Keshavarzian 1024a1fdb9 [border-agent] use separate DTLS transport and CoAP secure session (#11085)
This commit updates `BorderAgent` to utilize its own DTLS `Transport`
and CoAP `SecureSession`, separating it from the shared
`Tmf::SecureAgent` used by `Commissioner` and `Joiner` modules. This
change enables future support for multiple sessions within
`BorderAgent`.
2024-12-27 16:53:29 -08:00
Abtin Keshavarzian 2e39577111 [coaps] introduce Coap::SecureSession along with Dtls::Transport (#11056)
This commit introduces the `Dtls::Transport` and `Dtls::Session`
classes, separating session-related functions from transport-related
behaviors. It also introduces the `Coap::SecureSession` class, which
handles CoAP processing over a DTLS session. This simplifies the code
by allowing `Coap::SecureSession` to inherit many of its methods from
`Dtls::Session`, avoiding repetition. It also separates CoAP-specific
message processing from transport-related functionality.

`Tmf::SecureAgent` and `ApplicationCoapSecure` are updated to act as
both a `Dtls::Transport` and a single `Coap::SecureSession`.
2024-12-26 12:40:08 -08:00
Abtin Keshavarzian 53c02c6141 [secure-transport] introduce Extension class (#10978)
This commit updates `SecureTransport`. It introduces the `Extension`
class within `SecureTransport`, providing support for additional
cipher suites and related methods to configure the ciphers
(e.g., `SetPreSharedKey()`, `SetCertificate()`).

This class decouples this functionality from the common
`SecureTransport` object, allowing it to be added to any class.
Classes like `ApplicationCoapSecure` or `BleSecure` can inherit from
`Extension` to provide these methods. An `Extension` is then
associated with a `SecureTransport` (or any of its subclasses). This
approach ensures that only instances requiring extended cipher suite
support incur the associated memory cost and avoid repeated code.

This commit also introduces `Dtls`, `DtlsExtended`, and `Tls` as
subclasses of `SecureTransport` for easier use by other modules.
2024-12-04 10:19:58 -08:00
Abtin Keshavarzian 473af53155 [udp] add kNetifThreadInternal which disallows platform UDP use (#10965)
This commit introduces `kNetifThreadInternal` as a network interface
option for UDP sockets. Unlike other options, this disallows the use
of platform UDP for the socket, indicating that the socket should use
the OpenThread internal Thread network interface only.

This model replaces the previous approach where `ShouldUsePlatformUdp()`
would check the socket port against a set of port numbers used by
different modules (such as MLE, TMF, Joiner Router, etc) to determine
whether platform UDP APIs should be used. With the new model, each
module decides whether to associate its socket with the
`kNetifThreadInternal`.

This is a more flexible and extensible model, ensuring that sockets
that should not use the platform do not waste resources (they will
not be created or opened/closed on the platform). This also help
avoid edge cases where platform UDP operations may unintentionally
fail when the platform socket is not actually needed.
2024-11-28 08:58:19 -08:00
Abtin Keshavarzian a7e058f56c [coap] add base class CoapSecureBase and ApplicationCoapSecure (#10945)
This commit refactors COAPS classes, renaming the `CoapSecure` class
as `CoapSecureBase`, which is the base class of `Tmf::SecureAgent`
and a newly added `ApplicationCoapSecure` class. This change
simplifies the code and class hierarchy and ensures that the
Application COAP secure related functions are only provided by
`ApplicationCoapSecure` and when the corresponding config feature
`OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE` is enabled.
2024-11-20 10:20:47 -08:00
Abtin Keshavarzian e43120d903 [coaps] use LinkSecurityMode to determine layer two security usage (#10899)
This commit updates the `CoapSecure`, `Tmf`, and `SecureTransport`
modules to use the `LinkSecurityMode` enum and its defined constants
to indicate whether or not layer two security should be used. This
replaces the use of boolean input parameters with `kWithLinkSecurity`
or `kNoLinkSecurity` constants, improving code readability.
2024-11-06 09:16:02 +01:00
Abtin Keshavarzian 9f6921cf04 [core] optimize #include directives in core cpp files (#10717)
This commit removes unnecessary `#include` directives in core `cpp`
files that already include `instance.hpp`. The `instance.hpp` header
itself includes all necessary OT core headers and definitions as they
are contained within an `ot::Instance`.
2024-09-18 12:03:54 -07:00
Abtin Keshavarzian 5ff30d7cef [core] move locator Get<Type> definitions to instance.hpp (#10711)
This commit moves the locator `GetProvider::Get<Type>()` and its
related `Timer` and `Tasklet` methods to `instance.hpp`. With this
change we can remove `locator_getters.hpp` header fully thus
simplifying the code.
2024-09-16 10:10:51 -07:00
Rongli Sun f9349c1486 [border-agent] not forward MGMT_GET/SET commands directly to leader (#10652)
This commit doesn't forward the MGMT*GET/SET commands directly to leader
any more, and enforces the use of UDP Proxy for Thread Management
Commands.
2024-08-29 14:13:39 -07:00
Abtin Keshavarzian e581f07414 [ip6] add Ip6::Address::IsLinkLocalUnicastOrMulticast() (#10405)
This commit adds `IsLinkLocalUnicastOrMulticast()` to `Ip6::Address`
to indicate whether the address is either a link-local unicast or a
link-local multicast address.

The existing `IsLinkLocal()` is renamed to `IsLinkLocalUnicast()` to
clarify its purpose and align its name with `IsLinkLocalMulticast()`
and the new method.
2024-06-19 16:53:29 -07:00
Abtin Keshavarzian 5127e7e5c0 [mle] enhance RLOC and ALOC address generation (#10391)
This commit enhances the generation of RLOC and ALOC addresses in the
`Mle` class.

Methods retrieving RLOC/ALOC addresses no longer return an `Error` and
are now `void`. The previous check for a valid `GetRloc16()` value,
which returned `kErrorDetach` if unset, is removed because this
scenario only occurred before the device's initial attachment.
Post-attachment, the RLOC16 remains valid even if the device is
detached. This change simplifies the code since RLOC/ALOC address
retrieval happens after the initial attachment.

Additional enhancements include:

-   Changing the input parameter order in `GetCommissionerAloc()` to
    match `GetServiceAloc()`.
-   Using `Ip6::Address::SetToRoutingLocator()` to construct RLOC
    addresses, harmonizing address generation and improving code
    readability.
2024-06-17 09:23:43 -07:00
Abtin Keshavarzian 3315c44bb3 [mle] rename mesh local address methods to use Rloc and Eid (#10385)
This commit renames the methods for retrieving mesh local addresses to
`GetMeshLocalRloc()` and `GetMeshLocalEid()` (from `GetMeshLocal16()`
and `GetMeshLocal64()`, respectively) to align with the terminology
used in the Thread specification. Member and local variables are also
renamed accordingly.
2024-06-14 10:06:25 -07:00
Abtin Keshavarzian f12785def6 [dataset] add support for handling MGMT_ACTIVE_REPLACE on leader (#10201) 2024-05-13 09:57:19 -07:00
Przemysław Bida 5cab15840d [tcat] initial commit of bluetooth-based commissioning (#9210)
This commit introduces first implementation of Bluetooth based
comissioning for thread devices.

Co-authored-by: Arnulf Rupp <a.rupp@inventronicsglobal.com>
Co-authored-by: Piotr Jasinski <piotr.jasinski@nordicsemi.no>
2023-12-04 12:09:25 -08:00
Abtin Keshavarzian 0f94f26a20 [net-diag] introduce Server and Client classes (#8936)
This commit introduces `Server` and `Client` classes breaking the
`NetworkDiagnostic` module into two components. The `Server` responds
to queries and requests (handling Net Diag TMF commands), while
`Client` issues queries/requests and processes responses. The
`Server` is available under both FTD and MTD (which follows the
requirement of Thread spec). The client is enabled using newly added
`OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE` config option which is
also available as `OT_NETDIAG_CLIENT` CMake option or the autoconf
build switch `NETDIAG_CLIENT`. The client functionality is by default
enabled on Border Routers (tied to `CONFIG_BORDER_ROUTING_ENABLE`
config).

The previous `TMF_NETWORK_DIAG_MTD_ENABLE` config is now removed
along with its CMake `OT_MTD_NETDIAG` and autoconf switch. This
commit adds checks to trigger build error if the previous config
and/or its related CMake option are used.
2023-04-07 15:58:07 -07:00
Abtin Keshavarzian d9ea37a3bb [tmf] add local IPv6 DSCP values to indicate TMF message priority (#7869)
This commit adds new IPv6 header DSCP values which indicate a TMF
message priority. This allows intermediate routers forwarding TMF
message to be able to determine and use the TMF message priority that
originator of the message selects (e.g., address query/notification
use net-level priority whereas network diagnostics message use normal
priority). This replaces the previous behavior where on intermediate
routers all TMF messages were treated as net-level priority.

The new DSCP values are allocated from local codepoint range
`0bxxxx11` (per RFC 2474 - section 6). If the sender does not use
TMF-specific DSCP values, we use `kPriorityNet` as default on
intermediate router. This ensures that senders that are using older
code (do not use the new) experience the same behavior as before.
2023-04-07 12:23:01 -07:00
Abtin Keshavarzian 61d13e291f [tmf] allow pan-id query on MTD (#8919) 2023-04-03 10:44:43 -07:00
Abtin Keshavarzian 99a615bec2 [clang-format] use AllowShortFunctionsOnASingleLine: All (#8502)
This commit updates `AllowShortFunctionsOnASingleLine` to `All`
from `InlineOnly`.
2022-12-08 09:34:05 -08:00
Jonathan Hui 9c467a23ae [clang-format] apply v14 changes (#8490) 2022-12-07 16:23:20 -08:00
Abtin Keshavarzian 13311256f6 [tmf] add SecureAgent and simplify URI resource processing (#8260)
This commit adds a new class `Tmf::SecureAgent` as a sub-class of
`Coap::CoapSecure`. It also simplifies the handling of TMF URI
resources by secure agent (similar model as in `Tmf::Agent` added
in #8233.
2022-10-10 12:40:26 -07:00
Abtin Keshavarzian 812c36f658 [tmf] new model for handling TMF URI resources (#8233)
This commit updates and simplifies the handling of TMF URI resources.
The new model centralizes the processing and dispatching of URI
handlers in `Tmf::Agent`. It should help reduce memory (RAM and
code) use as well.

- A new enumeration `Uri` type is defined specifying all the TMF
  URIs along with functions to map between `Uri` and the related
  URI path string.
- We use binary search in a sorted table to match a path string
  (e.g., from a received CoAP message) to its corresponding URI.
- `Coap` class is updated to allow sub-classes to register an
   optional `ResourceHandler` to handle URI resources.
- `Tmf::Agent` uses the new `ResourceHandler` to process the TMF URI
  resources and invoke the related handlers on the proper module
  (e.g., passing `kUriAddressQuery` to `AddressResolver` module,
  `kUriActiveSet` to `MeshCoP::ActiveDatasetManager`, etc).
- The TMF handlers are defined as `HandleTmf<Uri>()` template method
  specializations which are defined on the proper module.
- Most URI handlers can be processed at any time but some perform
  additional checks, e.g., `kUriAddressSolicit` is passed to
  `Mle::MleRouter` which checks that device role is leader before
  processing the request.
2022-10-06 18:32:22 -07:00
Abtin Keshavarzian bd8513b904 [ip6] define Ip6::NetifIdentifier mirroring otNetifIdentifier (#8219) 2022-09-30 08:36:48 -07:00
Abtin Keshavarzian 158e59f267 [tmf] update IsTmfMessage() method (#7875)
This commit updates `Tmf::IsTmfMessage()` method to check source and
destination addresses. This change helps make this method more
generic(allow it to be used for both rx/tx messages). This commit
also simplifies the implementation (avoid using complex expression
containing multiple `&&` and `||`).
2022-07-12 10:15:34 -07:00
Abtin Keshavarzian cc003b3a42 [coap] add new helper to allocate and init CoAP message (#7631)
This commit adds new helper methods in `Coap` to allocate a new
message and initialize it as a confirmable or non-confirmable post to
a given URI path. It also adds a new helper method to allocate a CoAP
response message for a given request. These methods help simplify the
preparation of CoAP and TMF messages.
2022-05-06 10:27:55 -07:00
Abtin Keshavarzian ba5ebc7296 [tmf] add Tmf::MessageInfo (#7589)
This commit adds `Tmf::MessageInfo` which is a sub-class of the
`Ip6::MessageInfo` class intended for use when sending TMF messages.
The peer port number is by default set to the TMF port from the
constructor. This class also provides helper methods for commonly
used patterns, e.g., source or `SockAddr` set to device's RLOC
address and/or the destination or `PeerAddr` set to leader ALOC or
RLOC, or a given address.
2022-04-14 09:26:43 -07:00
Abtin Keshavarzian 524da6d2c4 [tmf] rename TMF agent class to Tmf::Agent (#6502)
This commit renames the TMF agent class from `Tmf::TmfAgent` to
`Tmf::Agent` (to follow style used by other modules).
2021-04-23 07:50:38 -07:00
Abtin Keshavarzian f7802d60a1 [style] rename header file to locator_getters.hpp (#6422)
This commit renames the `Locator` header file to follow the same style
used by other core modules (i.e., use underscore between words in a
file name).
2021-04-10 10:16:01 -07:00
Abtin Keshavarzian 7dca56e982 [error] add 'ot::Error' and 'kError{Name}' for use by core modules (#6237)
This commit adds a new core header files `common/error.hpp` which
defines `ot::Error` (mirroring `otError`) and `kError{Name}` constants
(mirroring the public `OT_ERROR_{NAME}` definitions). The new (C++
style) definitions are used by core modules. This commit also moves
`otThreadErrorToString()` (from `logging.hpp` to `error.hpp`) and
renames it to `ErrorToString()` which is used as the internal (to
core) function to covert an `Error` to a string.
2021-03-15 21:07:07 -07:00
Simon Lin d783c7abc8 [tmf] add Backbone TMF agent (#5471) 2020-09-11 10:11:42 -07:00
Yakun Xu 5e233fb617 [posix] allow bind to Thread interface only (#4965) 2020-08-28 18:52:31 -07:00