Compare commits

...

17 Commits

Author SHA1 Message Date
Jonathan Hui 318b4b0771 [bbr] remove domain prefix support from stack and harness (#13203)
This commit removes all Domain Prefix configuration and management logic
from the OpenThread stack, CLI commands, unit tests, and GRL harness
THCI wrapper.

- Removed public Backbone Router Domain Prefix APIs.
- Removed Domain Prefix flag ('mDp') and 'D' flag parser/formatter
  from core network data types, Spinel, and CLI.
- Cleaned up local Backbone Router and Leader logic to exclude Domain
  Prefix configuration, tracking, and events.
- Updated RoutingManager prefix advertisement (RIO) to exclude
  special handling for Domain Prefix.
- Updated CLI documentation to remove Domain Prefix references.
- Removed domain prefix helper methods from python test certification
  scripts.
- Removed auto-addition of default domain prefix and D flag support
  from GRL harness OpenThread.py.
2026-06-04 19:36:33 -07:00
Jonathan Hui c4a85578f5 [mle] validate peer extended address in Link Accept (#13207)
This commit ensures that the peer's extended address matches the stored
extended address when receiving a Link Accept for an already valid link,
preventing unintended frame counter resets and neighbor table updates.

To achieve this:
- We validate that the peer's extended address (extracted from the
  IPv6 peer address IID) matches the router's stored extended address
  when processing Link Accepts for a neighbor that is already in the
  kStateValid state. If there is a mismatch, the packet is rejected
  with kErrorSecurity.
- We gate InitNeighbor() and the resetting of MLE frame counters
  so they only execute if the neighbor is not already kStateValid.
  For valid neighbors, we only update link statistics (RSS, last
  heard, link quality, key sequence) and clear the Link Accept
  timeout without modifying the frame counters or average RSS history.
2026-06-04 13:33:07 -07:00
Abtin Keshavarzian b72d7144ee [cli] refactor IPv6 address parsing and synthesis helper (#13205)
This commit renames the static helper `Utils::ParseToIp6Address()` to
`Utils::ParseOrSynthesizeIp6Address()` to better reflect its behavior
of parsing an IPv6 address or synthesizing one from an IPv4 address
via NAT64.

Additionally, the method is refactored into a non-static member of the
`Utils` class. This eliminates the need to manually pass the `otInstance`
pointer, as the `Utils` class already maintains it. The internal
implementation is also simplified to reduce nesting by exiting early
upon successful IPv6 address parsing.

All callers in the CLI module (TCP, UDP, Ping, DNS) have been updated
to use the new member method.
2026-06-03 19:19:25 -07:00
Abtin Keshavarzian b2093f4f9e [dns] check for null character in read label (#13187)
This commit updates `Name::LabelIterator::ReadLabel()` to explicitly
check that the read label from the message does not contain any embedded
`kNullChar` (`\0`) characters. It uses `StringLength()` to verify that
the length of the string matches the expected label length. If a null
character is found before the end of the label, `kErrorParse` is
returned to prevent potential string truncation issues or
misinterpretation of the label name.

This broader check replaces a recent fix in `PtrRecord::ReadPtrName()`
from #13183 which only verified that the first label was not empty
or malformed by checking for a single-character label with a null
byte. By enforcing this validation centrally at the `ReadLabel()`
level, we now ensure that labels of any length are properly
protected against embedded null characters across all DNS record
types.
2026-06-03 14:55:20 -07:00
Abtin Keshavarzian 15e1c233bf [tests] simplify RLOC address creation using GetMeshLocalRloc() (#13198)
This commit refactors several Nexus diagnostic test cases to use the
existing `Mle::GetMeshLocalRloc()` method instead of manually assembling
the RLOC by combining the mesh-local prefix and the node's RLOC16. This
improves code readability and adheres to the standard pattern for
retrieving a node's Routing Locator.
2026-06-03 14:45:42 -07:00
Abtin Keshavarzian 3d7b9fb686 [mle] rename Get{Addr}() to Compose{Addr}() (#13197)
This commit renames several methods in the `Mle` class that construct
an IPv6 address from the mesh-local prefix and an RLOC16/ALOC16 from
`Get...()` to `Compose...()` to better reflect their behavior.

The affected methods are:
- `GetLeaderRloc()` -> `ComposeLeaderRloc()`
- `GetLeaderAloc()` -> `ComposeLeaderAloc()`
- `GetCommissionerAloc()` -> `ComposeCommissionerAloc()`
- `GetServiceAloc()` -> `ComposeServiceAloc()`
2026-06-03 14:42:43 -07:00
Abtin Keshavarzian ab3c6600a0 [icmp6] use Icmp6Header instead of Icmp::Header (#13194)
This commit updates the codebase to use the `Icmp6Header` type
directly, replacing the nested `Ip6::Icmp::Header` definition.
This change aligns the ICMPv6 header type definition with the
conventions used for other network protocol headers and simplifies
type references across the network, border router, and utility
modules.
2026-06-03 14:39:21 -07:00
Jonathan Hui ecd4c92465 [dua] completely remove DUA features and configurations (#13191)
This commit removes the OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE feature
and all associated code, tests, CLI commands, and harness references.

Changes:
- Removed OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE definition and all
  assert/preprocessor checks.
- Completely deleted dua_manager.cpp and dua_manager.hpp.
- Removed DUA registration notifying and request URI paths.
- Cleaned up all references to Domain Unicast Address (DUA) across
  child management, notifier, time ticker, and MLE.
- Removed DUA commands and logic from the CLI and Python cert tests
  (including packet verifier).
- Verified that the entire codebase compiles clean and all tests
  successfully pass using the Nexus test suite.
2026-06-03 12:29:18 -07:00
Jonathan Hui b69c905763 [nexus] fix and update 1_3_SRP_TC_1 integration test (#13200)
This commit updates the SRP registration and verification logic to pass
the 1_3_SRP_TC_1 test case in the Nexus simulator:

1. In test_1_3_SRP_TC_1.cpp, temporarily disable/enable the eth1 DNS-SD
   agent during SRV, AAAA, and browser resolver queries to force a
   clear of the local cache. This ensures the queries are sent over the
   wire to the Border Router (DUT) instead of being answered from the
   resolver's cache.
2. In verify_1_3_SRP_TC_1.py, add checks for mDNS query and response
   packets for Steps 9b, 9c, 15b, and 15c. Relax the Step 15c check to
   not require the ML-EID in the mDNS response, as advertising
   Mesh-Local addresses on the infrastructure link is optional and not
   done by the OpenThread SRP advertising proxy.
2026-06-03 10:55:54 -07:00
Abtin Keshavarzian c410733490 [tcp] add OPENTHREAD_CONFIG_TCP_ENABLE guards to headers (#13195)
This commit wraps the contents of `tcp6.hpp` and `tcp6_ext.hpp` with
`#if OPENTHREAD_CONFIG_TCP_ENABLE` feature guards to ensure that TCP
definitions and types are cleanly excluded when TCP support is disabled
in the build configuration. Additionally, it explicitly disables the
`OPENTHREAD_CONFIG_TCP_ENABLE` feature flag in the Toranj test
configuration to validate building without TCP support.
2026-06-03 08:29:35 -07:00
Jonathan Hui 1b238bffc0 [tests] remove test_trel_connectivity.py (#13196)
This commit removes the deprecated `test_trel_connectivity.py`
integration test. The TREL connectivity test functionality is
already fully covered by the Nexus simulation test suite, which
provides faster and more reliable testing.
2026-06-03 08:06:30 -07:00
Jonathan Hui c01cad7ba2 [nexus] migrate publish meshcop service cert test to nexus (#13186)
This commit migrates the legacy Thread certification test
'test_publish_meshcop_service.py' to the C++ simulation test suite
in the Nexus platform.

To avoid redundancy and keep the test suite clean, the coverage
is consolidated directly within 'tests/nexus/test_border_agent.cpp'
instead of introducing a new redundant test file.

Consolidated coverage and changes:
- Extended the state bitmap parser and 'ValidateMeshCoPTxtData' in
  'test_border_agent.cpp' to verify Backbone Router (BBR) active
  and primary flags (kFlagBbrIsActive, kFlagBbrIsPrimary) when
  OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE is enabled.
- Added a new test block in 'TestBorderAgentServiceRegistration' to
  enable Backbone Router on node0, verify that BBR active and primary
  flags are dynamically advertised in the MeshCoP TXT record over
  mDNS, and verify that disabling BBR correctly updates the TXT
  record state bitmap.
- Fully deleted the legacy Python certification script
  'test_publish_meshcop_service.py' from 'thread-cert'.
2026-06-02 07:46:15 -07:00
Abtin Keshavarzian 7ad13c8adb [ip4] use Icmp4Header directly for ICMPv4 (#13180)
This commit updates the codebase to use the `Icmp4Header` type directly,
replacing the nested `Ip4::Icmp::Header` type. The empty `Ip4::Icmp`
wrapper class is removed to simplify the header definition. This change
aligns the ICMPv4 header structure with the flat naming conventions used
for other IP headers (e.g., `Ip6::Icmp6Header`, `Ip6::UpdHeader`).
2026-06-02 07:45:50 -07:00
dependabot[bot] f6598900cf github-actions: bump docker/build-push-action from 7.1.0 to 7.2.0 (#13188)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 7.1.0 to 7.2.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/bcafcacb16a39f128d818304e6c9c0c18556b85f...f9f3042f7e2789586610d6e8b85c8f03e5195baf)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: 7.2.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>
2026-06-02 07:33:12 -07:00
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
mohammadmseet-hue 675162556b [mdns] reject empty PTR target label on receive (#13183)
`PtrRecord::ReadPtrName()` reads a PTR target's first label with
`Name::ReadLabel()`, which performs no emptiness check. A response whose
first label is a single NUL byte (wire `01 00`) is stored as an empty
C-string and cached by the browse cache as a service instance. When the
cache later builds a known-answer question, it calls
`Name::AppendLabel("")`, which returns `kErrorInvalidArgs`; the
surrounding `SuccessOrAssert()` turns that into an abort. A single
unauthenticated link-local mDNS response thus crashes any node with an
active browser.

Reject an empty first label in `ReadPtrName()` so the record is dropped
on receive and never cached. This matches the `Name::ValidateLabel`
checks already applied on the registration and resolver paths, and makes
the "ReadPtrName() validates that PTR record is well-formed" comment at
the call site accurate.

Add a regression test that delivers a PTR response with a single
NUL-byte instance label and verifies no result is reported and the
browser keeps querying without the malformed entry.
2026-06-01 13:19:16 -07:00
Abtin Keshavarzian 32b96a0d98 [docs] add missing TCP and UDP Doxygen groups (#13178)
This commit adds the missing Doxygen groups for TCP (`core-tcp`),
TCP Extensions (`core-tcp-ext`), and UDP (`core-udp`). These groups
are used in the code but were not previously defined.
2026-06-01 13:13:33 -07:00
142 changed files with 765 additions and 4177 deletions
+1 -1
View File
@@ -94,7 +94,7 @@ jobs:
- name: Build and push by digest
if: success()
id: build
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
file: etc/docker/environment/Dockerfile
platforms: ${{ matrix.platform }}
+1 -1
View File
@@ -80,7 +80,7 @@ jobs:
PYTHONPATH=./tests/scripts/thread-cert pytype tools/otci
- name: Build
run: |
./script/cmake-build simulation -DOT_THREAD_VERSION=1.4 -DOT_DUA=ON -DOT_MLR=ON -DOT_BACKBONE_ROUTER=ON \
./script/cmake-build simulation -DOT_THREAD_VERSION=1.4 -DOT_MLR=ON -DOT_BACKBONE_ROUTER=ON \
-DOT_CSL_RECEIVER=ON -DOT_SIMULATION_VIRTUAL_TIME=${VIRTUAL_TIME}
- name: Install OTCI Python Library
run: |
-1
View File
@@ -210,7 +210,6 @@ ot_option(OT_DNS_DSO OPENTHREAD_CONFIG_DNS_DSO_ENABLE "DNS Stateful Operations (
ot_option(OT_DNS_UPSTREAM_QUERY OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE "Allow sending DNS queries to upstream")
ot_option(OT_DNSSD_DISCOVERY_PROXY OPENTHREAD_CONFIG_DNSSD_DISCOVERY_PROXY_ENABLE "DNS-SD discovery proxy")
ot_option(OT_DNSSD_SERVER OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE "DNS-SD server")
ot_option(OT_DUA OPENTHREAD_CONFIG_DUA_ENABLE "Domain Unicast Address (DUA)")
ot_option(OT_DYNAMIC_STORE_FRAME_AHEAD_COUNTER OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE "dynamic store frame ahead counter")
ot_option(OT_ECDSA OPENTHREAD_CONFIG_ECDSA_ENABLE "ECDSA")
ot_option(OT_EXTERNAL_HEAP OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE "external heap")
-3
View File
@@ -138,9 +138,6 @@ if (openthread_enable_core_config_args) {
# Enable ECDSA support
openthread_config_ecdsa_enable = false
# Enable Domain Unicast Address feature for Thread 1.2
openthread_config_dua_enable = false
# Enable Multicast Listener Registration feature for Thread 1.2
openthread_config_mlr_enable = false
@@ -60,7 +60,6 @@
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 1
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 1
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 1
@@ -59,7 +59,6 @@
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 0
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 0
@@ -59,7 +59,6 @@
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_DSO_ENABLE 0
#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 0
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE 0
#define OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE 0
-43
View File
@@ -43,7 +43,6 @@
#include <openthread/error.h>
#include <openthread/instance.h>
#include <openthread/ip6.h>
#include <openthread/netdata.h>
#ifdef __cplusplus
extern "C" {
@@ -175,17 +174,6 @@ uint8_t otBackboneRouterGetRegistrationJitter(otInstance *aInstance);
*/
void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitter);
/**
* Gets the local Domain Prefix configuration.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aConfig A pointer to the Domain Prefix configuration.
*
* @retval OT_ERROR_NONE Successfully got the Domain Prefix configuration.
* @retval OT_ERROR_NOT_FOUND No Domain Prefix was configured.
*/
otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig);
/**
* Configures the response status for the next Multicast Listener Registration.
*
@@ -300,37 +288,6 @@ otError otBackboneRouterMulticastListenerGetNext(otInstance
otBackboneRouterMulticastListenerIterator *aIterator,
otBackboneRouterMulticastListenerInfo *aListenerInfo);
/**
* Represents the Domain Prefix events.
*/
typedef enum
{
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_ADDED = 0, ///< Domain Prefix was added.
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_REMOVED = 1, ///< Domain Prefix was removed.
OT_BACKBONE_ROUTER_DOMAIN_PREFIX_CHANGED = 2, ///< Domain Prefix was changed.
} otBackboneRouterDomainPrefixEvent;
/**
* Pointer is called whenever the Domain Prefix changed.
*
* @param[in] aContext The user context pointer.
* @param[in] aEvent The Domain Prefix event.
* @param[in] aDomainPrefix The new Domain Prefix if added or changed, NULL otherwise.
*/
typedef void (*otBackboneRouterDomainPrefixCallback)(void *aContext,
otBackboneRouterDomainPrefixEvent aEvent,
const otIp6Prefix *aDomainPrefix);
/**
* Sets the Backbone Router Domain Prefix callback.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aCallback A pointer to the Domain Prefix callback.
* @param[in] aContext A user context pointer.
*/
void otBackboneRouterSetDomainPrefixCallback(otInstance *aInstance,
otBackboneRouterDomainPrefixCallback aCallback,
void *aContext);
/**
* @}
*/
-2
View File
@@ -603,7 +603,6 @@ otError otBorderRoutingGetNextRouterEntry(otInstance *aI
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with both the default-route and on-mesh flags set.
* - It has added at least one domain prefix (with both the domain and on-mesh flags set).
*
* The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
*
@@ -629,7 +628,6 @@ otError otBorderRoutingGetNextPeerBrEntry(otInstance *
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with both the default-route and on-mesh flags set.
* - It has added at least one domain prefix (with both the domain and on-mesh flags set).
*
* The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
*
+1 -1
View File
@@ -52,7 +52,7 @@ extern "C" {
*
* @note This number versions both OpenThread platform and user APIs.
*/
#define OPENTHREAD_API_VERSION (601)
#define OPENTHREAD_API_VERSION (603)
/**
* @addtogroup api-instance
+1 -1
View File
@@ -73,7 +73,7 @@ typedef struct otBorderRouterConfig
bool mOnMesh : 1; ///< Whether this prefix is considered on-mesh.
bool mStable : 1; ///< Whether this configuration is considered Stable Network Data.
bool mNdDns : 1; ///< Whether this border router can supply DNS information via ND.
bool mDp : 1; ///< Whether prefix is a Thread Domain Prefix (added since Thread 1.2).
bool mDp : 1; ///< Reserved (previously Thread Domain Prefix flag).
uint16_t mRloc16; ///< The border router's RLOC16 (value ignored on config add).
} otBorderRouterConfig;
-32
View File
@@ -628,38 +628,6 @@ const char *otThreadGetDomainName(otInstance *aInstance);
*/
otError otThreadSetDomainName(otInstance *aInstance, const char *aDomainName);
/**
* Sets or clears the Interface Identifier manually specified for the Thread Domain Unicast Address.
*
* Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
*
* @note Only available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aIid A pointer to the Interface Identifier to set or NULL to clear.
*
* @retval OT_ERROR_NONE Successfully set/cleared the Interface Identifier.
* @retval OT_ERROR_INVALID_ARGS The specified Interface Identifier is reserved.
*
* @sa otThreadGetFixedDuaInterfaceIdentifier
*/
otError otThreadSetFixedDuaInterfaceIdentifier(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid);
/**
* Gets the Interface Identifier manually specified for the Thread Domain Unicast Address.
*
* Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
*
* @note Only available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to the Interface Identifier which was set manually, or NULL if none was set.
*
* @sa otThreadSetFixedDuaInterfaceIdentifier
*/
const otIp6InterfaceIdentifier *otThreadGetFixedDuaInterfaceIdentifier(otInstance *aInstance);
/**
* Gets the thrKeySequenceCounter.
*
-1
View File
@@ -54,7 +54,6 @@ build_nrf52840()
"-DOT_DIAGNOSTIC=ON"
"-DOT_DNSSD_SERVER=ON"
"-DOT_DNS_CLIENT=ON"
"-DOT_DUA=ON"
"-DOT_ECDSA=ON"
"-DOT_FULL_LOGS=ON"
"-DOT_JAM_DETECTION=ON"
+5 -5
View File
@@ -158,23 +158,23 @@ build_all_features()
# Build Thread 1.4 with full features
reset_source
CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON
"$(dirname "$0")"/cmake-build simulation "${options[@]}"
# Build Thread 1.4 with external heap and msg pool using heap
reset_source
CFLAGS="${cppflags[*]} ${CFLAGS} -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1" \
CXXFLAGS="${cppflags[*]} ${CXXFLAGS} -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1" \
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON
"$(dirname "$0")"/cmake-build simulation "${options[@]}"
# Build Thread 1.4 with full features and no log
reset_source
CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_LOG_OUTPUT=NONE
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_LOG_OUTPUT=NONE
# Build Thread 1.4 with full features and full logs
reset_source
CFLAGS="${cppflags[*]} ${CFLAGS}" CXXFLAGS="${cppflags[*]} ${CXXFLAGS}" \
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_FULL_LOGS=ON
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_FULL_LOGS=ON
# Build with Vendor Extension
reset_source
@@ -188,7 +188,7 @@ build_all_features()
# Build Thread 1.4 with full features and OT_ASSERT=OFF
reset_source
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_DUA=ON -DOT_ASSERT=OFF
"$(dirname "$0")"/cmake-build simulation "${options[@]}" -DOT_ASSERT=OFF
# Build with RAM settings
reset_source
-1
View File
@@ -112,7 +112,6 @@ OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_DNS_UPSTREAM_QUERY=ON'
"-DOT_DNSSD_DISCOVERY_PROXY=ON"
'-DOT_DNSSD_SERVER=ON'
'-DOT_DUA=ON'
'-DOT_MLR=ON'
'-DOT_ECDSA=ON'
'-DOT_HISTORY_TRACKER=ON'
-4
View File
@@ -125,7 +125,6 @@ build_simulation()
fi
if [[ ${version} != "1.1" ]]; then
options+=("-DOT_DUA=ON")
options+=("-DOT_MLR=ON")
fi
@@ -184,7 +183,6 @@ build_posix()
)
if [[ ${version} != "1.1" ]]; then
options+=("-DOT_DUA=ON")
options+=("-DOT_MLR=ON")
options+=("-DOT_LINK_METRICS_INITIATOR=ON")
options+=("-DOT_LINK_METRICS_SUBJECT=ON")
@@ -346,14 +344,12 @@ do_build_otbr_docker()
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_COVERAGE=ON"
"-DOT_DNS_CLIENT=ON"
"-DOT_DUA=ON"
"-DOT_MLR=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_SLAAC=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_FULL_LOGS=ON"
"-DOT_UPTIME=ON"
"-DOTBR_DUA_ROUTING=ON"
"-DOTBR_DHCP6_PD=ON"
)
local args=(
+1 -57
View File
@@ -50,7 +50,6 @@ Done
- [discover](#discover-channel)
- [dns](#dns-config)
- [domainname](#domainname)
- [dua](#dua-iid)
- [eidcache](#eidcache)
- [eui64](#eui64)
- [extaddr](#extaddr)
@@ -174,30 +173,6 @@ BBR Primary: None
Done
```
### bbr mgmt dua \<status\|coap-code\> [meshLocalIid]
Configure the response status for DUA.req with meshLocalIid in payload. Without meshLocalIid, simply respond any coming DUA.req next with the specified status or COAP code.
Only for testing/reference device.
known status value:
- 0: ST_DUA_SUCCESS
- 1: ST_DUA_REREGISTER
- 2: ST_DUA_INVALID
- 3: ST_DUA_DUPLICATE
- 4: ST_DUA_NO_RESOURCES
- 5: ST_DUA_BBR_NOT_PRIMARY
- 6: ST_DUA_GENERAL_FAILURE
- 160: COAP code 5.00
```bash
> bbr mgmt dua 1 2f7c235e5025a2fd
Done
> bbr mgmt dua 160
Done
```
### bbr mgmt mlr listener
Show the Multicast Listeners.
@@ -1959,34 +1934,6 @@ Set the Thread Domain Name for Thread 1.2 device.
Done
```
### dua iid
Get the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device.
```bash
> dua iid
0004000300020001
Done
```
### dua iid \<iid\>
Set the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device.
```bash
> dua iid 0004000300020001
Done
```
### dua iid clear
Clear the Interface Identifier manually specified for Thread Domain Unicast Address on Thread 1.2 device.
```bash
> dua iid clear
Done
```
### eidcache
Print the EID-to-RLOC cache entries.
@@ -3596,7 +3543,7 @@ Done
### prefix
Get the prefix list in the local Network Data. Note: For the Thread 1.2 border router with backbone capability, the local Domain Prefix would be listed as well (with flag `D`), with preceding `-` if backbone functionality is disabled.
Get the prefix list in the local Network Data.
```bash
> prefix
@@ -3609,8 +3556,6 @@ Done
Add a valid prefix to the Network Data.
Note: The Domain Prefix flag (`D`) is only available for Thread 1.2.
- p: Preferred flag
- a: Stateless IPv6 Address Autoconfiguration flag
- d: DHCPv6 IPv6 Address Configuration flag
@@ -3619,7 +3564,6 @@ Note: The Domain Prefix flag (`D`) is only available for Thread 1.2.
- o: On Mesh flag
- s: Stable flag
- n: Nd Dns flag
- D: Domain Prefix flag
- prf: Default router preference, which may be 'high', 'med', or 'low'.
```bash
-1
View File
@@ -430,7 +430,6 @@ Peer BRs are other devices within the Thread mesh that provide external IP conne
- It has added at least one external route entry.
- It has added at least one prefix entry with both the default-route and on-mesh flags set.
- It has added at least one domain prefix (with both the domain and on-mesh flags set).
The list of peer BRs specifically excludes the current device, even if it is itself acting as a BR.
-1
View File
@@ -466,7 +466,6 @@ The flags are as follows:
- `o`: On Mesh flag
- `s`: Stable flag
- `n`: Nd Dns flag
- `D`: Domain Prefix flag
Print the history as a table.
-2
View File
@@ -283,7 +283,6 @@ Publish an on-mesh prefix entry.
- o: On Mesh flag
- s: Stable flag
- n: Nd Dns flag
- D: Domain Prefix flag (only available for Thread 1.2).
- prf: Preference, which may be 'high', 'med', or 'low'.
```bash
@@ -352,7 +351,6 @@ On-mesh prefixes are listed under `Prefixes` header:
- o: On Mesh flag
- s: Stable flag
- n: Nd Dns flag
- D: Domain Prefix flag (only available for Thread 1.2).
- Preference `high`, `med`, or `low`
- RLOC16 of device which added the on-mesh prefix
-79
View File
@@ -1102,70 +1102,6 @@ template <> otError Interpreter::Process<Cmd("domainname")>(Arg aArgs[])
return ProcessGetSet(aArgs, otThreadGetDomainName, otThreadSetDomainName);
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
template <> otError Interpreter::Process<Cmd("dua")>(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
/**
* @cli dua iid
* @code
* dua iid
* 0004000300020001
* Done
* @endcode
* @par api_copy
* #otThreadGetFixedDuaInterfaceIdentifier
*/
if (aArgs[0] == "iid")
{
if (aArgs[1].IsEmpty())
{
const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(GetInstancePtr());
if (iid != nullptr)
{
OutputBytesLine(iid->mFields.m8);
}
}
/**
* @cli dua iid (set,clear)
* @code
* dua iid 0004000300020001
* Done
* @endcode
* @code
* dua iid clear
* Done
* @endcode
* @cparam dua iid @ca{iid|clear}
* `dua iid clear` passes a `nullptr` to #otThreadSetFixedDuaInterfaceIdentifier.
* Otherwise, you can pass the `iid`.
* @par api_copy
* #otThreadSetFixedDuaInterfaceIdentifier
*/
else if (aArgs[1] == "clear")
{
error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), nullptr);
}
else
{
otIp6InterfaceIdentifier iid;
SuccessOrExit(error = aArgs[1].ParseAsHexString(iid.mFields.m8));
error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), &iid);
}
}
else
{
error = OT_ERROR_INVALID_COMMAND;
}
exit:
return error;
}
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
/**
@@ -5514,9 +5450,6 @@ template <> otError Interpreter::Process<Cmd("prefix")>(Arg aArgs[])
* @endcode
* @par
* Get the prefix list in the local Network Data.
* @note For the Thread 1.2 border router with backbone capability, the local Domain Prefix
* is listed as well and includes the `D` flag. If backbone functionality is disabled, a dash
* `-` is printed before the local Domain Prefix.
* @par
* For more information about #otBorderRouterConfig flags, refer to @overview.
* @sa otBorderRouterGetNextOnMeshPrefix
@@ -5530,15 +5463,6 @@ template <> otError Interpreter::Process<Cmd("prefix")>(Arg aArgs[])
{
mNetworkData.OutputPrefix(config);
}
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
if (otBackboneRouterGetState(GetInstancePtr()) == OT_BACKBONE_ROUTER_STATE_DISABLED)
{
SuccessOrExit(otBackboneRouterGetDomainPrefix(GetInstancePtr(), &config));
OutputFormat("- ");
mNetworkData.OutputPrefix(config);
}
#endif
}
/**
* @cli prefix add
@@ -8671,9 +8595,6 @@ otError Interpreter::ProcessCommand(Arg aArgs[])
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
CmdEntry("domainname"),
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
CmdEntry("dua"),
#endif
#if OPENTHREAD_FTD
CmdEntry("eidcache"),
#endif
-1
View File
@@ -670,7 +670,6 @@ template <> otError Br::Process<Cmd("peers")>(Arg aArgs[])
* Data entries:
* - It has added at least one external route entry.
* - It has added at least one prefix entry with both the default-route and on-mesh flags set.
* - It has added at least one domain prefix (with both the domain and on-mesh flags set).
* The list of peer BRs specifically excludes the current device, even if its is itself acting as a BR.
* Info per BR entry:
* - RLOC16 of the BR
+2 -1
View File
@@ -452,7 +452,8 @@ otError Dns::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig)
VerifyOrExit(!aArgs[0].IsEmpty(), aConfig = nullptr);
SuccessOrExit(error = ParseToIp6Address(GetInstancePtr(), aArgs[0], aConfig->mServerSockAddr.mAddress, nat64Synth));
SuccessOrExit(error = ParseOrSynthesizeIp6Address(aArgs[0], aConfig->mServerSockAddr.mAddress, nat64Synth));
if (nat64Synth)
{
OutputFormat("Synthesized IPv6 DNS server address: ");
-1
View File
@@ -1305,7 +1305,6 @@ void History::OutputRxTxEntryTableFormat(const otHistoryTrackerMessageInfo &aInf
* * `o`: On mesh flag.
* * `s`: Stable flag.
* * `n`: Nd Dns flag.
* * `D`: Domain prefix flag.
* * Pref: Preference. Values can be either `high`, `med`, or `low`.
* * RLOC16
* @sa otHistoryTrackerIterateOnMeshPrefixHistory
-6
View File
@@ -96,11 +96,6 @@ void NetworkData::PrefixFlagsToString(const otBorderRouterConfig &aConfig, Flags
*flagsPtr++ = 'n';
}
if (aConfig.mDp)
{
*flagsPtr++ = 'D';
}
*flagsPtr = '\0';
}
@@ -804,7 +799,6 @@ exit:
* * o: On Mesh flag
* * s: Stable flag
* * n: Nd Dns flag
* * D: Domain Prefix flag (only available for Thread 1.2).
* * Preference `high`, `med`, or `low`
* * RLOC16 of device which added the on-mesh prefix
* @par
+1 -1
View File
@@ -96,7 +96,7 @@ otError PingSender::Process(Arg aArgs[])
aArgs++;
}
SuccessOrExit(error = ParseToIp6Address(GetInstancePtr(), aArgs[0], config.mDestination, nat64Synth));
SuccessOrExit(error = ParseOrSynthesizeIp6Address(aArgs[0], config.mDestination, nat64Synth));
if (nat64Synth)
{
+1 -1
View File
@@ -400,7 +400,7 @@ template <> otError TcpExample::Process<Cmd("connect")>(Arg aArgs[])
VerifyOrExit(mInitialized, error = OT_ERROR_INVALID_STATE);
SuccessOrExit(error = ParseToIp6Address(GetInstancePtr(), aArgs[0], sockaddr.mAddress, nat64Synth));
SuccessOrExit(error = ParseOrSynthesizeIp6Address(aArgs[0], sockaddr.mAddress, nat64Synth));
if (nat64Synth)
{
+2 -2
View File
@@ -144,7 +144,7 @@ template <> otError UdpExample::Process<Cmd("connect")>(Arg aArgs[])
otSockAddr sockaddr;
bool nat64Synth;
SuccessOrExit(error = ParseToIp6Address(GetInstancePtr(), aArgs[0], sockaddr.mAddress, nat64Synth));
SuccessOrExit(error = ParseOrSynthesizeIp6Address(aArgs[0], sockaddr.mAddress, nat64Synth));
if (nat64Synth)
{
@@ -281,7 +281,7 @@ template <> otError UdpExample::Process<Cmd("send")>(Arg aArgs[])
{
bool nat64Synth;
SuccessOrExit(error = ParseToIp6Address(GetInstancePtr(), aArgs[0], messageInfo.mPeerAddr, nat64Synth));
SuccessOrExit(error = ParseOrSynthesizeIp6Address(aArgs[0], messageInfo.mPeerAddr, nat64Synth));
if (nat64Synth)
{
+15 -18
View File
@@ -629,25 +629,27 @@ const char *Utils::PreferenceToString(signed int aPreference)
}
#if OPENTHREAD_FTD || OPENTHREAD_MTD
otError Utils::ParseToIp6Address(otInstance *aInstance, const Arg &aArg, otIp6Address &aAddress, bool &aSynthesized)
{
Error error = OT_ERROR_NONE;
VerifyOrExit(!aArg.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
error = aArg.ParseAsIp6Address(aAddress);
otError Utils::ParseOrSynthesizeIp6Address(const Arg &aArg, otIp6Address &aAddress, bool &aSynthesized)
{
Error error;
otIp4Address ip4Address;
aSynthesized = false;
if (error != OT_ERROR_NONE)
{
// It might be an IPv4 address, let's have a try.
otIp4Address ip4Address;
error = aArg.ParseAsIp6Address(aAddress);
// Do not touch the error value if we failed to parse it as an IPv4 address.
SuccessOrExit(aArg.ParseAsIp4Address(ip4Address));
SuccessOrExit(error = otNat64SynthesizeIp6Address(aInstance, &ip4Address, &aAddress));
aSynthesized = true;
if (error == OT_ERROR_NONE)
{
ExitNow();
}
// Try to parse it as an IPv4 address and synthesize.
SuccessOrExit(error = aArg.ParseAsIp4Address(ip4Address));
SuccessOrExit(error = otNat64SynthesizeIp6Address(GetInstancePtr(), &ip4Address, &aAddress));
aSynthesized = true;
exit:
return error;
}
@@ -708,11 +710,6 @@ otError Utils::ParsePrefix(Arg aArgs[], otBorderRouterConfig &aConfig)
aConfig.mNdDns = true;
break;
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
case 'D':
aConfig.mDp = true;
break;
#endif
case '-':
break;
+4 -8
View File
@@ -674,24 +674,20 @@ public:
static const char *PreferenceToString(signed int aPreference);
/**
* Parses the argument as an IP address.
* Parses the argument as an IPv6 address or synthesizes it from an IPv4 address.
*
* If the argument string is an IPv4 address, this method will try to synthesize an IPv6 address using preferred
* NAT64 prefix in the network data.
*
* @param[in] aInstance A pointer to OpenThread instance.
* @param[in] aArg The argument string to parse.
* @param[out] aAddress A reference to an `otIp6Address` to output the parsed IPv6 address.
* @param[out] aAddress A reference to an `otIp6Address` to output the parsed/synthesized IPv6 address.
* @param[out] aSynthesized Whether @p aAddress is synthesized from an IPv4 address.
*
* @retval OT_ERROR_NONE The argument was parsed successfully.
* @retval OT_ERROR_NONE The argument was parsed/synthesized successfully.
* @retval OT_ERROR_INVALID_ARGS The argument is empty or does not contain a valid IP address.
* @retval OT_ERROR_INVALID_STATE No valid NAT64 prefix in the network data.
*/
static otError ParseToIp6Address(otInstance *aInstance,
const Arg &aArg,
otIp6Address &aAddress,
bool &aSynthesized);
otError ParseOrSynthesizeIp6Address(const Arg &aArg, otIp6Address &aAddress, bool &aSynthesized);
/**
* Parses the argument as a Joiner Discerner.
-6
View File
@@ -103,10 +103,6 @@ if (openthread_enable_core_config_args) {
macro = "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE"
value = openthread_config_dns_client_enable
},
{
macro = "OPENTHREAD_CONFIG_DUA_ENABLE"
value = openthread_config_dua_enable
},
{
macro = "OPENTHREAD_CONFIG_ECDSA_ENABLE"
value = openthread_config_ecdsa_enable
@@ -694,8 +690,6 @@ openthread_core_files = [
"thread/csl_tx_scheduler.hpp",
"thread/discover_scanner.cpp",
"thread/discover_scanner.hpp",
"thread/dua_manager.cpp",
"thread/dua_manager.hpp",
"thread/energy_scan_server.cpp",
"thread/energy_scan_server.hpp",
"thread/indirect_sender.cpp",
-1
View File
@@ -237,7 +237,6 @@ set(COMMON_SOURCES
thread/child_table.cpp
thread/csl_tx_scheduler.cpp
thread/discover_scanner.cpp
thread/dua_manager.cpp
thread/energy_scan_server.cpp
thread/indirect_sender.cpp
thread/key_manager.cpp
-12
View File
@@ -82,18 +82,6 @@ void otBackboneRouterSetRegistrationJitter(otInstance *aInstance, uint8_t aJitte
return AsCoreType(aInstance).Get<BackboneRouter::Local>().SetRegistrationJitter(aJitter);
}
otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterConfig *aConfig)
{
return AsCoreType(aInstance).Get<BackboneRouter::Local>().GetDomainPrefix(AsCoreType(aConfig));
}
void otBackboneRouterSetDomainPrefixCallback(otInstance *aInstance,
otBackboneRouterDomainPrefixCallback aCallback,
void *aContext)
{
return AsCoreType(aInstance).Get<BackboneRouter::Local>().SetDomainPrefixCallback(aCallback, aContext);
}
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE
void otBackboneRouterSetMulticastListenerCallback(otInstance *aInstance,
otBackboneRouterMulticastListenerCallback aCallback,
+2 -26
View File
@@ -49,36 +49,12 @@ otError otBorderRouterGetNetData(otInstance *aInstance, bool aStable, uint8_t *a
otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRouterConfig *aConfig)
{
Error error = kErrorNone;
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
if (aConfig->mDp)
{
error = AsCoreType(aInstance).Get<BackboneRouter::Local>().SetDomainPrefix(AsCoreType(aConfig));
}
else
#endif
{
error = AsCoreType(aInstance).Get<NetworkData::Local>().AddOnMeshPrefix(AsCoreType(aConfig));
}
return error;
return AsCoreType(aInstance).Get<NetworkData::Local>().AddOnMeshPrefix(AsCoreType(aConfig));
}
otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefix *aPrefix)
{
Error error = kErrorNone;
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
error = AsCoreType(aInstance).Get<BackboneRouter::Local>().RemoveDomainPrefix(AsCoreType(aPrefix));
if (error == kErrorNotFound)
#endif
{
error = AsCoreType(aInstance).Get<NetworkData::Local>().RemoveOnMeshPrefix(AsCoreType(aPrefix));
}
return error;
return AsCoreType(aInstance).Get<NetworkData::Local>().RemoveOnMeshPrefix(AsCoreType(aPrefix));
}
otError otBorderRouterGetNextOnMeshPrefix(otInstance *aInstance,
+2 -33
View File
@@ -73,7 +73,7 @@ otError otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc)
Error error = kErrorNone;
VerifyOrExit(!AsCoreType(aInstance).Get<Mle::Mle>().HasRloc16(Mle::kInvalidRloc16), error = kErrorDetached);
AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderRloc(AsCoreType(aLeaderRloc));
AsCoreType(aInstance).Get<Mle::Mle>().ComposeLeaderRloc(AsCoreType(aLeaderRloc));
exit:
return error;
@@ -189,7 +189,7 @@ otError otThreadGetServiceAloc(otInstance *aInstance, uint8_t aServiceId, otIp6A
Error error = kErrorNone;
VerifyOrExit(!AsCoreType(aInstance).Get<Mle::Mle>().HasRloc16(Mle::kInvalidRloc16), error = kErrorDetached);
AsCoreType(aInstance).Get<Mle::Mle>().GetServiceAloc(aServiceId, AsCoreType(aServiceAloc));
AsCoreType(aInstance).Get<Mle::Mle>().ComposeServiceAloc(aServiceId, AsCoreType(aServiceAloc));
exit:
return error;
@@ -238,37 +238,6 @@ exit:
return error;
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
otError otThreadSetFixedDuaInterfaceIdentifier(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid)
{
Error error = kErrorNone;
if (aIid)
{
error = AsCoreType(aInstance).Get<DuaManager>().SetFixedDuaInterfaceIdentifier(AsCoreType(aIid));
}
else
{
AsCoreType(aInstance).Get<DuaManager>().ClearFixedDuaInterfaceIdentifier();
}
return error;
}
const otIp6InterfaceIdentifier *otThreadGetFixedDuaInterfaceIdentifier(otInstance *aInstance)
{
Instance &instance = AsCoreType(aInstance);
const otIp6InterfaceIdentifier *iid = nullptr;
if (instance.Get<DuaManager>().IsFixedDuaInterfaceIdentifierSet())
{
iid = &instance.Get<DuaManager>().GetFixedDuaInterfaceIdentifier();
}
return iid;
}
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
uint32_t otThreadGetKeySequenceCounter(otInstance *aInstance)
+2 -4
View File
@@ -116,12 +116,10 @@ bool BackboneTmfAgent::IsBackboneTmfMessage(const Ip6::MessageInfo &aMessageInfo
// A Backbone TMF message must comply with following rules:
// The destination must be one of:
// 1. All Network BBRs (Link-Local scope)
// 2. All Domain BBRs (Link-Local scope)
// 3. A Backbone Link-Local address
// 2. A Backbone Link-Local address
// The source must be a Backbone Link-local address.
return (Get<BackboneRouter::Local>().IsEnabled() && src.IsLinkLocalUnicast() &&
(dst.IsLinkLocalUnicast() || dst == Get<BackboneRouter::Local>().GetAllNetworkBackboneRoutersAddress() ||
dst == Get<BackboneRouter::Local>().GetAllDomainBackboneRoutersAddress()));
(dst.IsLinkLocalUnicast() || dst == Get<BackboneRouter::Local>().GetAllNetworkBackboneRoutersAddress()));
}
void BackboneTmfAgent::SubscribeMulticast(const Ip6::Address &aAddress)
+1 -74
View File
@@ -90,13 +90,7 @@ Leader::Leader(Instance &aInstance)
Reset();
}
void Leader::Reset(void)
{
mConfig.MarkAsAbsent();
// Domain Prefix Length 0 indicates no available Domain Prefix in the Thread network.
mDomainPrefix.SetLength(0);
}
void Leader::Reset(void) { mConfig.MarkAsAbsent(); }
Error Leader::ReadConfig(Config &aConfig) const
{
@@ -136,18 +130,6 @@ const char *Leader::PrimaryEventToString(PrimaryEvent aEvent)
return kStrings[aEvent];
}
const char *Leader::DomainPrefixEventToString(DomainPrefixEvent aEvent)
{
#define DomainPrefixEventMapList(_) \
_(kDomainPrefixAdded, "Added") \
_(kDomainPrefixRemoved, "Removed") \
_(kDomainPrefixRefreshed, "Refreshed")
DefineEnumStringArray(DomainPrefixEventMapList);
return kStrings[aEvent];
}
#endif // OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
void Leader::HandleNotifierEvents(Events aEvents)
@@ -155,7 +137,6 @@ void Leader::HandleNotifierEvents(Events aEvents)
if (aEvents.ContainsAny(kEventThreadNetdataChanged | kEventThreadRoleChanged))
{
UpdateBackboneRouterPrimary();
UpdateDomainPrefixConfig();
}
}
@@ -208,64 +189,10 @@ void Leader::UpdateBackboneRouterPrimary(void)
Get<Mlr::Manager>().HandleBackboneRouterPrimaryUpdate(event);
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Get<DuaManager>().HandleBackboneRouterPrimaryUpdate(event);
#endif
exit:
OT_UNUSED_VARIABLE(event);
}
void Leader::UpdateDomainPrefixConfig(void)
{
NetworkData::Iterator iterator = NetworkData::kIteratorInit;
NetworkData::OnMeshPrefixConfig prefixConfig;
DomainPrefixEvent event;
bool found = false;
while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{
if (prefixConfig.mDp)
{
found = true;
break;
}
}
if (!found)
{
VerifyOrExit(HasDomainPrefix());
mDomainPrefix.Clear();
event = kDomainPrefixRemoved;
}
else
{
VerifyOrExit(prefixConfig.GetPrefix() != mDomainPrefix);
event = HasDomainPrefix() ? kDomainPrefixRefreshed : kDomainPrefixAdded;
mDomainPrefix = prefixConfig.GetPrefix();
}
LogInfo("%s domain Prefix: %s", DomainPrefixEventToString(event), mDomainPrefix.ToString().AsCString());
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
Get<Local>().HandleDomainPrefixUpdate(event);
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Get<DuaManager>().HandleDomainPrefixUpdate(event);
#endif
exit:
OT_UNUSED_VARIABLE(event);
}
bool Leader::IsDomainUnicast(const Ip6::Address &aAddress) const
{
return HasDomainPrefix() && aAddress.MatchesPrefix(mDomainPrefix);
}
} // namespace BackboneRouter
} // namespace ot
+1 -40
View File
@@ -67,16 +67,6 @@ static_assert(kDefaultMlrTimeout >= kMinMlrTimeout && kDefaultMlrTimeout <= kMax
static_assert(kMaxMlrTimeout * 1000 > kMaxMlrTimeout, "SecToMsec(kMaxMlrTimeout) will overflow");
static_assert(kParentAggregateDelay > 1, "kParentAggregateDelay should be larger than 1 second");
/**
* Represents Domain Prefix changes.
*/
enum DomainPrefixEvent : uint8_t
{
kDomainPrefixAdded = OT_BACKBONE_ROUTER_DOMAIN_PREFIX_ADDED, ///< Domain Prefix Added.
kDomainPrefixRemoved = OT_BACKBONE_ROUTER_DOMAIN_PREFIX_REMOVED, ///< Domain Prefix Removed.
kDomainPrefixRefreshed = OT_BACKBONE_ROUTER_DOMAIN_PREFIX_CHANGED, ///< Domain Prefix Changed.
};
/**
* Represents Primary Backbone Router events.
*/
@@ -220,47 +210,18 @@ public:
*/
bool HasPrimary(void) const { return mConfig.IsPresent(); }
/**
* Gets the Domain Prefix in the Thread Network.
*
* @retval A pointer to the Domain Prefix or nullptr if there is no Domain Prefix.
*/
const Ip6::Prefix *GetDomainPrefix(void) const { return HasDomainPrefix() ? &mDomainPrefix : nullptr; }
/**
* Indicates whether or not the Domain Prefix is available in the Thread Network.
*
* @retval TRUE If there is Domain Prefix.
* @retval FALSE If there is no Domain Prefix.
*/
bool HasDomainPrefix(void) const { return (mDomainPrefix.GetLength() > 0); }
/**
* Indicates whether or not the address is a Domain Unicast Address.
*
* @param[in] aAddress A reference to the address.
*
* @retval true @p aAddress is a Domain Unicast Address.
* @retval false @p aAddress is not a Domain Unicast Address.
*/
bool IsDomainUnicast(const Ip6::Address &aAddress) const;
private:
void HandleNotifierEvents(Events aEvents);
void UpdateBackboneRouterPrimary(void);
void UpdateDomainPrefixConfig(void);
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
static const char *PrimaryEventToString(PrimaryEvent aEvent);
static const char *DomainPrefixEventToString(DomainPrefixEvent aEvent);
#endif
Config mConfig;
Ip6::Prefix mDomainPrefix;
Config mConfig;
};
} // namespace BackboneRouter
DefineMapEnum(otBackboneRouterDomainPrefixEvent, BackboneRouter::DomainPrefixEvent);
DefineCoreType(otBackboneRouterConfig, BackboneRouter::Config);
} // namespace ot
-116
View File
@@ -53,8 +53,6 @@ Local::Local(Instance &aInstance)
, mRegistrationTimeout(0)
, mMlrTimeout(kDefaultMlrTimeout)
{
mDomainPrefixConfig.GetPrefix().SetLength(0);
// Primary Backbone Router Aloc
mBbrPrimaryAloc.InitAsThreadOriginMeshLocal();
mBbrPrimaryAloc.GetAddress().GetIid().InitAsLocator(Mle::Aloc16::ForPrimaryBackboneRouter());
@@ -65,13 +63,6 @@ Local::Local(Instance &aInstance)
mAllNetworkBackboneRouters.mFields.m8[0] = 0xff; // Multicast
mAllNetworkBackboneRouters.mFields.m8[1] = 0x32; // Flags = 3, Scope = 2
mAllNetworkBackboneRouters.mFields.m8[15] = 3; // Group ID = 3
// All Domain Backbone Routers Multicast Address.
mAllDomainBackboneRouters.Clear();
mAllDomainBackboneRouters.mFields.m8[0] = 0xff; // Multicast
mAllDomainBackboneRouters.mFields.m8[1] = 0x32; // Flags = 3, Scope = 2
mAllDomainBackboneRouters.mFields.m8[15] = 3; // Group ID = 3
}
void Local::SetEnabled(bool aEnable)
@@ -81,12 +72,10 @@ void Local::SetEnabled(bool aEnable)
if (aEnable)
{
SetState(kStateSecondary);
AddDomainPrefixToNetworkData();
IgnoreError(AddService(kDecideBasedOnState));
}
else
{
RemoveDomainPrefixFromNetworkData();
RemoveService();
SetState(kStateDisabled);
}
@@ -318,59 +307,6 @@ exit:
}
}
Error Local::GetDomainPrefix(NetworkData::OnMeshPrefixConfig &aConfig)
{
Error error = kErrorNone;
VerifyOrExit(mDomainPrefixConfig.GetPrefix().GetLength() > 0, error = kErrorNotFound);
aConfig = mDomainPrefixConfig;
exit:
return error;
}
Error Local::RemoveDomainPrefix(const Ip6::Prefix &aPrefix)
{
Error error = kErrorNone;
VerifyOrExit(aPrefix.GetLength() > 0, error = kErrorInvalidArgs);
VerifyOrExit(mDomainPrefixConfig.GetPrefix() == aPrefix, error = kErrorNotFound);
if (IsEnabled())
{
RemoveDomainPrefixFromNetworkData();
}
mDomainPrefixConfig.GetPrefix().SetLength(0);
exit:
return error;
}
Error Local::SetDomainPrefix(const NetworkData::OnMeshPrefixConfig &aConfig)
{
Error error = kErrorNone;
VerifyOrExit(aConfig.IsValid(GetInstance()), error = kErrorInvalidArgs);
if (IsEnabled())
{
RemoveDomainPrefixFromNetworkData();
}
mDomainPrefixConfig = aConfig;
LogDomainPrefix(kActionSet, kErrorNone);
if (IsEnabled())
{
AddDomainPrefixToNetworkData();
}
exit:
return error;
}
void Local::ApplyNewMeshLocalPrefix(void)
{
VerifyOrExit(IsEnabled());
@@ -383,40 +319,6 @@ exit:
return;
}
void Local::HandleDomainPrefixUpdate(DomainPrefixEvent aEvent)
{
VerifyOrExit(IsEnabled());
if (aEvent == kDomainPrefixRemoved || aEvent == kDomainPrefixRefreshed)
{
Get<BackboneTmfAgent>().UnsubscribeMulticast(mAllDomainBackboneRouters);
}
if (aEvent == kDomainPrefixAdded || aEvent == kDomainPrefixRefreshed)
{
mAllDomainBackboneRouters.SetMulticastNetworkPrefix(*Get<Leader>().GetDomainPrefix());
Get<BackboneTmfAgent>().SubscribeMulticast(mAllDomainBackboneRouters);
}
mDomainPrefixCallback.InvokeIfSet(static_cast<otBackboneRouterDomainPrefixEvent>(aEvent),
Get<Leader>().GetDomainPrefix());
exit:
return;
}
void Local::RemoveDomainPrefixFromNetworkData(void)
{
Error error = kErrorNotFound; // only used for logging.
if (mDomainPrefixConfig.mPrefix.mLength > 0)
{
error = Get<NetworkData::Local>().RemoveOnMeshPrefix(mDomainPrefixConfig.GetPrefix());
}
LogDomainPrefix(kActionRemove, error);
}
void Local::IncrementSequenceNumber(void)
{
switch (mSequenceNumber)
@@ -435,18 +337,6 @@ void Local::IncrementSequenceNumber(void)
}
}
void Local::AddDomainPrefixToNetworkData(void)
{
Error error = kErrorNotFound; // only used for logging.
if (mDomainPrefixConfig.GetPrefix().GetLength() > 0)
{
error = Get<NetworkData::Local>().AddOnMeshPrefix(mDomainPrefixConfig);
}
LogDomainPrefix(kActionAdd, error);
}
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
const char *Local::ActionToString(Action aAction)
@@ -461,12 +351,6 @@ const char *Local::ActionToString(Action aAction)
return kStrings[aAction];
}
void Local::LogDomainPrefix(Action aAction, Error aError)
{
LogInfo("%s Domain Prefix: %s, %s", ActionToString(aAction), mDomainPrefixConfig.GetPrefix().ToString().AsCString(),
ErrorToString(aError));
}
void Local::LogService(Action aAction, Error aError)
{
LogInfo("%s BBR Service: seqno (%u), delay (%us), timeout (%lus), %s", ActionToString(aAction), mSequenceNumber,
+9 -74
View File
@@ -77,8 +77,6 @@ class Local : public InstanceLocator, private NonCopyable
friend class ot::Notifier;
public:
typedef otBackboneRouterDomainPrefixCallback DomainPrefixCallback; ///< Domain Prefix callback.
/**
* Represents Backbone Router state.
*/
@@ -190,37 +188,6 @@ public:
*/
void HandleBackboneRouterPrimaryUpdate(PrimaryEvent aEvent);
/**
* Gets the Domain Prefix configuration.
*
* @param[out] aConfig A reference to the Domain Prefix configuration.
*
* @retval kErrorNone Successfully got the Domain Prefix configuration.
* @retval kErrorNotFound No Domain Prefix was configured.
*/
Error GetDomainPrefix(NetworkData::OnMeshPrefixConfig &aConfig);
/**
* Removes the local Domain Prefix configuration.
*
* @param[in] aPrefix A reference to the IPv6 Domain Prefix.
*
* @retval kErrorNone Successfully removed the Domain Prefix.
* @retval kErrorInvalidArgs @p aPrefix is invalid.
* @retval kErrorNotFound No Domain Prefix was configured or @p aPrefix doesn't match.
*/
Error RemoveDomainPrefix(const Ip6::Prefix &aPrefix);
/**
* Sets the local Domain Prefix configuration.
*
* @param[in] aConfig A reference to the Domain Prefix configuration.
*
* @returns kErrorNone Successfully set the local Domain Prefix.
* @returns kErrorInvalidArgs @p aConfig is invalid.
*/
Error SetDomainPrefix(const NetworkData::OnMeshPrefixConfig &aConfig);
/**
* Returns a reference to the All Network Backbone Routers Multicast Address.
*
@@ -228,36 +195,11 @@ public:
*/
const Ip6::Address &GetAllNetworkBackboneRoutersAddress(void) const { return mAllNetworkBackboneRouters; }
/**
* Returns a reference to the All Domain Backbone Routers Multicast Address.
*
* @returns A reference to the All Domain Backbone Routers Multicast Address.
*/
const Ip6::Address &GetAllDomainBackboneRoutersAddress(void) const { return mAllDomainBackboneRouters; }
/**
* Applies the Mesh Local Prefix.
*/
void ApplyNewMeshLocalPrefix(void);
/**
* Updates the subscription of All Domain Backbone Routers Multicast Address.
*
* @param[in] aEvent The Domain Prefix event.
*/
void HandleDomainPrefixUpdate(DomainPrefixEvent aEvent);
/**
* Sets the Domain Prefix callback.
*
* @param[in] aCallback The callback function.
* @param[in] aContext A user context pointer.
*/
void SetDomainPrefixCallback(DomainPrefixCallback aCallback, void *aContext)
{
mDomainPrefixCallback.Set(aCallback, aContext);
}
private:
enum Action : uint8_t
{
@@ -271,33 +213,26 @@ private:
void UpdateState(void);
void RemoveService(void);
void HandleTimeTick(void);
void AddDomainPrefixToNetworkData(void);
void RemoveDomainPrefixFromNetworkData(void);
void IncrementSequenceNumber(void);
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
static const char *ActionToString(Action aAction);
void LogService(Action aAction, Error aError);
void LogDomainPrefix(Action aAction, Error aError);
#else
void LogService(Action, Error) {}
void LogDomainPrefix(Action, Error) {}
#endif
// Indicates whether or not already add Backbone Router Service to local server data.
// Used to check whether or not in restore stage after reset or whether to remove
// Backbone Router service for Secondary Backbone Router if it was added by force.
bool mIsServiceAdded;
State mState;
uint8_t mSequenceNumber;
uint8_t mRegistrationJitter;
uint16_t mReregistrationDelay;
uint16_t mRegistrationTimeout;
uint32_t mMlrTimeout;
NetworkData::OnMeshPrefixConfig mDomainPrefixConfig;
Ip6::Netif::UnicastAddress mBbrPrimaryAloc;
Ip6::Address mAllNetworkBackboneRouters;
Ip6::Address mAllDomainBackboneRouters;
Callback<DomainPrefixCallback> mDomainPrefixCallback;
bool mIsServiceAdded;
State mState;
uint8_t mSequenceNumber;
uint8_t mRegistrationJitter;
uint16_t mReregistrationDelay;
uint16_t mRegistrationTimeout;
uint32_t mMlrTimeout;
Ip6::Netif::UnicastAddress mBbrPrimaryAloc;
Ip6::Address mAllNetworkBackboneRouters;
};
} // namespace BackboneRouter
-1
View File
@@ -47,7 +47,6 @@
#include "common/locator.hpp"
#include "common/non_copyable.hpp"
#include "net/netif.hpp"
#include "thread/dua_manager.hpp"
#include "thread/mlr_types.hpp"
#include "thread/network_data.hpp"
#include "thread/tmf.hpp"
+4 -6
View File
@@ -284,16 +284,14 @@ bool FavoredOmrPrefix::IsInfrastructureDerived(void) const
void FavoredOmrPrefix::SetFrom(const NetworkData::OnMeshPrefixConfig &aOnMeshPrefixConfig)
{
mPrefix = aOnMeshPrefixConfig.GetPrefix();
mPreference = aOnMeshPrefixConfig.GetPreference();
mIsDomainPrefix = aOnMeshPrefixConfig.mDp;
mPrefix = aOnMeshPrefixConfig.GetPrefix();
mPreference = aOnMeshPrefixConfig.GetPreference();
}
void FavoredOmrPrefix::SetFrom(const OmrPrefix &aOmrPrefix)
{
mPrefix = aOmrPrefix.GetPrefix();
mPreference = aOmrPrefix.GetPreference();
mIsDomainPrefix = aOmrPrefix.IsDomainPrefix();
mPrefix = aOmrPrefix.GetPrefix();
mPreference = aOmrPrefix.GetPreference();
}
bool FavoredOmrPrefix::IsFavoredOver(const NetworkData::OnMeshPrefixConfig &aOmrPrefixConfig) const
-15
View File
@@ -569,20 +569,6 @@ public:
*/
RoutePreference GetPreference(void) const { return mPreference; }
/**
* Indicates whether the OMR prefix is a domain prefix.
*
* @retval TRUE If the OMR prefix is a domain prefix.
* @retval FALSE If the OMR prefix is not a domain prefix.
*/
bool IsDomainPrefix(void) const { return mIsDomainPrefix; }
/**
* Sets the OMR prefix and its preference.
*
* @param[in] aPrefix The IPv6 prefix to set.
* @param[in] aPreference The preference to set.
*/
void SetPrefix(const Ip6::Prefix &aPrefix, RoutePreference aPreference);
/**
@@ -599,7 +585,6 @@ public:
protected:
Ip6::Prefix mPrefix;
RoutePreference mPreference;
bool mIsDomainPrefix;
};
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+7 -7
View File
@@ -107,25 +107,25 @@ Error InfraIf::Send(const Icmp6Packet &aPacket, const Ip6::Address &aDestination
void InfraIf::HandledReceived(uint32_t aIfIndex, const Ip6::Address &aSource, const Icmp6Packet &aPacket)
{
Error error = kErrorNone;
const Ip6::Icmp::Header *icmp6Header;
Error error = kErrorNone;
const Ip6::Icmp6Header *icmp6Header;
VerifyOrExit(mInitialized && mIsRunning, error = kErrorInvalidState);
VerifyOrExit(aIfIndex == mIfIndex, error = kErrorDrop);
VerifyOrExit(aPacket.GetBytes() != nullptr, error = kErrorInvalidArgs);
VerifyOrExit(aPacket.GetLength() >= sizeof(Ip6::Icmp::Header), error = kErrorParse);
VerifyOrExit(aPacket.GetLength() >= sizeof(Ip6::Icmp6Header), error = kErrorParse);
icmp6Header = reinterpret_cast<const Ip6::Icmp::Header *>(aPacket.GetBytes());
icmp6Header = reinterpret_cast<const Ip6::Icmp6Header *>(aPacket.GetBytes());
switch (icmp6Header->GetType())
{
case Ip6::Icmp::Header::kTypeRouterAdvert:
case Ip6::Icmp6Header::kTypeRouterAdvert:
Get<RxRaTracker>().HandleRouterAdvertisement(aPacket, aSource);
break;
case Ip6::Icmp::Header::kTypeNeighborAdvert:
case Ip6::Icmp6Header::kTypeNeighborAdvert:
Get<RxRaTracker>().HandleNeighborAdvertisement(aPacket);
break;
case Ip6::Icmp::Header::kTypeRouterSolicit:
case Ip6::Icmp6Header::kTypeRouterSolicit:
Get<RoutingManager>().HandleRouterSolicit(aPacket, aSource);
break;
default:
+5 -15
View File
@@ -706,8 +706,8 @@ void RoutingManager::CheckReachabilityToSendIcmpError(const Message &aMessage, c
messageInfo.Clear();
messageInfo.SetPeerAddr(aIp6Header.GetSource());
IgnoreError(Get<Ip6::Icmp>().SendError(Ip6::Icmp::Header::kTypeDstUnreach,
Ip6::Icmp::Header::kCodeDstUnreachProhibited, messageInfo, aMessage));
IgnoreError(Get<Ip6::Icmp>().SendError(Ip6::Icmp6Header::kTypeDstUnreach,
Ip6::Icmp6Header::kCodeDstUnreachProhibited, messageInfo, aMessage));
exit:
return;
@@ -1169,11 +1169,6 @@ RoutingManager::OmrPrefixManager::InfoString RoutingManager::OmrPrefixManager::F
string.Append("%s (prf:%s", aFavoredPrefix.GetPrefix().ToString().AsCString(),
RoutePreferenceToString(aFavoredPrefix.GetPreference()));
if (aFavoredPrefix.IsDomainPrefix())
{
string.Append(", domain");
}
if (aFavoredPrefix.GetPrefix() == mLocalPrefix.GetPrefix())
{
string.Append(", local");
@@ -1909,7 +1904,7 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
// (2) Favored OMR prefix.
if (!omrPrefixManager.GetFavoredPrefix().IsEmpty() && !omrPrefixManager.GetFavoredPrefix().IsDomainPrefix())
if (!omrPrefixManager.GetFavoredPrefix().IsEmpty())
{
mPrefixes.Add(omrPrefixManager.GetFavoredPrefix().GetPrefix());
}
@@ -1928,11 +1923,6 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
// it, while it might still be present in the Network Data due to
// delays in registering changes with the leader.
if (prefixConfig.mDp)
{
continue;
}
if (IsValidOmrPrefix(prefixConfig) &&
(prefixConfig.GetPrefix() != omrPrefixManager.GetLocalPrefix().GetPrefix()))
{
@@ -1940,13 +1930,13 @@ Error RoutingManager::RioAdvertiser::AppendRios(RouterAdvert::TxMessage &aRaMess
}
}
// (4) All other on-mesh prefixes (excluding Domain Prefix).
// (4) All other on-mesh prefixes.
iterator = NetworkData::kIteratorInit;
while (Get<NetworkData::Leader>().GetNext(iterator, prefixConfig) == kErrorNone)
{
if (prefixConfig.mOnMesh && !prefixConfig.mDp && !IsValidOmrPrefix(prefixConfig))
if (prefixConfig.mOnMesh && !IsValidOmrPrefix(prefixConfig))
{
mPrefixes.Add(prefixConfig.GetPrefix());
}
-3
View File
@@ -143,9 +143,6 @@ void Notifier::EmitEvents(void)
#if OPENTHREAD_CONFIG_MLR_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)
Get<Mlr::Manager>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Get<DuaManager>().HandleNotifierEvents(events);
#endif
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
Get<Trel::Link>().HandleNotifierEvents(events);
#endif
+1 -14
View File
@@ -71,13 +71,6 @@ void SettingsBase::ChildInfo::Log(Action aAction) const
}
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
void SettingsBase::DadInfo::Log(Action aAction) const
{
LogInfo("%s DadInfo {DadCounter:%2d}", ActionToString(aAction), GetDadCounter());
}
#endif
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
void SettingsBase::LogPrefix(Action aAction, Key aKey, const Ip6::Prefix &aPrefix)
{
@@ -151,7 +144,7 @@ const char *SettingsBase::KeyToString(Key aKey)
_(kKeyChildInfo, "ChildInfo") \
_(6, "") \
_(kKeySlaacIidSecretKey, "SlaacIidSecretKey") \
_(kKeyDadInfo, "DadInfo") \
_(8, "") \
_(9, "") \
_(10, "") \
_(kKeySrpEcdsaKey, "SrpEcdsaKey") \
@@ -487,12 +480,6 @@ void Settings::Log(Action aAction, Error aError, Key aKey, const void *aValue)
break;
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
case kKeyDadInfo:
reinterpret_cast<const DadInfo *>(aValue)->Log(aAction);
break;
#endif
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
case kKeyBrUlaPrefix:
LogPrefix(aAction, aKey, *reinterpret_cast<const Ip6::Prefix *>(aValue));
-40
View File
@@ -112,7 +112,6 @@ public:
kKeyParentInfo = OT_SETTINGS_KEY_PARENT_INFO,
kKeyChildInfo = OT_SETTINGS_KEY_CHILD_INFO,
kKeySlaacIidSecretKey = OT_SETTINGS_KEY_SLAAC_IID_SECRET_KEY,
kKeyDadInfo = OT_SETTINGS_KEY_DAD_INFO,
kKeySrpEcdsaKey = OT_SETTINGS_KEY_SRP_ECDSA_KEY,
kKeySrpClientInfo = OT_SETTINGS_KEY_SRP_CLIENT_INFO,
kKeySrpServerInfo = OT_SETTINGS_KEY_SRP_SERVER_INFO,
@@ -486,45 +485,6 @@ public:
};
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
/**
* Represents the duplicate address detection information for settings storage.
*/
OT_TOOL_PACKED_BEGIN
class DadInfo : private Clearable<DadInfo>
{
friend class Settings;
friend class Clearable<DadInfo>;
public:
static constexpr Key kKey = kKeyDadInfo; ///< The associated key.
/**
* Initializes the `DadInfo` object.
*/
void Init(void) { Clear(); }
/**
* Returns the Dad Counter.
*
* @returns The Dad Counter value.
*/
uint8_t GetDadCounter(void) const { return mDadCounter; }
/**
* Sets the Dad Counter.
*
* @param[in] aDadCounter The Dad Counter value.
*/
void SetDadCounter(uint8_t aDadCounter) { mDadCounter = aDadCounter; }
private:
void Log(Action aAction) const;
uint8_t mDadCounter; ///< Dad Counter used to resolve address conflict in Thread 1.2 DUA feature.
} OT_TOOL_PACKED_END;
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
/**
* Defines constants and types for BR ULA prefix settings.
-7
View File
@@ -104,13 +104,6 @@ void TimeTicker::HandleTimer(void)
}
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
if (mReceivers & Mask(kDuaManager))
{
Get<DuaManager>().HandleTimeTick();
}
#endif
if (mReceivers & Mask(kIp6Mpl))
{
Get<Ip6::Mpl>().HandleTimeTick();
-1
View File
@@ -66,7 +66,6 @@ public:
kAddressResolver, ///< `AddressResolver`
kChildSupervisor, ///< `ChildSupervisor`
kIp6FragmentReassembler, ///< `Ip6::Ip6` (handling of fragmented messages)
kDuaManager, ///< `DuaManager`
kNetworkDataNotifier, ///< `NetworkData::Notifier`
kIp6Mpl, ///< `Ip6::Mpl`
kBbrLocal, ///< `BackboneRouter::Local`
-1
View File
@@ -66,7 +66,6 @@
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*
* A Border Router which provides IP connectivity and is acting as a REED is eligible to request a router role upgrade
* by sending an "Address Solicit" request to leader with status reason `BorderRouterRequest`. This reason is used when
-9
View File
@@ -524,15 +524,6 @@
#define OPENTHREAD_CONFIG_OTNS_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_DUA_ENABLE
*
* Define as 1 to support Thread 1.2 Domain Unicast Address feature.
*/
#ifndef OPENTHREAD_CONFIG_DUA_ENABLE
#define OPENTHREAD_CONFIG_DUA_ENABLE 0
#endif
/**
* @def OPENTHREAD_CONFIG_MLR_ENABLE
*
-14
View File
@@ -212,20 +212,6 @@
#define OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_SEND_RESPONSE 1
#endif
/**
* @def OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
*
* Define to 1 for Thread 1.2 FTD device to register DUA of its MTD children registered
* even if it doesn't enable DUA feature itself.
*/
#ifndef OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
#define OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
#endif
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE && OPENTHREAD_CONFIG_THREAD_VERSION < OT_THREAD_VERSION_1_2
#error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE"
#endif
/**
* @def OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
*
-4
View File
@@ -215,10 +215,6 @@ Instance::Instance(void)
#if OPENTHREAD_CONFIG_MLR_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE)
, mMlrManager(*this)
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
, mDuaManager(*this)
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
, mSrpServer(*this)
#if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
-9
View File
@@ -128,7 +128,6 @@
#include "thread/anycast_locator.hpp"
#include "thread/child_supervision.hpp"
#include "thread/discover_scanner.hpp"
#include "thread/dua_manager.hpp"
#include "thread/energy_scan_server.hpp"
#include "thread/key_manager.hpp"
#include "thread/link_metrics.hpp"
@@ -769,10 +768,6 @@ private:
Mlr::Manager mMlrManager;
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
DuaManager mDuaManager;
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
Srp::Server mSrpServer;
#if OPENTHREAD_CONFIG_SRP_SERVER_ADVERTISING_PROXY_ENABLE
@@ -1252,10 +1247,6 @@ template <> inline BackboneRouter::BackboneTmfAgent &Instance::Get(void)
template <> inline Mlr::Manager &Instance::Get(void) { return mMlrManager; }
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
template <> inline DuaManager &Instance::Get(void) { return mDuaManager; }
#endif
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
template <> inline LinkMetrics::Initiator &Instance::Get(void) { return mInitiator; }
#endif
+1 -1
View File
@@ -331,7 +331,7 @@ void Manager::HandleCommissionerPetitionAccepted(CoapDtlsSession &aSession, uint
mCommissionerSession = &aSession;
Get<Mle::Mle>().GetCommissionerAloc(aSessionId, mCommissionerAloc.GetAddress());
Get<Mle::Mle>().ComposeCommissionerAloc(aSessionId, mCommissionerAloc.GetAddress());
Get<ThreadNetif>().AddUnicastAddress(mCommissionerAloc);
IgnoreError(Get<Ip6::Udp>().AddReceiver(mCommissionerUdpReceiver));
+1 -1
View File
@@ -678,7 +678,7 @@ void Admitter::CommissionerPetitioner::AddAlocAndUdpReceiver(void)
{
Ip6::Address alocAddr;
Get<Mle::Mle>().GetCommissionerAloc(mSessionId, alocAddr);
Get<Mle::Mle>().ComposeCommissionerAloc(mSessionId, alocAddr);
if (Get<ThreadNetif>().HasUnicastAddress(mAloc))
{
+1 -1
View File
@@ -735,7 +735,7 @@ void Commissioner::HandleLeaderPetitionResponse(Coap::Msg *aMsg, Error aResult)
ExitNow();
}
Get<Mle::Mle>().GetCommissionerAloc(mSessionId, mCommissionerAloc.GetAddress());
Get<Mle::Mle>().ComposeCommissionerAloc(mSessionId, mCommissionerAloc.GetAddress());
Get<ThreadNetif>().AddUnicastAddress(mCommissionerAloc);
SetState(kStateActive);
+1 -1
View File
@@ -190,7 +190,7 @@ Error DatasetManager::HandleSetOrReplace(MgmtCommand aCommand, const Coap::Msg &
Ip6::Address destination;
SuccessOrExit(Get<NetworkData::Leader>().FindCommissioningSessionId(localSessionId));
Get<Mle::Mle>().GetCommissionerAloc(localSessionId, destination);
Get<Mle::Mle>().ComposeCommissionerAloc(localSessionId, destination);
Get<Leader>().SendDatasetChanged(destination);
}
+2 -2
View File
@@ -184,7 +184,7 @@ void Checksum::UpdateMessageChecksum(Message &aMessage,
break;
case Ip6::kProtoIcmp6:
headerOffset = Ip6::Icmp::Header::kChecksumFieldOffset;
headerOffset = Ip6::Icmp6Header::kChecksumFieldOffset;
break;
default:
@@ -219,7 +219,7 @@ void Checksum::UpdateMessageChecksum(Message &aMessage,
break;
case Ip4::kProtoIcmp:
headerOffset = Ip4::Icmp::Header::kChecksumFieldOffset;
headerOffset = Ip4::Icmp4Header::kChecksumFieldOffset;
break;
default:
+3
View File
@@ -639,6 +639,9 @@ Error Name::LabelIterator::ReadLabel(char *aLabelBuffer, uint8_t &aLabelLength,
aLabelBuffer[mLabelLength] = kNullChar;
aLabelLength = mLabelLength;
// Check that there is no `kNullChar` (`\0`) in the read label.
VerifyOrExit(StringLength(aLabelBuffer, mLabelLength) == mLabelLength, error = kErrorParse);
if (!aAllowDotCharInLabel)
{
VerifyOrExit(StringFind(aLabelBuffer, kLabelSeparatorChar) == nullptr, error = kErrorParse);
+8 -2
View File
@@ -74,7 +74,10 @@ exit:
return error;
}
Error Icmp::SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Message &aMessage)
Error Icmp::SendError(Icmp6Header::Type aType,
Icmp6Header::Code aCode,
const MessageInfo &aMessageInfo,
const Message &aMessage)
{
Error error;
Headers headers;
@@ -86,7 +89,10 @@ exit:
return error;
}
Error Icmp::SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Headers &aHeaders)
Error Icmp::SendError(Icmp6Header::Type aType,
Icmp6Header::Code aCode,
const MessageInfo &aMessageInfo,
const Headers &aHeaders)
{
Error error = kErrorNone;
MessageInfo messageInfoLocal;
+11 -5
View File
@@ -69,8 +69,6 @@ class Icmp : public InstanceLocator,
private NonCopyable
{
public:
typedef Icmp6Header Header; ///< ICMPv6 header
/**
* Implements ICMPv6 message handlers.
*/
@@ -93,7 +91,7 @@ public:
}
private:
void HandleReceiveMessage(Message &aMessage, const MessageInfo &aMessageInfo, const Header &aIcmp6Header)
void HandleReceiveMessage(Message &aMessage, const MessageInfo &aMessageInfo, const Icmp6Header &aIcmp6Header)
{
mReceiveCallback(mContext, &aMessage, &aMessageInfo, &aIcmp6Header);
}
@@ -150,7 +148,10 @@ public:
* @retval kErrorNone Successfully enqueued the ICMPv6 error message.
* @retval kErrorNoBufs Insufficient buffers available.
*/
Error SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Message &aMessage);
Error SendError(Icmp6Header::Type aType,
Icmp6Header::Code aCode,
const MessageInfo &aMessageInfo,
const Message &aMessage);
/**
* Sends an ICMPv6 error message.
@@ -163,7 +164,10 @@ public:
* @retval kErrorNone Successfully enqueued the ICMPv6 error message.
* @retval kErrorNoBufs Insufficient buffers available.
*/
Error SendError(Header::Type aType, Header::Code aCode, const MessageInfo &aMessageInfo, const Headers &aHeaders);
Error SendError(Icmp6Header::Type aType,
Icmp6Header::Code aCode,
const MessageInfo &aMessageInfo,
const Headers &aHeaders);
/**
* Handles an ICMPv6 message.
@@ -210,6 +214,8 @@ public:
uint16_t GetEchoSequence(void) const { return mEchoSequence; }
private:
typedef Icmp6Header Header;
Error HandleEchoRequest(Message &aRequestMessage, const MessageInfo &aMessageInfo);
LinkedList<Handler> mHandlers;
+105 -105
View File
@@ -563,124 +563,124 @@ private:
} OT_TOOL_PACKED_END;
/**
* Implements ICMP(v4).
* Note: ICMP(v4) messages will only be generated / handled by NAT64. So only header definition is required.
* Represents an ICMPv4 header.
*/
class Icmp
OT_TOOL_PACKED_BEGIN
class Icmp4Header : public Clearable<Icmp4Header>
{
public:
static constexpr uint16_t kChecksumFieldOffset = 2; ///< The byte offset of the Checksum field in the ICMPv4 header.
/**
* Represents an IPv4 ICMP header.
* ICMPv4 message types.
*
* Only the ICMPv4 types used with NAT64 are listed here.
*/
OT_TOOL_PACKED_BEGIN
class Header : public Clearable<Header>
enum Type : uint8_t
{
public:
static constexpr uint16_t kChecksumFieldOffset = 2;
// A few ICMP types, only the ICMP types work with NAT64 are listed here.
enum Type : uint8_t
{
kTypeEchoReply = 0,
kTypeDestinationUnreachable = 3,
kTypeEchoRequest = 8,
kTypeTimeExceeded = 11,
};
kTypeEchoReply = 0, ///< Echo Reply.
kTypeDestinationUnreachable = 3, ///< Destination Unreachable.
kTypeEchoRequest = 8, ///< Echo Request.
kTypeTimeExceeded = 11, ///< Time Exceeded.
};
enum Code : uint8_t
{
kCodeNone = 0,
// Destination Unreachable codes
kCodeNetworkUnreachable = 0,
kCodeHostUnreachable = 1,
kCodeProtocolUnreachable = 2,
kCodePortUnreachable = 3,
kCodeSourceRouteFailed = 5,
kCodeNetworkUnknown = 6,
kCodeHostUnknown = 7,
};
/**
* ICMPv4 message codes.
*/
enum Code : uint8_t
{
kCodeNone = 0, ///< None.
/**
* Returns the type of the ICMP message.
*
* @returns The type field of the ICMP message.
*/
uint8_t GetType(void) const { return mType; }
kCodeNetworkUnreachable = 0, ///< Network Unreachable.
kCodeHostUnreachable = 1, ///< Host Unreachable.
kCodeProtocolUnreachable = 2, ///< Protocol Unreachable.
kCodePortUnreachable = 3, ///< Port Unreachable.
kCodeSourceRouteFailed = 5, ///< Source Route Failed.
kCodeNetworkUnknown = 6, ///< Network Unknown.
kCodeHostUnknown = 7, ///< Host Unknown.
};
/**
* Sets the type of the ICMP message.
*
* @param[in] aType The type of the ICMP message.
*/
void SetType(uint8_t aType) { mType = aType; }
/**
* Returns the ICMPv4 message type.
*
* @returns The ICMPv4 message type.
*/
uint8_t GetType(void) const { return mType; }
/**
* Returns the code of the ICMP message.
*
* @returns The code field of the ICMP message.
*/
uint8_t GetCode(void) const { return mCode; }
/**
* Sets the ICMPv4 message type.
*
* @param[in] aType The ICMPv4 message type.
*/
void SetType(uint8_t aType) { mType = aType; }
/**
* Sets the code of the ICMP message.
*
* @param[in] aCode The code of the ICMP message.
*/
void SetCode(uint8_t aCode) { mCode = aCode; }
/**
* Returns the ICMPv4 message code.
*
* @returns The ICMPv4 message code.
*/
uint8_t GetCode(void) const { return mCode; }
/**
* Sets the checksum field in the ICMP message.
*
* @returns The checksum of the ICMP message.
*/
uint16_t GetChecksum(void) const { return BigEndian::HostSwap16(mChecksum); }
/**
* Sets the ICMPv4 message code.
*
* @param[in] aCode The ICMPv4 message code.
*/
void SetCode(uint8_t aCode) { mCode = aCode; }
/**
* Sets the checksum field in the ICMP message.
*
* @param[in] aChecksum The checksum of the ICMP message.
*/
void SetChecksum(uint16_t aChecksum) { mChecksum = BigEndian::HostSwap16(aChecksum); }
/**
* Returns the ICMPv4 message checksum.
*
* @returns The ICMPv4 message checksum.
*/
uint16_t GetChecksum(void) const { return BigEndian::HostSwap16(mChecksum); }
/**
* Returns the ICMPv4 message ID for Echo Requests and Replies.
*
* @returns The ICMPv4 message ID.
*/
uint16_t GetId(void) const { return BigEndian::HostSwap16(mData.m16[0]); }
/**
* Sets the ICMPv4 message checksum.
*
* @param[in] aChecksum The ICMPv4 message checksum.
*/
void SetChecksum(uint16_t aChecksum) { mChecksum = BigEndian::HostSwap16(aChecksum); }
/**
* Sets the ICMPv4 message ID for Echo Requests and Replies.
*
* @param[in] aId The ICMPv4 message ID.
*/
void SetId(uint16_t aId) { mData.m16[0] = BigEndian::HostSwap16(aId); }
/**
* Returns the ICMPv4 message ID for Echo Requests and Replies.
*
* @returns The ICMPv4 message ID.
*/
uint16_t GetId(void) const { return BigEndian::HostSwap16(mData.m16[0]); }
/**
* Returns the rest of header field in the ICMP message.
*
* @returns The rest of header field in the ICMP message. The returned buffer has 4 octets.
*/
const uint8_t *GetRestOfHeader(void) const { return mData.m8; }
/**
* Sets the ICMPv4 message ID for Echo Requests and Replies.
*
* @param[in] aId The ICMPv4 message ID.
*/
void SetId(uint16_t aId) { mData.m16[0] = BigEndian::HostSwap16(aId); }
/**
* Sets the rest of header field in the ICMP message.
*
* @param[in] aRestOfHeader The rest of header field in the ICMP message. The buffer should have 4 octets.
*/
void SetRestOfHeader(const uint8_t *aRestOfHeader) { memcpy(mData.m8, aRestOfHeader, sizeof(mData)); }
/**
* Returns the "Rest of Header" field in the ICMPv4 message.
*
* @returns The "Rest of Header" field in the ICMPv4 message. The returned buffer has 4 octets.
*/
const uint8_t *GetRestOfHeader(void) const { return mData.m8; }
private:
uint8_t mType;
uint8_t mCode;
uint16_t mChecksum;
union OT_TOOL_PACKED_FIELD
{
uint8_t m8[4];
uint16_t m16[2];
uint32_t m32[1];
} mData;
} OT_TOOL_PACKED_END;
};
/**
* Sets the "Rest of Header" field in the ICMPv4 message.
*
* @param[in] aRestOfHeader The "Rest of Header" field in the ICMPv4 message. The buffer should have 4 octets.
*/
void SetRestOfHeader(const uint8_t *aRestOfHeader) { memcpy(mData.m8, aRestOfHeader, sizeof(mData)); }
private:
uint8_t mType;
uint8_t mCode;
uint16_t mChecksum;
union OT_TOOL_PACKED_FIELD
{
uint8_t m8[4];
uint16_t m16[2];
uint32_t m32[1];
} mData;
} OT_TOOL_PACKED_END;
// Internet Protocol Numbers
static constexpr uint8_t kProtoTcp = Ip6::kProtoTcp; ///< Transmission Control Protocol
@@ -691,7 +691,7 @@ using TcpHeader = Ip6::TcpHeader; ///< TCP header (the same as in IPv6)
using UdpHeader = Ip6::UdpHeader; ///< UDP header (the same as in IPv6)
/**
* Represents parsed IPv4 header along with UDP/TCP/ICMP4 headers from a received message/frame.
* Represents parsed IPv4 header along with UDP/TCP/ICMPv4 headers from a received message/frame.
*/
class Headers : private Clearable<Headers>
{
@@ -799,7 +799,7 @@ public:
*
* @returns The ICMPv4 header.
*/
const Icmp::Header &GetIcmpHeader(void) const { return mHeader.mIcmp; }
const Icmp4Header &GetIcmpHeader(void) const { return mHeader.mIcmp; }
/**
* Returns the source port number if the header is UDP or TCP, or zero otherwise
@@ -833,9 +833,9 @@ private:
Header mIp4Header;
union
{
UdpHeader mUdp;
TcpHeader mTcp;
Icmp::Header mIcmp;
UdpHeader mUdp;
TcpHeader mTcp;
Icmp4Header mIcmp;
} mHeader;
};
+11 -17
View File
@@ -41,8 +41,8 @@ namespace Ip6 {
RegisterLogModule("Ip6");
const uint8_t Ip6::kForwardIcmpTypes[] = {
Icmp::Header::kTypeDstUnreach, Icmp::Header::kTypePacketToBig, Icmp::Header::kTypeTimeExceeded,
Icmp::Header::kTypeParameterProblem, Icmp::Header::kTypeEchoRequest, Icmp::Header::kTypeEchoReply,
Icmp6Header::kTypeDstUnreach, Icmp6Header::kTypePacketToBig, Icmp6Header::kTypeTimeExceeded,
Icmp6Header::kTypeParameterProblem, Icmp6Header::kTypeEchoRequest, Icmp6Header::kTypeEchoReply,
};
Ip6::Ip6(Instance &aInstance)
@@ -756,14 +756,14 @@ void Ip6::UpdateReassemblyList(void)
if (now - message.GetTimestamp() >= TimeMilli::SecToMsec(kReassemblyTimeout))
{
LogInfo("Reassembly timeout.");
SendIcmpError(message, Icmp::Header::kTypeTimeExceeded, Icmp::Header::kCodeFragmReasTimeEx);
SendIcmpError(message, Icmp6Header::kTypeTimeExceeded, Icmp6Header::kCodeFragmReasTimeEx);
mReassemblyList.DequeueAndFree(message);
}
}
}
void Ip6::SendIcmpError(Message &aMessage, Icmp::Header::Type aIcmpType, Icmp::Header::Code aIcmpCode)
void Ip6::SendIcmpError(Message &aMessage, Icmp6Header::Type aIcmpType, Icmp6Header::Code aIcmpCode)
{
Error error = kErrorNone;
Header header;
@@ -1011,10 +1011,10 @@ Error Ip6::PassToHost(OwnedPtr<Message> &aMessagePtr,
case kProtoIcmp6:
if (mIcmp.ShouldHandleEchoRequest(aHeader.GetDestination()))
{
Icmp::Header icmp;
Icmp6Header icmp;
IgnoreError(aMessagePtr->Read(aMessagePtr->GetOffset(), icmp));
VerifyOrExit(icmp.GetType() != Icmp::Header::kTypeEchoRequest, error = kErrorDrop);
VerifyOrExit(icmp.GetType() != Icmp6Header::kTypeEchoRequest, error = kErrorDrop);
}
break;
@@ -1102,18 +1102,12 @@ Error Ip6::SendRaw(OwnedPtr<Message> aMessagePtr)
ExitNow(error = kErrorDrop);
}
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
// The filtering rules don't apply to packets from DUA.
if (!Get<BackboneRouter::Leader>().IsDomainUnicast(header.GetSource()))
#endif
// When the packet is forwarded from host to Thread, if its source is on-mesh or its destination is
// mesh-local, we'll drop the packet unless the packet originates from this device.
if (Get<NetworkData::Leader>().IsOnMesh(header.GetSource()) ||
Get<Mle::Mle>().IsMeshLocalAddress(header.GetDestination()))
{
// When the packet is forwarded from host to Thread, if its source is on-mesh or its destination is
// mesh-local, we'll drop the packet unless the packet originates from this device.
if (Get<NetworkData::Leader>().IsOnMesh(header.GetSource()) ||
Get<Mle::Mle>().IsMeshLocalAddress(header.GetDestination()))
{
VerifyOrExit(Get<ThreadNetif>().HasUnicastAddress(header.GetSource()), error = kErrorDrop);
}
VerifyOrExit(Get<ThreadNetif>().HasUnicastAddress(header.GetSource()), error = kErrorDrop);
}
if (header.GetDestination().IsMulticast())
+8 -5
View File
@@ -87,6 +87,9 @@ namespace Ip6 {
* @defgroup core-ip6-mpl MPL
* @defgroup core-ip6-netif Network Interfaces
* @defgroup core-ip6-slaac SLAAC
* @defgroup core-tcp TCP
* @defgroup core-tcp-ext TCP Extension
* @defgroup core-udp UDP
*
* @}
*/
@@ -357,7 +360,7 @@ private:
void CleanupFragmentationBuffer(void);
void HandleTimeTick(void);
void UpdateReassemblyList(void);
void SendIcmpError(Message &aMessage, Icmp::Header::Type aIcmpType, Icmp::Header::Code aIcmpCode);
void SendIcmpError(Message &aMessage, Icmp6Header::Type aIcmpType, Icmp6Header::Code aIcmpCode);
#endif
Error ReadHopByHopHeader(const Message &aMessage, OffsetRange &aOffsetRange, HopByHopHeader &aHbhHeader) const;
Error AddMplOption(Message &aMessage, Header &aHeader);
@@ -543,7 +546,7 @@ public:
*
* @returns The ICMPv6 header.
*/
const Icmp::Header &GetIcmpHeader(void) const { return mHeader.mIcmp; }
const Icmp6Header &GetIcmpHeader(void) const { return mHeader.mIcmp; }
/**
* Returns the source port number if header is UDP or TCP, or zero otherwise
@@ -577,9 +580,9 @@ private:
Header mIp6Header;
union
{
UdpHeader mUdp;
TcpHeader mTcp;
Icmp::Header mIcmp;
UdpHeader mUdp;
TcpHeader mTcp;
Icmp6Header mIcmp;
} mHeader;
};
+11 -11
View File
@@ -622,9 +622,9 @@ exit:
Error Translator::TranslateIcmp4(Message &aMessage, uint16_t aOriginalId)
{
Error error = kErrorNone;
Ip4::Icmp::Header icmp4Header;
Ip6::Icmp::Header icmp6Header;
Error error = kErrorNone;
Ip4::Icmp4Header icmp4Header;
Ip6::Icmp6Header icmp6Header;
// TODO: Implement the translation of other ICMP messages.
@@ -634,12 +634,12 @@ Error Translator::TranslateIcmp4(Message &aMessage, uint16_t aOriginalId)
switch (icmp4Header.GetType())
{
case Ip4::Icmp::Header::Type::kTypeEchoReply:
case Ip4::Icmp4Header::Type::kTypeEchoReply:
// The only difference between ICMPv6 echo and ICMP4 echo is
// the message type field, so we can reinterpret it as ICMP6
// header and set the message type.
SuccessOrExit(error = aMessage.Read(0, icmp6Header));
icmp6Header.SetType(Ip6::Icmp::Header::kTypeEchoReply);
icmp6Header.SetType(Ip6::Icmp6Header::kTypeEchoReply);
icmp6Header.SetId(aOriginalId);
aMessage.Write(0, icmp6Header);
break;
@@ -655,9 +655,9 @@ exit:
Error Translator::TranslateIcmp6(Message &aMessage, uint16_t aTranslatedId)
{
Error error = kErrorNone;
Ip4::Icmp::Header icmp4Header;
Ip6::Icmp::Header icmp6Header;
Error error = kErrorNone;
Ip4::Icmp4Header icmp4Header;
Ip6::Icmp6Header icmp6Header;
// TODO: Implement the translation of other ICMP messages.
@@ -667,12 +667,12 @@ Error Translator::TranslateIcmp6(Message &aMessage, uint16_t aTranslatedId)
switch (icmp6Header.GetType())
{
case Ip6::Icmp::Header::kTypeEchoRequest:
case Ip6::Icmp6Header::kTypeEchoRequest:
// The only difference between ICMPv6 echo and ICMP4 echo is
// the message type field, so we can reinterpret it as ICMP6
// the message type field, so we can reinterpret it as ICMP4
// header and set the message type.
SuccessOrExit(error = aMessage.Read(0, icmp4Header));
icmp4Header.SetType(Ip4::Icmp::Header::Type::kTypeEchoRequest);
icmp4Header.SetType(Ip4::Icmp4Header::Type::kTypeEchoRequest);
icmp4Header.SetId(aTranslatedId);
aMessage.Write(0, icmp4Header);
break;
+4 -4
View File
@@ -275,7 +275,7 @@ void RouterAdvert::Header::SetToDefault(void)
OT_UNUSED_VARIABLE(mRetransTimer);
Clear();
mType = Icmp::Header::kTypeRouterAdvert;
mType = Icmp6Header::kTypeRouterAdvert;
}
RoutePreference RouterAdvert::Header::GetDefaultRouterPreference(void) const
@@ -443,7 +443,7 @@ exit:
RouterSolicitHeader::RouterSolicitHeader(void)
{
mHeader.Clear();
mHeader.SetType(Icmp::Header::kTypeRouterSolicit);
mHeader.SetType(Icmp6Header::kTypeRouterSolicit);
}
//----------------------------------------------------------------------------------------------------------------------
@@ -455,7 +455,7 @@ NeighborSolicitHeader::NeighborSolicitHeader(void)
OT_UNUSED_VARIABLE(mReserved);
Clear();
mType = Icmp::Header::kTypeNeighborSolicit;
mType = Icmp6Header::kTypeNeighborSolicit;
}
//----------------------------------------------------------------------------------------------------------------------
@@ -467,7 +467,7 @@ NeighborAdvertMessage::NeighborAdvertMessage(void)
OT_UNUSED_VARIABLE(mReserved);
Clear();
mType = Icmp::Header::kTypeNeighborAdvert;
mType = Icmp6Header::kTypeNeighborAdvert;
}
} // namespace Nd
+6 -6
View File
@@ -832,7 +832,7 @@ public:
* @retval TRUE The header is valid.
* @retval FALSE The header is not valid.
*/
bool IsValid(void) const { return GetType() == Icmp::Header::kTypeRouterAdvert; }
bool IsValid(void) const { return GetType() == Icmp6Header::kTypeRouterAdvert; }
/**
* Sets the RA message to default values.
@@ -920,7 +920,7 @@ public:
*
* @returns The ICMPv6 message type.
*/
Icmp::Header::Type GetType(void) const { return static_cast<Icmp::Header::Type>(mType); }
Icmp6Header::Type GetType(void) const { return static_cast<Icmp6Header::Type>(mType); }
private:
// Router Advertisement Message
@@ -989,7 +989,7 @@ public:
bool IsValid(void) const
{
return (mData.GetBytes() != nullptr) && (mData.GetLength() >= sizeof(Header)) &&
(GetHeader().GetType() == Icmp::Header::kTypeRouterAdvert);
(GetHeader().GetType() == Icmp6Header::kTypeRouterAdvert);
}
/**
@@ -1125,7 +1125,7 @@ public:
RouterSolicitHeader(void);
private:
Icmp::Header mHeader; // The common ICMPv6 header.
Icmp6Header mHeader; // The common ICMPv6 header.
} OT_TOOL_PACKED_END;
static_assert(sizeof(RouterSolicitHeader) == 8, "invalid RouterSolicitHeader structure");
@@ -1147,7 +1147,7 @@ public:
* @retval TRUE If the message header is valid.
* @retval FALSE If the message header is not valid.
*/
bool IsValid(void) const { return (mType == Icmp::Header::kTypeNeighborSolicit) && (mCode == 0); }
bool IsValid(void) const { return (mType == Icmp6Header::kTypeNeighborSolicit) && (mCode == 0); }
/**
* Gets the Target Address field.
@@ -1208,7 +1208,7 @@ public:
* @retval TRUE If the message is valid.
* @retval FALSE If the message is not valid.
*/
bool IsValid(void) const { return (mType == Icmp::Header::kTypeNeighborAdvert) && (mCode == 0); }
bool IsValid(void) const { return (mType == Icmp6Header::kTypeNeighborAdvert) && (mCode == 0); }
/**
* Indicates whether or not the Router Flag is set in the NA message.
+1 -1
View File
@@ -118,7 +118,7 @@ Error Slaac::FindDomainIdFor(const Address &aAddress, uint8_t &aDomainId) const
bool Slaac::IsSlaac(const NetworkData::OnMeshPrefixConfig &aConfig) const
{
return aConfig.mSlaac && !aConfig.mDp && (aConfig.GetPrefix().GetLength() == NetworkPrefix::kLength);
return aConfig.mSlaac && (aConfig.GetPrefix().GetLength() == NetworkPrefix::kLength);
}
bool Slaac::IsFiltered(const NetworkData::OnMeshPrefixConfig &aConfig) const
+4
View File
@@ -36,6 +36,8 @@
#include "openthread-core-config.h"
#if OPENTHREAD_CONFIG_TCP_ENABLE
#include <openthread/tcp.h>
#include "common/as_core_type.hpp"
@@ -592,4 +594,6 @@ DefineCoreType(otTcpListener, Ip6::Tcp::Listener);
} // namespace ot
#endif // OPENTHREAD_CONFIG_TCP_ENABLE
#endif // OT_CORE_NET_TCP6_HPP_
+4
View File
@@ -36,6 +36,8 @@
#include "openthread-core-config.h"
#if OPENTHREAD_CONFIG_TCP_ENABLE
#include <openthread/tcp_ext.h>
#include "net/tcp6.hpp"
@@ -130,4 +132,6 @@ DefineCoreType(otTcpCircularSendBuffer, Ip6::TcpCircularSendBuffer);
} // namespace ot
#endif // OPENTHREAD_CONFIG_TCP_ENABLE
#endif // OT_CORE_NET_TCP6_EXT_HPP_
+6 -16
View File
@@ -754,17 +754,7 @@ template <> void AddressResolver::HandleTmf<kUriAddressError>(Coap::Msg &aMsg)
if (address.GetAddress() == target && Get<Mle::Mle>().GetMeshLocalEid().GetIid() != meshLocalIid)
{
// Target EID matches address and Mesh Local EID differs
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (Get<BackboneRouter::Leader>().IsDomainUnicast(address.GetAddress()))
{
Get<DuaManager>().NotifyDuplicateDomainUnicastAddress();
}
else
#endif
{
Get<ThreadNetif>().RemoveUnicastAddress(address);
}
Get<ThreadNetif>().RemoveUnicastAddress(address);
ExitNow();
}
}
@@ -995,16 +985,16 @@ void AddressResolver::HandleIcmpReceive(void *aContext,
AsCoreType(aIcmpHeader));
}
void AddressResolver::HandleIcmpReceive(Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp::Header &aIcmpHeader)
void AddressResolver::HandleIcmpReceive(Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp6Header &aIcmpHeader)
{
OT_UNUSED_VARIABLE(aMessageInfo);
Ip6::Header ip6Header;
VerifyOrExit(aIcmpHeader.GetType() == Ip6::Icmp::Header::kTypeDstUnreach);
VerifyOrExit(aIcmpHeader.GetCode() == Ip6::Icmp::Header::kCodeDstUnreachNoRoute);
VerifyOrExit(aIcmpHeader.GetType() == Ip6::Icmp6Header::kTypeDstUnreach);
VerifyOrExit(aIcmpHeader.GetCode() == Ip6::Icmp6Header::kCodeDstUnreachNoRoute);
SuccessOrExit(aMessage.Read(aMessage.GetOffset(), ip6Header));
Remove(ip6Header.GetDestination(), kReasonReceivedIcmpDstUnreachNoRoute);
+3 -3
View File
@@ -366,9 +366,9 @@ private:
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otIcmp6Header *aIcmpHeader);
void HandleIcmpReceive(Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp::Header &aIcmpHeader);
void HandleIcmpReceive(Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp6Header &aIcmpHeader);
void HandleTimeTick(void);
void LogCacheEntryChange(EntryChange aChange,
-20
View File
@@ -228,26 +228,6 @@ exit:
return hasAddress;
}
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
Error Child::GetDomainUnicastAddress(Ip6::Address &aAddress) const
{
Error error = kErrorNotFound;
for (const Ip6::Address &ip6Address : mIp6Addresses)
{
if (Get<BackboneRouter::Leader>().IsDomainUnicast(ip6Address))
{
aAddress = ip6Address;
error = kErrorNone;
ExitNow();
}
}
exit:
return error;
}
#endif
#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
bool Child::HasMlrRegisteredAddress(const Ip6::Address &aAddress) const
-12
View File
@@ -186,18 +186,6 @@ public:
*/
bool HasIp6Address(const Ip6::Address &aAddress) const;
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
/**
* Retrieves the Domain Unicast Address registered by the child.
*
* @param[out] aAddress A reference to return the DUA address.
*
* @retval kErrorNone Successfully retrieved the DUA address, @p aAddress is updated.
* @retval kErrorNotFound Could not find any DUA address.
*/
Error GetDomainUnicastAddress(Ip6::Address &aAddress) const;
#endif
/**
* Gets the child timeout.
*
-748
View File
@@ -1,748 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file implements managing DUA.
*/
#include "dua_manager.hpp"
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
#include "instance/instance.hpp"
namespace ot {
RegisterLogModule("DuaManager");
DuaManager::DuaManager(Instance &aInstance)
: InstanceLocator(aInstance)
, mRegistrationTask(aInstance)
, mIsDuaPending(false)
#if OPENTHREAD_CONFIG_DUA_ENABLE
, mDuaState(kNotExist)
, mDadCounter(0)
, mLastRegistrationTime(0)
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
, mChildIndexDuaRegistering(Mle::kMaxChildren)
#endif
{
mDelay.mValue = 0;
#if OPENTHREAD_CONFIG_DUA_ENABLE
mDomainUnicastAddress.InitAsThreadOriginGlobalScope();
mFixedDuaInterfaceIdentifier.Clear();
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
mChildDuaMask.Clear();
mChildDuaRegisteredMask.Clear();
#endif
}
void DuaManager::HandleDomainPrefixUpdate(BackboneRouter::DomainPrefixEvent aEvent)
{
if ((aEvent == BackboneRouter::kDomainPrefixRemoved) || (aEvent == BackboneRouter::kDomainPrefixRefreshed))
{
if (mIsDuaPending)
{
IgnoreError(Get<Tmf::Agent>().AbortTransaction(HandleDuaResponse, this));
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
RemoveDomainUnicastAddress();
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
if (!mChildDuaMask.IsEmpty())
{
mChildDuaMask.Clear();
mChildDuaRegisteredMask.Clear();
}
#endif
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
switch (aEvent)
{
case BackboneRouter::kDomainPrefixRefreshed:
case BackboneRouter::kDomainPrefixAdded:
{
const Ip6::Prefix *prefix = Get<BackboneRouter::Leader>().GetDomainPrefix();
OT_ASSERT(prefix != nullptr);
mDomainUnicastAddress.mPrefixLength = prefix->GetLength();
mDomainUnicastAddress.GetAddress().Clear();
mDomainUnicastAddress.GetAddress().SetPrefix(*prefix);
}
break;
case BackboneRouter::kDomainPrefixRemoved:
ExitNow();
}
// Apply cached DUA Interface Identifier manually specified.
if (IsFixedDuaInterfaceIdentifierSet())
{
mDomainUnicastAddress.GetAddress().SetIid(mFixedDuaInterfaceIdentifier);
}
else
{
SuccessOrExit(GenerateDomainUnicastAddressIid());
}
AddDomainUnicastAddress();
exit:
return;
#endif
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
Error DuaManager::GenerateDomainUnicastAddressIid(void)
{
Error error;
uint8_t dadCounter = mDadCounter;
if ((error = Get<Ip6::Slaac>().GenerateIid(mDomainUnicastAddress, dadCounter)) == kErrorNone)
{
if (dadCounter != mDadCounter)
{
mDadCounter = dadCounter;
Store();
}
LogInfo("Generated DUA: %s", mDomainUnicastAddress.GetAddress().ToString().AsCString());
}
else
{
LogWarnOnError(error, "generate DUA");
}
return error;
}
Error DuaManager::SetFixedDuaInterfaceIdentifier(const Ip6::InterfaceIdentifier &aIid)
{
Error error = kErrorNone;
VerifyOrExit(!aIid.IsReserved(), error = kErrorInvalidArgs);
VerifyOrExit(mFixedDuaInterfaceIdentifier.IsUnspecified() || mFixedDuaInterfaceIdentifier != aIid);
mFixedDuaInterfaceIdentifier = aIid;
LogInfo("Set DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
if (Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
{
RemoveDomainUnicastAddress();
mDomainUnicastAddress.GetAddress().SetIid(mFixedDuaInterfaceIdentifier);
AddDomainUnicastAddress();
}
exit:
return error;
}
void DuaManager::ClearFixedDuaInterfaceIdentifier(void)
{
// Nothing to clear.
VerifyOrExit(IsFixedDuaInterfaceIdentifierSet());
if (GetDomainUnicastAddress().GetIid() == mFixedDuaInterfaceIdentifier &&
Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
{
RemoveDomainUnicastAddress();
if (GenerateDomainUnicastAddressIid() == kErrorNone)
{
AddDomainUnicastAddress();
}
}
LogInfo("Cleared DUA IID: %s", mFixedDuaInterfaceIdentifier.ToString().AsCString());
mFixedDuaInterfaceIdentifier.Clear();
exit:
return;
}
void DuaManager::Restore(void)
{
Settings::DadInfo dadInfo;
SuccessOrExit(Get<Settings>().Read(dadInfo));
mDadCounter = dadInfo.GetDadCounter();
exit:
return;
}
void DuaManager::Store(void)
{
Settings::DadInfo dadInfo;
dadInfo.SetDadCounter(mDadCounter);
Get<Settings>().Save(dadInfo);
}
void DuaManager::AddDomainUnicastAddress(void)
{
mDuaState = kToRegister;
mLastRegistrationTime = TimerMilli::GetNow();
Get<ThreadNetif>().AddUnicastAddress(mDomainUnicastAddress);
}
void DuaManager::RemoveDomainUnicastAddress(void)
{
if (mDuaState == kRegistering && mIsDuaPending)
{
IgnoreError(Get<Tmf::Agent>().AbortTransaction(HandleDuaResponse, this));
}
mDuaState = kNotExist;
mDomainUnicastAddress.mPreferred = false;
Get<ThreadNetif>().RemoveUnicastAddress(mDomainUnicastAddress);
}
void DuaManager::UpdateRegistrationDelay(uint8_t aDelay)
{
if (mDelay.mFields.mRegistrationDelay == 0 || mDelay.mFields.mRegistrationDelay > aDelay)
{
mDelay.mFields.mRegistrationDelay = aDelay;
LogDebg("update regdelay %d", mDelay.mFields.mRegistrationDelay);
UpdateTimeTickerRegistration();
}
}
void DuaManager::NotifyDuplicateDomainUnicastAddress(void)
{
RemoveDomainUnicastAddress();
mDadCounter++;
if (GenerateDomainUnicastAddressIid() == kErrorNone)
{
AddDomainUnicastAddress();
}
}
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
void DuaManager::UpdateReregistrationDelay(void)
{
uint16_t delay;
VerifyOrExit(Get<BackboneRouter::Leader>().HasPrimary());
delay = Get<BackboneRouter::Leader>().GetConfig().SelectRandomReregistrationDelay();
if (mDelay.mFields.mReregistrationDelay == 0 || mDelay.mFields.mReregistrationDelay > delay)
{
mDelay.mFields.mReregistrationDelay = delay;
UpdateTimeTickerRegistration();
LogDebg("update reregdelay %d", mDelay.mFields.mReregistrationDelay);
}
exit:
return;
}
void DuaManager::UpdateCheckDelay(uint8_t aDelay)
{
if (mDelay.mFields.mCheckDelay == 0 || mDelay.mFields.mCheckDelay > aDelay)
{
mDelay.mFields.mCheckDelay = aDelay;
LogDebg("update checkdelay %d", mDelay.mFields.mCheckDelay);
UpdateTimeTickerRegistration();
}
}
void DuaManager::HandleNotifierEvents(Events aEvents)
{
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (aEvents.Contains(kEventThreadNetdataChanged) && Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
{
Lowpan::Context context;
Get<NetworkData::Leader>().FindContextForAddress(GetDomainUnicastAddress(), context);
if (!context.IsValid())
{
RemoveDomainUnicastAddress();
}
}
#endif
VerifyOrExit(Get<Mle::Mle>().IsAttached(), mDelay.mValue = 0);
if (aEvents.Contains(kEventThreadRoleChanged))
{
if (Get<Mle::Mle>().HasRestored())
{
UpdateReregistrationDelay();
}
#if OPENTHREAD_CONFIG_DUA_ENABLE && OPENTHREAD_FTD
else if (Get<Mle::Mle>().IsRouter())
{
// Wait for link establishment with neighboring routers.
UpdateRegistrationDelay(kNewRouterRegistrationDelay);
}
else if (Get<Mle::Mle>().WillBecomeRouterSoon())
{
// Will check again in case the device decides to stay REED when jitter timeout expires.
UpdateRegistrationDelay(Get<Mle::Mle>().GetRouterRoleTransitionTimeout() + kNewRouterRegistrationDelay + 1);
}
#endif
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (aEvents.ContainsAny(kEventIp6AddressAdded))
{
UpdateRegistrationDelay(kNewDuaRegistrationDelay);
}
#endif
exit:
return;
}
void DuaManager::HandleBackboneRouterPrimaryUpdate(BackboneRouter::PrimaryEvent aEvent)
{
if (aEvent == BackboneRouter::kPrimaryAdded || aEvent == BackboneRouter::kPrimaryUpdatedReregister)
{
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (Get<Mle::Mle>().IsFullThreadDevice() || Get<Mle::Mle>().GetParent().IsThreadVersion1p1())
#endif
{
UpdateReregistrationDelay();
}
}
}
void DuaManager::HandleTimeTick(void)
{
bool attempt = false;
#if OPENTHREAD_CONFIG_DUA_ENABLE
LogDebg("regdelay %d, reregdelay %d, checkdelay %d", mDelay.mFields.mRegistrationDelay,
mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
if ((mDuaState != kNotExist) &&
(TimerMilli::GetNow() > (mLastRegistrationTime + TimeMilli::SecToMsec(kDuaDadPeriod))))
{
mDomainUnicastAddress.mPreferred = true;
}
if ((mDelay.mFields.mRegistrationDelay > 0) && (--mDelay.mFields.mRegistrationDelay == 0))
{
attempt = true;
}
#else
LogDebg("reregdelay %d, checkdelay %d", mDelay.mFields.mReregistrationDelay, mDelay.mFields.mCheckDelay);
#endif
if ((mDelay.mFields.mCheckDelay > 0) && (--mDelay.mFields.mCheckDelay == 0))
{
attempt = true;
}
if ((mDelay.mFields.mReregistrationDelay > 0) && (--mDelay.mFields.mReregistrationDelay == 0))
{
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (mDuaState != kNotExist)
{
mDuaState = kToRegister;
}
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
mChildDuaRegisteredMask.Clear();
#endif
attempt = true;
}
if (attempt)
{
mRegistrationTask.Post();
}
UpdateTimeTickerRegistration();
}
void DuaManager::UpdateTimeTickerRegistration(void)
{
if (mDelay.mValue == 0)
{
Get<TimeTicker>().UnregisterReceiver(TimeTicker::kDuaManager);
}
else
{
Get<TimeTicker>().RegisterReceiver(TimeTicker::kDuaManager);
}
}
void DuaManager::PerformNextRegistration(void)
{
Error error = kErrorNone;
Coap::Message *message = nullptr;
Ip6::Address dua;
Ip6::Address destAddr;
VerifyOrExit(Get<Mle::Mle>().IsAttached());
VerifyOrExit(Get<BackboneRouter::Leader>().HasPrimary());
// Only allow one outgoing DUA.req
VerifyOrExit(!mIsDuaPending);
// Only send DUA.req when necessary
#if OPENTHREAD_CONFIG_DUA_ENABLE
#if OPENTHREAD_FTD
if (!Get<Mle::Mle>().IsRouterOrLeader() && Get<Mle::Mle>().WillBecomeRouterSoon())
{
UpdateRegistrationDelay(Get<Mle::Mle>().GetRouterRoleTransitionTimeout() + kNewRouterRegistrationDelay + 1);
ExitNow();
}
#endif
VerifyOrExit(Get<Mle::Mle>().IsFullThreadDevice() || Get<Mle::Mle>().GetParent().IsThreadVersion1p1());
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
{
bool needReg = false;
#if OPENTHREAD_CONFIG_DUA_ENABLE
needReg = (mDuaState == kToRegister && mDelay.mFields.mRegistrationDelay == 0);
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
needReg = needReg || (!mChildDuaMask.IsEmpty() && mChildDuaMask != mChildDuaRegisteredMask);
#endif
VerifyOrExit(needReg);
}
// Prepare DUA.req
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriDuaRegistrationRequest);
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (mDuaState == kToRegister && mDelay.mFields.mRegistrationDelay == 0)
{
dua = GetDomainUnicastAddress();
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, dua));
SuccessOrExit(error = Tlv::Append<ThreadMeshLocalEidTlv>(*message, Get<Mle::Mle>().GetMeshLocalEid().GetIid()));
mDuaState = kRegistering;
mLastRegistrationTime = TimerMilli::GetNow();
}
else
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
{
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
uint32_t lastTransactionTime;
Child *child = nullptr;
OT_ASSERT(mChildIndexDuaRegistering == Mle::kMaxChildren);
for (Child &iter : Get<ChildTable>().Iterate(Child::kInStateValid))
{
uint16_t childIndex = Get<ChildTable>().GetChildIndex(iter);
if (mChildDuaMask.Has(childIndex) && !mChildDuaRegisteredMask.Has(childIndex))
{
mChildIndexDuaRegistering = childIndex;
break;
}
}
child = Get<ChildTable>().GetChildAtIndex(mChildIndexDuaRegistering);
SuccessOrAssert(child->GetDomainUnicastAddress(dua));
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, dua));
SuccessOrExit(error = Tlv::Append<ThreadMeshLocalEidTlv>(*message, child->GetMeshLocalIid()));
lastTransactionTime = Time::MsecToSec(TimerMilli::GetNow() - child->GetLastHeard());
SuccessOrExit(error = Tlv::Append<ThreadLastTransactionTimeTlv>(*message, lastTransactionTime));
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
}
if (!Get<Mle::Mle>().IsFullThreadDevice() && Get<Mle::Mle>().GetParent().IsThreadVersion1p1())
{
uint8_t pbbrServiceId;
SuccessOrExit(error = Get<BackboneRouter::Leader>().GetServiceId(pbbrServiceId));
Get<Mle::Mle>().GetServiceAloc(pbbrServiceId, destAddr);
}
else
{
destAddr.InitAsRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(),
Get<BackboneRouter::Leader>().GetServer16());
}
SuccessOrExit(error = Get<Tmf::Agent>().SendMessageTo(*message, destAddr, HandleDuaResponse, this));
mIsDuaPending = true;
mRegisteringDua = dua;
mDelay.mValue = 0;
// Generally Thread 1.2 Router would send DUA.req on behalf for DUA registered by its MTD child.
// When Thread 1.2 MTD attaches to Thread 1.1 parent, 1.2 MTD should send DUA.req to PBBR itself.
// In this case, Thread 1.2 sleepy end device relies on fast data poll to fetch the response timely.
if (!Get<Mle::Mle>().IsRxOnWhenIdle())
{
Get<DataPollSender>().SendFastPolls();
}
LogInfo("Sent %s for DUA %s", UriToString<kUriDuaRegistrationRequest>(), dua.ToString().AsCString());
exit:
if (error == kErrorNoBufs)
{
UpdateCheckDelay(kNoBufDelay);
}
LogWarnOnError(error, "perform next registration");
FreeMessageOnError(message, error);
}
void DuaManager::HandleDuaResponse(Coap::Msg *aMsg, Error aResult)
{
Error error;
mIsDuaPending = false;
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
mChildIndexDuaRegistering = Mle::kMaxChildren;
#endif
if (aResult == kErrorResponseTimeout)
{
UpdateCheckDelay(KResponseTimeoutDelay);
ExitNow(error = aResult);
}
VerifyOrExit(aResult == kErrorNone, error = kErrorParse);
OT_ASSERT(aMsg != nullptr);
VerifyOrExit(aMsg->GetCode() == Coap::kCodeChanged || aMsg->GetCode() >= Coap::kCodeBadRequest,
error = kErrorParse);
error = ProcessDuaResponse(aMsg->mMessage);
exit:
if (error != kErrorResponseTimeout)
{
mRegistrationTask.Post();
}
LogInfo("Received %s response: %s", UriToString<kUriDuaRegistrationRequest>(), ErrorToString(error));
}
template <> void DuaManager::HandleTmf<kUriDuaRegistrationNotify>(Coap::Msg &aMsg)
{
Error error;
if (aMsg.IsConfirmable() && Get<Tmf::Agent>().SendAckResponse(aMsg) == kErrorNone)
{
LogInfo("Sent %s ack", UriToString<kUriDuaRegistrationNotify>());
}
error = ProcessDuaResponse(aMsg.mMessage);
OT_UNUSED_VARIABLE(error);
LogInfo("Received %s: %s", UriToString<kUriDuaRegistrationNotify>(), ErrorToString(error));
}
Error DuaManager::ProcessDuaResponse(Coap::Message &aMessage)
{
Error error = kErrorNone;
Ip6::Address target;
uint8_t status;
if (aMessage.ReadCode() >= Coap::kCodeBadRequest)
{
status = kDuaGeneralFailure;
target = mRegisteringDua;
}
else
{
SuccessOrExit(error = Tlv::Find<ThreadStatusTlv>(aMessage, status));
SuccessOrExit(error = Tlv::Find<ThreadTargetTlv>(aMessage, target));
}
VerifyOrExit(Get<BackboneRouter::Leader>().IsDomainUnicast(target), error = kErrorDrop);
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (Get<ThreadNetif>().HasUnicastAddress(target))
{
switch (static_cast<DuaStatus>(status))
{
case kDuaSuccess:
mLastRegistrationTime = TimerMilli::GetNow();
mDuaState = kRegistered;
break;
case kDuaReRegister:
if (Get<ThreadNetif>().HasUnicastAddress(GetDomainUnicastAddress()))
{
RemoveDomainUnicastAddress();
AddDomainUnicastAddress();
}
break;
case kDuaInvalid:
// Domain Prefix might be invalid.
RemoveDomainUnicastAddress();
break;
case kDuaDuplicate:
NotifyDuplicateDomainUnicastAddress();
break;
case kDuaNoResources:
case kDuaNotPrimary:
case kDuaGeneralFailure:
UpdateReregistrationDelay();
break;
}
}
else
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
{
Child *child = nullptr;
uint16_t childIndex;
for (Child &iter : Get<ChildTable>().Iterate(Child::kInStateValid))
{
if (iter.HasIp6Address(target))
{
child = &iter;
break;
}
}
VerifyOrExit(child != nullptr, error = kErrorNotFound);
childIndex = Get<ChildTable>().GetChildIndex(*child);
switch (status)
{
case kDuaSuccess:
// Mark as Registered
if (mChildDuaMask.Has(childIndex))
{
mChildDuaRegisteredMask.Add(childIndex);
}
break;
case kDuaReRegister:
// Parent stops registering for the Child's DUA until next Child Update Request
mChildDuaMask.Remove(childIndex);
mChildDuaRegisteredMask.Remove(childIndex);
break;
case kDuaInvalid:
case kDuaDuplicate:
IgnoreError(child->RemoveIp6Address(target));
mChildDuaMask.Remove(childIndex);
mChildDuaRegisteredMask.Remove(childIndex);
break;
case kDuaNoResources:
case kDuaNotPrimary:
case kDuaGeneralFailure:
UpdateReregistrationDelay();
break;
}
if (status != kDuaSuccess)
{
SendAddressNotification(target, static_cast<DuaStatus>(status), *child);
}
}
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
exit:
UpdateTimeTickerRegistration();
return error;
}
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
void DuaManager::SendAddressNotification(Ip6::Address &aAddress, DuaStatus aStatus, const Child &aChild)
{
Coap::Message *message = nullptr;
Error error;
message = Get<Tmf::Agent>().AllocateAndInitPriorityConfirmablePostMessage(kUriDuaRegistrationNotify);
VerifyOrExit(message != nullptr, error = kErrorNoBufs);
SuccessOrExit(error = Tlv::Append<ThreadStatusTlv>(*message, aStatus));
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, aAddress));
SuccessOrExit(error = Get<Tmf::Agent>().SendMessageToRloc(*message, aChild.GetRloc16()));
LogInfo("Sent %s for child %04x DUA %s", UriToString<kUriDuaRegistrationNotify>(), aChild.GetRloc16(),
aAddress.ToString().AsCString());
exit:
if (error != kErrorNone)
{
FreeMessage(message);
// TODO: (DUA) (P4) may enhance to guarantee the delivery of DUA.ntf
LogWarn("Sent %s for child %04x DUA %s Error %s", UriToString<kUriDuaRegistrationNotify>(), aChild.GetRloc16(),
aAddress.ToString().AsCString(), ErrorToString(error));
}
}
void DuaManager::HandleChildDuaAddressEvent(const Child &aChild, ChildDuaAddressEvent aEvent)
{
uint16_t childIndex = Get<ChildTable>().GetChildIndex(aChild);
if ((aEvent == kAddressRemoved || aEvent == kAddressChanged) && mChildDuaMask.Has(childIndex))
{
// Abort on going proxy DUA.req for this child
if (mChildIndexDuaRegistering == childIndex)
{
IgnoreError(Get<Tmf::Agent>().AbortTransaction(HandleDuaResponse, this));
}
mChildDuaMask.Remove(childIndex);
mChildDuaRegisteredMask.Remove(childIndex);
}
if (aEvent == kAddressAdded || aEvent == kAddressChanged ||
(aEvent == kAddressUnchanged && !mChildDuaMask.Has(childIndex)))
{
if (mChildDuaMask == mChildDuaRegisteredMask)
{
UpdateCheckDelay(
Random::NonCrypto::GenerateInClosedRange<uint8_t>(1, BackboneRouter::kParentAggregateDelay));
}
mChildDuaMask.Add(childIndex);
mChildDuaRegisteredMask.Remove(childIndex);
}
}
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
} // namespace ot
#endif // OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
-281
View File
@@ -1,281 +0,0 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* This file includes definitions for managing Domain Unicast Address feature defined in Thread 1.2.
*/
#ifndef OT_CORE_THREAD_DUA_MANAGER_HPP_
#define OT_CORE_THREAD_DUA_MANAGER_HPP_
#include "openthread-core-config.h"
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
#if OPENTHREAD_CONFIG_DUA_ENABLE && (OPENTHREAD_CONFIG_THREAD_VERSION < OT_THREAD_VERSION_1_2)
#error "Thread 1.2 or higher version is required for OPENTHREAD_CONFIG_DUA_ENABLE"
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE && !OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
#error "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE is required for OPENTHREAD_CONFIG_DUA_ENABLE"
#endif
#include "backbone_router/bbr_leader.hpp"
#include "coap/coap_message.hpp"
#include "common/locator.hpp"
#include "common/non_copyable.hpp"
#include "common/notifier.hpp"
#include "common/tasklet.hpp"
#include "common/time.hpp"
#include "common/time_ticker.hpp"
#include "common/timer.hpp"
#include "net/netif.hpp"
#include "thread/child.hpp"
#include "thread/thread_tlvs.hpp"
#include "thread/tmf.hpp"
namespace ot {
/**
* @addtogroup core-dua
*
* @brief
* This module includes definitions for generating, managing, registering Domain Unicast Address.
*
* @{
*
* @defgroup core-dua Dua
*
* @}
*/
/**
* Domain Unicast Address (DUA) Registration Status values
*/
enum DuaStatus : uint8_t
{
kDuaSuccess = 0, ///< Successful registration.
kDuaReRegister = 1, ///< Registration was accepted but immediate reregistration is required to solve.
kDuaInvalid = 2, ///< Registration rejected (Fatal): Target EID is not a valid DUA.
kDuaDuplicate = 3, ///< Registration rejected (Fatal): DUA is already in use by another device.
kDuaNoResources = 4, ///< Registration rejected (Non-fatal): Backbone Router Resource shortage.
kDuaNotPrimary = 5, ///< Registration rejected (Non-fatal): Backbone Router is not primary at this moment.
kDuaGeneralFailure = 6, ///< Registration failure (Non-fatal): Reason(s) not further specified.
};
/**
* Implements managing DUA.
*/
class DuaManager : public InstanceLocator, private NonCopyable
{
friend class ot::Notifier;
friend class ot::TimeTicker;
friend class Tmf::Agent;
public:
/**
* Initializes the object.
*
* @param[in] aInstance A reference to the OpenThread instance.
*/
explicit DuaManager(Instance &aInstance);
/**
* Notifies Domain Prefix changes.
*
* @param[in] aEvent The Domain Prefix event.
*/
void HandleDomainPrefixUpdate(BackboneRouter::DomainPrefixEvent aEvent);
/**
* Notifies the `DuaManager` of a Primary Backbone Router event.
*
* @param[in] aEvent The Primary Backbone Router event.
*/
void HandleBackboneRouterPrimaryUpdate(BackboneRouter::PrimaryEvent aEvent);
#if OPENTHREAD_CONFIG_DUA_ENABLE
/**
* Returns a reference to the Domain Unicast Address.
*
* @returns A reference to the Domain Unicast Address.
*/
const Ip6::Address &GetDomainUnicastAddress(void) const { return mDomainUnicastAddress.GetAddress(); }
/**
* Sets the Interface Identifier manually specified for the Thread Domain Unicast Address.
*
* @param[in] aIid A reference to the Interface Identifier to set.
*
* @retval kErrorNone Successfully set the Interface Identifier.
* @retval kErrorInvalidArgs The specified Interface Identifier is reserved.
*/
Error SetFixedDuaInterfaceIdentifier(const Ip6::InterfaceIdentifier &aIid);
/**
* Clears the Interface Identifier manually specified for the Thread Domain Unicast Address.
*/
void ClearFixedDuaInterfaceIdentifier(void);
/**
* Indicates whether or not there is Interface Identifier manually specified for the Thread
* Domain Unicast Address.
*
* @retval true If there is Interface Identifier manually specified.
* @retval false If there is no Interface Identifier manually specified.
*/
bool IsFixedDuaInterfaceIdentifierSet(void) { return !mFixedDuaInterfaceIdentifier.IsUnspecified(); }
/**
* Gets the Interface Identifier for the Thread Domain Unicast Address if manually specified.
*
* @returns A reference to the Interface Identifier.
*/
const Ip6::InterfaceIdentifier &GetFixedDuaInterfaceIdentifier(void) const { return mFixedDuaInterfaceIdentifier; }
/*
* Restores duplicate address detection information from non-volatile memory.
*/
void Restore(void);
/**
* Notifies duplicated Domain Unicast Address.
*/
void NotifyDuplicateDomainUnicastAddress(void);
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
/**
* Events related to a Child DUA address.
*/
enum ChildDuaAddressEvent : uint8_t
{
kAddressAdded, ///< A new DUA registered by the Child via Address Registration.
kAddressChanged, ///< A different DUA registered by the Child via Address Registration.
kAddressRemoved, ///< DUA registered by the Child is removed and not in Address Registration.
kAddressUnchanged, ///< The Child registers the same DUA again.
};
/**
* Handles Child DUA address event.
*
* @param[in] aChild A child.
* @param[in] aEvent The DUA address event for @p aChild.
*/
void HandleChildDuaAddressEvent(const Child &aChild, ChildDuaAddressEvent aEvent);
#endif
private:
static constexpr uint32_t kDuaDadPeriod = 100; // DAD wait time to become "Preferred" (in sec).
static constexpr uint8_t kNoBufDelay = 5; // In sec.
static constexpr uint8_t KResponseTimeoutDelay = 30; // In sec.
static constexpr uint8_t kNewRouterRegistrationDelay = 3; // Delay (in sec) to establish link for a new router.
static constexpr uint8_t kNewDuaRegistrationDelay = 1; // Delay (in sec) for newly added DUA.
#if OPENTHREAD_CONFIG_DUA_ENABLE
Error GenerateDomainUnicastAddressIid(void);
void Store(void);
void AddDomainUnicastAddress(void);
void RemoveDomainUnicastAddress(void);
void UpdateRegistrationDelay(uint8_t aDelay);
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
void SendAddressNotification(Ip6::Address &aAddress, DuaStatus aStatus, const Child &aChild);
#endif
void HandleNotifierEvents(Events aEvents);
void HandleTimeTick(void);
void UpdateTimeTickerRegistration(void);
DeclareTmfResponseHandlerIn(DuaManager, HandleDuaResponse);
template <Uri kUri> void HandleTmf(Coap::Msg &aMsg);
Error ProcessDuaResponse(Coap::Message &aMessage);
void PerformNextRegistration(void);
void UpdateReregistrationDelay(void);
void UpdateCheckDelay(uint8_t aDelay);
using RegistrationTask = TaskletIn<DuaManager, &DuaManager::PerformNextRegistration>;
RegistrationTask mRegistrationTask;
Ip6::Address mRegisteringDua;
bool mIsDuaPending : 1;
#if OPENTHREAD_CONFIG_DUA_ENABLE
enum DuaState : uint8_t
{
kNotExist, ///< DUA is not available.
kToRegister, ///< DUA is to be registered.
kRegistering, ///< DUA is being registered.
kRegistered, ///< DUA is registered.
};
DuaState mDuaState;
uint8_t mDadCounter;
TimeMilli mLastRegistrationTime; // The time (in milliseconds) when sent last DUA.req or received DUA.rsp.
Ip6::InterfaceIdentifier mFixedDuaInterfaceIdentifier;
Ip6::Netif::UnicastAddress mDomainUnicastAddress;
#endif
union
{
struct
{
uint16_t mReregistrationDelay; // Delay (in seconds) for DUA re-registration.
uint8_t mCheckDelay; // Delay (in seconds) for checking whether or not registration is required.
#if OPENTHREAD_CONFIG_DUA_ENABLE
uint8_t mRegistrationDelay; // Delay (in seconds) for DUA registration.
#endif
} mFields;
uint32_t mValue; // Non-zero indicates timer should start.
} mDelay;
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
// TODO: (DUA) may re-evaluate the alternative option of distributing the flags into the child table:
// - Child class itself have some padding - may save some RAM
// - Avoid cross reference between a bit-vector and the child entry
ChildMask mChildDuaMask; // Child Mask for child who registers DUA via Child Update Request.
ChildMask mChildDuaRegisteredMask; // Child Mask for child's DUA that was registered by the parent on behalf.
uint16_t mChildIndexDuaRegistering; // Child Index of the DUA being registered.
#endif
};
DeclareTmfHandler(DuaManager, kUriDuaRegistrationNotify);
} // namespace ot
#endif // OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
#endif // OT_CORE_THREAD_DUA_MANAGER_HPP_
+2 -24
View File
@@ -165,28 +165,6 @@ void MeshForwarder::HandleResolved(const Ip6::Address &aEid, Error aError)
continue;
}
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
// Pass back to IPv6 layer for DUA destination resolved
// by Backbone Query
if (Get<BackboneRouter::Local>().IsPrimary() && Get<BackboneRouter::Leader>().IsDomainUnicast(ip6Dst) &&
Get<Mle::Mle>().HasRloc16(Get<AddressResolver>().LookUp(ip6Dst)))
{
uint8_t hopLimit;
mSendQueue.Dequeue(message);
// Avoid decreasing Hop Limit twice
IgnoreError(message.Read(Ip6::Header::kHopLimitFieldOffset, hopLimit));
hopLimit++;
message.Write(Ip6::Header::kHopLimitFieldOffset, hopLimit);
message.SetLoopbackToHostAllowed(true);
message.SetOrigin(Message::kOriginHostTrusted);
IgnoreError(Get<Ip6::Ip6>().HandleDatagram(OwnedPtr<Message>(&message)));
continue;
}
#endif
message.SetResolvingAddress(false);
didUpdate = true;
}
@@ -560,8 +538,8 @@ void MeshForwarder::SendDestinationUnreachable(uint16_t aMeshSource, const Ip6::
messageInfo.GetPeerAddr().InitAsRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aMeshSource);
IgnoreError(Get<Ip6::Icmp>().SendError(Ip6::Icmp::Header::kTypeDstUnreach,
Ip6::Icmp::Header::kCodeDstUnreachNoRoute, messageInfo, aIp6Headers));
IgnoreError(Get<Ip6::Icmp>().SendError(Ip6::Icmp6Header::kTypeDstUnreach, Ip6::Icmp6Header::kCodeDstUnreachNoRoute,
messageInfo, aIp6Headers));
}
void MeshForwarder::HandleMesh(RxInfo &aRxInfo)
+4 -23
View File
@@ -356,10 +356,6 @@ void Mle::Restore(void)
IgnoreError(Get<MeshCoP::ActiveDatasetManager>().Restore());
IgnoreError(Get<MeshCoP::PendingDatasetManager>().Restore());
#if OPENTHREAD_CONFIG_DUA_ENABLE
Get<DuaManager>().Restore();
#endif
SuccessOrExit(Get<Settings>().Read(networkInfo));
Get<KeyManager>().SetCurrentKeySequence(networkInfo.GetKeySequence(),
@@ -891,22 +887,22 @@ void Mle::SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLead
mLeaderData.SetLeaderRouterId(aLeaderRouterId);
}
void Mle::GetLeaderRloc(Ip6::Address &aAddress) const
void Mle::ComposeLeaderRloc(Ip6::Address &aAddress) const
{
aAddress.InitAsRoutingLocator(mMeshLocalPrefix, GetLeaderRloc16());
}
void Mle::GetLeaderAloc(Ip6::Address &aAddress) const
void Mle::ComposeLeaderAloc(Ip6::Address &aAddress) const
{
aAddress.InitAsAnycastLocator(mMeshLocalPrefix, Aloc16::ForLeader());
}
void Mle::GetCommissionerAloc(uint16_t aSessionId, Ip6::Address &aAddress) const
void Mle::ComposeCommissionerAloc(uint16_t aSessionId, Ip6::Address &aAddress) const
{
aAddress.InitAsAnycastLocator(mMeshLocalPrefix, Aloc16::FromCommissionerSessionId(aSessionId));
}
void Mle::GetServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const
void Mle::ComposeServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const
{
aAddress.InitAsAnycastLocator(mMeshLocalPrefix, Aloc16::FromServiceId(aServiceId));
}
@@ -3670,14 +3666,6 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode
// Continue to append the other addresses if not `kAppendMeshLocalOnly` mode
VerifyOrExit(aMode != kAppendMeshLocalOnly);
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (Get<ThreadNetif>().HasUnicastAddress(Get<DuaManager>().GetDomainUnicastAddress()))
{
// Prioritize DUA, compressed entry
SuccessOrExit(error = AppendAddressRegistrationEntry(Get<DuaManager>().GetDomainUnicastAddress()));
}
#endif
for (const Ip6::Netif::UnicastAddress &addr : Get<ThreadNetif>().GetUnicastAddresses())
{
if (!Get<Mle>().ShouldRegisterUnicastAddrWithParent(addr))
@@ -3690,13 +3678,6 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode
continue;
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
if (addr.GetAddress() == Get<DuaManager>().GetDomainUnicastAddress())
{
continue;
}
#endif
SuccessOrExit(error = AppendAddressRegistrationEntry(addr.GetAddress()));
}
+11 -15
View File
@@ -566,34 +566,34 @@ public:
uint16_t GetLeaderRloc16(void) const { return Rloc16FromRouterId(GetLeaderId()); }
/**
* Retrieves the Leader's RLOC.
* Composes the Leader's RLOC.
*
* @param[out] aAddress A reference to an address to return the Leader's RLOC.
*/
void GetLeaderRloc(Ip6::Address &aAddress) const;
void ComposeLeaderRloc(Ip6::Address &aAddress) const;
/**
* Retrieves the Leader's ALOC.
* Composes the Leader's ALOC.
*
* @param[out] aAddress A reference to an address to return the Leader's ALOC.
*/
void GetLeaderAloc(Ip6::Address &aAddress) const;
void ComposeLeaderAloc(Ip6::Address &aAddress) const;
/**
* Retrieves the Commissioner's ALOC for a given session ID.
* Composes the Commissioner's ALOC for a given session ID.
*
* @param[in] aSessionId Commissioner session id.
* @param[in] aSessionId Commissioner session ID.
* @param[out] aAddress A reference to an address to return the Commissioner's ALOC.
*/
void GetCommissionerAloc(uint16_t aSessionId, Ip6::Address &aAddress) const;
void ComposeCommissionerAloc(uint16_t aSessionId, Ip6::Address &aAddress) const;
/**
* Retrieves the Service ALOC for given Service ID.
* Composes the Service ALOC for a given Service ID.
*
* @param[in] aServiceId Service ID to get ALOC for.
* @param[out] aAddress A reference to an address to return the Service ALOC.
* @param[in] aServiceId Service ID to compose ALOC for.
* @param[out] aAddress A reference to an address to return the Service ALOC.
*/
void GetServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const;
void ComposeServiceAloc(uint8_t aServiceId, Ip6::Address &aAddress) const;
/**
* Returns the most recently received Leader Data.
@@ -2485,10 +2485,6 @@ private:
DeclareTmfResponseHandlerIn(Mle, HandleAddressSolicitResponse);
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
void SignalDuaAddressEvent(const Child &aChild, const Ip6::Address &aOldDua) const;
#endif
static bool IsMessageMleSubType(const Message &aMessage);
static bool IsMessageChildUpdateRequest(const Message &aMessage);
static void HandleAdvertiseTrickleTimer(TrickleTimer &aTimer);
+29 -61
View File
@@ -456,7 +456,7 @@ void Mle::SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, LeaderStart
if (aRole == kRoleLeader)
{
GetLeaderAloc(mLeaderAloc.GetAddress());
ComposeLeaderAloc(mLeaderAloc.GetAddress());
Get<ThreadNetif>().AddUnicastAddress(mLeaderAloc);
Get<NetworkData::Leader>().Start(aStartMode);
Get<MeshCoP::ActiveDatasetManager>().StartLeader();
@@ -903,6 +903,7 @@ void Mle::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
LeaderData leaderData;
uint8_t linkMargin;
bool shouldUpdateRoutes = false;
Mac::ExtAddress extAddress;
SuccessOrExit(error = Tlv::Find<SourceAddressTlv>(aRxInfo.mMessage, sourceAddress));
@@ -928,6 +929,8 @@ void Mle::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
break;
case Neighbor::kStateValid:
extAddress.SetFromIid(aRxInfo.mMessageInfo.GetPeerAddr().GetIid());
VerifyOrExit(router->GetExtAddress() == extAddress, error = kErrorSecurity);
break;
default:
@@ -1042,20 +1045,32 @@ void Mle::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
OT_ASSERT(false);
}
InitNeighbor(*router, aRxInfo);
router->SetRloc16(sourceAddress);
router->GetLinkFrameCounters().SetAll(linkFrameCounter);
router->SetLinkAckFrameCounter(linkFrameCounter);
router->SetMleFrameCounter(mleFrameCounter);
router->SetVersion(version);
router->SetDeviceMode(DeviceMode(DeviceMode::kModeFullThreadDevice | DeviceMode::kModeRxOnWhenIdle |
DeviceMode::kModeFullNetworkData));
if (neighborState != Neighbor::kStateValid)
{
InitNeighbor(*router, aRxInfo);
router->SetRloc16(sourceAddress);
router->GetLinkFrameCounters().SetAll(linkFrameCounter);
router->SetLinkAckFrameCounter(linkFrameCounter);
router->SetMleFrameCounter(mleFrameCounter);
router->SetDeviceMode(DeviceMode(DeviceMode::kModeFullThreadDevice | DeviceMode::kModeRxOnWhenIdle |
DeviceMode::kModeFullNetworkData));
router->SetKeySequence(aRxInfo.mKeySequence);
router->SetState(Neighbor::kStateValid);
}
else
{
router->GetLinkInfo().AddRss(aRxInfo.mMessage.GetAverageRss());
router->SetLastHeard(TimerMilli::GetNow());
}
router->SetLinkQualityOut(LinkQualityForLinkMargin(linkMargin));
router->SetState(Neighbor::kStateValid);
router->SetKeySequence(aRxInfo.mKeySequence);
router->SetVersion(version);
router->ClearLinkAcceptTimeout();
mNeighborTable.Signal(NeighborTable::kRouterAdded, *router);
if (neighborState != Neighbor::kStateValid)
{
mNeighborTable.Signal(NeighborTable::kRouterAdded, *router);
}
mDelayedSender.RemoveScheduledLinkRequest(*router);
@@ -1826,9 +1841,6 @@ Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
OffsetRange offsetRange;
uint8_t count = 0;
uint8_t storedCount = 0;
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
Ip6::Address oldDua;
#endif
#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
Child::Ip6AddressArray oldMlrRegisteredAddresses;
#endif
@@ -1837,13 +1849,6 @@ Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
SuccessOrExit(error = Tlv::FindTlvValueOffsetRange(aRxInfo.mMessage, Tlv::kAddressRegistration, offsetRange));
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
if (aChild.GetDomainUnicastAddress(oldDua) != kErrorNone)
{
oldDua.Clear();
}
#endif
#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
aChild.GetAllMlrRegisteredAddresses(oldMlrRegisteredAddresses);
#endif
@@ -1932,9 +1937,6 @@ Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
// Clear EID-to-RLOC cache for the unicast address registered by the child.
Get<AddressResolver>().RemoveEntryForAddress(address);
}
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
SignalDuaAddressEvent(aChild, oldDua);
#endif
#if OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
Get<Mlr::Manager>().UpdateChildRegistrations(aChild, oldMlrRegisteredAddresses);
@@ -1956,40 +1958,6 @@ exit:
return error;
}
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
void Mle::SignalDuaAddressEvent(const Child &aChild, const Ip6::Address &aOldDua) const
{
DuaManager::ChildDuaAddressEvent event = DuaManager::kAddressUnchanged;
Ip6::Address newDua;
if (aChild.GetDomainUnicastAddress(newDua) == kErrorNone)
{
if (aOldDua.IsUnspecified())
{
event = DuaManager::kAddressAdded;
}
else if (aOldDua != newDua)
{
event = DuaManager::kAddressChanged;
}
}
else
{
// Child has no DUA address. If there was no old DUA, no need
// to signal.
VerifyOrExit(!aOldDua.IsUnspecified());
event = DuaManager::kAddressRemoved;
}
Get<DuaManager>().HandleChildDuaAddressEvent(aChild, event);
exit:
return;
}
#endif // OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
bool Mle::IsMessageMleSubType(const Message &aMessage) { return aMessage.IsSubTypeMle(); }
bool Mle::IsMessageChildUpdateRequest(const Message &aMessage)
@@ -3232,7 +3200,7 @@ Error Mle::SendAddressSolicit(RouterUpgradeReason aReason)
SuccessOrExit(error = Tlv::Append<XtalAccuracyTlv>(*message, otPlatTimeGetXtalAccuracy()));
#endif
GetLeaderRloc(leaderRloc);
ComposeLeaderRloc(leaderRloc);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessageTo(*message, leaderRloc, HandleAddressSolicitResponse, this));
mAddressSolicitPending = true;
@@ -3256,7 +3224,7 @@ void Mle::SendAddressRelease(void)
SuccessOrExit(error = Tlv::Append<ThreadRloc16Tlv>(*message, Rloc16FromRouterId(mRouterId)));
SuccessOrExit(error = Tlv::Append<ThreadExtMacAddressTlv>(*message, Get<Mac::Mac>().GetExtAddress()));
GetLeaderRloc(leaderRloc);
ComposeLeaderRloc(leaderRloc);
SuccessOrExit(error = Get<Tmf::Agent>().SendMessageTo(*message, leaderRloc));
+1 -1
View File
@@ -528,7 +528,7 @@ Error Manager::SendMessage(const Ip6::Address *aAddresses,
uint8_t pbbrServiceId;
SuccessOrExit(error = Get<BackboneRouter::Leader>().GetServiceId(pbbrServiceId));
Get<Mle::Mle>().GetServiceAloc(pbbrServiceId, destAddr);
Get<Mle::Mle>().ComposeServiceAloc(pbbrServiceId, destAddr);
}
else
{
-4
View File
@@ -323,10 +323,6 @@ void NeighborTable::Signal(Event aEvent, const Neighbor &aNeighbor)
case kChildRemoved:
Get<Notifier>().Signal(kEventThreadChildRemoved);
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
Get<DuaManager>().HandleChildDuaAddressEvent(static_cast<const Child &>(aNeighbor),
DuaManager::kAddressRemoved);
#endif
break;
#if OPENTHREAD_FTD
+1 -1
View File
@@ -514,7 +514,7 @@ void NetworkData::FindRlocs(BorderRouterFilter aBrFilter, RoleFilter aRoleFilter
case kAnyBrOrServer:
break;
case kBrProvidingExternalIpConn:
matches = prefix.mOnMesh && (prefix.mDefaultRoute || prefix.mDp);
matches = prefix.mOnMesh && prefix.mDefaultRoute;
break;
}
-3
View File
@@ -274,7 +274,6 @@ public:
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*
* Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the
* full set and not the stable subset).
@@ -292,7 +291,6 @@ public:
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*
* Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the
* full set and not the stable subset).
@@ -311,7 +309,6 @@ public:
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*
* Should be used when the RLOC16s are present in the Network Data (when the Network Data contains the
* full set and not the stable subset).
@@ -105,7 +105,6 @@ public:
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*
* Does not check the current role of device.
*
+1 -1
View File
@@ -83,7 +83,7 @@ Error Iterator::GetNextDnsSrpAnycastInfo(DnsSrpAnycastInfo &aInfo)
const Manager::DnsSrpAnycastServiceData *anycastData =
reinterpret_cast<const Manager::DnsSrpAnycastServiceData *>(mServiceTlv->GetServiceData());
Get<Mle::Mle>().GetServiceAloc(mServiceTlv->GetServiceId(), aInfo.mAnycastAddress);
Get<Mle::Mle>().ComposeServiceAloc(mServiceTlv->GetServiceId(), aInfo.mAnycastAddress);
aInfo.mSequenceNumber = anycastData->GetSequenceNumber();
aInfo.mRloc16 = mServerSubTlv->GetServer16();
aInfo.mVersion =
+1 -9
View File
@@ -945,14 +945,6 @@ public:
*/
bool IsNdDns(void) const { return (BigEndian::HostSwap16(mFlags) & kNdDnsFlag) != 0; }
/**
* Indicates whether or not the Domain Prefix flag is set.
*
* @retval TRUE If the Domain Prefix flag is set.
* @retval FALSE If the Domain Prefix flag is not set.
*/
bool IsDp(void) const { return (BigEndian::HostSwap16(mFlags) & kDpFlag) != 0; }
/**
* Returns a pointer to the next BorderRouterEntry
*
@@ -999,7 +991,7 @@ private:
static constexpr uint16_t kDefaultRouteFlag = 1 << 9;
static constexpr uint16_t kOnMeshFlag = 1 << 8;
static constexpr uint16_t kNdDnsFlag = 1 << 7;
static constexpr uint16_t kDpFlag = 1 << 6;
// Flag bit 6 (1 << 6) was previously kDpFlag (Domain Prefix)
uint16_t mRloc;
uint16_t mFlags;
+1 -8
View File
@@ -116,13 +116,6 @@ uint16_t OnMeshPrefixConfig::ConvertToTlvFlags(void) const
flags |= BorderRouterEntry::kNdDnsFlag;
}
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
if (mDp)
{
flags |= BorderRouterEntry::kDpFlag;
}
#endif
flags |= (static_cast<uint16_t>(RoutePreferenceToValue(mPreference)) << BorderRouterEntry::kPreferenceOffset);
return flags;
@@ -151,7 +144,7 @@ void OnMeshPrefixConfig::SetFromTlvFlags(uint16_t aFlags)
mDefaultRoute = ((aFlags & BorderRouterEntry::kDefaultRouteFlag) != 0);
mOnMesh = ((aFlags & BorderRouterEntry::kOnMeshFlag) != 0);
mNdDns = ((aFlags & BorderRouterEntry::kNdDnsFlag) != 0);
mDp = ((aFlags & BorderRouterEntry::kDpFlag) != 0);
mDp = false;
mPreference = RoutePreferenceFromValue(static_cast<uint8_t>(aFlags >> BorderRouterEntry::kPreferenceOffset));
}
-1
View File
@@ -112,7 +112,6 @@ enum RoleFilter : uint8_t
*
* - It has added at least one external route entry.
* - It has added at least one prefix entry with default-route and on-mesh flags set.
* - It has added at least one domain prefix (domain and on-mesh flags set).
*/
enum BorderRouterFilter : uint8_t
{
+1 -5
View File
@@ -123,10 +123,6 @@ bool Agent::HandleResource(const char *aUriPath, Msg &aMsg)
Case(kUriRelayRx, Agent);
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE || (OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE)
Case(kUriDuaRegistrationNotify, DuaManager);
#endif
#if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
Case(kUriAnycastLocate, AnycastLocator);
#endif
@@ -263,7 +259,7 @@ Error Agent::SendMessageToLeaderAloc(Message &aMessage, ResponseHandler aHandler
{
Ip6::MessageInfo messageInfo;
Get<Mle::Mle>().GetLeaderAloc(messageInfo.GetPeerAddr());
Get<Mle::Mle>().ComposeLeaderAloc(messageInfo.GetPeerAddr());
PrepareMessageInfo(messageInfo);
return SendMessage(aMessage, messageInfo, aHandler, aContext);
-2
View File
@@ -95,8 +95,6 @@ struct Entry
_("d/dr", kUriDiagnosticReset, "DiagReset") \
_("h/an", kUriHistoryAnswer, "HistAnswer") \
_("h/qy", kUriHistoryQuery, "HistQuery") \
_("n/dn", kUriDuaRegistrationNotify, "DuaRegNotify") \
_("n/dr", kUriDuaRegistrationRequest, "DuaRegRequest") \
_("n/mr", kUriMlr, "Mlr")
// We use the X-Macro pattern here. The `UriEntryMapList` macro defines the
+45 -49
View File
@@ -45,53 +45,51 @@ namespace ot {
*/
enum Uri : uint8_t
{
kUriAddressError, ///< Address Error ("a/ae")
kUriAddressNotify, ///< Address Notify ("a/an")
kUriAddressQuery, ///< Address Query ("a/aq")
kUriAddressRelease, ///< Address Release ("a/ar")
kUriAddressSolicit, ///< Address Solicit ("a/as")
kUriServerData, ///< Server Data Registration ("a/sd")
kUriAnycastLocate, ///< Anycast Locate ("a/yl")
kUriBackboneMlr, ///< Backbone Multicast Listener Report ("b/bmr")
kUriAnnounceBegin, ///< Announce Begin ("c/ab")
kUriActiveGet, ///< MGMT_ACTIVE_GET "c/ag"
kUriActiveReplace, ///< MGMT_ACTIVE_REPLACE ("c/ar")
kUriActiveSet, ///< MGMT_ACTIVE_SET ("c/as")
kUriCommissionerKeepAlive, ///< Commissioner Keep Alive ("c/ca")
kUriCommissionerGet, ///< MGMT_COMMISSIONER_GET ("c/cg")
kUriCommissionerPetition, ///< Commissioner Petition ("c/cp")
kUriCommissionerSet, ///< MGMT_COMMISSIONER_SET ("c/cs")
kUriDatasetChanged, ///< MGMT_DATASET_CHANGED ("c/dc")
kUriEnergyReport, ///< Energy Report ("c/er")
kUriEnergyScan, ///< Energy Scan ("c/es")
kUriJoinerEntrust, ///< Joiner Entrust ("c/je")
kUriJoinerFinalize, ///< Joiner Finalize ("c/jf")
kUriLeaderKeepAlive, ///< Leader Keep Alive ("c/la")
kUriLeaderPetition, ///< Leader Petition ("c/lp")
kUriEnrollerJoinerAccept, ///< Enroller Joiner Accept ("c/nj")
kUriEnrollerKeepAlive, ///< Enroller KeepAlive ("c/nk")
kUriEnrollerJoinerRelease, ///< Enroller Joiner Release ("c/nl")
kUriEnrollerRegister, ///< Enroller Register ("c/nr")
kUriEnrollerReportState, ///< Report Admitter State (to enroller) ("c/ns")
kUriPanIdConflict, ///< PAN ID Conflict ("c/pc")
kUriPendingGet, ///< MGMT_PENDING_GET ("c/pg")
kUriPanIdQuery, ///< PAN ID Query ("c/pq")
kUriPendingSet, ///< MGMT_PENDING_SET ("c/ps")
kUriRelayRx, ///< Relay RX ("c/rx")
kUriTcatEnable, ///< TCAT Enable ("c/te")
kUriRelayTx, ///< Relay TX ("c/tx")
kUriProxyRx, ///< Proxy RX ("c/ur")
kUriProxyTx, ///< Proxy TX ("c/ut")
kUriDiagnosticGetAnswer, ///< Network Diagnostic Get Answer ("d/da")
kUriDiagnosticGetRequest, ///< Network Diagnostic Get Request ("d/dg")
kUriDiagnosticGetQuery, ///< Network Diagnostic Get Query ("d/dq")
kUriDiagnosticReset, ///< Network Diagnostic Reset ("d/dr")
kUriHistoryAnswer, ///< History Answer ("h/an")
kUriHistoryQuery, ///< History Query ("h/qy")
kUriDuaRegistrationNotify, ///< DUA Registration Notification ("n/dn")
kUriDuaRegistrationRequest, ///< DUA Registration Request ("n/dr")
kUriMlr, ///< Multicast Listener Registration ("n/mr")
kUriUnknown, ///< Unknown URI
kUriAddressError, ///< Address Error ("a/ae")
kUriAddressNotify, ///< Address Notify ("a/an")
kUriAddressQuery, ///< Address Query ("a/aq")
kUriAddressRelease, ///< Address Release ("a/ar")
kUriAddressSolicit, ///< Address Solicit ("a/as")
kUriServerData, ///< Server Data Registration ("a/sd")
kUriAnycastLocate, ///< Anycast Locate ("a/yl")
kUriBackboneMlr, ///< Backbone Multicast Listener Report ("b/bmr")
kUriAnnounceBegin, ///< Announce Begin ("c/ab")
kUriActiveGet, ///< MGMT_ACTIVE_GET "c/ag"
kUriActiveReplace, ///< MGMT_ACTIVE_REPLACE ("c/ar")
kUriActiveSet, ///< MGMT_ACTIVE_SET ("c/as")
kUriCommissionerKeepAlive, ///< Commissioner Keep Alive ("c/ca")
kUriCommissionerGet, ///< MGMT_COMMISSIONER_GET ("c/cg")
kUriCommissionerPetition, ///< Commissioner Petition ("c/cp")
kUriCommissionerSet, ///< MGMT_COMMISSIONER_SET ("c/cs")
kUriDatasetChanged, ///< MGMT_DATASET_CHANGED ("c/dc")
kUriEnergyReport, ///< Energy Report ("c/er")
kUriEnergyScan, ///< Energy Scan ("c/es")
kUriJoinerEntrust, ///< Joiner Entrust ("c/je")
kUriJoinerFinalize, ///< Joiner Finalize ("c/jf")
kUriLeaderKeepAlive, ///< Leader Keep Alive ("c/la")
kUriLeaderPetition, ///< Leader Petition ("c/lp")
kUriEnrollerJoinerAccept, ///< Enroller Joiner Accept ("c/nj")
kUriEnrollerKeepAlive, ///< Enroller KeepAlive ("c/nk")
kUriEnrollerJoinerRelease, ///< Enroller Joiner Release ("c/nl")
kUriEnrollerRegister, ///< Enroller Register ("c/nr")
kUriEnrollerReportState, ///< Report Admitter State (to enroller) ("c/ns")
kUriPanIdConflict, ///< PAN ID Conflict ("c/pc")
kUriPendingGet, ///< MGMT_PENDING_GET ("c/pg")
kUriPanIdQuery, ///< PAN ID Query ("c/pq")
kUriPendingSet, ///< MGMT_PENDING_SET ("c/ps")
kUriRelayRx, ///< Relay RX ("c/rx")
kUriTcatEnable, ///< TCAT Enable ("c/te")
kUriRelayTx, ///< Relay TX ("c/tx")
kUriProxyRx, ///< Proxy RX ("c/ur")
kUriProxyTx, ///< Proxy TX ("c/ut")
kUriDiagnosticGetAnswer, ///< Network Diagnostic Get Answer ("d/da")
kUriDiagnosticGetRequest, ///< Network Diagnostic Get Request ("d/dg")
kUriDiagnosticGetQuery, ///< Network Diagnostic Get Query ("d/dq")
kUriDiagnosticReset, ///< Network Diagnostic Reset ("d/dr")
kUriHistoryAnswer, ///< History Answer ("h/an")
kUriHistoryQuery, ///< History Query ("h/qy")
kUriMlr, ///< Multicast Listener Registration ("n/mr")
kUriUnknown, ///< Unknown URI
};
/**
@@ -163,8 +161,6 @@ template <> const char *UriToString<kUriDiagnosticGetAnswer>(void);
template <> const char *UriToString<kUriDiagnosticGetRequest>(void);
template <> const char *UriToString<kUriDiagnosticGetQuery>(void);
template <> const char *UriToString<kUriDiagnosticReset>(void);
template <> const char *UriToString<kUriDuaRegistrationNotify>(void);
template <> const char *UriToString<kUriDuaRegistrationRequest>(void);
template <> const char *UriToString<kUriMlr>(void);
} // namespace ot
+4 -4
View File
@@ -185,15 +185,15 @@ void PingSender::HandleIcmpReceive(void *aContext,
AsCoreType(aIcmpHeader));
}
void PingSender::HandleIcmpReceive(const Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp::Header &aIcmpHeader)
void PingSender::HandleIcmpReceive(const Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp6Header &aIcmpHeader)
{
Reply reply;
uint32_t timestamp;
VerifyOrExit(mTimer.IsRunning());
VerifyOrExit(aIcmpHeader.GetType() == Ip6::Icmp::Header::kTypeEchoReply);
VerifyOrExit(aIcmpHeader.GetType() == Ip6::Icmp6Header::kTypeEchoReply);
VerifyOrExit(aIcmpHeader.GetId() == mIdentifier);
SuccessOrExit(aMessage.Read(aMessage.GetOffset(), timestamp));
+3 -3
View File
@@ -160,9 +160,9 @@ private:
otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otIcmp6Header *aIcmpHeader);
void HandleIcmpReceive(const Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp::Header &aIcmpHeader);
void HandleIcmpReceive(const Message &aMessage,
const Ip6::MessageInfo &aMessageInfo,
const Ip6::Icmp6Header &aIcmpHeader);
using PingTimer = TimerMilliIn<PingSender, &PingSender::HandleTimer>;
-4
View File
@@ -2151,10 +2151,6 @@ template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_CAPS>(void)
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_THREAD_LINK_METRICS));
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_DUA));
#endif
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_CAP_REFERENCE_DEVICE));
#endif
-6
View File
@@ -335,9 +335,6 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DOMAIN_NAME),
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DUA_ID),
#endif
#endif // OPENTHREAD_FTD
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_PRIMARY),
@@ -651,9 +648,6 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE && OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_MLR_REQUEST),
#endif
#if OPENTHREAD_FTD && OPENTHREAD_CONFIG_DUA_ENABLE
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_DUA_ID),
#endif
#if OPENTHREAD_FTD
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_THREAD_BACKBONE_ROUTER_LOCAL_STATE),
-47
View File
@@ -385,53 +385,6 @@ exit:
}
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_THREAD_DUA_ID>(void)
{
const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(mInstance);
otError error = OT_ERROR_NONE;
if (iid == nullptr)
{
// send empty response
}
else
{
for (uint8_t i : iid->mFields.m8)
{
SuccessOrExit(error = mEncoder.WriteUint8(i));
}
}
exit:
return error;
}
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_THREAD_DUA_ID>(void)
{
otError error = OT_ERROR_NONE;
if (mDecoder.GetRemainingLength() == 0)
{
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, nullptr));
}
else
{
otIp6InterfaceIdentifier iid;
for (uint8_t &i : iid.mFields.m8)
{
SuccessOrExit(error = mDecoder.ReadUint8(i));
}
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, &iid));
}
exit:
return error;
}
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
#if OPENTHREAD_CONFIG_BORDER_AGENT_EPHEMERAL_KEY_ENABLE
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_BORDER_AGENT_EPHEMERAL_KEY_ENABLE>(void)
+1 -6
View File
@@ -129,11 +129,6 @@ static uint8_t BorderRouterConfigToFlagByteExtended(const otBorderRouterConfig &
flags |= SPINEL_NET_FLAG_EXT_DNS;
}
if (aConfig.mDp)
{
flags |= SPINEL_NET_FLAG_EXT_DP;
}
return flags;
}
@@ -1026,7 +1021,7 @@ template <> otError NcpBase::HandlePropertyInsert<SPINEL_PROP_THREAD_ON_MESH_NET
(mDecoder.ReadUint8(flagsExtended) == OT_ERROR_NONE))
{
borderRouterConfig.mNdDns = ((flagsExtended & SPINEL_NET_FLAG_EXT_DNS) != 0);
borderRouterConfig.mDp = ((flagsExtended & SPINEL_NET_FLAG_EXT_DP) != 0);
borderRouterConfig.mDp = false;
}
error = otBorderRouterAddOnMeshPrefix(mInstance, &borderRouterConfig);

Some files were not shown because too many files have changed in this diff Show More