mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 09:57:47 +00:00
[mle] refactor MleRouter and Mle classes into a single Mle class (#11411)
This commit refactors the `Mle` modules and combines the `MleRouter` and `Mle` classes into a single `Mle` class which now handles both FTD and MTD functionalities. The `MleRouter` and `Mle` classes were originally intended as sub-classes, where the base class `Mle` would provide MTD and common behaviors, and `MleRouter` would implement FTD-specific behaviors. However, over the years and as new features were implemented, these two classes became more intertwined, and the `Mle` class began to include many FTD-related functions and interactions with `MleRouter` private variables and methods. This commit simplifies the code by combining the two into a single class. The previous `mle_router.cpp` file is also renamed to `mle_ftd.cpp` to indicate that it implements FTD-specific MLE behaviors.
This commit is contained in:
+1
-2
@@ -660,8 +660,7 @@ openthread_core_files = [
|
||||
"thread/mesh_forwarder_mtd.cpp",
|
||||
"thread/mle.cpp",
|
||||
"thread/mle.hpp",
|
||||
"thread/mle_router.cpp",
|
||||
"thread/mle_router.hpp",
|
||||
"thread/mle_ftd.cpp",
|
||||
"thread/mle_tlvs.cpp",
|
||||
"thread/mle_tlvs.hpp",
|
||||
"thread/mle_types.cpp",
|
||||
|
||||
@@ -224,7 +224,7 @@ set(COMMON_SOURCES
|
||||
thread/mesh_forwarder_ftd.cpp
|
||||
thread/mesh_forwarder_mtd.cpp
|
||||
thread/mle.cpp
|
||||
thread/mle_router.cpp
|
||||
thread/mle_ftd.cpp
|
||||
thread/mle_tlvs.cpp
|
||||
thread/mle_types.cpp
|
||||
thread/mlr_manager.cpp
|
||||
|
||||
@@ -266,7 +266,7 @@ void otIp6SetSlaacPrefixFilter(otInstance *aInstance, otIp6SlaacPrefixFilter aFi
|
||||
|
||||
otError otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetMeshLocalIid(AsCoreType(aIid));
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetMeshLocalIid(AsCoreType(aIid));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,7 +69,7 @@ otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
|
||||
}
|
||||
#endif
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
SuccessOrExit(error = instance.Get<Mac::Mac>().SetPanChannel(aChannel));
|
||||
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
@@ -90,7 +90,7 @@ otError otLinkSetWakeupChannel(otInstance *aInstance, uint8_t aChannel)
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
SuccessOrExit(error = instance.Get<Mac::Mac>().SetWakeupChannel(aChannel));
|
||||
|
||||
@@ -112,7 +112,7 @@ otError otLinkSetSupportedChannelMask(otInstance *aInstance, uint32_t aChannelMa
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<Mac::Mac>().SetSupportedChannelMask(Mac::ChannelMask(aChannelMask));
|
||||
|
||||
@@ -130,11 +130,11 @@ otError otLinkSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExt
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<Mac::Mac>().SetExtAddress(AsCoreType(aExtAddress));
|
||||
|
||||
instance.Get<Mle::MleRouter>().UpdateLinkLocalAddress();
|
||||
instance.Get<Mle::Mle>().UpdateLinkLocalAddress();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
@@ -152,7 +152,7 @@ otError otLinkSetPanId(otInstance *aInstance, otPanId aPanId)
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<Mac::Mac>().SetPanId(aPanId);
|
||||
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
@@ -464,17 +464,14 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
uint32_t otLinkGetCslTimeout(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetCslTimeout();
|
||||
}
|
||||
uint32_t otLinkGetCslTimeout(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().GetCslTimeout(); }
|
||||
|
||||
otError otLinkSetCslTimeout(otInstance *aInstance, uint32_t aTimeout)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(kMaxCslTimeout >= aTimeout, error = kErrorInvalidArgs);
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetCslTimeout(aTimeout);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetCslTimeout(aTimeout);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -108,12 +108,12 @@ void otNetDataGetCommissioningDataset(otInstance *aInstance, otCommissioningData
|
||||
|
||||
uint8_t otNetDataGetVersion(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData().GetDataVersion(NetworkData::kFullSet);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderData().GetDataVersion(NetworkData::kFullSet);
|
||||
}
|
||||
|
||||
uint8_t otNetDataGetStableVersion(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData().GetDataVersion(NetworkData::kStableSubset);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderData().GetDataVersion(NetworkData::kStableSubset);
|
||||
}
|
||||
|
||||
otError otNetDataSteeringDataCheckJoiner(otInstance *aInstance, const otExtAddress *aEui64)
|
||||
|
||||
@@ -52,7 +52,7 @@ otError otNetworkTimeSetSyncPeriod(otInstance *aInstance, uint16_t aTimeSyncPeri
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
AsCoreType(aInstance).Get<TimeSync>().SetTimeSyncPeriod(aTimeSyncPeriod);
|
||||
|
||||
@@ -69,7 +69,7 @@ otError otNetworkTimeSetXtalThreshold(otInstance *aInstance, uint16_t aXtalThres
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
AsCoreType(aInstance).Get<TimeSync>().SetXtalThreshold(aXtalThreshold);
|
||||
|
||||
|
||||
+36
-45
@@ -39,14 +39,11 @@
|
||||
|
||||
using namespace ot;
|
||||
|
||||
uint32_t otThreadGetChildTimeout(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetTimeout();
|
||||
}
|
||||
uint32_t otThreadGetChildTimeout(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().GetTimeout(); }
|
||||
|
||||
void otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetTimeout(aTimeout);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetTimeout(aTimeout);
|
||||
}
|
||||
|
||||
const otExtendedPanId *otThreadGetExtendedPanId(otInstance *aInstance)
|
||||
@@ -60,7 +57,7 @@ otError otThreadSetExtendedPanId(otInstance *aInstance, const otExtendedPanId *a
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
const MeshCoP::ExtendedPanId &extPanId = AsCoreType(aExtendedPanId);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<MeshCoP::ExtendedPanIdManager>().SetExtPanId(extPanId);
|
||||
|
||||
@@ -86,14 +83,14 @@ otLinkModeConfig otThreadGetLinkMode(otInstance *aInstance)
|
||||
{
|
||||
otLinkModeConfig config;
|
||||
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().GetDeviceMode().Get(config);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().GetDeviceMode().Get(config);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
otError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetDeviceMode(Mle::DeviceMode(aConfig));
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetDeviceMode(Mle::DeviceMode(aConfig));
|
||||
}
|
||||
|
||||
void otThreadGetNetworkKey(otInstance *aInstance, otNetworkKey *aNetworkKey)
|
||||
@@ -113,7 +110,7 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<KeyManager>().SetNetworkKey(AsCoreType(aKey));
|
||||
|
||||
@@ -132,7 +129,7 @@ otError otThreadSetNetworkKeyRef(otInstance *aInstance, otNetworkKeyRef aKeyRef)
|
||||
|
||||
VerifyOrExit(aKeyRef != 0, error = kErrorInvalidArgs);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<KeyManager>().SetNetworkKeyRef((aKeyRef));
|
||||
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
@@ -145,26 +142,26 @@ exit:
|
||||
|
||||
const otIp6Address *otThreadGetRloc(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetMeshLocalRloc();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetMeshLocalRloc();
|
||||
}
|
||||
|
||||
const otIp6Address *otThreadGetMeshLocalEid(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetMeshLocalEid();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetMeshLocalEid();
|
||||
}
|
||||
|
||||
const otMeshLocalPrefix *otThreadGetMeshLocalPrefix(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetMeshLocalPrefix();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetMeshLocalPrefix();
|
||||
}
|
||||
|
||||
otError otThreadSetMeshLocalPrefix(otInstance *aInstance, const otMeshLocalPrefix *aMeshLocalPrefix)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetMeshLocalPrefix(AsCoreType(aMeshLocalPrefix));
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetMeshLocalPrefix(AsCoreType(aMeshLocalPrefix));
|
||||
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
AsCoreType(aInstance).Get<MeshCoP::PendingDatasetManager>().Clear();
|
||||
|
||||
@@ -174,17 +171,17 @@ exit:
|
||||
|
||||
const otIp6Address *otThreadGetLinkLocalIp6Address(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetLinkLocalAddress();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetLinkLocalAddress();
|
||||
}
|
||||
|
||||
const otIp6Address *otThreadGetLinkLocalAllThreadNodesMulticastAddress(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetLinkLocalAllThreadNodesAddress();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetLinkLocalAllThreadNodesAddress();
|
||||
}
|
||||
|
||||
const otIp6Address *otThreadGetRealmLocalAllThreadNodesMulticastAddress(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetRealmLocalAllThreadNodesAddress();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetRealmLocalAllThreadNodesAddress();
|
||||
}
|
||||
|
||||
otError otThreadGetServiceAloc(otInstance *aInstance, uint8_t aServiceId, otIp6Address *aServiceAloc)
|
||||
@@ -207,7 +204,7 @@ otError otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
#if !OPENTHREAD_CONFIG_ALLOW_EMPTY_NETWORK_NAME
|
||||
// Thread interfaces support a zero length name internally for backwards compatibility, but new names
|
||||
@@ -233,7 +230,7 @@ otError otThreadSetDomainName(otInstance *aInstance, const char *aDomainName)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
error = AsCoreType(aInstance).Get<MeshCoP::NetworkNameManager>().SetDomainName(aDomainName);
|
||||
|
||||
@@ -295,12 +292,9 @@ void otThreadSetKeySwitchGuardTime(otInstance *aInstance, uint16_t aKeySwitchGua
|
||||
AsCoreType(aInstance).Get<KeyManager>().SetKeySwitchGuardTime(aKeySwitchGuardTime);
|
||||
}
|
||||
|
||||
otError otThreadBecomeDetached(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().BecomeDetached();
|
||||
}
|
||||
otError otThreadBecomeDetached(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().BecomeDetached(); }
|
||||
|
||||
otError otThreadBecomeChild(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::MleRouter>().BecomeChild(); }
|
||||
otError otThreadBecomeChild(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().BecomeChild(); }
|
||||
|
||||
otError otThreadGetNextNeighborInfo(otInstance *aInstance, otNeighborInfoIterator *aIterator, otNeighborInfo *aInfo)
|
||||
{
|
||||
@@ -311,7 +305,7 @@ otError otThreadGetNextNeighborInfo(otInstance *aInstance, otNeighborInfoIterato
|
||||
|
||||
otDeviceRole otThreadGetDeviceRole(otInstance *aInstance)
|
||||
{
|
||||
return MapEnum(AsCoreType(aInstance).Get<Mle::MleRouter>().GetRole());
|
||||
return MapEnum(AsCoreType(aInstance).Get<Mle::Mle>().GetRole());
|
||||
}
|
||||
|
||||
const char *otThreadDeviceRoleToString(otDeviceRole aRole) { return Mle::RoleToString(MapEnum(aRole)); }
|
||||
@@ -322,29 +316,26 @@ otError otThreadGetLeaderData(otInstance *aInstance, otLeaderData *aLeaderData)
|
||||
|
||||
AssertPointerIsNotNull(aLeaderData);
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsAttached(), error = kErrorDetached);
|
||||
*aLeaderData = AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData();
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsAttached(), error = kErrorDetached);
|
||||
*aLeaderData = AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderData();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
uint8_t otThreadGetLeaderRouterId(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderId();
|
||||
}
|
||||
uint8_t otThreadGetLeaderRouterId(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderId(); }
|
||||
|
||||
uint8_t otThreadGetLeaderWeight(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData().GetWeighting();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderData().GetWeighting();
|
||||
}
|
||||
|
||||
uint32_t otThreadGetPartitionId(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderData().GetPartitionId();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderData().GetPartitionId();
|
||||
}
|
||||
|
||||
uint16_t otThreadGetRloc16(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::MleRouter>().GetRloc16(); }
|
||||
uint16_t otThreadGetRloc16(otInstance *aInstance) { return AsCoreType(aInstance).Get<Mle::Mle>().GetRloc16(); }
|
||||
|
||||
otError otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
|
||||
{
|
||||
@@ -357,7 +348,7 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
|
||||
|
||||
AssertPointerIsNotNull(aParentRssi);
|
||||
|
||||
*aParentRssi = AsCoreType(aInstance).Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetAverageRss();
|
||||
*aParentRssi = AsCoreType(aInstance).Get<Mle::Mle>().GetParent().GetLinkInfo().GetAverageRss();
|
||||
|
||||
VerifyOrExit(*aParentRssi != Radio::kInvalidRssi, error = kErrorFailed);
|
||||
|
||||
@@ -371,7 +362,7 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi)
|
||||
|
||||
AssertPointerIsNotNull(aLastRssi);
|
||||
|
||||
*aLastRssi = AsCoreType(aInstance).Get<Mle::MleRouter>().GetParent().GetLinkInfo().GetLastRss();
|
||||
*aLastRssi = AsCoreType(aInstance).Get<Mle::Mle>().GetParent().GetLinkInfo().GetLastRss();
|
||||
|
||||
VerifyOrExit(*aLastRssi != Radio::kInvalidRssi, error = kErrorFailed);
|
||||
|
||||
@@ -390,11 +381,11 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled)
|
||||
|
||||
if (aEnabled)
|
||||
{
|
||||
error = AsCoreType(aInstance).Get<Mle::MleRouter>().Start();
|
||||
error = AsCoreType(aInstance).Get<Mle::Mle>().Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().Stop();
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().Stop();
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -407,7 +398,7 @@ bool otThreadIsSingleton(otInstance *aInstance)
|
||||
bool isSingleton = false;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
isSingleton = AsCoreType(aInstance).Get<Mle::MleRouter>().IsSingleton();
|
||||
isSingleton = AsCoreType(aInstance).Get<Mle::Mle>().IsSingleton();
|
||||
#else
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
#endif
|
||||
@@ -470,14 +461,14 @@ void otThreadResetTimeInQueueStat(otInstance *aInstance)
|
||||
|
||||
const otMleCounters *otThreadGetMleCounters(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetCounters();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetCounters();
|
||||
}
|
||||
|
||||
void otThreadResetMleCounters(otInstance *aInstance) { AsCoreType(aInstance).Get<Mle::MleRouter>().ResetCounters(); }
|
||||
void otThreadResetMleCounters(otInstance *aInstance) { AsCoreType(aInstance).Get<Mle::Mle>().ResetCounters(); }
|
||||
|
||||
uint32_t otThreadGetCurrentAttachDuration(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetCurrentAttachDuration();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetCurrentAttachDuration();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE
|
||||
@@ -485,7 +476,7 @@ void otThreadRegisterParentResponseCallback(otInstance *aInst
|
||||
otThreadParentResponseCallback aCallback,
|
||||
void *aContext)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().RegisterParentResponseStatsCallback(aCallback, aContext);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().RegisterParentResponseStatsCallback(aCallback, aContext);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -506,7 +497,7 @@ bool otThreadIsAnycastLocateInProgress(otInstance *aInstance)
|
||||
|
||||
otError otThreadDetachGracefully(otInstance *aInstance, otDetachGracefullyCallback aCallback, void *aContext)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().DetachGracefully(aCallback, aContext);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().DetachGracefully(aCallback, aContext);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_DYNAMIC_STORE_FRAME_AHEAD_COUNTER_ENABLE
|
||||
|
||||
@@ -51,62 +51,62 @@ otError otThreadSetMaxAllowedChildren(otInstance *aInstance, uint16_t aMaxChildr
|
||||
|
||||
uint8_t otThreadGetMaxChildIpAddresses(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetMaxChildIpAddresses();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetMaxChildIpAddresses();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
otError otThreadSetMaxChildIpAddresses(otInstance *aInstance, uint8_t aMaxIpAddresses)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetMaxChildIpAddresses(aMaxIpAddresses);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetMaxChildIpAddresses(aMaxIpAddresses);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool otThreadIsRouterEligible(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().IsRouterEligible();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().IsRouterEligible();
|
||||
}
|
||||
|
||||
otError otThreadSetRouterEligible(otInstance *aInstance, bool aEligible)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetRouterEligible(aEligible);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetRouterEligible(aEligible);
|
||||
}
|
||||
|
||||
otError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetPreferredRouterId(aRouterId);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetPreferredRouterId(aRouterId);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
const otDeviceProperties *otThreadGetDeviceProperties(otInstance *aInstance)
|
||||
{
|
||||
return &AsCoreType(aInstance).Get<Mle::MleRouter>().GetDeviceProperties();
|
||||
return &AsCoreType(aInstance).Get<Mle::Mle>().GetDeviceProperties();
|
||||
}
|
||||
|
||||
void otThreadSetDeviceProperties(otInstance *aInstance, const otDeviceProperties *aDeviceProperties)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetDeviceProperties(AsCoreType(aDeviceProperties));
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetDeviceProperties(AsCoreType(aDeviceProperties));
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetLeaderWeight();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetLeaderWeight();
|
||||
}
|
||||
|
||||
void otThreadSetLocalLeaderWeight(otInstance *aInstance, uint8_t aWeight)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetLeaderWeight(aWeight);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetLeaderWeight(aWeight);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
uint32_t otThreadGetPreferredLeaderPartitionId(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetPreferredLeaderPartitionId();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetPreferredLeaderPartitionId();
|
||||
}
|
||||
|
||||
void otThreadSetPreferredLeaderPartitionId(otInstance *aInstance, uint32_t aPartitionId)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetPreferredLeaderPartitionId(aPartitionId);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetPreferredLeaderPartitionId(aPartitionId);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -134,32 +134,32 @@ void otThreadSetContextIdReuseDelay(otInstance *aInstance, uint32_t aDelay)
|
||||
|
||||
uint8_t otThreadGetNetworkIdTimeout(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetNetworkIdTimeout();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetNetworkIdTimeout();
|
||||
}
|
||||
|
||||
void otThreadSetNetworkIdTimeout(otInstance *aInstance, uint8_t aTimeout)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetNetworkIdTimeout(aTimeout);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetNetworkIdTimeout(aTimeout);
|
||||
}
|
||||
|
||||
uint8_t otThreadGetRouterUpgradeThreshold(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetRouterUpgradeThreshold();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetRouterUpgradeThreshold();
|
||||
}
|
||||
|
||||
void otThreadSetRouterUpgradeThreshold(otInstance *aInstance, uint8_t aThreshold)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetRouterUpgradeThreshold(aThreshold);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetRouterUpgradeThreshold(aThreshold);
|
||||
}
|
||||
|
||||
uint8_t otThreadGetChildRouterLinks(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetChildRouterLinks();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetChildRouterLinks();
|
||||
}
|
||||
|
||||
otError otThreadSetChildRouterLinks(otInstance *aInstance, uint8_t aChildRouterLinks)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetChildRouterLinks(aChildRouterLinks);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetChildRouterLinks(aChildRouterLinks);
|
||||
}
|
||||
|
||||
otError otThreadReleaseRouterId(otInstance *aInstance, uint8_t aRouterId)
|
||||
@@ -176,32 +176,32 @@ exit:
|
||||
|
||||
otError otThreadBecomeRouter(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().BecomeRouter(ThreadStatusTlv::kHaveChildIdRequest);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().BecomeRouter(ThreadStatusTlv::kHaveChildIdRequest);
|
||||
}
|
||||
|
||||
otError otThreadBecomeLeader(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().BecomeLeader(/* aCheckWeight */ true);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().BecomeLeader(/* aCheckWeight */ true);
|
||||
}
|
||||
|
||||
uint8_t otThreadGetRouterDowngradeThreshold(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetRouterDowngradeThreshold();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetRouterDowngradeThreshold();
|
||||
}
|
||||
|
||||
void otThreadSetRouterDowngradeThreshold(otInstance *aInstance, uint8_t aThreshold)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetRouterDowngradeThreshold(aThreshold);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetRouterDowngradeThreshold(aThreshold);
|
||||
}
|
||||
|
||||
uint8_t otThreadGetRouterSelectionJitter(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetRouterSelectionJitter();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetRouterSelectionJitter();
|
||||
}
|
||||
|
||||
void otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitter)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetRouterSelectionJitter(aRouterJitter);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetRouterSelectionJitter(aRouterJitter);
|
||||
}
|
||||
|
||||
otError otThreadGetChildInfoById(otInstance *aInstance, uint16_t aChildId, otChildInfo *aChildInfo)
|
||||
@@ -260,7 +260,7 @@ otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntr
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
void otThreadSetSteeringData(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetSteeringData(AsCoreTypePtr(aExtAddress));
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetSteeringData(AsCoreTypePtr(aExtAddress));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -277,7 +277,7 @@ otError otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(AsCoreType(aInstance).Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
AsCoreType(aInstance).Get<KeyManager>().SetPskc(AsCoreType(aPskc));
|
||||
AsCoreType(aInstance).Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
@@ -294,7 +294,7 @@ otError otThreadSetPskcRef(otInstance *aInstance, otPskcRef aKeyRef)
|
||||
Instance &instance = AsCoreType(aInstance);
|
||||
|
||||
VerifyOrExit(aKeyRef != 0, error = kErrorInvalidArgs);
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(instance.Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<KeyManager>().SetPskcRef(aKeyRef);
|
||||
instance.Get<MeshCoP::ActiveDatasetManager>().Clear();
|
||||
@@ -307,12 +307,12 @@ exit:
|
||||
|
||||
int8_t otThreadGetParentPriority(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetAssignParentPriority();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetAssignParentPriority();
|
||||
}
|
||||
|
||||
otError otThreadSetParentPriority(otInstance *aInstance, int8_t aParentPriority)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().SetAssignParentPriority(aParentPriority);
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().SetAssignParentPriority(aParentPriority);
|
||||
}
|
||||
|
||||
void otThreadRegisterNeighborTableCallback(otInstance *aInstance, otNeighborTableCallback aCallback)
|
||||
@@ -324,7 +324,7 @@ void otThreadSetDiscoveryRequestCallback(otInstance *aInsta
|
||||
otThreadDiscoveryRequestCallback aCallback,
|
||||
void *aContext)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetDiscoveryRequestCallback(aCallback, aContext);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetDiscoveryRequestCallback(aCallback, aContext);
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
@@ -351,12 +351,12 @@ otError otThreadSendProactiveBackboneNotification(otInstance *aIns
|
||||
|
||||
void otThreadSetCcmEnabled(otInstance *aInstance, bool aEnabled)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetCcmEnabled(aEnabled);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetCcmEnabled(aEnabled);
|
||||
}
|
||||
|
||||
void otThreadSetThreadVersionCheckEnabled(otInstance *aInstance, bool aEnabled)
|
||||
{
|
||||
AsCoreType(aInstance).Get<Mle::MleRouter>().SetThreadVersionCheckEnabled(aEnabled);
|
||||
AsCoreType(aInstance).Get<Mle::Mle>().SetThreadVersionCheckEnabled(aEnabled);
|
||||
}
|
||||
|
||||
void otThreadSetTmfOriginFilterEnabled(otInstance *aInstance, bool aEnabled)
|
||||
@@ -384,7 +384,7 @@ otError otThreadSetRouterIdRange(otInstance *aInstance, uint8_t aMinRouterId, ui
|
||||
|
||||
uint32_t otThreadGetAdvertisementTrickleIntervalMax(otInstance *aInstance)
|
||||
{
|
||||
return AsCoreType(aInstance).Get<Mle::MleRouter>().GetAdvertisementTrickleIntervalMax();
|
||||
return AsCoreType(aInstance).Get<Mle::Mle>().GetAdvertisementTrickleIntervalMax();
|
||||
}
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
@@ -97,7 +97,7 @@ void otUdpForwardReceive(otInstance *aInstance,
|
||||
{
|
||||
Ip6::MessageInfo messageInfo;
|
||||
|
||||
messageInfo.SetSockAddr(AsCoreType(aInstance).Get<Mle::MleRouter>().GetMeshLocalRloc());
|
||||
messageInfo.SetSockAddr(AsCoreType(aInstance).Get<Mle::Mle>().GetMeshLocalRloc());
|
||||
messageInfo.SetSockPort(aSockPort);
|
||||
messageInfo.SetPeerAddr(AsCoreType(aPeerAddr));
|
||||
messageInfo.SetPeerPort(aPeerPort);
|
||||
|
||||
@@ -176,7 +176,7 @@ Error Local::AddService(RegisterMode aMode)
|
||||
{
|
||||
case kDecideBasedOnState:
|
||||
VerifyOrExit(!Get<BackboneRouter::Leader>().HasPrimary() ||
|
||||
Get<BackboneRouter::Leader>().GetServer16() == Get<Mle::MleRouter>().GetRloc16());
|
||||
Get<BackboneRouter::Leader>().GetServer16() == Get<Mle::Mle>().GetRloc16());
|
||||
break;
|
||||
case kForceRegistration:
|
||||
break;
|
||||
@@ -213,7 +213,7 @@ void Local::SetState(State aState)
|
||||
{
|
||||
case kStateDisabled:
|
||||
// Update All Network Backbone Routers Multicast Address for both Secondary and Primary state.
|
||||
mAllNetworkBackboneRouters.SetMulticastNetworkPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
mAllNetworkBackboneRouters.SetMulticastNetworkPrefix(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
break;
|
||||
case kStateSecondary:
|
||||
break;
|
||||
@@ -225,7 +225,7 @@ void Local::SetState(State aState)
|
||||
if (aState == kStatePrimary)
|
||||
{
|
||||
// Add Primary Backbone Router ALOC for Primary Backbone Router.
|
||||
mBbrPrimaryAloc.GetAddress().SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
mBbrPrimaryAloc.GetAddress().SetPrefix(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
Get<ThreadNetif>().AddUnicastAddress(mBbrPrimaryAloc);
|
||||
}
|
||||
|
||||
@@ -241,14 +241,14 @@ void Local::HandleBackboneRouterPrimaryUpdate(Leader::State aState, const Config
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aState);
|
||||
|
||||
VerifyOrExit(IsEnabled() && Get<Mle::MleRouter>().IsAttached());
|
||||
VerifyOrExit(IsEnabled() && Get<Mle::Mle>().IsAttached());
|
||||
|
||||
// Wait some jitter before trying to Register.
|
||||
if (aConfig.mServer16 == Mle::kInvalidRloc16)
|
||||
{
|
||||
mRegistrationTimeout = 1;
|
||||
|
||||
if (!Get<Mle::MleRouter>().IsLeader())
|
||||
if (!Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
mRegistrationTimeout +=
|
||||
Random::NonCrypto::GetUint16InRange(0, static_cast<uint16_t>(mRegistrationJitter) + 1);
|
||||
@@ -256,7 +256,7 @@ void Local::HandleBackboneRouterPrimaryUpdate(Leader::State aState, const Config
|
||||
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kBbrLocal);
|
||||
}
|
||||
else if (aConfig.mServer16 != Get<Mle::MleRouter>().GetRloc16())
|
||||
else if (aConfig.mServer16 != Get<Mle::Mle>().GetRloc16())
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
@@ -285,7 +285,7 @@ void Local::HandleTimeTick(void)
|
||||
// Delay registration while router role transition is pending
|
||||
// (i.e., device may soon switch from REED to router role).
|
||||
|
||||
VerifyOrExit(!Get<Mle::MleRouter>().IsRouterRoleTransitionPending());
|
||||
VerifyOrExit(!Get<Mle::Mle>().IsRouterRoleTransitionPending());
|
||||
|
||||
if (mRegistrationTimeout > 0)
|
||||
{
|
||||
@@ -362,7 +362,7 @@ void Local::ApplyNewMeshLocalPrefix(void)
|
||||
VerifyOrExit(IsEnabled());
|
||||
|
||||
Get<BackboneTmfAgent>().UnsubscribeMulticast(mAllNetworkBackboneRouters);
|
||||
mAllNetworkBackboneRouters.SetMulticastNetworkPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
mAllNetworkBackboneRouters.SetMulticastNetworkPrefix(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
Get<BackboneTmfAgent>().SubscribeMulticast(mAllNetworkBackboneRouters);
|
||||
|
||||
exit:
|
||||
|
||||
@@ -495,7 +495,7 @@ bool Manager::ShouldForwardDuaToBackbone(const Ip6::Address &aAddress)
|
||||
// Do not forward to Backbone if the DUA belongs to a MTD Child (which may have failed in DUA registration)
|
||||
VerifyOrExit(Get<NeighborTable>().FindNeighbor(aAddress) == nullptr);
|
||||
// Forward to Backbone only if the DUA is resolved to the PBBR's RLOC16
|
||||
VerifyOrExit(Get<AddressResolver>().LookUp(aAddress) == Get<Mle::MleRouter>().GetRloc16());
|
||||
VerifyOrExit(Get<AddressResolver>().LookUp(aAddress) == Get<Mle::Mle>().GetRloc16());
|
||||
|
||||
forwardToBackbone = true;
|
||||
|
||||
@@ -688,7 +688,7 @@ void Manager::HandleDadBackboneAnswer(const Ip6::Address &aDua, const Ip6::Inter
|
||||
{
|
||||
Ip6::Address dest;
|
||||
|
||||
dest.SetToRoutingLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), ndProxy->GetRloc16());
|
||||
dest.SetToRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), ndProxy->GetRloc16());
|
||||
Get<AddressResolver>().SendAddressError(aDua, aMeshLocalIid, &dest);
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ void Manager::HandleExtendedBackboneAnswer(const Ip6::Address &aDua,
|
||||
{
|
||||
Ip6::Address dest;
|
||||
|
||||
dest.SetToRoutingLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), aSrcRloc16);
|
||||
dest.SetToRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aSrcRloc16);
|
||||
Get<AddressResolver>().SendAddressQueryResponse(aDua, aMeshLocalIid, &aTimeSinceLastTransaction, dest);
|
||||
|
||||
LogInfo("HandleExtendedBackboneAnswer: target=%s, mliid=%s, LTT=%lus, rloc16=%04x", aDua.ToString().AsCString(),
|
||||
|
||||
@@ -281,7 +281,7 @@ exit:
|
||||
|
||||
void RoutingManager::EvaluateState(void)
|
||||
{
|
||||
if (mIsEnabled && Get<Mle::MleRouter>().IsAttached() && mInfraIf.IsRunning())
|
||||
if (mIsEnabled && Get<Mle::Mle>().IsAttached() && mInfraIf.IsRunning())
|
||||
{
|
||||
Start();
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ void TimeTicker::HandleTimer(void)
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if (mReceivers & Mask(kMleRouter))
|
||||
if (mReceivers & Mask(kMle))
|
||||
{
|
||||
Get<Mle::MleRouter>().HandleTimeTick();
|
||||
Get<Mle::Mle>().HandleTimeTick();
|
||||
}
|
||||
|
||||
if (mReceivers & Mask(kAddressResolver))
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
enum Receiver : uint8_t
|
||||
{
|
||||
kMeshForwarder, ///< `MeshForwarder`
|
||||
kMleRouter, ///< `Mle::MleRouter`
|
||||
kMle, ///< `Mle::Mle`
|
||||
kAddressResolver, ///< `AddressResolver`
|
||||
kChildSupervisor, ///< `ChildSupervisor`
|
||||
kIp6FragmentReassembler, ///< `Ip6::Ip6` (handling of fragmented messages)
|
||||
|
||||
@@ -146,7 +146,7 @@ Instance::Instance(void)
|
||||
, mLowpan(*this)
|
||||
, mMac(*this)
|
||||
, mMeshForwarder(*this)
|
||||
, mMleRouter(*this)
|
||||
, mMle(*this)
|
||||
, mDiscoverScanner(*this)
|
||||
, mAddressResolver(*this)
|
||||
#if OPENTHREAD_CONFIG_MULTI_RADIO
|
||||
@@ -403,7 +403,7 @@ void Instance::AfterInit(void)
|
||||
// Restore datasets and network information
|
||||
|
||||
Get<Settings>().Init();
|
||||
Get<Mle::MleRouter>().Restore();
|
||||
Get<Mle::Mle>().Restore();
|
||||
|
||||
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
|
||||
Get<Trel::Link>().AfterInit();
|
||||
@@ -470,7 +470,7 @@ Error Instance::ErasePersistentInfo(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsDisabled(), error = kErrorInvalidState);
|
||||
Get<Settings>().Wipe();
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
Get<KeyManager>().DestroyTemporaryKeys();
|
||||
@@ -496,7 +496,7 @@ void Instance::GetBufferInfo(BufferInfo &aInfo)
|
||||
Get<Ip6::Mpl>().GetBufferedMessageSetInfo(aInfo.mMplQueue);
|
||||
#endif
|
||||
|
||||
Get<Mle::MleRouter>().GetMessageQueueInfo(aInfo.mMleQueue);
|
||||
Get<Mle::Mle>().GetMessageQueueInfo(aInfo.mMleQueue);
|
||||
|
||||
Get<Tmf::Agent>().GetRequestAndCachedResponsesQueueInfo(aInfo.mCoapQueue);
|
||||
|
||||
|
||||
@@ -122,7 +122,6 @@
|
||||
#include "thread/link_quality.hpp"
|
||||
#include "thread/mesh_forwarder.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/mle_router.hpp"
|
||||
#include "thread/mlr_manager.hpp"
|
||||
#include "thread/network_data_local.hpp"
|
||||
#include "thread/network_data_notifier.hpp"
|
||||
@@ -551,7 +550,7 @@ private:
|
||||
Lowpan::Lowpan mLowpan;
|
||||
Mac::Mac mMac;
|
||||
MeshForwarder mMeshForwarder;
|
||||
Mle::MleRouter mMleRouter;
|
||||
Mle::Mle mMle;
|
||||
Mle::DiscoverScanner mDiscoverScanner;
|
||||
AddressResolver mAddressResolver;
|
||||
|
||||
@@ -770,24 +769,20 @@ template <> inline Crypto::Storage::KeyRefManager &Instance::Get(void) { return
|
||||
template <> inline RadioSelector &Instance::Get(void) { return mRadioSelector; }
|
||||
#endif
|
||||
|
||||
template <> inline Mle::Mle &Instance::Get(void) { return mMleRouter; }
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
template <> inline Mle::MleRouter &Instance::Get(void) { return mMleRouter; }
|
||||
#endif
|
||||
template <> inline Mle::Mle &Instance::Get(void) { return mMle; }
|
||||
|
||||
template <> inline Mle::DiscoverScanner &Instance::Get(void) { return mDiscoverScanner; }
|
||||
|
||||
template <> inline NeighborTable &Instance::Get(void) { return mMleRouter.mNeighborTable; }
|
||||
template <> inline NeighborTable &Instance::Get(void) { return mMle.mNeighborTable; }
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
template <> inline ChildTable &Instance::Get(void) { return mMleRouter.mChildTable; }
|
||||
template <> inline ChildTable &Instance::Get(void) { return mMle.mChildTable; }
|
||||
|
||||
template <> inline RouterTable &Instance::Get(void) { return mMleRouter.mRouterTable; }
|
||||
template <> inline RouterTable &Instance::Get(void) { return mMle.mRouterTable; }
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
template <> inline WakeupTxScheduler &Instance::Get(void) { return mMleRouter.mWakeupTxScheduler; }
|
||||
template <> inline WakeupTxScheduler &Instance::Get(void) { return mMle.mWakeupTxScheduler; }
|
||||
#endif
|
||||
|
||||
template <> inline Ip6::Netif &Instance::Get(void) { return mThreadNetif; }
|
||||
|
||||
@@ -90,7 +90,7 @@ void DataPollHandler::HandleDataPoll(Mac::RxFrame &aFrame)
|
||||
uint16_t indirectMsgCount;
|
||||
|
||||
VerifyOrExit(aFrame.GetSecurityEnabled());
|
||||
VerifyOrExit(!Get<Mle::MleRouter>().IsDetached());
|
||||
VerifyOrExit(!Get<Mle::Mle>().IsDetached());
|
||||
|
||||
SuccessOrExit(aFrame.GetSrcAddr(macSource));
|
||||
child = Get<ChildTable>().FindChild(macSource, Child::kInStateValidOrRestoring);
|
||||
|
||||
@@ -57,16 +57,16 @@ DataPollSender::DataPollSender(Instance &aInstance)
|
||||
|
||||
const Neighbor &DataPollSender::GetParent(void) const
|
||||
{
|
||||
const Neighbor &parentCandidate = Get<Mle::MleRouter>().GetParentCandidate();
|
||||
const Neighbor &parentCandidate = Get<Mle::Mle>().GetParentCandidate();
|
||||
|
||||
return parentCandidate.IsStateValid() ? parentCandidate : Get<Mle::MleRouter>().GetParent();
|
||||
return parentCandidate.IsStateValid() ? parentCandidate : Get<Mle::Mle>().GetParent();
|
||||
}
|
||||
|
||||
void DataPollSender::StartPolling(void)
|
||||
{
|
||||
VerifyOrExit(!mEnabled);
|
||||
|
||||
OT_ASSERT(!Get<Mle::MleRouter>().IsRxOnWhenIdle());
|
||||
OT_ASSERT(!Get<Mle::Mle>().IsRxOnWhenIdle());
|
||||
|
||||
mEnabled = true;
|
||||
ScheduleNextPoll(kRecalculatePollPeriod);
|
||||
@@ -136,7 +136,7 @@ Error DataPollSender::GetPollDestinationAddress(Mac::Address &aDest) const
|
||||
|
||||
// Use extended address attaching to a new parent (i.e. parent is the parent candidate).
|
||||
if ((Get<Mac::Mac>().GetShortAddress() == Mac::kShortAddrInvalid) ||
|
||||
(&parent == &Get<Mle::MleRouter>().GetParentCandidate()))
|
||||
(&parent == &Get<Mle::Mle>().GetParentCandidate()))
|
||||
{
|
||||
aDest.SetExtended(parent.GetExtAddress());
|
||||
}
|
||||
@@ -206,7 +206,7 @@ void DataPollSender::HandlePollSent(Mac::TxFrame &aFrame, Error aError)
|
||||
if (GetParent().IsStateInvalid())
|
||||
{
|
||||
StopPolling();
|
||||
IgnoreError(Get<Mle::MleRouter>().BecomeDetached());
|
||||
IgnoreError(Get<Mle::Mle>().BecomeDetached());
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ void DataPollSender::ProcessTxDone(const Mac::TxFrame &aFrame, const Mac::RxFram
|
||||
bool sendDataPoll = false;
|
||||
|
||||
VerifyOrExit(mEnabled);
|
||||
VerifyOrExit(Get<Mle::MleRouter>().GetParent().IsEnhancedKeepAliveSupported());
|
||||
VerifyOrExit(Get<Mle::Mle>().GetParent().IsEnhancedKeepAliveSupported());
|
||||
VerifyOrExit(aFrame.GetSecurityEnabled());
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
|
||||
@@ -522,12 +522,12 @@ uint32_t DataPollSender::GetDefaultPollPeriod(void) const
|
||||
uint32_t pollAhead = static_cast<uint32_t>(kRetxPollPeriod) * kMaxPollRetxAttempts;
|
||||
uint32_t period;
|
||||
|
||||
period = Time::SecToMsec(Min(Get<Mle::MleRouter>().GetTimeout(), Time::MsecToSec(TimerMilli::kMaxDelay)));
|
||||
period = Time::SecToMsec(Min(Get<Mle::Mle>().GetTimeout(), Time::MsecToSec(TimerMilli::kMaxDelay)));
|
||||
|
||||
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE && OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE
|
||||
if (Get<Mac::Mac>().IsCslEnabled())
|
||||
{
|
||||
period = Min(period, Time::SecToMsec(Get<Mle::MleRouter>().GetCslTimeout()));
|
||||
period = Min(period, Time::SecToMsec(Get<Mle::Mle>().GetCslTimeout()));
|
||||
pollAhead = static_cast<uint32_t>(kRetxPollPeriod);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1879,7 +1879,7 @@ void Mac::HandleReceivedFrame(RxFrame *aFrame, Error aError)
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
// Allow multicasts from neighbor routers if FTD
|
||||
if (neighbor == nullptr && dstaddr.IsBroadcast() && Get<Mle::MleRouter>().IsFullThreadDevice())
|
||||
if (neighbor == nullptr && dstaddr.IsBroadcast() && Get<Mle::Mle>().IsFullThreadDevice())
|
||||
{
|
||||
neighbor = Get<NeighborTable>().FindRxOnlyNeighborRouter(srcaddr);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void BorderAgent::HandleNotifierEvents(Events aEvents)
|
||||
{
|
||||
if (aEvents.Contains(kEventThreadRoleChanged))
|
||||
{
|
||||
if (Get<Mle::MleRouter>().IsAttached())
|
||||
if (Get<Mle::Mle>().IsAttached())
|
||||
{
|
||||
Start();
|
||||
}
|
||||
@@ -397,8 +397,8 @@ Error BorderAgent::MeshCoPTxtEncoder::EncodeTxtData(void)
|
||||
|
||||
if (state.mThreadIfStatus == kThreadIfStatusActive)
|
||||
{
|
||||
SuccessOrExit(error = AppendTxtEntry(
|
||||
"pt", BigEndian::HostSwap32(Get<Mle::MleRouter>().GetLeaderData().GetPartitionId())));
|
||||
SuccessOrExit(
|
||||
error = AppendTxtEntry("pt", BigEndian::HostSwap32(Get<Mle::Mle>().GetLeaderData().GetPartitionId())));
|
||||
if (Get<MeshCoP::ActiveDatasetManager>().GetTimestamp().IsValid())
|
||||
{
|
||||
SuccessOrExit(error = AppendTxtEntry("at", Get<MeshCoP::ActiveDatasetManager>().GetTimestamp()));
|
||||
@@ -469,7 +469,7 @@ BorderAgent::MeshCoPTxtEncoder::StateBitmap BorderAgent::MeshCoPTxtEncoder::GetS
|
||||
state.mConnectionMode = kConnectionModePskc;
|
||||
state.mAvailability = kAvailabilityHigh;
|
||||
|
||||
switch (Get<Mle::MleRouter>().GetRole())
|
||||
switch (Get<Mle::Mle>().GetRole())
|
||||
{
|
||||
case Mle::DeviceRole::kRoleDisabled:
|
||||
state.mThreadIfStatus = kThreadIfStatusNotInitialized;
|
||||
|
||||
@@ -265,7 +265,7 @@ Error Commissioner::Start(StateCallback aStateCallback, JoinerCallback aJoinerCa
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsAttached(), error = kErrorInvalidState);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsAttached(), error = kErrorInvalidState);
|
||||
VerifyOrExit(mState == kStateDisabled, error = kErrorAlready);
|
||||
|
||||
SuccessOrExit(error = Get<Tmf::SecureAgent>().Open());
|
||||
@@ -932,7 +932,7 @@ template <> void Commissioner::HandleTmf<kUriRelayRx>(Coap::Message &aMessage, c
|
||||
aMessage.SetOffset(offsetRange.GetOffset());
|
||||
SuccessOrExit(error = aMessage.SetLength(offsetRange.GetEndOffset()));
|
||||
|
||||
joinerMessageInfo.SetPeerAddr(Get<Mle::MleRouter>().GetMeshLocalEid());
|
||||
joinerMessageInfo.SetPeerAddr(Get<Mle::Mle>().GetMeshLocalEid());
|
||||
joinerMessageInfo.GetPeerAddr().SetIid(mJoinerIid);
|
||||
joinerMessageInfo.SetPeerPort(mJoinerPort);
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ Error DatasetManager::ApplyConfiguration(const Dataset &aDataset) const
|
||||
#endif
|
||||
|
||||
case Tlv::kMeshLocalPrefix:
|
||||
Get<Mle::MleRouter>().SetMeshLocalPrefix(cur->ReadValueAs<MeshLocalPrefixTlv>());
|
||||
Get<Mle::Mle>().SetMeshLocalPrefix(cur->ReadValueAs<MeshLocalPrefixTlv>());
|
||||
break;
|
||||
|
||||
case Tlv::kSecurityPolicy:
|
||||
@@ -324,7 +324,7 @@ void DatasetManager::SaveLocal(const Dataset &aDataset)
|
||||
{
|
||||
LocalSave(aDataset);
|
||||
|
||||
switch (Get<Mle::MleRouter>().GetRole())
|
||||
switch (Get<Mle::Mle>().GetRole())
|
||||
{
|
||||
case Mle::kRoleDisabled:
|
||||
Restore(aDataset);
|
||||
@@ -439,7 +439,7 @@ void DatasetManager::SyncLocalWithLeader(const Dataset &aDataset)
|
||||
Error error = kErrorNone;
|
||||
|
||||
VerifyOrExit(!mMgmtPending, error = kErrorBusy);
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsChild() || Get<Mle::MleRouter>().IsRouter(), error = kErrorInvalidState);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsChild() || Get<Mle::Mle>().IsRouter(), error = kErrorInvalidState);
|
||||
|
||||
VerifyOrExit(mNetworkTimestamp < mLocalTimestamp, error = kErrorAlready);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ Error DatasetManager::ProcessSetOrReplaceRequest(MgmtCommand aCommand,
|
||||
}
|
||||
|
||||
if ((dataset.Read<MeshLocalPrefixTlv>(meshLocalPrefix) == kErrorNone) &&
|
||||
(meshLocalPrefix != Get<Mle::MleRouter>().GetMeshLocalPrefix()))
|
||||
(meshLocalPrefix != Get<Mle::Mle>().GetMeshLocalPrefix()))
|
||||
{
|
||||
aInfo.mAffectsConnectivity = true;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ Error ActiveDatasetManager::GenerateLocal(void)
|
||||
Error error = kErrorNone;
|
||||
Dataset dataset;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsAttached(), error = kErrorInvalidState);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsAttached(), error = kErrorInvalidState);
|
||||
VerifyOrExit(!mLocalTimestamp.IsValid(), error = kErrorAlready);
|
||||
|
||||
IgnoreError(Read(dataset));
|
||||
@@ -306,7 +306,7 @@ Error ActiveDatasetManager::GenerateLocal(void)
|
||||
|
||||
if (!dataset.Contains<MeshLocalPrefixTlv>())
|
||||
{
|
||||
IgnoreError(dataset.Write<MeshLocalPrefixTlv>(Get<Mle::MleRouter>().GetMeshLocalPrefix()));
|
||||
IgnoreError(dataset.Write<MeshLocalPrefixTlv>(Get<Mle::Mle>().GetMeshLocalPrefix()));
|
||||
}
|
||||
|
||||
if (!dataset.Contains<NetworkKeyTlv>())
|
||||
|
||||
@@ -135,7 +135,7 @@ Error Joiner::Start(const char *aPskd,
|
||||
// Use random-generated extended address.
|
||||
randomAddress.GenerateRandom();
|
||||
Get<Mac::Mac>().SetExtAddress(randomAddress);
|
||||
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
|
||||
Get<Mle::Mle>().UpdateLinkLocalAddress();
|
||||
|
||||
SuccessOrExit(error = Get<Tmf::SecureAgent>().Open(Ip6::NetifIdentifier::kNetifThreadInternal));
|
||||
SuccessOrExit(error = Get<Tmf::SecureAgent>().Bind(kJoinerUdpPort));
|
||||
@@ -256,7 +256,7 @@ void Joiner::HandleDiscoverResult(Mle::DiscoverScanner::ScanResult *aResult)
|
||||
else
|
||||
{
|
||||
Get<Mac::Mac>().SetExtAddress(mId);
|
||||
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
|
||||
Get<Mle::Mle>().UpdateLinkLocalAddress();
|
||||
|
||||
mJoinerRouterIndex = 0;
|
||||
TryNextJoinerRouter(kErrorNone);
|
||||
@@ -577,7 +577,7 @@ void Joiner::HandleTimer(void)
|
||||
|
||||
extAddress.GenerateRandom();
|
||||
Get<Mac::Mac>().SetExtAddress(extAddress);
|
||||
Get<Mle::MleRouter>().UpdateLinkLocalAddress();
|
||||
Get<Mle::Mle>().UpdateLinkLocalAddress();
|
||||
|
||||
error = kErrorNone;
|
||||
break;
|
||||
|
||||
@@ -61,7 +61,7 @@ void JoinerRouter::HandleNotifierEvents(Events aEvents)
|
||||
|
||||
void JoinerRouter::Start(void)
|
||||
{
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsFullThreadDevice());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsFullThreadDevice());
|
||||
|
||||
if (Get<NetworkData::Leader>().IsJoiningAllowed())
|
||||
{
|
||||
@@ -132,7 +132,7 @@ void JoinerRouter::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &a
|
||||
|
||||
SuccessOrExit(error = Tlv::Append<JoinerUdpPortTlv>(*message, aMessageInfo.GetPeerPort()));
|
||||
SuccessOrExit(error = Tlv::Append<JoinerIidTlv>(*message, aMessageInfo.GetPeerAddr().GetIid()));
|
||||
SuccessOrExit(error = Tlv::Append<JoinerRouterLocatorTlv>(*message, Get<Mle::MleRouter>().GetRloc16()));
|
||||
SuccessOrExit(error = Tlv::Append<JoinerRouterLocatorTlv>(*message, Get<Mle::Mle>().GetRloc16()));
|
||||
|
||||
offsetRange.InitFromMessageOffsetToEnd(aMessage);
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ template <> void Leader::HandleTmf<kUriLeaderPetition>(Coap::Message &aMessage,
|
||||
|
||||
LogInfo("Received %s", UriToString<kUriLeaderPetition>());
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsRoutingLocator(aMessageInfo.GetPeerAddr()));
|
||||
VerifyOrExit(Get<Mle::Mle>().IsRoutingLocator(aMessageInfo.GetPeerAddr()));
|
||||
|
||||
SuccessOrExit(Tlv::Find<CommissionerIdTlv>(aMessage, commissionerId));
|
||||
|
||||
@@ -124,7 +124,7 @@ template <> void Leader::HandleTmf<kUriLeaderKeepAlive>(Coap::Message &aMessage,
|
||||
|
||||
LogInfo("Received %s", UriToString<kUriLeaderKeepAlive>());
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
||||
|
||||
SuccessOrExit(Tlv::Find<StateTlv>(aMessage, state));
|
||||
|
||||
@@ -214,7 +214,7 @@ exit:
|
||||
|
||||
void Leader::HandleTimer(void)
|
||||
{
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
||||
|
||||
ResignCommissioner();
|
||||
|
||||
|
||||
@@ -924,7 +924,7 @@ Error TcatAgent::HandleStartThreadInterface(void)
|
||||
#endif
|
||||
|
||||
Get<ThreadNetif>().Up();
|
||||
error = Get<Mle::MleRouter>().Start();
|
||||
error = Get<Mle::Mle>().Start();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
|
||||
@@ -268,9 +268,9 @@ void Client::Solicit(uint16_t aRloc16)
|
||||
#if OPENTHREAD_ENABLE_DHCP6_MULTICAST_SOLICIT
|
||||
messageInfo.GetPeerAddr().SetToRealmLocalAllRoutersMulticast();
|
||||
#else
|
||||
messageInfo.GetPeerAddr().SetToRoutingLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), aRloc16);
|
||||
messageInfo.GetPeerAddr().SetToRoutingLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aRloc16);
|
||||
#endif
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocalRloc());
|
||||
messageInfo.SetSockAddr(Get<Mle::Mle>().GetMeshLocalRloc());
|
||||
messageInfo.mPeerPort = kDhcpServerPort;
|
||||
|
||||
SuccessOrExit(error = mSocket.SendTo(*message, messageInfo));
|
||||
|
||||
@@ -54,7 +54,7 @@ Server::Server(Instance &aInstance)
|
||||
Error Server::UpdateService(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t rloc16 = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
NetworkData::Iterator iterator;
|
||||
NetworkData::OnMeshPrefixConfig config;
|
||||
Lowpan::Context lowpanContext;
|
||||
@@ -159,7 +159,7 @@ void Server::AddPrefixAgent(const Ip6::Prefix &aIp6Prefix, const Lowpan::Context
|
||||
|
||||
VerifyOrExit(newEntry != nullptr, error = kErrorNoBufs);
|
||||
|
||||
newEntry->Set(aIp6Prefix, Get<Mle::MleRouter>().GetMeshLocalPrefix(), aContext.mContextId);
|
||||
newEntry->Set(aIp6Prefix, Get<Mle::Mle>().GetMeshLocalPrefix(), aContext.mContextId);
|
||||
Get<ThreadNetif>().AddUnicastAddress(newEntry->GetAloc());
|
||||
mPrefixAgentsCount++;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ bool Filter::Accept(Message &aMessage) const
|
||||
VerifyOrExit(headers.GetDestinationAddress().IsLinkLocalUnicastOrMulticast());
|
||||
|
||||
// Allow all link-local IPv6 datagrams when Thread is not enabled
|
||||
if (Get<Mle::MleRouter>().GetRole() == Mle::kRoleDisabled)
|
||||
if (Get<Mle::Mle>().GetRole() == Mle::kRoleDisabled)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace NeighborDiscovery {
|
||||
void Agent::UpdateService(void)
|
||||
{
|
||||
Error error;
|
||||
uint16_t rloc16 = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
NetworkData::Iterator iterator;
|
||||
NetworkData::OnMeshPrefixConfig config;
|
||||
Lowpan::Context lowpanContext;
|
||||
@@ -99,7 +99,7 @@ void Agent::UpdateService(void)
|
||||
uint16_t aloc16 = Mle::kAloc16NeighborDiscoveryAgentStart + lowpanContext.mContextId - 1;
|
||||
|
||||
mAloc.InitAsThreadOrigin();
|
||||
mAloc.GetAddress().SetToAnycastLocator(Get<Mle::MleRouter>().GetMeshLocalPrefix(), aloc16);
|
||||
mAloc.GetAddress().SetToAnycastLocator(Get<Mle::Mle>().GetMeshLocalPrefix(), aloc16);
|
||||
mAloc.mMeshLocal = true;
|
||||
Get<ThreadNetif>().AddUnicastAddress(mAloc);
|
||||
ExitNow();
|
||||
|
||||
@@ -214,7 +214,7 @@ void Link::BeginTransmit(void)
|
||||
{
|
||||
uint16_t fcf = Mac::Frame::kTypeAck;
|
||||
|
||||
if (!Get<Mle::MleRouter>().IsRxOnWhenIdle())
|
||||
if (!Get<Mle::Mle>().IsRxOnWhenIdle())
|
||||
{
|
||||
fcf |= kFcfFramePending;
|
||||
}
|
||||
@@ -275,20 +275,20 @@ void Link::HandleTimer(void)
|
||||
// router/leader during a partition merge, so it is always treated
|
||||
// as a neighbor.
|
||||
|
||||
switch (Get<Mle::MleRouter>().GetRole())
|
||||
switch (Get<Mle::Mle>().GetRole())
|
||||
{
|
||||
case Mle::kRoleDisabled:
|
||||
break;
|
||||
|
||||
case Mle::kRoleDetached:
|
||||
case Mle::kRoleChild:
|
||||
HandleTimer(Get<Mle::MleRouter>().GetParent());
|
||||
HandleTimer(Get<Mle::Mle>().GetParent());
|
||||
|
||||
OT_FALL_THROUGH;
|
||||
|
||||
case Mle::kRoleRouter:
|
||||
case Mle::kRoleLeader:
|
||||
HandleTimer(Get<Mle::MleRouter>().GetParentCandidate());
|
||||
HandleTimer(Get<Mle::Mle>().GetParentCandidate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ Error AddressResolver::GetNextCacheEntry(EntryInfo &aInfo, Iterator &aIterator)
|
||||
VerifyOrExit(entry->IsLastTransactionTimeValid());
|
||||
|
||||
aInfo.mLastTransTime = entry->GetLastTransactionTime();
|
||||
AsCoreType(&aInfo.mMeshLocalEid).SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
AsCoreType(&aInfo.mMeshLocalEid).SetPrefix(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
AsCoreType(&aInfo.mMeshLocalEid).SetIid(entry->GetMeshLocalIid());
|
||||
|
||||
ExitNow();
|
||||
@@ -369,7 +369,7 @@ void AddressResolver::UpdateSnoopedCacheEntry(const Ip6::Address &aEid, uint16_t
|
||||
uint16_t numNonEvictable = 0;
|
||||
CacheEntry *entry;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsFullThreadDevice());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsFullThreadDevice());
|
||||
|
||||
#if OPENTHREAD_CONFIG_TMF_ALLOW_ADDRESS_RESOLUTION_USING_NET_DATA_SERVICES
|
||||
{
|
||||
@@ -634,7 +634,7 @@ exit:
|
||||
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE
|
||||
if (Get<BackboneRouter::Local>().IsPrimary() && Get<BackboneRouter::Leader>().IsDomainUnicast(aEid))
|
||||
{
|
||||
uint16_t selfRloc16 = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t selfRloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
|
||||
LogInfo("Extending %s to %s for target %s, rloc16=%04x(self)", UriToString<kUriAddressQuery>(),
|
||||
UriToString<kUriBackboneQuery>(), aEid.ToString().AsCString(), selfRloc16);
|
||||
@@ -785,7 +785,7 @@ void AddressResolver::HandleTmf<kUriAddressError>(Coap::Message &aMessage, const
|
||||
|
||||
for (Ip6::Netif::UnicastAddress &address : Get<ThreadNetif>().GetUnicastAddresses())
|
||||
{
|
||||
if (address.GetAddress() == target && Get<Mle::MleRouter>().GetMeshLocalEid().GetIid() != meshLocalIid)
|
||||
if (address.GetAddress() == target && Get<Mle::Mle>().GetMeshLocalEid().GetIid() != meshLocalIid)
|
||||
{
|
||||
// Target EID matches address and Mesh Local EID differs
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
@@ -854,7 +854,7 @@ void AddressResolver::HandleTmf<kUriAddressQuery>(Coap::Message &aMessage, const
|
||||
|
||||
if (Get<ThreadNetif>().HasUnicastAddress(target))
|
||||
{
|
||||
SendAddressQueryResponse(target, Get<Mle::MleRouter>().GetMeshLocalEid().GetIid(), nullptr,
|
||||
SendAddressQueryResponse(target, Get<Mle::Mle>().GetMeshLocalEid().GetIid(), nullptr,
|
||||
aMessageInfo.GetPeerAddr());
|
||||
ExitNow();
|
||||
}
|
||||
@@ -903,7 +903,7 @@ void AddressResolver::SendAddressQueryResponse(const Ip6::Address &a
|
||||
|
||||
SuccessOrExit(error = Tlv::Append<ThreadTargetTlv>(*message, aTarget));
|
||||
SuccessOrExit(error = Tlv::Append<ThreadMeshLocalEidTlv>(*message, aMeshLocalIid));
|
||||
SuccessOrExit(error = Tlv::Append<ThreadRloc16Tlv>(*message, Get<Mle::MleRouter>().GetRloc16()));
|
||||
SuccessOrExit(error = Tlv::Append<ThreadRloc16Tlv>(*message, Get<Mle::Mle>().GetRloc16()));
|
||||
|
||||
if (aLastTransactionTime != nullptr)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <openthread/thread_ftd.h>
|
||||
|
||||
#include "coap/coap.hpp"
|
||||
#include "common/as_core_type.hpp"
|
||||
#include "common/linked_list.hpp"
|
||||
|
||||
@@ -116,7 +116,7 @@ exit:
|
||||
|
||||
void AnnounceSenderBase::HandleTimer(void)
|
||||
{
|
||||
Get<Mle::MleRouter>().SendAnnounce(mChannel);
|
||||
Get<Mle::Mle>().SendAnnounce(mChannel);
|
||||
|
||||
// Go to the next channel in the mask. If we have reached the end
|
||||
// of the channel mask, we start over from the first channel in
|
||||
@@ -206,7 +206,7 @@ void AnnounceSender::HandleRoleChanged(void)
|
||||
|
||||
case Mle::kRoleChild:
|
||||
#if OPENTHREAD_FTD
|
||||
if (Get<Mle::MleRouter>().IsRouterEligible() && Get<Mle::Mle>().IsRxOnWhenIdle())
|
||||
if (Get<Mle::Mle>().IsRouterEligible() && Get<Mle::Mle>().IsRxOnWhenIdle())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ Error Child::GetMeshLocalIp6Address(Ip6::Address &aAddress) const
|
||||
|
||||
VerifyOrExit(!mMeshLocalIid.IsUnspecified(), error = kErrorNotFound);
|
||||
|
||||
aAddress.SetPrefix(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
aAddress.SetPrefix(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
aAddress.SetIid(mMeshLocalIid);
|
||||
|
||||
exit:
|
||||
@@ -188,7 +188,7 @@ Error Child::AddIp6Address(const Ip6::Address &aAddress)
|
||||
|
||||
VerifyOrExit(!aAddress.IsUnspecified(), error = kErrorInvalidArgs);
|
||||
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::Mle>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
VerifyOrExit(mMeshLocalIid.IsUnspecified(), error = kErrorAlready);
|
||||
mMeshLocalIid = aAddress.GetIid();
|
||||
@@ -207,7 +207,7 @@ Error Child::RemoveIp6Address(const Ip6::Address &aAddress)
|
||||
Error error = kErrorNotFound;
|
||||
Ip6AddrEntry *entry;
|
||||
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::Mle>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
if (aAddress.GetIid() == mMeshLocalIid)
|
||||
{
|
||||
@@ -251,7 +251,7 @@ bool Child::HasIp6Address(const Ip6::Address &aAddress) const
|
||||
|
||||
VerifyOrExit(!aAddress.IsUnspecified());
|
||||
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::Mle>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
hasAddress = (aAddress.GetIid() == mMeshLocalIid);
|
||||
ExitNow();
|
||||
|
||||
@@ -182,8 +182,8 @@ void SupervisionListener::UpdateOnReceive(const Mac::Address &aSourceAddress, bo
|
||||
{
|
||||
// If listener is enabled and device is a child and it received a secure frame from its parent, restart the timer.
|
||||
|
||||
VerifyOrExit(mTimer.IsRunning() && aIsSecure && Get<Mle::MleRouter>().IsChild() &&
|
||||
(Get<NeighborTable>().FindNeighbor(aSourceAddress) == &Get<Mle::MleRouter>().GetParent()));
|
||||
VerifyOrExit(mTimer.IsRunning() && aIsSecure && Get<Mle::Mle>().IsChild() &&
|
||||
(Get<NeighborTable>().FindNeighbor(aSourceAddress) == &Get<Mle::Mle>().GetParent()));
|
||||
|
||||
RestartTimer();
|
||||
|
||||
@@ -193,7 +193,7 @@ exit:
|
||||
|
||||
void SupervisionListener::RestartTimer(void)
|
||||
{
|
||||
if ((mTimeout != 0) && !Get<Mle::MleRouter>().IsDisabled() && !Get<MeshForwarder>().GetRxOnWhenIdle())
|
||||
if ((mTimeout != 0) && !Get<Mle::Mle>().IsDisabled() && !Get<MeshForwarder>().GetRxOnWhenIdle())
|
||||
{
|
||||
mTimer.Start(Time::SecToMsec(mTimeout));
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void SupervisionListener::RestartTimer(void)
|
||||
|
||||
void SupervisionListener::HandleTimer(void)
|
||||
{
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsChild() && !Get<MeshForwarder>().GetRxOnWhenIdle());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsChild() && !Get<MeshForwarder>().GetRxOnWhenIdle());
|
||||
|
||||
LogWarn("Supervision timeout. No frame from parent in %u sec", mTimeout);
|
||||
mCounter++;
|
||||
|
||||
@@ -291,7 +291,7 @@ void DuaManager::UpdateCheckDelay(uint8_t aDelay)
|
||||
|
||||
void DuaManager::HandleNotifierEvents(Events aEvents)
|
||||
{
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
|
||||
#if OPENTHREAD_CONFIG_DUA_ENABLE
|
||||
if (aEvents.Contains(kEventThreadNetdataChanged))
|
||||
@@ -420,7 +420,7 @@ void DuaManager::UpdateTimeTickerRegistration(void)
|
||||
void DuaManager::PerformNextRegistration(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
Coap::Message *message = nullptr;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
Ip6::Address dua;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
#include "thread/thread_tlvs.hpp"
|
||||
|
||||
@@ -230,7 +230,7 @@ void KeyManager::ResetFrameCounters(void)
|
||||
Router *parent;
|
||||
|
||||
// reset parent frame counters
|
||||
parent = &Get<Mle::MleRouter>().GetParent();
|
||||
parent = &Get<Mle::Mle>().GetParent();
|
||||
parent->SetKeySequence(0);
|
||||
parent->GetLinkFrameCounters().Reset();
|
||||
parent->SetLinkAckFrameCounter(0);
|
||||
@@ -473,7 +473,7 @@ void KeyManager::MacFrameCounterUsed(uint32_t aMacFrameCounter)
|
||||
|
||||
if (mMacFrameCounters.Get154() >= mStoredMacFrameCounter)
|
||||
{
|
||||
IgnoreError(Get<Mle::MleRouter>().Store());
|
||||
IgnoreError(Get<Mle::Mle>().Store());
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -490,7 +490,7 @@ void KeyManager::IncrementTrelMacFrameCounter(void)
|
||||
|
||||
if (mMacFrameCounters.GetTrel() >= mStoredMacFrameCounter)
|
||||
{
|
||||
IgnoreError(Get<Mle::MleRouter>().Store());
|
||||
IgnoreError(Get<Mle::Mle>().Store());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -501,7 +501,7 @@ void KeyManager::IncrementMleFrameCounter(void)
|
||||
|
||||
if (mMleFrameCounter >= mStoredMleFrameCounter)
|
||||
{
|
||||
IgnoreError(Get<Mle::MleRouter>().Store());
|
||||
IgnoreError(Get<Mle::Mle>().Store());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -640,9 +640,9 @@ exit:
|
||||
|
||||
Error MeshForwarder::UpdateIp6Route(Message &aMessage)
|
||||
{
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Error error = kErrorNone;
|
||||
Ip6::Header ip6Header;
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
Error error = kErrorNone;
|
||||
Ip6::Header ip6Header;
|
||||
|
||||
mAddMeshHeader = false;
|
||||
|
||||
@@ -790,7 +790,7 @@ Mac::TxFrame *MeshForwarder::HandleFrameRequest(Mac::TxFrames &aTxFrames)
|
||||
{
|
||||
Mac::Address macDestAddr;
|
||||
|
||||
macDestAddr.SetShort(Get<Mle::MleRouter>().GetParent().GetRloc16());
|
||||
macDestAddr.SetShort(Get<Mle::Mle>().GetParent().GetRloc16());
|
||||
PrepareEmptyFrame(*frame, macDestAddr, /* aAckRequest */ true);
|
||||
}
|
||||
break;
|
||||
@@ -1172,7 +1172,7 @@ void MeshForwarder::UpdateNeighborLinkFailures(Neighbor &aNeighbor,
|
||||
(aNeighbor.GetLinkFailures() >= aFailLimit))
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
Get<Mle::MleRouter>().RemoveRouterLink(static_cast<Router &>(aNeighbor));
|
||||
Get<Mle::Mle>().RemoveRouterLink(static_cast<Router &>(aNeighbor));
|
||||
#else
|
||||
IgnoreError(Get<Mle::Mle>().BecomeDetached());
|
||||
#endif
|
||||
@@ -1726,7 +1726,7 @@ Error MeshForwarder::SendEmptyMessage(void)
|
||||
OwnedPtr<Message> messagePtr;
|
||||
|
||||
VerifyOrExit(mEnabled && !Get<Mac::Mac>().GetRxOnWhenIdle() &&
|
||||
Get<Mle::MleRouter>().GetParent().IsStateValidOrRestoring(),
|
||||
Get<Mle::Mle>().GetParent().IsStateValidOrRestoring(),
|
||||
error = kErrorInvalidState);
|
||||
|
||||
messagePtr.Reset(Get<MessagePool>().Allocate(Message::kTypeMacEmptyData));
|
||||
|
||||
@@ -389,9 +389,9 @@ exit:
|
||||
|
||||
Error MeshForwarder::UpdateIp6RouteFtd(const Ip6::Header &aIp6Header, Message &aMessage)
|
||||
{
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Error error = kErrorNone;
|
||||
Neighbor *neighbor;
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
Error error = kErrorNone;
|
||||
Neighbor *neighbor;
|
||||
|
||||
mMeshDest = Mle::kInvalidRloc16;
|
||||
|
||||
@@ -663,7 +663,7 @@ void MeshForwarder::ResolveRoutingLoops(uint16_t aSourceRloc16, uint16_t aDestRl
|
||||
VerifyOrExit(router != nullptr);
|
||||
|
||||
router->SetNextHopToInvalid();
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
|
||||
exit:
|
||||
return;
|
||||
@@ -696,7 +696,7 @@ void MeshForwarder::UpdateEidRlocCacheAndStaleChild(RxInfo &aRxInfo)
|
||||
|
||||
if (!Get<Mle::Mle>().HasMatchingRouterIdWith(aRxInfo.GetSrcAddr().GetShort()))
|
||||
{
|
||||
Get<Mle::MleRouter>().RemoveNeighbor(*neighbor);
|
||||
Get<Mle::Mle>().RemoveNeighbor(*neighbor);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
+98
-49
@@ -92,6 +92,36 @@ Mle::Mle(Instance &aInstance)
|
||||
, mWedAttachState(kWedDetached)
|
||||
, mWedAttachTimer(aInstance)
|
||||
#endif
|
||||
#if OPENTHREAD_FTD
|
||||
, mRouterEligible(true)
|
||||
, mAddressSolicitPending(false)
|
||||
, mAddressSolicitRejected(false)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mCcmEnabled(false)
|
||||
, mThreadVersionCheckEnabled(true)
|
||||
#endif
|
||||
, mNetworkIdTimeout(kNetworkIdTimeout)
|
||||
, mRouterUpgradeThreshold(kRouterUpgradeThreshold)
|
||||
, mRouterDowngradeThreshold(kRouterDowngradeThreshold)
|
||||
, mPreviousPartitionRouterIdSequence(0)
|
||||
, mPreviousPartitionIdTimeout(0)
|
||||
, mChildRouterLinks(kChildRouterLinks)
|
||||
, mAlternateRloc16Timeout(0)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mMaxChildIpAddresses(0)
|
||||
#endif
|
||||
, mParentPriority(kParentPriorityUnspecified)
|
||||
, mNextChildId(kMaxChildId)
|
||||
, mPreviousPartitionIdRouter(0)
|
||||
, mPreviousPartitionId(0)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mPreferredLeaderPartitionId(0)
|
||||
#endif
|
||||
, mAdvertiseTrickleTimer(aInstance, Mle::HandleAdvertiseTrickleTimer)
|
||||
, mChildTable(aInstance)
|
||||
, mRouterTable(aInstance)
|
||||
, mRouterRoleRestorer(aInstance)
|
||||
#endif // OPENTHREAD_FTD
|
||||
{
|
||||
mParent.Init(aInstance);
|
||||
mParentCandidate.Init(aInstance);
|
||||
@@ -121,6 +151,26 @@ Mle::Mle(Instance &aInstance)
|
||||
|
||||
mMeshLocalPrefix.Clear();
|
||||
SetMeshLocalPrefix(AsCoreType(&kMeshLocalPrefixInit));
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
mDeviceMode.Set(mDeviceMode.Get() | DeviceMode::kModeFullThreadDevice | DeviceMode::kModeFullNetworkData);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
mLeaderWeight = mDeviceProperties.CalculateLeaderWeight();
|
||||
#else
|
||||
mLeaderWeight = kDefaultLeaderWeight;
|
||||
#endif
|
||||
|
||||
mLeaderAloc.InitAsThreadOriginMeshLocal();
|
||||
|
||||
SetRouterId(kInvalidRouterId);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
mSteeringData.Clear();
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
}
|
||||
|
||||
Error Mle::Enable(void)
|
||||
@@ -193,7 +243,7 @@ Error Mle::Start(StartMode aMode)
|
||||
#if OPENTHREAD_FTD
|
||||
else if (IsRouterRloc16(GetRloc16()))
|
||||
{
|
||||
if (Get<MleRouter>().BecomeRouter(ThreadStatusTlv::kTooFewRouters) != kErrorNone)
|
||||
if (BecomeRouter(ThreadStatusTlv::kTooFewRouters) != kErrorNone)
|
||||
{
|
||||
Attach(kAnyPartition);
|
||||
}
|
||||
@@ -228,7 +278,7 @@ void Mle::Stop(StopMode aMode)
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(mMeshLocalEid);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
Get<MleRouter>().mRouterRoleRestorer.Stop();
|
||||
mRouterRoleRestorer.Stop();
|
||||
#endif
|
||||
|
||||
SetRole(kRoleDisabled);
|
||||
@@ -442,8 +492,8 @@ void Mle::Restore(void)
|
||||
#if OPENTHREAD_FTD
|
||||
else
|
||||
{
|
||||
Get<MleRouter>().SetRouterId(RouterIdFromRloc16(GetRloc16()));
|
||||
Get<MleRouter>().SetPreviousPartitionId(networkInfo.GetPreviousPartitionId());
|
||||
SetRouterId(RouterIdFromRloc16(GetRloc16()));
|
||||
SetPreviousPartitionId(networkInfo.GetPreviousPartitionId());
|
||||
Get<ChildTable>().Restore();
|
||||
}
|
||||
#endif
|
||||
@@ -603,7 +653,7 @@ void Mle::Attach(AttachMode aMode)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
Get<MleRouter>().StopAdvertiseTrickleTimer();
|
||||
StopAdvertiseTrickleTimer();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -695,7 +745,7 @@ void Mle::SetStateDetached(void)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsLeader())
|
||||
{
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(Get<MleRouter>().mLeaderAloc);
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -712,8 +762,8 @@ void Mle::SetStateDetached(void)
|
||||
Get<MeshForwarder>().SetRxOnWhenIdle(true);
|
||||
Get<Mac::Mac>().SetBeaconEnabled(false);
|
||||
#if OPENTHREAD_FTD
|
||||
Get<MleRouter>().ClearAlternateRloc16();
|
||||
Get<MleRouter>().HandleDetachStart();
|
||||
ClearAlternateRloc16();
|
||||
HandleDetachStart();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -722,7 +772,7 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsLeader())
|
||||
{
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(Get<MleRouter>().mLeaderAloc);
|
||||
Get<ThreadNetif>().RemoveUnicastAddress(mLeaderAloc);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -739,7 +789,7 @@ void Mle::SetStateChild(uint16_t aRloc16)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
Get<MleRouter>().HandleChildStart(mAttachMode);
|
||||
HandleChildStart(mAttachMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -768,7 +818,7 @@ void Mle::InformPreviousChannel(void)
|
||||
VerifyOrExit(IsChild() || IsRouter());
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
VerifyOrExit(!IsFullThreadDevice() || IsRouter() || !Get<MleRouter>().IsRouterRoleTransitionPending());
|
||||
VerifyOrExit(!IsFullThreadDevice() || IsRouter() || !IsRouterRoleTransitionPending());
|
||||
#endif
|
||||
|
||||
mAlternatePanId = Mac::kPanIdBroadcast;
|
||||
@@ -839,7 +889,7 @@ Error Mle::SetDeviceMode(DeviceMode aDeviceMode)
|
||||
#if OPENTHREAD_FTD
|
||||
if (!aDeviceMode.IsFullThreadDevice())
|
||||
{
|
||||
Get<MleRouter>().ClearAlternateRloc16();
|
||||
ClearAlternateRloc16();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -985,7 +1035,7 @@ void Mle::SetRloc16(uint16_t aRloc16)
|
||||
else
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
Get<MleRouter>().ClearAlternateRloc16();
|
||||
ClearAlternateRloc16();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1000,7 +1050,7 @@ void Mle::SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLead
|
||||
if (mLeaderData.GetPartitionId() != aPartitionId)
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
Get<MleRouter>().HandlePartitionChange();
|
||||
HandlePartitionChange();
|
||||
#endif
|
||||
Get<Notifier>().Signal(kEventThreadPartitionIdChanged);
|
||||
mCounters.mPartitionIdChanges++;
|
||||
@@ -1161,7 +1211,7 @@ void Mle::HandleNotifierEvents(Events aEvents)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
Get<MleRouter>().HandleNetworkDataUpdateRouter();
|
||||
HandleNetworkDataUpdateRouter();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -1206,7 +1256,7 @@ void Mle::HandleNotifierEvents(Events aEvents)
|
||||
#if OPENTHREAD_FTD
|
||||
if (aEvents.Contains(kEventSecurityPolicyChanged))
|
||||
{
|
||||
Get<MleRouter>().HandleSecurityPolicyChanged();
|
||||
HandleSecurityPolicyChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1446,9 +1496,9 @@ void Mle::HandleAttachTimer(void)
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsDetached() && Get<MleRouter>().mRouterRoleRestorer.IsActive())
|
||||
if (IsDetached() && mRouterRoleRestorer.IsActive())
|
||||
{
|
||||
Get<MleRouter>().mRouterRoleRestorer.HandleTimer();
|
||||
mRouterRoleRestorer.HandleTimer();
|
||||
ExitNow();
|
||||
}
|
||||
#endif
|
||||
@@ -1613,7 +1663,7 @@ uint32_t Mle::Reattach(void)
|
||||
IgnoreError(BecomeDetached());
|
||||
}
|
||||
#if OPENTHREAD_FTD
|
||||
else if (IsFullThreadDevice() && Get<MleRouter>().BecomeLeader(/* aCheckWeight */ false) == kErrorNone)
|
||||
else if (IsFullThreadDevice() && BecomeLeader(/* aCheckWeight */ false) == kErrorNone)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -2374,7 +2424,7 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
case kCommandDiscoveryRequest:
|
||||
Get<MleRouter>().HandleDiscoveryRequest(rxInfo);
|
||||
HandleDiscoveryRequest(rxInfo);
|
||||
break;
|
||||
#endif
|
||||
case kCommandDiscoveryResponse:
|
||||
@@ -2537,27 +2587,27 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
case kCommandLinkRequest:
|
||||
Get<MleRouter>().HandleLinkRequest(rxInfo);
|
||||
HandleLinkRequest(rxInfo);
|
||||
break;
|
||||
|
||||
case kCommandLinkAccept:
|
||||
Get<MleRouter>().HandleLinkAccept(rxInfo);
|
||||
HandleLinkAccept(rxInfo);
|
||||
break;
|
||||
|
||||
case kCommandLinkAcceptAndRequest:
|
||||
Get<MleRouter>().HandleLinkAcceptAndRequest(rxInfo);
|
||||
HandleLinkAcceptAndRequest(rxInfo);
|
||||
break;
|
||||
|
||||
case kCommandDataRequest:
|
||||
Get<MleRouter>().HandleDataRequest(rxInfo);
|
||||
HandleDataRequest(rxInfo);
|
||||
break;
|
||||
|
||||
case kCommandParentRequest:
|
||||
Get<MleRouter>().HandleParentRequest(rxInfo);
|
||||
HandleParentRequest(rxInfo);
|
||||
break;
|
||||
|
||||
case kCommandChildIdRequest:
|
||||
Get<MleRouter>().HandleChildIdRequest(rxInfo);
|
||||
HandleChildIdRequest(rxInfo);
|
||||
break;
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
@@ -2708,14 +2758,14 @@ void Mle::ReestablishLinkWithNeighbor(Neighbor &aNeighbor)
|
||||
|
||||
if (IsRouterRloc16(aNeighbor.GetRloc16()))
|
||||
{
|
||||
Get<MleRouter>().SendLinkRequest(static_cast<Router *>(&aNeighbor));
|
||||
SendLinkRequest(static_cast<Router *>(&aNeighbor));
|
||||
}
|
||||
else if (Get<ChildTable>().Contains(aNeighbor))
|
||||
{
|
||||
Child &child = static_cast<Child &>(aNeighbor);
|
||||
|
||||
child.SetState(Child::kStateChildUpdateRequest);
|
||||
IgnoreError(Get<MleRouter>().SendChildUpdateRequestToChild(child));
|
||||
IgnoreError(SendChildUpdateRequestToChild(child));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2741,7 +2791,7 @@ void Mle::HandleAdvertisement(RxInfo &aRxInfo)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
SuccessOrExit(error = Get<MleRouter>().HandleAdvertisementOnFtd(aRxInfo, sourceAddress, leaderData));
|
||||
SuccessOrExit(error = HandleAdvertisementOnFtd(aRxInfo, sourceAddress, leaderData));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2762,7 +2812,7 @@ void Mle::HandleAdvertisement(RxInfo &aRxInfo)
|
||||
SetLeaderData(leaderData);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
SuccessOrExit(error = Get<MleRouter>().ReadAndProcessRouteTlvOnFtdChild(aRxInfo, mParent.GetRouterId()));
|
||||
SuccessOrExit(error = ReadAndProcessRouteTlvOnFtdChild(aRxInfo, mParent.GetRouterId()));
|
||||
#endif
|
||||
|
||||
mRetrieveNewNetworkData = true;
|
||||
@@ -2808,7 +2858,7 @@ void Mle::HandleDataResponse(RxInfo &aRxInfo)
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
SuccessOrExit(error = Get<MleRouter>().ReadAndProcessRouteTlvOnFtdChild(aRxInfo, mParent.GetRouterId()));
|
||||
SuccessOrExit(error = ReadAndProcessRouteTlvOnFtdChild(aRxInfo, mParent.GetRouterId()));
|
||||
#endif
|
||||
|
||||
error = HandleLeaderData(aRxInfo);
|
||||
@@ -3149,8 +3199,8 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
|
||||
case kBetterPartition:
|
||||
VerifyOrExit(!isPartitionIdSame);
|
||||
|
||||
VerifyOrExit(MleRouter::ComparePartitions(connectivityTlv.IsSingleton(), leaderData,
|
||||
Get<MleRouter>().IsSingleton(), mLeaderData) > 0);
|
||||
VerifyOrExit(Mle::ComparePartitions(connectivityTlv.IsSingleton(), leaderData, IsSingleton(), mLeaderData) >
|
||||
0);
|
||||
break;
|
||||
|
||||
case kBetterParent:
|
||||
@@ -3172,8 +3222,8 @@ void Mle::HandleParentResponse(RxInfo &aRxInfo)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsFullThreadDevice())
|
||||
{
|
||||
compare = MleRouter::ComparePartitions(connectivityTlv.IsSingleton(), leaderData,
|
||||
mParentCandidate.mIsSingleton, mParentCandidate.mLeaderData);
|
||||
compare = Mle::ComparePartitions(connectivityTlv.IsSingleton(), leaderData, mParentCandidate.mIsSingleton,
|
||||
mParentCandidate.mLeaderData);
|
||||
}
|
||||
|
||||
// Only consider partitions that are the same or better
|
||||
@@ -3313,8 +3363,7 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
|
||||
SetLeaderData(leaderData);
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
SuccessOrExit(error =
|
||||
Get<MleRouter>().ReadAndProcessRouteTlvOnFtdChild(aRxInfo, RouterIdFromRloc16(sourceAddress)));
|
||||
SuccessOrExit(error = ReadAndProcessRouteTlvOnFtdChild(aRxInfo, RouterIdFromRloc16(sourceAddress)));
|
||||
#endif
|
||||
|
||||
mParentCandidate.CopyTo(mParent);
|
||||
@@ -3351,7 +3400,7 @@ void Mle::HandleChildUpdateRequest(RxInfo &aRxInfo)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsRouterOrLeader())
|
||||
{
|
||||
Get<MleRouter>().HandleChildUpdateRequestOnParent(aRxInfo);
|
||||
HandleChildUpdateRequestOnParent(aRxInfo);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -3474,7 +3523,7 @@ void Mle::HandleChildUpdateResponse(RxInfo &aRxInfo)
|
||||
#if OPENTHREAD_FTD
|
||||
if (IsRouterOrLeader())
|
||||
{
|
||||
Get<MleRouter>().HandleChildUpdateResponseOnParent(aRxInfo);
|
||||
HandleChildUpdateResponseOnParent(aRxInfo);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -4462,7 +4511,7 @@ Error Mle::DetachGracefully(DetachCallback aCallback, void *aContext)
|
||||
|
||||
case kRoleRouter:
|
||||
#if OPENTHREAD_FTD
|
||||
Get<MleRouter>().SendAddressRelease();
|
||||
SendAddressRelease();
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -4724,16 +4773,16 @@ void Mle::DelayedSender::Execute(const Schedule &aSchedule)
|
||||
ParentResponseInfo info;
|
||||
|
||||
IgnoreError(aSchedule.Read(sizeof(Header), info));
|
||||
Get<MleRouter>().SendParentResponse(info);
|
||||
Get<Mle>().SendParentResponse(info);
|
||||
break;
|
||||
}
|
||||
|
||||
case kTypeAdvertisement:
|
||||
Get<MleRouter>().SendAdvertisement(header.mDestination);
|
||||
Get<Mle>().SendAdvertisement(header.mDestination);
|
||||
break;
|
||||
|
||||
case kTypeDataResponse:
|
||||
Get<MleRouter>().SendMulticastDataResponse();
|
||||
Get<Mle>().SendMulticastDataResponse();
|
||||
break;
|
||||
|
||||
case kTypeLinkAccept:
|
||||
@@ -4741,7 +4790,7 @@ void Mle::DelayedSender::Execute(const Schedule &aSchedule)
|
||||
LinkAcceptInfo info;
|
||||
|
||||
IgnoreError(aSchedule.Read(sizeof(Header), info));
|
||||
IgnoreError(Get<MleRouter>().SendLinkAccept(info));
|
||||
IgnoreError(Get<Mle>().SendLinkAccept(info));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4755,7 +4804,7 @@ void Mle::DelayedSender::Execute(const Schedule &aSchedule)
|
||||
|
||||
if (router != nullptr)
|
||||
{
|
||||
Get<MleRouter>().SendLinkRequest(router);
|
||||
Get<Mle>().SendLinkRequest(router);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -4766,7 +4815,7 @@ void Mle::DelayedSender::Execute(const Schedule &aSchedule)
|
||||
DiscoveryResponseInfo info;
|
||||
|
||||
IgnoreError(aSchedule.Read(sizeof(Header), info));
|
||||
IgnoreError(Get<MleRouter>().SendDiscoveryResponse(header.mDestination, info));
|
||||
IgnoreError(Get<Mle>().SendDiscoveryResponse(header.mDestination, info));
|
||||
break;
|
||||
}
|
||||
#endif // OPENTHREAD_FTD
|
||||
@@ -5231,7 +5280,7 @@ Error Mle::TxMessage::AppendConnectivityTlv(void)
|
||||
ConnectivityTlv tlv;
|
||||
|
||||
tlv.Init();
|
||||
Get<MleRouter>().FillConnectivityTlv(tlv);
|
||||
Get<Mle>().FillConnectivityTlv(tlv);
|
||||
|
||||
return tlv.AppendTo(*this);
|
||||
}
|
||||
@@ -5321,9 +5370,9 @@ Error Mle::TxMessage::AppendSteeringDataTlv(void)
|
||||
MeshCoP::SteeringData steeringData;
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
if (!Get<MleRouter>().mSteeringData.IsEmpty())
|
||||
if (!Get<Mle>().mSteeringData.IsEmpty())
|
||||
{
|
||||
steeringData = Get<MleRouter>().mSteeringData;
|
||||
steeringData = Get<Mle>().mSteeringData;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
+658
-7
@@ -36,28 +36,41 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <openthread/thread_ftd.h>
|
||||
|
||||
#include "coap/coap_message.hpp"
|
||||
#include "common/callback.hpp"
|
||||
#include "common/encoding.hpp"
|
||||
#include "common/locator.hpp"
|
||||
#include "common/log.hpp"
|
||||
#include "common/non_copyable.hpp"
|
||||
#include "common/notifier.hpp"
|
||||
#include "common/time_ticker.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "common/trickle_timer.hpp"
|
||||
#include "crypto/aes_ccm.hpp"
|
||||
#include "mac/mac.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "mac/wakeup_tx_scheduler.hpp"
|
||||
#include "meshcop/dataset.hpp"
|
||||
#include "meshcop/joiner_router.hpp"
|
||||
#include "meshcop/meshcop.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "net/icmp6.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
#include "thread/child.hpp"
|
||||
#include "thread/child_table.hpp"
|
||||
#include "thread/link_metrics.hpp"
|
||||
#include "thread/link_metrics_tlvs.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/mle_tlvs.hpp"
|
||||
#include "thread/mle_types.hpp"
|
||||
#include "thread/neighbor_table.hpp"
|
||||
#include "thread/network_data_types.hpp"
|
||||
#include "thread/router.hpp"
|
||||
#include "thread/router_table.hpp"
|
||||
#include "thread/thread_tlvs.hpp"
|
||||
#include "thread/tmf.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
@@ -97,18 +110,11 @@ namespace Mle {
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
class MleRouter;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Implements MLE functionality required by the Thread EndDevices, Router, and Leader roles.
|
||||
*/
|
||||
class Mle : public InstanceLocator, private NonCopyable
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
friend class MleRouter;
|
||||
#endif
|
||||
friend class DiscoverScanner;
|
||||
friend class ot::Instance;
|
||||
friend class ot::Notifier;
|
||||
@@ -117,6 +123,10 @@ class Mle : public InstanceLocator, private NonCopyable
|
||||
friend class ot::LinkMetrics::Initiator;
|
||||
#endif
|
||||
friend class ot::UnitTester;
|
||||
#if OPENTHREAD_FTD
|
||||
friend class ot::TimeTicker;
|
||||
friend class Tmf::Agent;
|
||||
#endif
|
||||
|
||||
public:
|
||||
typedef otDetachGracefullyCallback DetachCallback; ///< Callback to signal end of graceful detach.
|
||||
@@ -758,6 +768,408 @@ public:
|
||||
void *aCallbackContext);
|
||||
#endif // OPENTHREAD_CONFIG_WAKEUP_COORDINATOR_ENABLE
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
/**
|
||||
* Indicates whether or not the device is router-eligible.
|
||||
*
|
||||
* @retval true If device is router-eligible.
|
||||
* @retval false If device is not router-eligible.
|
||||
*/
|
||||
bool IsRouterEligible(void) const;
|
||||
|
||||
/**
|
||||
* Sets whether or not the device is router-eligible.
|
||||
*
|
||||
* If @p aEligible is false and the device is currently operating as a router, this call will cause the device to
|
||||
* detach and attempt to reattach as a child.
|
||||
*
|
||||
* @param[in] aEligible TRUE to configure device router-eligible, FALSE otherwise.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the router-eligible configuration.
|
||||
* @retval kErrorNotCapable The device is not capable of becoming a router.
|
||||
*/
|
||||
Error SetRouterEligible(bool aEligible);
|
||||
|
||||
/**
|
||||
* Indicates whether a node is the only router on the network.
|
||||
*
|
||||
* @retval TRUE It is the only router in the network.
|
||||
* @retval FALSE It is a child or is not a single router in the network.
|
||||
*/
|
||||
bool IsSingleton(void) const;
|
||||
|
||||
/**
|
||||
* Generates an Address Solicit request for a Router ID.
|
||||
*
|
||||
* @param[in] aStatus The reason for requesting a Router ID.
|
||||
*
|
||||
* @retval kErrorNone Successfully generated an Address Solicit message.
|
||||
* @retval kErrorNotCapable Device is not capable of becoming a router
|
||||
* @retval kErrorInvalidState Thread is not enabled
|
||||
*/
|
||||
Error BecomeRouter(ThreadStatusTlv::Status aStatus);
|
||||
|
||||
/**
|
||||
* Becomes a leader and starts a new partition.
|
||||
*
|
||||
* If the device is already attached, this method can be used to attempt to take over as the leader, creating a new
|
||||
* partition. For this to work, the local leader weight must be greater than the weight of the current leader. The
|
||||
* @p aCheckWeight can be used to ensure that this check is performed.
|
||||
*
|
||||
* @param[in] aCheckWeight Check that the local leader weight is larger than the weight of the current leader.
|
||||
*
|
||||
* @retval kErrorNone Successfully become a Leader and started a new partition.
|
||||
* @retval kErrorInvalidState Thread is not enabled.
|
||||
* @retval kErrorNotCapable Device is not capable of becoming a leader (not router eligible), or
|
||||
* @p aCheckWeight is true and cannot override the current leader due to its local
|
||||
* leader weight being same or smaller than current leader's weight.
|
||||
*/
|
||||
Error BecomeLeader(bool aCheckWeight);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
/**
|
||||
* Gets the device properties which are used to determine the Leader Weight.
|
||||
*
|
||||
* @returns The current device properties.
|
||||
*/
|
||||
const DeviceProperties &GetDeviceProperties(void) const { return mDeviceProperties; }
|
||||
|
||||
/**
|
||||
* Sets the device properties which are then used to determine and set the Leader Weight.
|
||||
*
|
||||
* @param[in] aDeviceProperties The device properties.
|
||||
*/
|
||||
void SetDeviceProperties(const DeviceProperties &aDeviceProperties);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the Leader Weighting value for this Thread interface.
|
||||
*
|
||||
* @returns The Leader Weighting value for this Thread interface.
|
||||
*/
|
||||
uint8_t GetLeaderWeight(void) const { return mLeaderWeight; }
|
||||
|
||||
/**
|
||||
* Sets the Leader Weighting value for this Thread interface.
|
||||
*
|
||||
* Directly sets the Leader Weight to the new value replacing its previous value (which may have been
|
||||
* determined from a previous call to `SetDeviceProperties()`).
|
||||
*
|
||||
* @param[in] aWeight The Leader Weighting value.
|
||||
*/
|
||||
void SetLeaderWeight(uint8_t aWeight) { mLeaderWeight = aWeight; }
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
/**
|
||||
* Returns the preferred Partition Id when operating in the Leader role for certification testing.
|
||||
*
|
||||
* @returns The preferred Partition Id value.
|
||||
*/
|
||||
uint32_t GetPreferredLeaderPartitionId(void) const { return mPreferredLeaderPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the preferred Partition Id when operating in the Leader role for certification testing.
|
||||
*
|
||||
* @param[in] aPartitionId The preferred Leader Partition Id.
|
||||
*/
|
||||
void SetPreferredLeaderPartitionId(uint32_t aPartitionId) { mPreferredLeaderPartitionId = aPartitionId; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets the preferred Router Id. Upon becoming a router/leader the node
|
||||
* attempts to use this Router Id. If the preferred Router Id is not set or if it
|
||||
* can not be used, a randomly generated router Id is picked.
|
||||
* This property can be set when he device role is detached or disabled.
|
||||
*
|
||||
* @param[in] aRouterId The preferred Router Id.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the preferred Router Id.
|
||||
* @retval kErrorInvalidState Could not set (role is other than detached and disabled)
|
||||
*/
|
||||
Error SetPreferredRouterId(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Gets the Partition Id which the device joined successfully once.
|
||||
*/
|
||||
uint32_t GetPreviousPartitionId(void) const { return mPreviousPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the Partition Id which the device joins successfully.
|
||||
*
|
||||
* @param[in] aPartitionId The Partition Id.
|
||||
*/
|
||||
void SetPreviousPartitionId(uint32_t aPartitionId) { mPreviousPartitionId = aPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the Router Id.
|
||||
*
|
||||
* @param[in] aRouterId The Router Id.
|
||||
*/
|
||||
void SetRouterId(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Returns the NETWORK_ID_TIMEOUT value.
|
||||
*
|
||||
* @returns The NETWORK_ID_TIMEOUT value.
|
||||
*/
|
||||
uint8_t GetNetworkIdTimeout(void) const { return mNetworkIdTimeout; }
|
||||
|
||||
/**
|
||||
* Sets the NETWORK_ID_TIMEOUT value.
|
||||
*
|
||||
* @param[in] aTimeout The NETWORK_ID_TIMEOUT value.
|
||||
*/
|
||||
void SetNetworkIdTimeout(uint8_t aTimeout) { mNetworkIdTimeout = aTimeout; }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @returns The ROUTER_SELECTION_JITTER value in seconds.
|
||||
*/
|
||||
uint8_t GetRouterSelectionJitter(void) const { return mRouterRoleTransition.GetJitter(); }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @param[in] aRouterJitter The router selection jitter value (in seconds).
|
||||
*/
|
||||
void SetRouterSelectionJitter(uint8_t aRouterJitter) { mRouterRoleTransition.SetJitter(aRouterJitter); }
|
||||
|
||||
/**
|
||||
* Indicates whether or not router role transition (upgrade from REED or downgrade to REED) is pending.
|
||||
*
|
||||
* @retval TRUE Router role transition is pending.
|
||||
* @retval FALSE Router role transition is not pending
|
||||
*/
|
||||
bool IsRouterRoleTransitionPending(void) const { return mRouterRoleTransition.IsPending(); }
|
||||
|
||||
/**
|
||||
* Returns the current timeout delay in seconds till router role transition (upgrade from REED or downgrade to
|
||||
* REED).
|
||||
*
|
||||
* @returns The timeout in seconds till router role transition, or zero if not pending role transition.
|
||||
*/
|
||||
uint8_t GetRouterRoleTransitionTimeout(void) const { return mRouterRoleTransition.GetTimeout(); }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @returns The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*/
|
||||
uint8_t GetRouterUpgradeThreshold(void) const { return mRouterUpgradeThreshold; }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @param[in] aThreshold The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*/
|
||||
void SetRouterUpgradeThreshold(uint8_t aThreshold) { mRouterUpgradeThreshold = aThreshold; }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @returns The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*/
|
||||
uint8_t GetRouterDowngradeThreshold(void) const { return mRouterDowngradeThreshold; }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @param[in] aThreshold The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*/
|
||||
void SetRouterDowngradeThreshold(uint8_t aThreshold) { mRouterDowngradeThreshold = aThreshold; }
|
||||
|
||||
/**
|
||||
* Returns the MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @returns The MLE_CHILD_ROUTER_LINKS value.
|
||||
*/
|
||||
uint8_t GetChildRouterLinks(void) const { return mChildRouterLinks; }
|
||||
|
||||
/**
|
||||
* Sets the MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @param[in] aChildRouterLinks The MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the value.
|
||||
* @retval kErrorInvalidState Thread protocols are enabled.
|
||||
*/
|
||||
Error SetChildRouterLinks(uint8_t aChildRouterLinks);
|
||||
|
||||
/**
|
||||
* Returns if the REED is expected to become Router soon.
|
||||
*
|
||||
* @retval TRUE If the REED is going to become a Router soon.
|
||||
* @retval FALSE If the REED is not going to become a Router soon.
|
||||
*/
|
||||
bool IsExpectedToBecomeRouterSoon(void) const;
|
||||
|
||||
/**
|
||||
* Removes a link to a neighbor.
|
||||
*
|
||||
* @param[in] aNeighbor A reference to the neighbor object.
|
||||
*/
|
||||
void RemoveNeighbor(Neighbor &aNeighbor);
|
||||
|
||||
/**
|
||||
* Invalidates a direct link to a neighboring router (due to failed link-layer acks).
|
||||
*
|
||||
* @param[in] aRouter A reference to the router object.
|
||||
*/
|
||||
void RemoveRouterLink(Router &aRouter);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the given Thread partition attributes are preferred.
|
||||
*
|
||||
* @param[in] aSingletonA Whether or not the Thread Partition A has a single router.
|
||||
* @param[in] aLeaderDataA A reference to Thread Partition A's Leader Data.
|
||||
* @param[in] aSingletonB Whether or not the Thread Partition B has a single router.
|
||||
* @param[in] aLeaderDataB A reference to Thread Partition B's Leader Data.
|
||||
*
|
||||
* @retval 1 If partition A is preferred.
|
||||
* @retval 0 If partition A and B have equal preference.
|
||||
* @retval -1 If partition B is preferred.
|
||||
*/
|
||||
static int ComparePartitions(bool aSingletonA,
|
||||
const LeaderData &aLeaderDataA,
|
||||
bool aSingletonB,
|
||||
const LeaderData &aLeaderDataB);
|
||||
|
||||
/**
|
||||
* Fills an ConnectivityTlv.
|
||||
*
|
||||
* @param[out] aTlv A reference to the tlv to be filled.
|
||||
*/
|
||||
void FillConnectivityTlv(ConnectivityTlv &aTlv);
|
||||
|
||||
/**
|
||||
* Schedule tx of MLE Advertisement message (unicast) to the given neighboring router after a random delay.
|
||||
*
|
||||
* @param[in] aRouter The router to send the Advertisement to.
|
||||
*
|
||||
*/
|
||||
void ScheduleUnicastAdvertisementTo(const Router &aRouter);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
/**
|
||||
* Sets steering data out of band
|
||||
*
|
||||
* @param[in] aExtAddress Value used to set steering data
|
||||
* All zeros clears steering data
|
||||
* All 0xFFs sets steering data to 0xFF
|
||||
* Anything else is used to compute the bloom filter
|
||||
*/
|
||||
void SetSteeringData(const Mac::ExtAddress *aExtAddress);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the assigned parent priority.
|
||||
*
|
||||
* @returns The assigned parent priority value, -2 means not assigned.
|
||||
*/
|
||||
int8_t GetAssignParentPriority(void) const { return mParentPriority; }
|
||||
|
||||
/**
|
||||
* Sets the parent priority.
|
||||
*
|
||||
* @param[in] aParentPriority The parent priority value.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the parent priority.
|
||||
* @retval kErrorInvalidArgs If the parent priority value is not among 1, 0, -1 and -2.
|
||||
*/
|
||||
Error SetAssignParentPriority(int8_t aParentPriority);
|
||||
|
||||
/**
|
||||
* Gets the longest MLE Timeout TLV for all active MTD children.
|
||||
*
|
||||
* @param[out] aTimeout A reference to where the information is placed.
|
||||
*
|
||||
* @retval kErrorNone Successfully get the max child timeout
|
||||
* @retval kErrorInvalidState Not an active router
|
||||
* @retval kErrorNotFound NO MTD child
|
||||
*/
|
||||
Error GetMaxChildTimeout(uint32_t &aTimeout) const;
|
||||
|
||||
/**
|
||||
* Sets the callback that is called when processing an MLE Discovery Request message.
|
||||
*
|
||||
* @param[in] aCallback A pointer to a function that is called to deliver MLE Discovery Request data.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
void SetDiscoveryRequestCallback(otThreadDiscoveryRequestCallback aCallback, void *aContext)
|
||||
{
|
||||
mDiscoveryRequestCallback.Set(aCallback, aContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the MLE Advertisement Trickle timer interval.
|
||||
*/
|
||||
void ResetAdvertiseInterval(void);
|
||||
|
||||
/**
|
||||
* Updates the MLE Advertisement Trickle timer max interval (if timer is running).
|
||||
*
|
||||
* This is called when there is change in router table.
|
||||
*/
|
||||
void UpdateAdvertiseInterval(void);
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
/**
|
||||
* Generates an MLE Time Synchronization message.
|
||||
*
|
||||
* @retval kErrorNone Successfully sent an MLE Time Synchronization message.
|
||||
* @retval kErrorNoBufs Insufficient buffers to generate the MLE Time Synchronization message.
|
||||
*/
|
||||
Error SendTimeSync(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*
|
||||
* @returns The maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*/
|
||||
uint8_t GetMaxChildIpAddresses(void) const;
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
/**
|
||||
* Sets/restores the maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent.
|
||||
*
|
||||
* @param[in] aMaxIpAddresses The maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent. 0 to clear the setting and restore the default.
|
||||
*
|
||||
* @retval kErrorNone Successfully set/cleared the number.
|
||||
* @retval kErrorInvalidArgs If exceeds the allowed maximum number.
|
||||
*/
|
||||
Error SetMaxChildIpAddresses(uint8_t aMaxIpAddresses);
|
||||
|
||||
/**
|
||||
* Sets whether the device was commissioned using CCM.
|
||||
*
|
||||
* @param[in] aEnabled TRUE if the device was commissioned using CCM, FALSE otherwise.
|
||||
*/
|
||||
void SetCcmEnabled(bool aEnabled) { mCcmEnabled = aEnabled; }
|
||||
|
||||
/**
|
||||
* Sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled.
|
||||
*
|
||||
* @param[in] aEnabled TRUE to enable Security Policy TLV version-threshold for routing, FALSE otherwise.
|
||||
*/
|
||||
void SetThreadVersionCheckEnabled(bool aEnabled) { mThreadVersionCheckEnabled = aEnabled; }
|
||||
|
||||
/**
|
||||
* Gets the current Interval Max value used by Advertisement trickle timer.
|
||||
*
|
||||
* @returns The Interval Max of Advertisement trickle timer in milliseconds.
|
||||
*/
|
||||
uint32_t GetAdvertisementTrickleIntervalMax(void) const { return mAdvertiseTrickleTimer.GetIntervalMax(); }
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Constants
|
||||
@@ -832,6 +1244,65 @@ private:
|
||||
static constexpr uint32_t kDefaultChildTimeout = OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT;
|
||||
static constexpr uint32_t kDefaultCslTimeout = OPENTHREAD_CONFIG_CSL_TIMEOUT;
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
// Advertisement trickle timer constants - all times are in milliseconds.
|
||||
static constexpr uint32_t kAdvIntervalMin = 1000; // I_MIN
|
||||
static constexpr uint32_t kAdvIntervalNeighborMultiplier = 4000; // Multiplier for I_MAX per router neighbor
|
||||
static constexpr uint32_t kAdvIntervalMaxLowerBound = 12000; // Lower bound for I_MAX
|
||||
static constexpr uint32_t kAdvIntervalMaxUpperBound = 32000; // Upper bound for I_MAX
|
||||
static constexpr uint32_t kReedAdvIntervalMin = 570000;
|
||||
static constexpr uint32_t kReedAdvIntervalMax = 630000;
|
||||
#if OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE
|
||||
static constexpr uint32_t kAdvIntervalMaxLogRoutes = 5000;
|
||||
#endif
|
||||
|
||||
static constexpr uint32_t kMaxUnicastAdvertisementDelay = 1000; // Max random delay for unciast Adv tx
|
||||
static constexpr uint32_t kMaxNeighborAge = 100000; // Max neighbor age on router (in msec)
|
||||
static constexpr uint32_t kMaxNeighborAgeOnChild = 150000; // Max neighbor age on FTD child (in msec)
|
||||
static constexpr uint32_t kMaxLeaderToRouterTimeout = 90000; // (in msec)
|
||||
static constexpr uint8_t kMinDowngradeNeighbors = 7;
|
||||
static constexpr uint8_t kNetworkIdTimeout = 120; // (in sec)
|
||||
static constexpr uint8_t kRouterSelectionJitter = 120; // (in sec)
|
||||
static constexpr uint8_t kRouterDowngradeThreshold = 23;
|
||||
static constexpr uint8_t kRouterUpgradeThreshold = 16;
|
||||
static constexpr uint16_t kDiscoveryMaxJitter = 250; // Max jitter delay Discovery Responses (in msec).
|
||||
static constexpr uint16_t kUnsolicitedDataResponseJitter = 500; // Max delay for unsol Data Response (in msec).
|
||||
static constexpr uint8_t kLeaderDowngradeExtraDelay = 10; // Extra delay to downgrade leader (in sec).
|
||||
static constexpr uint8_t kDefaultLeaderWeight = 64;
|
||||
static constexpr uint8_t kAlternateRloc16Timeout = 8; // Time to use alternate RLOC16 (in sec).
|
||||
|
||||
// Threshold to accept a router upgrade request with reason
|
||||
// `kBorderRouterRequest` (number of BRs acting as router in
|
||||
// Network Data).
|
||||
static constexpr uint8_t kRouterUpgradeBorderRouterRequestThreshold = 2;
|
||||
|
||||
static constexpr uint8_t kLinkRequestMinMargin = OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN;
|
||||
static constexpr uint8_t kPartitionMergeMinMargin = OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN;
|
||||
static constexpr uint8_t kChildRouterLinks = OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS;
|
||||
static constexpr uint8_t kMaxChildIpAddresses = OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD;
|
||||
|
||||
// Constants for gradual router link establishment (on FTD child)
|
||||
struct GradualChildRouterLink
|
||||
{
|
||||
static constexpr uint8_t kExtraChildRouterLinks = OPENTHREAD_CONFIG_MLE_EXTRA_CHILD_ROUTER_LINKS_GRADUAL;
|
||||
static constexpr uint32_t kWaitDurationAfterAttach = 300; // in seconds (5 minutes)
|
||||
static constexpr uint32_t kMinLinkRequestDelay = 1500; // in msec
|
||||
static constexpr uint32_t kMaxLinkRequestDelay = 10000; // in msec
|
||||
static constexpr uint32_t kProbabilityPercentage = 5; // in percent
|
||||
};
|
||||
|
||||
static constexpr uint8_t kMinCriticalChildrenCount = 6;
|
||||
|
||||
static constexpr uint16_t kChildSupervisionDefaultIntervalForOlderVersion =
|
||||
OPENTHREAD_CONFIG_CHILD_SUPERVISION_OLDER_VERSION_CHILD_DEFAULT_INTERVAL;
|
||||
|
||||
static constexpr int8_t kParentPriorityHigh = 1;
|
||||
static constexpr int8_t kParentPriorityMedium = 0;
|
||||
static constexpr int8_t kParentPriorityLow = -1;
|
||||
static constexpr int8_t kParentPriorityUnspecified = -2;
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Enumerations
|
||||
|
||||
@@ -1317,6 +1788,57 @@ private:
|
||||
};
|
||||
#endif // OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
class RouterRoleTransition
|
||||
{
|
||||
public:
|
||||
RouterRoleTransition(void);
|
||||
|
||||
bool IsPending(void) const { return (mTimeout != 0); }
|
||||
void StartTimeout(void);
|
||||
void StopTimeout(void) { mTimeout = 0; }
|
||||
void IncreaseTimeout(uint8_t aIncrement) { mTimeout += aIncrement; }
|
||||
uint8_t GetTimeout(void) const { return mTimeout; }
|
||||
bool HandleTimeTick(void);
|
||||
uint8_t GetJitter(void) const { return mJitter; }
|
||||
void SetJitter(uint8_t aJitter) { mJitter = aJitter; }
|
||||
|
||||
private:
|
||||
uint8_t mTimeout;
|
||||
uint8_t mJitter;
|
||||
};
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
class RouterRoleRestorer : public InstanceLocator
|
||||
{
|
||||
// Attempts to restore the router or leader role after an MLE
|
||||
// restart(e.g., after a device reboot) by sending multicast
|
||||
// Link Requests.
|
||||
|
||||
public:
|
||||
RouterRoleRestorer(Instance &aInstance);
|
||||
|
||||
bool IsActive(void) const { return mAttempts > 0; }
|
||||
void Start(DeviceRole aPreviousRole);
|
||||
void Stop(void) { mAttempts = 0; }
|
||||
void HandleTimer(void);
|
||||
|
||||
void GenerateRandomChallenge(void) { mChallenge.GenerateRandom(); }
|
||||
const TxChallenge &GetChallenge(void) const { return mChallenge; }
|
||||
|
||||
private:
|
||||
void SendMulticastLinkRequest(void);
|
||||
|
||||
uint8_t mAttempts;
|
||||
TxChallenge mChallenge;
|
||||
};
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
@@ -1452,6 +1974,83 @@ private:
|
||||
static void LogSendError(MessageType, Error) {}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
void SetAlternateRloc16(uint16_t aRloc16);
|
||||
void ClearAlternateRloc16(void);
|
||||
void HandleDetachStart(void);
|
||||
void HandleChildStart(AttachMode aMode);
|
||||
void HandleSecurityPolicyChanged(void);
|
||||
void HandleLinkRequest(RxInfo &aRxInfo);
|
||||
void HandleLinkAccept(RxInfo &aRxInfo);
|
||||
void HandleLinkAcceptAndRequest(RxInfo &aRxInfo);
|
||||
void HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType);
|
||||
Error HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData);
|
||||
void HandleParentRequest(RxInfo &aRxInfo);
|
||||
void HandleChildIdRequest(RxInfo &aRxInfo);
|
||||
void HandleChildUpdateRequestOnParent(RxInfo &aRxInfo);
|
||||
void HandleChildUpdateResponseOnParent(RxInfo &aRxInfo);
|
||||
void HandleDataRequest(RxInfo &aRxInfo);
|
||||
void HandleNetworkDataUpdateRouter(void);
|
||||
void HandleDiscoveryRequest(RxInfo &aRxInfo);
|
||||
void EstablishRouterLinkOnFtdChild(Router &aRouter, RxInfo &aRxInfo, uint8_t aLinkMargin);
|
||||
Error ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo);
|
||||
Error ReadAndProcessRouteTlvOnFtdChild(RxInfo &aRxInfo, uint8_t aParentId);
|
||||
void StopAdvertiseTrickleTimer(void);
|
||||
uint32_t DetermineAdvertiseIntervalMax(void) const;
|
||||
Error SendAddressSolicit(ThreadStatusTlv::Status aStatus);
|
||||
void SendAddressSolicitResponse(const Coap::Message &aRequest,
|
||||
ThreadStatusTlv::Status aResponseStatus,
|
||||
const Router *aRouter,
|
||||
const Ip6::MessageInfo &aMessageInfo);
|
||||
void SendAddressRelease(void);
|
||||
void SendMulticastAdvertisement(void);
|
||||
void SendAdvertisement(const Ip6::Address &aDestination);
|
||||
void SendLinkRequest(Router *aRouter);
|
||||
Error SendLinkAccept(const LinkAcceptInfo &aInfo);
|
||||
void SendParentResponse(const ParentResponseInfo &aInfo);
|
||||
Error SendChildIdResponse(Child &aChild);
|
||||
Error SendChildUpdateRequestToChild(Child &aChild);
|
||||
void SendChildUpdateResponseToChild(Child *aChild,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
const TlvList &aTlvList,
|
||||
const RxChallenge &aChallenge);
|
||||
void SendMulticastDataResponse(void);
|
||||
void SendDataResponse(const Ip6::Address &aDestination,
|
||||
const TlvList &aTlvList,
|
||||
const Message *aRequestMessage = nullptr);
|
||||
Error SendDiscoveryResponse(const Ip6::Address &aDestination, const DiscoveryResponseInfo &aInfo);
|
||||
void SetStateRouter(uint16_t aRloc16);
|
||||
void SetStateLeader(uint16_t aRloc16, LeaderStartMode aStartMode);
|
||||
void SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, LeaderStartMode aStartMode);
|
||||
void StopLeader(void);
|
||||
void SynchronizeChildNetworkData(void);
|
||||
Error ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild);
|
||||
bool HasNeighborWithGoodLinkQuality(void) const;
|
||||
void HandlePartitionChange(void);
|
||||
void SetChildStateToValid(Child &aChild);
|
||||
bool HasChildren(void);
|
||||
void RemoveChildren(void);
|
||||
bool ShouldDowngrade(uint8_t aNeighborId, const RouteTlv &aRouteTlv) const;
|
||||
bool NeighborHasComparableConnectivity(const RouteTlv &aRouteTlv, uint8_t aNeighborId) const;
|
||||
void HandleAdvertiseTrickleTimer(void);
|
||||
void HandleAddressSolicitResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);
|
||||
void HandleTimeTick(void);
|
||||
|
||||
template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
#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);
|
||||
static void HandleAddressSolicitResponse(void *aContext,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
otError aResult);
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Variables
|
||||
|
||||
@@ -1533,8 +2132,60 @@ private:
|
||||
WedAttachTimer mWedAttachTimer;
|
||||
Callback<WakeupCallback> mWakeupCallback;
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
bool mRouterEligible : 1;
|
||||
bool mAddressSolicitPending : 1;
|
||||
bool mAddressSolicitRejected : 1;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
bool mCcmEnabled : 1;
|
||||
bool mThreadVersionCheckEnabled : 1;
|
||||
#endif
|
||||
|
||||
uint8_t mRouterId;
|
||||
uint8_t mPreviousRouterId;
|
||||
uint8_t mNetworkIdTimeout;
|
||||
uint8_t mRouterUpgradeThreshold;
|
||||
uint8_t mRouterDowngradeThreshold;
|
||||
uint8_t mLeaderWeight;
|
||||
uint8_t mPreviousPartitionRouterIdSequence;
|
||||
uint8_t mPreviousPartitionIdTimeout;
|
||||
uint8_t mChildRouterLinks;
|
||||
uint8_t mAlternateRloc16Timeout;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
uint8_t mMaxChildIpAddresses;
|
||||
#endif
|
||||
int8_t mParentPriority;
|
||||
uint16_t mNextChildId;
|
||||
uint32_t mPreviousPartitionIdRouter;
|
||||
uint32_t mPreviousPartitionId;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
uint32_t mPreferredLeaderPartitionId;
|
||||
#endif
|
||||
|
||||
TrickleTimer mAdvertiseTrickleTimer;
|
||||
ChildTable mChildTable;
|
||||
RouterTable mRouterTable;
|
||||
RouterRoleRestorer mRouterRoleRestorer;
|
||||
RouterRoleTransition mRouterRoleTransition;
|
||||
Ip6::Netif::UnicastAddress mLeaderAloc;
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
DeviceProperties mDeviceProperties;
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
MeshCoP::SteeringData mSteeringData;
|
||||
#endif
|
||||
Callback<otThreadDiscoveryRequestCallback> mDiscoveryRequestCallback;
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
};
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
DeclareTmfHandler(Mle, kUriAddressSolicit);
|
||||
DeclareTmfHandler(Mle, kUriAddressRelease);
|
||||
#endif
|
||||
|
||||
} // namespace Mle
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* This file implements MLE functionality required for the Thread Router and Leader roles.
|
||||
*/
|
||||
|
||||
#include "mle_router.hpp"
|
||||
#include "mle.hpp"
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
@@ -41,55 +41,7 @@ namespace Mle {
|
||||
|
||||
RegisterLogModule("Mle");
|
||||
|
||||
MleRouter::MleRouter(Instance &aInstance)
|
||||
: Mle(aInstance)
|
||||
, mRouterEligible(true)
|
||||
, mAddressSolicitPending(false)
|
||||
, mAddressSolicitRejected(false)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mCcmEnabled(false)
|
||||
, mThreadVersionCheckEnabled(true)
|
||||
#endif
|
||||
, mNetworkIdTimeout(kNetworkIdTimeout)
|
||||
, mRouterUpgradeThreshold(kRouterUpgradeThreshold)
|
||||
, mRouterDowngradeThreshold(kRouterDowngradeThreshold)
|
||||
, mPreviousPartitionRouterIdSequence(0)
|
||||
, mPreviousPartitionIdTimeout(0)
|
||||
, mChildRouterLinks(kChildRouterLinks)
|
||||
, mAlternateRloc16Timeout(0)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mMaxChildIpAddresses(0)
|
||||
#endif
|
||||
, mParentPriority(kParentPriorityUnspecified)
|
||||
, mNextChildId(kMaxChildId)
|
||||
, mPreviousPartitionIdRouter(0)
|
||||
, mPreviousPartitionId(0)
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
, mPreferredLeaderPartitionId(0)
|
||||
#endif
|
||||
, mAdvertiseTrickleTimer(aInstance, MleRouter::HandleAdvertiseTrickleTimer)
|
||||
, mChildTable(aInstance)
|
||||
, mRouterTable(aInstance)
|
||||
, mRouterRoleRestorer(aInstance)
|
||||
{
|
||||
mDeviceMode.Set(mDeviceMode.Get() | DeviceMode::kModeFullThreadDevice | DeviceMode::kModeFullNetworkData);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
mLeaderWeight = mDeviceProperties.CalculateLeaderWeight();
|
||||
#else
|
||||
mLeaderWeight = kDefaultLeaderWeight;
|
||||
#endif
|
||||
|
||||
mLeaderAloc.InitAsThreadOriginMeshLocal();
|
||||
|
||||
SetRouterId(kInvalidRouterId);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
mSteeringData.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void MleRouter::SetAlternateRloc16(uint16_t aRloc16)
|
||||
void Mle::SetAlternateRloc16(uint16_t aRloc16)
|
||||
{
|
||||
VerifyOrExit(aRloc16 != Mac::kShortAddrInvalid);
|
||||
|
||||
@@ -102,7 +54,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::ClearAlternateRloc16(void)
|
||||
void Mle::ClearAlternateRloc16(void)
|
||||
{
|
||||
VerifyOrExit(Get<Mac::Mac>().GetAlternateShortAddress() != Mac::kShortAddrInvalid);
|
||||
|
||||
@@ -113,18 +65,18 @@ exit:
|
||||
mAlternateRloc16Timeout = 0;
|
||||
}
|
||||
|
||||
void MleRouter::HandlePartitionChange(void)
|
||||
void Mle::HandlePartitionChange(void)
|
||||
{
|
||||
mPreviousPartitionId = mLeaderData.GetPartitionId();
|
||||
mPreviousPartitionRouterIdSequence = mRouterTable.GetRouterIdSequence();
|
||||
mPreviousPartitionIdTimeout = GetNetworkIdTimeout();
|
||||
|
||||
Get<AddressResolver>().Clear();
|
||||
IgnoreError(Get<Tmf::Agent>().AbortTransaction(&MleRouter::HandleAddressSolicitResponse, this));
|
||||
IgnoreError(Get<Tmf::Agent>().AbortTransaction(&Mle::HandleAddressSolicitResponse, this));
|
||||
mRouterTable.Clear();
|
||||
}
|
||||
|
||||
bool MleRouter::IsRouterEligible(void) const
|
||||
bool Mle::IsRouterEligible(void) const
|
||||
{
|
||||
bool rval = false;
|
||||
const SecurityPolicy &secPolicy = Get<KeyManager>().GetSecurityPolicy();
|
||||
@@ -161,7 +113,7 @@ exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
Error MleRouter::SetRouterEligible(bool aEligible)
|
||||
Error Mle::SetRouterEligible(bool aEligible)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -203,7 +155,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::HandleSecurityPolicyChanged(void)
|
||||
void Mle::HandleSecurityPolicyChanged(void)
|
||||
{
|
||||
// If we are currently router or leader and no longer eligible to
|
||||
// be a router (due to security policy change), we start jitter
|
||||
@@ -225,7 +177,7 @@ exit:
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
void MleRouter::SetDeviceProperties(const DeviceProperties &aDeviceProperties)
|
||||
void Mle::SetDeviceProperties(const DeviceProperties &aDeviceProperties)
|
||||
{
|
||||
mDeviceProperties = aDeviceProperties;
|
||||
mDeviceProperties.ClampWeightAdjustment();
|
||||
@@ -233,7 +185,7 @@ void MleRouter::SetDeviceProperties(const DeviceProperties &aDeviceProperties)
|
||||
}
|
||||
#endif
|
||||
|
||||
Error MleRouter::BecomeRouter(ThreadStatusTlv::Status aStatus)
|
||||
Error Mle::BecomeRouter(ThreadStatusTlv::Status aStatus)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -264,7 +216,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error MleRouter::BecomeLeader(bool aCheckWeight)
|
||||
Error Mle::BecomeLeader(bool aCheckWeight)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Router *router;
|
||||
@@ -321,27 +273,27 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::StopLeader(void)
|
||||
void Mle::StopLeader(void)
|
||||
{
|
||||
StopAdvertiseTrickleTimer();
|
||||
Get<ThreadNetif>().UnsubscribeAllRoutersMulticast();
|
||||
}
|
||||
|
||||
void MleRouter::HandleDetachStart(void)
|
||||
void Mle::HandleDetachStart(void)
|
||||
{
|
||||
mRouterTable.ClearNeighbors();
|
||||
StopLeader();
|
||||
Get<TimeTicker>().UnregisterReceiver(TimeTicker::kMleRouter);
|
||||
Get<TimeTicker>().UnregisterReceiver(TimeTicker::kMle);
|
||||
}
|
||||
|
||||
void MleRouter::HandleChildStart(AttachMode aMode)
|
||||
void Mle::HandleChildStart(AttachMode aMode)
|
||||
{
|
||||
mAddressSolicitRejected = false;
|
||||
|
||||
mRouterRoleTransition.StartTimeout();
|
||||
|
||||
StopLeader();
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kMleRouter);
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kMle);
|
||||
|
||||
if (mRouterEligible)
|
||||
{
|
||||
@@ -416,18 +368,18 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
void MleRouter::SetStateRouter(uint16_t aRloc16)
|
||||
void Mle::SetStateRouter(uint16_t aRloc16)
|
||||
{
|
||||
// The `aStartMode` is ignored when used with `kRoleRouter`
|
||||
SetStateRouterOrLeader(kRoleRouter, aRloc16, /* aStartMode */ kStartingAsLeader);
|
||||
}
|
||||
|
||||
void MleRouter::SetStateLeader(uint16_t aRloc16, LeaderStartMode aStartMode)
|
||||
void Mle::SetStateLeader(uint16_t aRloc16, LeaderStartMode aStartMode)
|
||||
{
|
||||
SetStateRouterOrLeader(kRoleLeader, aRloc16, aStartMode);
|
||||
}
|
||||
|
||||
void MleRouter::SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, LeaderStartMode aStartMode)
|
||||
void Mle::SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, LeaderStartMode aStartMode)
|
||||
{
|
||||
if (aRole == kRoleLeader)
|
||||
{
|
||||
@@ -449,7 +401,7 @@ void MleRouter::SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, Leade
|
||||
Get<ThreadNetif>().SubscribeAllRoutersMulticast();
|
||||
mPreviousPartitionIdRouter = mLeaderData.GetPartitionId();
|
||||
Get<Mac::Mac>().SetBeaconEnabled(true);
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kMleRouter);
|
||||
Get<TimeTicker>().RegisterReceiver(TimeTicker::kMle);
|
||||
|
||||
if (aRole == kRoleLeader)
|
||||
{
|
||||
@@ -473,12 +425,9 @@ void MleRouter::SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, Leade
|
||||
LogNote("Partition ID 0x%lx", ToUlong(mLeaderData.GetPartitionId()));
|
||||
}
|
||||
|
||||
void MleRouter::HandleAdvertiseTrickleTimer(TrickleTimer &aTimer)
|
||||
{
|
||||
aTimer.Get<MleRouter>().HandleAdvertiseTrickleTimer();
|
||||
}
|
||||
void Mle::HandleAdvertiseTrickleTimer(TrickleTimer &aTimer) { aTimer.Get<Mle>().HandleAdvertiseTrickleTimer(); }
|
||||
|
||||
void MleRouter::HandleAdvertiseTrickleTimer(void)
|
||||
void Mle::HandleAdvertiseTrickleTimer(void)
|
||||
{
|
||||
VerifyOrExit(IsRouterEligible(), mAdvertiseTrickleTimer.Stop());
|
||||
|
||||
@@ -488,9 +437,9 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::StopAdvertiseTrickleTimer(void) { mAdvertiseTrickleTimer.Stop(); }
|
||||
void Mle::StopAdvertiseTrickleTimer(void) { mAdvertiseTrickleTimer.Stop(); }
|
||||
|
||||
uint32_t MleRouter::DetermineAdvertiseIntervalMax(void) const
|
||||
uint32_t Mle::DetermineAdvertiseIntervalMax(void) const
|
||||
{
|
||||
uint32_t interval;
|
||||
|
||||
@@ -507,7 +456,7 @@ uint32_t MleRouter::DetermineAdvertiseIntervalMax(void) const
|
||||
return interval;
|
||||
}
|
||||
|
||||
void MleRouter::UpdateAdvertiseInterval(void)
|
||||
void Mle::UpdateAdvertiseInterval(void)
|
||||
{
|
||||
if (IsRouterOrLeader() && mAdvertiseTrickleTimer.IsRunning())
|
||||
{
|
||||
@@ -515,7 +464,7 @@ void MleRouter::UpdateAdvertiseInterval(void)
|
||||
}
|
||||
}
|
||||
|
||||
void MleRouter::ResetAdvertiseInterval(void)
|
||||
void Mle::ResetAdvertiseInterval(void)
|
||||
{
|
||||
VerifyOrExit(IsRouterOrLeader());
|
||||
|
||||
@@ -530,7 +479,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::SendMulticastAdvertisement(void)
|
||||
void Mle::SendMulticastAdvertisement(void)
|
||||
{
|
||||
Ip6::Address destination;
|
||||
|
||||
@@ -538,7 +487,7 @@ void MleRouter::SendMulticastAdvertisement(void)
|
||||
SendAdvertisement(destination);
|
||||
}
|
||||
|
||||
void MleRouter::ScheduleUnicastAdvertisementTo(const Router &aRouter)
|
||||
void Mle::ScheduleUnicastAdvertisementTo(const Router &aRouter)
|
||||
{
|
||||
Ip6::Address destination;
|
||||
|
||||
@@ -547,7 +496,7 @@ void MleRouter::ScheduleUnicastAdvertisementTo(const Router &aRouter)
|
||||
Random::NonCrypto::GetUint32InRange(0, kMaxUnicastAdvertisementDelay));
|
||||
}
|
||||
|
||||
void MleRouter::SendAdvertisement(const Ip6::Address &aDestination)
|
||||
void Mle::SendAdvertisement(const Ip6::Address &aDestination)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
TxMessage *message = nullptr;
|
||||
@@ -595,7 +544,7 @@ exit:
|
||||
LogSendError(kTypeAdvertisement, error);
|
||||
}
|
||||
|
||||
void MleRouter::SendLinkRequest(Router *aRouter)
|
||||
void Mle::SendLinkRequest(Router *aRouter)
|
||||
{
|
||||
static const uint8_t kDetachedTlvs[] = {Tlv::kAddress16, Tlv::kRoute};
|
||||
static const uint8_t kRouterTlvs[] = {Tlv::kLinkMargin};
|
||||
@@ -677,7 +626,7 @@ exit:
|
||||
FreeMessageOnError(message, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
void Mle::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Neighbor *neighbor = nullptr;
|
||||
@@ -784,7 +733,7 @@ exit:
|
||||
OT_UNUSED_VARIABLE(neighbor);
|
||||
}
|
||||
|
||||
Error MleRouter::SendLinkAccept(const LinkAcceptInfo &aInfo)
|
||||
Error Mle::SendLinkAccept(const LinkAcceptInfo &aInfo)
|
||||
{
|
||||
static const uint8_t kRouterTlvs[] = {Tlv::kLinkMargin};
|
||||
|
||||
@@ -871,14 +820,11 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::HandleLinkAccept(RxInfo &aRxInfo) { HandleLinkAcceptVariant(aRxInfo, kTypeLinkAccept); }
|
||||
void Mle::HandleLinkAccept(RxInfo &aRxInfo) { HandleLinkAcceptVariant(aRxInfo, kTypeLinkAccept); }
|
||||
|
||||
void MleRouter::HandleLinkAcceptAndRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
HandleLinkAcceptVariant(aRxInfo, kTypeLinkAcceptAndRequest);
|
||||
}
|
||||
void Mle::HandleLinkAcceptAndRequest(RxInfo &aRxInfo) { HandleLinkAcceptVariant(aRxInfo, kTypeLinkAcceptAndRequest); }
|
||||
|
||||
void MleRouter::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
|
||||
void Mle::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
|
||||
{
|
||||
// Handles "Link Accept" or "Link Accept And Request".
|
||||
|
||||
@@ -1087,7 +1033,7 @@ exit:
|
||||
LogProcessError(aMessageType, error);
|
||||
}
|
||||
|
||||
Error MleRouter::ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo)
|
||||
Error Mle::ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo)
|
||||
{
|
||||
// This method processes `aRouteTlv` read from an MLE message.
|
||||
//
|
||||
@@ -1122,7 +1068,7 @@ Error MleRouter::ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo)
|
||||
return error;
|
||||
}
|
||||
|
||||
Error MleRouter::ReadAndProcessRouteTlvOnFtdChild(RxInfo &aRxInfo, uint8_t aParentId)
|
||||
Error Mle::ReadAndProcessRouteTlvOnFtdChild(RxInfo &aRxInfo, uint8_t aParentId)
|
||||
{
|
||||
// This method reads and processes Route TLV from message on an
|
||||
// FTD child if message contains one. It returns `kErrorNone`
|
||||
@@ -1154,7 +1100,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
bool MleRouter::IsSingleton(void) const
|
||||
bool Mle::IsSingleton(void) const
|
||||
{
|
||||
bool isSingleton = true;
|
||||
|
||||
@@ -1165,10 +1111,10 @@ exit:
|
||||
return isSingleton;
|
||||
}
|
||||
|
||||
int MleRouter::ComparePartitions(bool aSingletonA,
|
||||
const LeaderData &aLeaderDataA,
|
||||
bool aSingletonB,
|
||||
const LeaderData &aLeaderDataB)
|
||||
int Mle::ComparePartitions(bool aSingletonA,
|
||||
const LeaderData &aLeaderDataA,
|
||||
bool aSingletonB,
|
||||
const LeaderData &aLeaderDataB)
|
||||
{
|
||||
int rval = 0;
|
||||
|
||||
@@ -1185,7 +1131,7 @@ exit:
|
||||
return rval;
|
||||
}
|
||||
|
||||
Error MleRouter::HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData)
|
||||
Error Mle::HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData)
|
||||
{
|
||||
// This method processes a received MLE Advertisement message on
|
||||
// an FTD device. It is called from `Mle::HandleAdvertisement()`
|
||||
@@ -1375,7 +1321,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::EstablishRouterLinkOnFtdChild(Router &aRouter, RxInfo &aRxInfo, uint8_t aLinkMargin)
|
||||
void Mle::EstablishRouterLinkOnFtdChild(Router &aRouter, RxInfo &aRxInfo, uint8_t aLinkMargin)
|
||||
{
|
||||
// Decide on an FTD child whether to establish a link with a
|
||||
// router upon receiving an advertisement from it.
|
||||
@@ -1437,7 +1383,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::HandleParentRequest(RxInfo &aRxInfo)
|
||||
void Mle::HandleParentRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t version;
|
||||
@@ -1537,7 +1483,7 @@ exit:
|
||||
LogProcessError(kTypeParentRequest, error);
|
||||
}
|
||||
|
||||
bool MleRouter::HasNeighborWithGoodLinkQuality(void) const
|
||||
bool Mle::HasNeighborWithGoodLinkQuality(void) const
|
||||
{
|
||||
bool haveNeighbor = true;
|
||||
uint8_t linkMargin;
|
||||
@@ -1570,11 +1516,11 @@ exit:
|
||||
return haveNeighbor;
|
||||
}
|
||||
|
||||
void MleRouter::HandleTimeTick(void)
|
||||
void Mle::HandleTimeTick(void)
|
||||
{
|
||||
bool roleTransitionTimeoutExpired = false;
|
||||
|
||||
VerifyOrExit(IsFullThreadDevice(), Get<TimeTicker>().UnregisterReceiver(TimeTicker::kMleRouter));
|
||||
VerifyOrExit(IsFullThreadDevice(), Get<TimeTicker>().UnregisterReceiver(TimeTicker::kMle));
|
||||
|
||||
if (mPreviousPartitionIdTimeout > 0)
|
||||
{
|
||||
@@ -1802,7 +1748,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::SendParentResponse(const ParentResponseInfo &aInfo)
|
||||
void Mle::SendParentResponse(const ParentResponseInfo &aInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
TxMessage *message = nullptr;
|
||||
@@ -1848,7 +1794,7 @@ exit:
|
||||
LogSendError(kTypeParentResponse, error);
|
||||
}
|
||||
|
||||
uint8_t MleRouter::GetMaxChildIpAddresses(void) const
|
||||
uint8_t Mle::GetMaxChildIpAddresses(void) const
|
||||
{
|
||||
uint8_t num = kMaxChildIpAddresses;
|
||||
|
||||
@@ -1863,7 +1809,7 @@ uint8_t MleRouter::GetMaxChildIpAddresses(void) const
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
Error MleRouter::SetMaxChildIpAddresses(uint8_t aMaxIpAddresses)
|
||||
Error Mle::SetMaxChildIpAddresses(uint8_t aMaxIpAddresses)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -1876,7 +1822,7 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
Error MleRouter::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
|
||||
Error Mle::ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild)
|
||||
{
|
||||
Error error;
|
||||
OffsetRange offsetRange;
|
||||
@@ -2044,7 +1990,7 @@ exit:
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
|
||||
void MleRouter::SignalDuaAddressEvent(const Child &aChild, const Ip6::Address &aOldDua) const
|
||||
void Mle::SignalDuaAddressEvent(const Child &aChild, const Ip6::Address &aOldDua) const
|
||||
{
|
||||
DuaManager::ChildDuaAddressEvent event = DuaManager::kAddressUnchanged;
|
||||
Ip6::Address newDua;
|
||||
@@ -2077,14 +2023,14 @@ exit:
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_TMF_PROXY_DUA_ENABLE
|
||||
|
||||
bool MleRouter::IsMessageMleSubType(const Message &aMessage) { return aMessage.IsSubTypeMle(); }
|
||||
bool Mle::IsMessageMleSubType(const Message &aMessage) { return aMessage.IsSubTypeMle(); }
|
||||
|
||||
bool MleRouter::IsMessageChildUpdateRequest(const Message &aMessage)
|
||||
bool Mle::IsMessageChildUpdateRequest(const Message &aMessage)
|
||||
{
|
||||
return aMessage.IsMleCommand(kCommandChildUpdateRequest);
|
||||
}
|
||||
|
||||
void MleRouter::HandleChildIdRequest(RxInfo &aRxInfo)
|
||||
void Mle::HandleChildIdRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Mac::ExtAddress extAddr;
|
||||
@@ -2245,7 +2191,7 @@ exit:
|
||||
LogProcessError(kTypeChildIdRequest, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleChildUpdateRequestOnParent(RxInfo &aRxInfo)
|
||||
void Mle::HandleChildUpdateRequestOnParent(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Mac::ExtAddress extAddr;
|
||||
@@ -2463,7 +2409,7 @@ exit:
|
||||
LogProcessError(kTypeChildUpdateRequestOfChild, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleChildUpdateResponseOnParent(RxInfo &aRxInfo)
|
||||
void Mle::HandleChildUpdateResponseOnParent(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t sourceAddress;
|
||||
@@ -2608,7 +2554,7 @@ exit:
|
||||
LogProcessError(kTypeChildUpdateResponseOfChild, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleDataRequest(RxInfo &aRxInfo)
|
||||
void Mle::HandleDataRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
TlvList tlvList;
|
||||
@@ -2665,7 +2611,7 @@ exit:
|
||||
LogProcessError(kTypeDataRequest, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleNetworkDataUpdateRouter(void)
|
||||
void Mle::HandleNetworkDataUpdateRouter(void)
|
||||
{
|
||||
uint16_t delay;
|
||||
|
||||
@@ -2687,7 +2633,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::SynchronizeChildNetworkData(void)
|
||||
void Mle::SynchronizeChildNetworkData(void)
|
||||
{
|
||||
VerifyOrExit(IsRouterOrLeader());
|
||||
|
||||
@@ -2711,7 +2657,7 @@ exit:
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
void MleRouter::SetSteeringData(const Mac::ExtAddress *aExtAddress)
|
||||
void Mle::SetSteeringData(const Mac::ExtAddress *aExtAddress)
|
||||
{
|
||||
Mac::ExtAddress nullExtAddr;
|
||||
Mac::ExtAddress allowAnyExtAddr;
|
||||
@@ -2738,7 +2684,7 @@ void MleRouter::SetSteeringData(const Mac::ExtAddress *aExtAddress)
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
|
||||
void MleRouter::HandleDiscoveryRequest(RxInfo &aRxInfo)
|
||||
void Mle::HandleDiscoveryRequest(RxInfo &aRxInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Tlv::ParsedInfo tlvInfo;
|
||||
@@ -2826,7 +2772,7 @@ exit:
|
||||
LogProcessError(kTypeDiscoveryRequest, error);
|
||||
}
|
||||
|
||||
Error MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, const DiscoveryResponseInfo &aInfo)
|
||||
Error Mle::SendDiscoveryResponse(const Ip6::Address &aDestination, const DiscoveryResponseInfo &aInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
TxMessage *message;
|
||||
@@ -2902,7 +2848,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error MleRouter::SendChildIdResponse(Child &aChild)
|
||||
Error Mle::SendChildIdResponse(Child &aChild)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Ip6::Address destination;
|
||||
@@ -2994,7 +2940,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error MleRouter::SendChildUpdateRequestToChild(Child &aChild)
|
||||
Error Mle::SendChildUpdateRequestToChild(Child &aChild)
|
||||
{
|
||||
static const uint8_t kTlvs[] = {Tlv::kTimeout, Tlv::kAddressRegistration};
|
||||
|
||||
@@ -3063,10 +3009,10 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::SendChildUpdateResponseToChild(Child *aChild,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
const TlvList &aTlvList,
|
||||
const RxChallenge &aChallenge)
|
||||
void Mle::SendChildUpdateResponseToChild(Child *aChild,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
const TlvList &aTlvList,
|
||||
const RxChallenge &aChallenge)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
TxMessage *message;
|
||||
@@ -3165,7 +3111,7 @@ exit:
|
||||
FreeMessageOnError(message, error);
|
||||
}
|
||||
|
||||
void MleRouter::SendMulticastDataResponse(void)
|
||||
void Mle::SendMulticastDataResponse(void)
|
||||
{
|
||||
Ip6::Address destination;
|
||||
TlvList tlvList;
|
||||
@@ -3175,9 +3121,7 @@ void MleRouter::SendMulticastDataResponse(void)
|
||||
SendDataResponse(destination, tlvList);
|
||||
}
|
||||
|
||||
void MleRouter::SendDataResponse(const Ip6::Address &aDestination,
|
||||
const TlvList &aTlvList,
|
||||
const Message *aRequestMessage)
|
||||
void Mle::SendDataResponse(const Ip6::Address &aDestination, const TlvList &aTlvList, const Message *aRequestMessage)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aRequestMessage);
|
||||
|
||||
@@ -3239,7 +3183,7 @@ exit:
|
||||
LogSendError(kTypeDataResponse, error);
|
||||
}
|
||||
|
||||
void MleRouter::RemoveRouterLink(Router &aRouter)
|
||||
void Mle::RemoveRouterLink(Router &aRouter)
|
||||
{
|
||||
switch (mRole)
|
||||
{
|
||||
@@ -3260,7 +3204,7 @@ void MleRouter::RemoveRouterLink(Router &aRouter)
|
||||
}
|
||||
}
|
||||
|
||||
void MleRouter::RemoveNeighbor(Neighbor &aNeighbor)
|
||||
void Mle::RemoveNeighbor(Neighbor &aNeighbor)
|
||||
{
|
||||
VerifyOrExit(!aNeighbor.IsStateInvalid());
|
||||
|
||||
@@ -3311,7 +3255,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
Error MleRouter::SetPreferredRouterId(uint8_t aRouterId)
|
||||
Error Mle::SetPreferredRouterId(uint8_t aRouterId)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -3323,13 +3267,13 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::SetRouterId(uint8_t aRouterId)
|
||||
void Mle::SetRouterId(uint8_t aRouterId)
|
||||
{
|
||||
mRouterId = aRouterId;
|
||||
mPreviousRouterId = mRouterId;
|
||||
}
|
||||
|
||||
Error MleRouter::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
Error Mle::SendAddressSolicit(ThreadStatusTlv::Status aStatus)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
@@ -3365,7 +3309,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void MleRouter::SendAddressRelease(void)
|
||||
void Mle::SendAddressRelease(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
@@ -3388,18 +3332,16 @@ exit:
|
||||
LogSendError(kTypeAddressRelease, error);
|
||||
}
|
||||
|
||||
void MleRouter::HandleAddressSolicitResponse(void *aContext,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
otError aResult)
|
||||
void Mle::HandleAddressSolicitResponse(void *aContext,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
otError aResult)
|
||||
{
|
||||
static_cast<MleRouter *>(aContext)->HandleAddressSolicitResponse(AsCoapMessagePtr(aMessage),
|
||||
AsCoreTypePtr(aMessageInfo), aResult);
|
||||
static_cast<Mle *>(aContext)->HandleAddressSolicitResponse(AsCoapMessagePtr(aMessage), AsCoreTypePtr(aMessageInfo),
|
||||
aResult);
|
||||
}
|
||||
|
||||
void MleRouter::HandleAddressSolicitResponse(Coap::Message *aMessage,
|
||||
const Ip6::MessageInfo *aMessageInfo,
|
||||
Error aResult)
|
||||
void Mle::HandleAddressSolicitResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult)
|
||||
{
|
||||
uint8_t status;
|
||||
uint16_t rloc16;
|
||||
@@ -3507,7 +3449,7 @@ exit:
|
||||
InformPreviousChannel();
|
||||
}
|
||||
|
||||
Error MleRouter::SetChildRouterLinks(uint8_t aChildRouterLinks)
|
||||
Error Mle::SetChildRouterLinks(uint8_t aChildRouterLinks)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -3517,7 +3459,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
bool MleRouter::IsExpectedToBecomeRouterSoon(void) const
|
||||
bool Mle::IsExpectedToBecomeRouterSoon(void) const
|
||||
{
|
||||
static constexpr uint8_t kMaxDelay = 10;
|
||||
|
||||
@@ -3526,7 +3468,7 @@ bool MleRouter::IsExpectedToBecomeRouterSoon(void) const
|
||||
mAddressSolicitPending);
|
||||
}
|
||||
|
||||
template <> void MleRouter::HandleTmf<kUriAddressSolicit>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
template <> void Mle::HandleTmf<kUriAddressSolicit>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
ThreadStatusTlv::Status responseStatus = ThreadStatusTlv::kNoAddressAvailable;
|
||||
@@ -3624,10 +3566,10 @@ exit:
|
||||
}
|
||||
}
|
||||
|
||||
void MleRouter::SendAddressSolicitResponse(const Coap::Message &aRequest,
|
||||
ThreadStatusTlv::Status aResponseStatus,
|
||||
const Router *aRouter,
|
||||
const Ip6::MessageInfo &aMessageInfo)
|
||||
void Mle::SendAddressSolicitResponse(const Coap::Message &aRequest,
|
||||
ThreadStatusTlv::Status aResponseStatus,
|
||||
const Router *aRouter,
|
||||
const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
Coap::Message *message = Get<Tmf::Agent>().NewPriorityResponseMessage(aRequest);
|
||||
|
||||
@@ -3676,7 +3618,7 @@ exit:
|
||||
FreeMessage(message);
|
||||
}
|
||||
|
||||
template <> void MleRouter::HandleTmf<kUriAddressRelease>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
template <> void Mle::HandleTmf<kUriAddressRelease>(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
uint16_t rloc16;
|
||||
Mac::ExtAddress extAddress;
|
||||
@@ -3707,7 +3649,7 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
void MleRouter::FillConnectivityTlv(ConnectivityTlv &aTlv)
|
||||
void Mle::FillConnectivityTlv(ConnectivityTlv &aTlv)
|
||||
{
|
||||
int8_t parentPriority = kParentPriorityMedium;
|
||||
|
||||
@@ -3763,7 +3705,7 @@ void MleRouter::FillConnectivityTlv(ConnectivityTlv &aTlv)
|
||||
aTlv.SetSedDatagramCount(OPENTHREAD_CONFIG_DEFAULT_SED_DATAGRAM_COUNT);
|
||||
}
|
||||
|
||||
bool MleRouter::ShouldDowngrade(uint8_t aNeighborId, const RouteTlv &aRouteTlv) const
|
||||
bool Mle::ShouldDowngrade(uint8_t aNeighborId, const RouteTlv &aRouteTlv) const
|
||||
{
|
||||
// Determine whether all conditions are satisfied for the router
|
||||
// to downgrade after receiving info for a neighboring router
|
||||
@@ -3825,7 +3767,7 @@ exit:
|
||||
return shouldDowngrade;
|
||||
}
|
||||
|
||||
bool MleRouter::NeighborHasComparableConnectivity(const RouteTlv &aRouteTlv, uint8_t aNeighborId) const
|
||||
bool Mle::NeighborHasComparableConnectivity(const RouteTlv &aRouteTlv, uint8_t aNeighborId) const
|
||||
{
|
||||
// Check whether the neighboring router with Router ID `aNeighborId`
|
||||
// (along with its `aRouteTlv`) has as good or better-quality links
|
||||
@@ -3881,7 +3823,7 @@ exit:
|
||||
return isComparable;
|
||||
}
|
||||
|
||||
void MleRouter::SetChildStateToValid(Child &aChild)
|
||||
void Mle::SetChildStateToValid(Child &aChild)
|
||||
{
|
||||
VerifyOrExit(!aChild.IsStateValid());
|
||||
|
||||
@@ -3898,9 +3840,9 @@ exit:
|
||||
return;
|
||||
}
|
||||
|
||||
bool MleRouter::HasChildren(void) { return mChildTable.HasChildren(Child::kInStateValidOrAttaching); }
|
||||
bool Mle::HasChildren(void) { return mChildTable.HasChildren(Child::kInStateValidOrAttaching); }
|
||||
|
||||
void MleRouter::RemoveChildren(void)
|
||||
void Mle::RemoveChildren(void)
|
||||
{
|
||||
for (Child &child : Get<ChildTable>().Iterate(Child::kInStateValidOrRestoring))
|
||||
{
|
||||
@@ -3908,7 +3850,7 @@ void MleRouter::RemoveChildren(void)
|
||||
}
|
||||
}
|
||||
|
||||
Error MleRouter::SetAssignParentPriority(int8_t aParentPriority)
|
||||
Error Mle::SetAssignParentPriority(int8_t aParentPriority)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
|
||||
@@ -3921,7 +3863,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
Error MleRouter::GetMaxChildTimeout(uint32_t &aTimeout) const
|
||||
Error Mle::GetMaxChildTimeout(uint32_t &aTimeout) const
|
||||
{
|
||||
Error error = kErrorNotFound;
|
||||
|
||||
@@ -3949,7 +3891,7 @@ exit:
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
Error MleRouter::SendTimeSync(void)
|
||||
Error Mle::SendTimeSync(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Ip6::Address destination;
|
||||
@@ -3973,18 +3915,15 @@ exit:
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// RouterRoleTransition
|
||||
|
||||
MleRouter::RouterRoleTransition::RouterRoleTransition(void)
|
||||
Mle::RouterRoleTransition::RouterRoleTransition(void)
|
||||
: mTimeout(0)
|
||||
, mJitter(kRouterSelectionJitter)
|
||||
{
|
||||
}
|
||||
|
||||
void MleRouter::RouterRoleTransition::StartTimeout(void)
|
||||
{
|
||||
mTimeout = 1 + Random::NonCrypto::GetUint8InRange(0, mJitter);
|
||||
}
|
||||
void Mle::RouterRoleTransition::StartTimeout(void) { mTimeout = 1 + Random::NonCrypto::GetUint8InRange(0, mJitter); }
|
||||
|
||||
bool MleRouter::RouterRoleTransition::HandleTimeTick(void)
|
||||
bool Mle::RouterRoleTransition::HandleTimeTick(void)
|
||||
{
|
||||
bool expired = false;
|
||||
|
||||
@@ -3999,13 +3938,13 @@ exit:
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// RouterRoleRestorer
|
||||
|
||||
MleRouter::RouterRoleRestorer::RouterRoleRestorer(Instance &aInstance)
|
||||
Mle::RouterRoleRestorer::RouterRoleRestorer(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
, mAttempts(0)
|
||||
{
|
||||
}
|
||||
|
||||
void MleRouter::RouterRoleRestorer::Start(DeviceRole aPreviousRole)
|
||||
void Mle::RouterRoleRestorer::Start(DeviceRole aPreviousRole)
|
||||
{
|
||||
// If the device was previously the leader or had more than
|
||||
// `kMinCriticalChildrenCount` children, we use more link
|
||||
@@ -4016,7 +3955,7 @@ void MleRouter::RouterRoleRestorer::Start(DeviceRole aPreviousRole)
|
||||
switch (aPreviousRole)
|
||||
{
|
||||
case kRoleRouter:
|
||||
if (Get<MleRouter>().mChildTable.GetNumChildren(Child::kInStateValidOrRestoring) < kMinCriticalChildrenCount)
|
||||
if (Get<Mle>().mChildTable.GetNumChildren(Child::kInStateValidOrRestoring) < kMinCriticalChildrenCount)
|
||||
{
|
||||
mAttempts = kMaxTxCount;
|
||||
break;
|
||||
@@ -4037,7 +3976,7 @@ void MleRouter::RouterRoleRestorer::Start(DeviceRole aPreviousRole)
|
||||
SendMulticastLinkRequest();
|
||||
}
|
||||
|
||||
void MleRouter::RouterRoleRestorer::HandleTimer(void)
|
||||
void Mle::RouterRoleRestorer::HandleTimer(void)
|
||||
{
|
||||
if (mAttempts > 0)
|
||||
{
|
||||
@@ -4047,7 +3986,7 @@ void MleRouter::RouterRoleRestorer::HandleTimer(void)
|
||||
SendMulticastLinkRequest();
|
||||
}
|
||||
|
||||
void MleRouter::RouterRoleRestorer::SendMulticastLinkRequest(void)
|
||||
void Mle::RouterRoleRestorer::SendMulticastLinkRequest(void)
|
||||
{
|
||||
uint32_t delay;
|
||||
|
||||
@@ -4059,7 +3998,7 @@ void MleRouter::RouterRoleRestorer::SendMulticastLinkRequest(void)
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
Get<MleRouter>().SendLinkRequest(nullptr);
|
||||
Get<Mle>().SendLinkRequest(nullptr);
|
||||
|
||||
delay = (mAttempts == 1) ? kLinkRequestTimeout
|
||||
: Random::NonCrypto::GetUint32InRange(kMulticastRetxDelayMin, kMulticastRetxDelayMax);
|
||||
@@ -1,742 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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 MLE functionality required by the Thread Router and Leader roles.
|
||||
*/
|
||||
|
||||
#ifndef MLE_ROUTER_HPP_
|
||||
#define MLE_ROUTER_HPP_
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include <openthread/thread_ftd.h>
|
||||
|
||||
#include "coap/coap_message.hpp"
|
||||
#include "common/callback.hpp"
|
||||
#include "common/time_ticker.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "common/trickle_timer.hpp"
|
||||
#include "mac/mac_types.hpp"
|
||||
#include "meshcop/meshcop_tlvs.hpp"
|
||||
#include "net/icmp6.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
#include "thread/child.hpp"
|
||||
#include "thread/child_table.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/mle_tlvs.hpp"
|
||||
#include "thread/router.hpp"
|
||||
#include "thread/router_table.hpp"
|
||||
#include "thread/thread_tlvs.hpp"
|
||||
#include "thread/tmf.hpp"
|
||||
|
||||
namespace ot {
|
||||
namespace Mle {
|
||||
|
||||
/**
|
||||
* @addtogroup core-mle-router
|
||||
*
|
||||
* @brief
|
||||
* This module includes definitions for MLE functionality required by the Thread Router and Leader roles.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
|
||||
/**
|
||||
* Implements MLE functionality required by the Thread Router and Leader roles.
|
||||
*/
|
||||
class MleRouter : public Mle
|
||||
{
|
||||
friend class Mle;
|
||||
friend class ot::Instance;
|
||||
friend class ot::TimeTicker;
|
||||
friend class Tmf::Agent;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initializes the object.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
*/
|
||||
explicit MleRouter(Instance &aInstance);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the device is router-eligible.
|
||||
*
|
||||
* @retval true If device is router-eligible.
|
||||
* @retval false If device is not router-eligible.
|
||||
*/
|
||||
bool IsRouterEligible(void) const;
|
||||
|
||||
/**
|
||||
* Sets whether or not the device is router-eligible.
|
||||
*
|
||||
* If @p aEligible is false and the device is currently operating as a router, this call will cause the device to
|
||||
* detach and attempt to reattach as a child.
|
||||
*
|
||||
* @param[in] aEligible TRUE to configure device router-eligible, FALSE otherwise.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the router-eligible configuration.
|
||||
* @retval kErrorNotCapable The device is not capable of becoming a router.
|
||||
*/
|
||||
Error SetRouterEligible(bool aEligible);
|
||||
|
||||
/**
|
||||
* Indicates whether a node is the only router on the network.
|
||||
*
|
||||
* @retval TRUE It is the only router in the network.
|
||||
* @retval FALSE It is a child or is not a single router in the network.
|
||||
*/
|
||||
bool IsSingleton(void) const;
|
||||
|
||||
/**
|
||||
* Generates an Address Solicit request for a Router ID.
|
||||
*
|
||||
* @param[in] aStatus The reason for requesting a Router ID.
|
||||
*
|
||||
* @retval kErrorNone Successfully generated an Address Solicit message.
|
||||
* @retval kErrorNotCapable Device is not capable of becoming a router
|
||||
* @retval kErrorInvalidState Thread is not enabled
|
||||
*/
|
||||
Error BecomeRouter(ThreadStatusTlv::Status aStatus);
|
||||
|
||||
/**
|
||||
* Becomes a leader and starts a new partition.
|
||||
*
|
||||
* If the device is already attached, this method can be used to attempt to take over as the leader, creating a new
|
||||
* partition. For this to work, the local leader weight must be greater than the weight of the current leader. The
|
||||
* @p aCheckWeight can be used to ensure that this check is performed.
|
||||
*
|
||||
* @param[in] aCheckWeight Check that the local leader weight is larger than the weight of the current leader.
|
||||
*
|
||||
* @retval kErrorNone Successfully become a Leader and started a new partition.
|
||||
* @retval kErrorInvalidState Thread is not enabled.
|
||||
* @retval kErrorNotCapable Device is not capable of becoming a leader (not router eligible), or
|
||||
* @p aCheckWeight is true and cannot override the current leader due to its local
|
||||
* leader weight being same or smaller than current leader's weight.
|
||||
*/
|
||||
Error BecomeLeader(bool aCheckWeight);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
/**
|
||||
* Gets the device properties which are used to determine the Leader Weight.
|
||||
*
|
||||
* @returns The current device properties.
|
||||
*/
|
||||
const DeviceProperties &GetDeviceProperties(void) const { return mDeviceProperties; }
|
||||
|
||||
/**
|
||||
* Sets the device properties which are then used to determine and set the Leader Weight.
|
||||
*
|
||||
* @param[in] aDeviceProperties The device properties.
|
||||
*/
|
||||
void SetDeviceProperties(const DeviceProperties &aDeviceProperties);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the Leader Weighting value for this Thread interface.
|
||||
*
|
||||
* @returns The Leader Weighting value for this Thread interface.
|
||||
*/
|
||||
uint8_t GetLeaderWeight(void) const { return mLeaderWeight; }
|
||||
|
||||
/**
|
||||
* Sets the Leader Weighting value for this Thread interface.
|
||||
*
|
||||
* Directly sets the Leader Weight to the new value replacing its previous value (which may have been
|
||||
* determined from a previous call to `SetDeviceProperties()`).
|
||||
*
|
||||
* @param[in] aWeight The Leader Weighting value.
|
||||
*/
|
||||
void SetLeaderWeight(uint8_t aWeight) { mLeaderWeight = aWeight; }
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
/**
|
||||
* Returns the preferred Partition Id when operating in the Leader role for certification testing.
|
||||
*
|
||||
* @returns The preferred Partition Id value.
|
||||
*/
|
||||
uint32_t GetPreferredLeaderPartitionId(void) const { return mPreferredLeaderPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the preferred Partition Id when operating in the Leader role for certification testing.
|
||||
*
|
||||
* @param[in] aPartitionId The preferred Leader Partition Id.
|
||||
*/
|
||||
void SetPreferredLeaderPartitionId(uint32_t aPartitionId) { mPreferredLeaderPartitionId = aPartitionId; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets the preferred Router Id. Upon becoming a router/leader the node
|
||||
* attempts to use this Router Id. If the preferred Router Id is not set or if it
|
||||
* can not be used, a randomly generated router Id is picked.
|
||||
* This property can be set when he device role is detached or disabled.
|
||||
*
|
||||
* @param[in] aRouterId The preferred Router Id.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the preferred Router Id.
|
||||
* @retval kErrorInvalidState Could not set (role is other than detached and disabled)
|
||||
*/
|
||||
Error SetPreferredRouterId(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Gets the Partition Id which the device joined successfully once.
|
||||
*/
|
||||
uint32_t GetPreviousPartitionId(void) const { return mPreviousPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the Partition Id which the device joins successfully.
|
||||
*
|
||||
* @param[in] aPartitionId The Partition Id.
|
||||
*/
|
||||
void SetPreviousPartitionId(uint32_t aPartitionId) { mPreviousPartitionId = aPartitionId; }
|
||||
|
||||
/**
|
||||
* Sets the Router Id.
|
||||
*
|
||||
* @param[in] aRouterId The Router Id.
|
||||
*/
|
||||
void SetRouterId(uint8_t aRouterId);
|
||||
|
||||
/**
|
||||
* Returns the NETWORK_ID_TIMEOUT value.
|
||||
*
|
||||
* @returns The NETWORK_ID_TIMEOUT value.
|
||||
*/
|
||||
uint8_t GetNetworkIdTimeout(void) const { return mNetworkIdTimeout; }
|
||||
|
||||
/**
|
||||
* Sets the NETWORK_ID_TIMEOUT value.
|
||||
*
|
||||
* @param[in] aTimeout The NETWORK_ID_TIMEOUT value.
|
||||
*/
|
||||
void SetNetworkIdTimeout(uint8_t aTimeout) { mNetworkIdTimeout = aTimeout; }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @returns The ROUTER_SELECTION_JITTER value in seconds.
|
||||
*/
|
||||
uint8_t GetRouterSelectionJitter(void) const { return mRouterRoleTransition.GetJitter(); }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_SELECTION_JITTER value.
|
||||
*
|
||||
* @param[in] aRouterJitter The router selection jitter value (in seconds).
|
||||
*/
|
||||
void SetRouterSelectionJitter(uint8_t aRouterJitter) { mRouterRoleTransition.SetJitter(aRouterJitter); }
|
||||
|
||||
/**
|
||||
* Indicates whether or not router role transition (upgrade from REED or downgrade to REED) is pending.
|
||||
*
|
||||
* @retval TRUE Router role transition is pending.
|
||||
* @retval FALSE Router role transition is not pending
|
||||
*/
|
||||
bool IsRouterRoleTransitionPending(void) const { return mRouterRoleTransition.IsPending(); }
|
||||
|
||||
/**
|
||||
* Returns the current timeout delay in seconds till router role transition (upgrade from REED or downgrade to
|
||||
* REED).
|
||||
*
|
||||
* @returns The timeout in seconds till router role transition, or zero if not pending role transition.
|
||||
*/
|
||||
uint8_t GetRouterRoleTransitionTimeout(void) const { return mRouterRoleTransition.GetTimeout(); }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @returns The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*/
|
||||
uint8_t GetRouterUpgradeThreshold(void) const { return mRouterUpgradeThreshold; }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_UPGRADE_THRESHOLD value.
|
||||
*
|
||||
* @param[in] aThreshold The ROUTER_UPGRADE_THRESHOLD value.
|
||||
*/
|
||||
void SetRouterUpgradeThreshold(uint8_t aThreshold) { mRouterUpgradeThreshold = aThreshold; }
|
||||
|
||||
/**
|
||||
* Returns the ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @returns The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*/
|
||||
uint8_t GetRouterDowngradeThreshold(void) const { return mRouterDowngradeThreshold; }
|
||||
|
||||
/**
|
||||
* Sets the ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*
|
||||
* @param[in] aThreshold The ROUTER_DOWNGRADE_THRESHOLD value.
|
||||
*/
|
||||
void SetRouterDowngradeThreshold(uint8_t aThreshold) { mRouterDowngradeThreshold = aThreshold; }
|
||||
|
||||
/**
|
||||
* Returns the MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @returns The MLE_CHILD_ROUTER_LINKS value.
|
||||
*/
|
||||
uint8_t GetChildRouterLinks(void) const { return mChildRouterLinks; }
|
||||
|
||||
/**
|
||||
* Sets the MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @param[in] aChildRouterLinks The MLE_CHILD_ROUTER_LINKS value.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the value.
|
||||
* @retval kErrorInvalidState Thread protocols are enabled.
|
||||
*/
|
||||
Error SetChildRouterLinks(uint8_t aChildRouterLinks);
|
||||
|
||||
/**
|
||||
* Returns if the REED is expected to become Router soon.
|
||||
*
|
||||
* @retval TRUE If the REED is going to become a Router soon.
|
||||
* @retval FALSE If the REED is not going to become a Router soon.
|
||||
*/
|
||||
bool IsExpectedToBecomeRouterSoon(void) const;
|
||||
|
||||
/**
|
||||
* Removes a link to a neighbor.
|
||||
*
|
||||
* @param[in] aNeighbor A reference to the neighbor object.
|
||||
*/
|
||||
void RemoveNeighbor(Neighbor &aNeighbor);
|
||||
|
||||
/**
|
||||
* Invalidates a direct link to a neighboring router (due to failed link-layer acks).
|
||||
*
|
||||
* @param[in] aRouter A reference to the router object.
|
||||
*/
|
||||
void RemoveRouterLink(Router &aRouter);
|
||||
|
||||
/**
|
||||
* Indicates whether or not the given Thread partition attributes are preferred.
|
||||
*
|
||||
* @param[in] aSingletonA Whether or not the Thread Partition A has a single router.
|
||||
* @param[in] aLeaderDataA A reference to Thread Partition A's Leader Data.
|
||||
* @param[in] aSingletonB Whether or not the Thread Partition B has a single router.
|
||||
* @param[in] aLeaderDataB A reference to Thread Partition B's Leader Data.
|
||||
*
|
||||
* @retval 1 If partition A is preferred.
|
||||
* @retval 0 If partition A and B have equal preference.
|
||||
* @retval -1 If partition B is preferred.
|
||||
*/
|
||||
static int ComparePartitions(bool aSingletonA,
|
||||
const LeaderData &aLeaderDataA,
|
||||
bool aSingletonB,
|
||||
const LeaderData &aLeaderDataB);
|
||||
|
||||
/**
|
||||
* Fills an ConnectivityTlv.
|
||||
*
|
||||
* @param[out] aTlv A reference to the tlv to be filled.
|
||||
*/
|
||||
void FillConnectivityTlv(ConnectivityTlv &aTlv);
|
||||
|
||||
/**
|
||||
* Schedule tx of MLE Advertisement message (unicast) to the given neighboring router after a random delay.
|
||||
*
|
||||
* @param[in] aRouter The router to send the Advertisement to.
|
||||
*
|
||||
*/
|
||||
void ScheduleUnicastAdvertisementTo(const Router &aRouter);
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
/**
|
||||
* Sets steering data out of band
|
||||
*
|
||||
* @param[in] aExtAddress Value used to set steering data
|
||||
* All zeros clears steering data
|
||||
* All 0xFFs sets steering data to 0xFF
|
||||
* Anything else is used to compute the bloom filter
|
||||
*/
|
||||
void SetSteeringData(const Mac::ExtAddress *aExtAddress);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the assigned parent priority.
|
||||
*
|
||||
* @returns The assigned parent priority value, -2 means not assigned.
|
||||
*/
|
||||
int8_t GetAssignParentPriority(void) const { return mParentPriority; }
|
||||
|
||||
/**
|
||||
* Sets the parent priority.
|
||||
*
|
||||
* @param[in] aParentPriority The parent priority value.
|
||||
*
|
||||
* @retval kErrorNone Successfully set the parent priority.
|
||||
* @retval kErrorInvalidArgs If the parent priority value is not among 1, 0, -1 and -2.
|
||||
*/
|
||||
Error SetAssignParentPriority(int8_t aParentPriority);
|
||||
|
||||
/**
|
||||
* Gets the longest MLE Timeout TLV for all active MTD children.
|
||||
*
|
||||
* @param[out] aTimeout A reference to where the information is placed.
|
||||
*
|
||||
* @retval kErrorNone Successfully get the max child timeout
|
||||
* @retval kErrorInvalidState Not an active router
|
||||
* @retval kErrorNotFound NO MTD child
|
||||
*/
|
||||
Error GetMaxChildTimeout(uint32_t &aTimeout) const;
|
||||
|
||||
/**
|
||||
* Sets the callback that is called when processing an MLE Discovery Request message.
|
||||
*
|
||||
* @param[in] aCallback A pointer to a function that is called to deliver MLE Discovery Request data.
|
||||
* @param[in] aContext A pointer to application-specific context.
|
||||
*/
|
||||
void SetDiscoveryRequestCallback(otThreadDiscoveryRequestCallback aCallback, void *aContext)
|
||||
{
|
||||
mDiscoveryRequestCallback.Set(aCallback, aContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the MLE Advertisement Trickle timer interval.
|
||||
*/
|
||||
void ResetAdvertiseInterval(void);
|
||||
|
||||
/**
|
||||
* Updates the MLE Advertisement Trickle timer max interval (if timer is running).
|
||||
*
|
||||
* This is called when there is change in router table.
|
||||
*/
|
||||
void UpdateAdvertiseInterval(void);
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
/**
|
||||
* Generates an MLE Time Synchronization message.
|
||||
*
|
||||
* @retval kErrorNone Successfully sent an MLE Time Synchronization message.
|
||||
* @retval kErrorNoBufs Insufficient buffers to generate the MLE Time Synchronization message.
|
||||
*/
|
||||
Error SendTimeSync(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*
|
||||
* @returns The maximum number of IP addresses that each MTD child may register with this device as parent.
|
||||
*/
|
||||
uint8_t GetMaxChildIpAddresses(void) const;
|
||||
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
/**
|
||||
* Sets/restores the maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent.
|
||||
*
|
||||
* @param[in] aMaxIpAddresses The maximum number of IP addresses that each MTD child may register with this
|
||||
* device as parent. 0 to clear the setting and restore the default.
|
||||
*
|
||||
* @retval kErrorNone Successfully set/cleared the number.
|
||||
* @retval kErrorInvalidArgs If exceeds the allowed maximum number.
|
||||
*/
|
||||
Error SetMaxChildIpAddresses(uint8_t aMaxIpAddresses);
|
||||
|
||||
/**
|
||||
* Sets whether the device was commissioned using CCM.
|
||||
*
|
||||
* @param[in] aEnabled TRUE if the device was commissioned using CCM, FALSE otherwise.
|
||||
*/
|
||||
void SetCcmEnabled(bool aEnabled) { mCcmEnabled = aEnabled; }
|
||||
|
||||
/**
|
||||
* Sets whether the Security Policy TLV version-threshold for routing (VR field) is enabled.
|
||||
*
|
||||
* @param[in] aEnabled TRUE to enable Security Policy TLV version-threshold for routing, FALSE otherwise.
|
||||
*/
|
||||
void SetThreadVersionCheckEnabled(bool aEnabled) { mThreadVersionCheckEnabled = aEnabled; }
|
||||
|
||||
/**
|
||||
* Gets the current Interval Max value used by Advertisement trickle timer.
|
||||
*
|
||||
* @returns The Interval Max of Advertisement trickle timer in milliseconds.
|
||||
*/
|
||||
uint32_t GetAdvertisementTrickleIntervalMax(void) const { return mAdvertiseTrickleTimer.GetIntervalMax(); }
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Constants
|
||||
|
||||
// Advertisement trickle timer constants - all times are in milliseconds.
|
||||
static constexpr uint32_t kAdvIntervalMin = 1000; // I_MIN
|
||||
static constexpr uint32_t kAdvIntervalNeighborMultiplier = 4000; // Multiplier for I_MAX per router neighbor
|
||||
static constexpr uint32_t kAdvIntervalMaxLowerBound = 12000; // Lower bound for I_MAX
|
||||
static constexpr uint32_t kAdvIntervalMaxUpperBound = 32000; // Upper bound for I_MAX
|
||||
static constexpr uint32_t kReedAdvIntervalMin = 570000;
|
||||
static constexpr uint32_t kReedAdvIntervalMax = 630000;
|
||||
#if OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE
|
||||
static constexpr uint32_t kAdvIntervalMaxLogRoutes = 5000;
|
||||
#endif
|
||||
|
||||
static constexpr uint32_t kMaxUnicastAdvertisementDelay = 1000; // Max random delay for unciast Adv tx
|
||||
static constexpr uint32_t kMaxNeighborAge = 100000; // Max neighbor age on router (in msec)
|
||||
static constexpr uint32_t kMaxNeighborAgeOnChild = 150000; // Max neighbor age on FTD child (in msec)
|
||||
static constexpr uint32_t kMaxLeaderToRouterTimeout = 90000; // (in msec)
|
||||
static constexpr uint8_t kMinDowngradeNeighbors = 7;
|
||||
static constexpr uint8_t kNetworkIdTimeout = 120; // (in sec)
|
||||
static constexpr uint8_t kRouterSelectionJitter = 120; // (in sec)
|
||||
static constexpr uint8_t kRouterDowngradeThreshold = 23;
|
||||
static constexpr uint8_t kRouterUpgradeThreshold = 16;
|
||||
static constexpr uint16_t kDiscoveryMaxJitter = 250; // Max jitter delay Discovery Responses (in msec).
|
||||
static constexpr uint16_t kUnsolicitedDataResponseJitter = 500; // Max delay for unsol Data Response (in msec).
|
||||
static constexpr uint8_t kLeaderDowngradeExtraDelay = 10; // Extra delay to downgrade leader (in sec).
|
||||
static constexpr uint8_t kDefaultLeaderWeight = 64;
|
||||
static constexpr uint8_t kAlternateRloc16Timeout = 8; // Time to use alternate RLOC16 (in sec).
|
||||
|
||||
// Threshold to accept a router upgrade request with reason
|
||||
// `kBorderRouterRequest` (number of BRs acting as router in
|
||||
// Network Data).
|
||||
static constexpr uint8_t kRouterUpgradeBorderRouterRequestThreshold = 2;
|
||||
|
||||
static constexpr uint8_t kLinkRequestMinMargin = OPENTHREAD_CONFIG_MLE_LINK_REQUEST_MARGIN_MIN;
|
||||
static constexpr uint8_t kPartitionMergeMinMargin = OPENTHREAD_CONFIG_MLE_PARTITION_MERGE_MARGIN_MIN;
|
||||
static constexpr uint8_t kChildRouterLinks = OPENTHREAD_CONFIG_MLE_CHILD_ROUTER_LINKS;
|
||||
static constexpr uint8_t kMaxChildIpAddresses = OPENTHREAD_CONFIG_MLE_IP_ADDRS_PER_CHILD;
|
||||
|
||||
// Constants for gradual router link establishment (on FTD child)
|
||||
struct GradualChildRouterLink
|
||||
{
|
||||
static constexpr uint8_t kExtraChildRouterLinks = OPENTHREAD_CONFIG_MLE_EXTRA_CHILD_ROUTER_LINKS_GRADUAL;
|
||||
static constexpr uint32_t kWaitDurationAfterAttach = 300; // in seconds (5 minutes)
|
||||
static constexpr uint32_t kMinLinkRequestDelay = 1500; // in msec
|
||||
static constexpr uint32_t kMaxLinkRequestDelay = 10000; // in msec
|
||||
static constexpr uint32_t kProbabilityPercentage = 5; // in percent
|
||||
};
|
||||
|
||||
static constexpr uint8_t kMinCriticalChildrenCount = 6;
|
||||
|
||||
static constexpr uint16_t kChildSupervisionDefaultIntervalForOlderVersion =
|
||||
OPENTHREAD_CONFIG_CHILD_SUPERVISION_OLDER_VERSION_CHILD_DEFAULT_INTERVAL;
|
||||
|
||||
static constexpr int8_t kParentPriorityHigh = 1;
|
||||
static constexpr int8_t kParentPriorityMedium = 0;
|
||||
static constexpr int8_t kParentPriorityLow = -1;
|
||||
static constexpr int8_t kParentPriorityUnspecified = -2;
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Nested types
|
||||
|
||||
class RouterRoleTransition
|
||||
{
|
||||
public:
|
||||
RouterRoleTransition(void);
|
||||
|
||||
bool IsPending(void) const { return (mTimeout != 0); }
|
||||
void StartTimeout(void);
|
||||
void StopTimeout(void) { mTimeout = 0; }
|
||||
void IncreaseTimeout(uint8_t aIncrement) { mTimeout += aIncrement; }
|
||||
uint8_t GetTimeout(void) const { return mTimeout; }
|
||||
bool HandleTimeTick(void);
|
||||
uint8_t GetJitter(void) const { return mJitter; }
|
||||
void SetJitter(uint8_t aJitter) { mJitter = aJitter; }
|
||||
|
||||
private:
|
||||
uint8_t mTimeout;
|
||||
uint8_t mJitter;
|
||||
};
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
class RouterRoleRestorer : public InstanceLocator
|
||||
{
|
||||
// Attempts to restore the router or leader role after an MLE
|
||||
// restart(e.g., after a device reboot) by sending multicast
|
||||
// Link Requests.
|
||||
|
||||
public:
|
||||
RouterRoleRestorer(Instance &aInstance);
|
||||
|
||||
bool IsActive(void) const { return mAttempts > 0; }
|
||||
void Start(DeviceRole aPreviousRole);
|
||||
void Stop(void) { mAttempts = 0; }
|
||||
void HandleTimer(void);
|
||||
|
||||
void GenerateRandomChallenge(void) { mChallenge.GenerateRandom(); }
|
||||
const TxChallenge &GetChallenge(void) const { return mChallenge; }
|
||||
|
||||
private:
|
||||
void SendMulticastLinkRequest(void);
|
||||
|
||||
uint8_t mAttempts;
|
||||
TxChallenge mChallenge;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Methods
|
||||
|
||||
void SetAlternateRloc16(uint16_t aRloc16);
|
||||
void ClearAlternateRloc16(void);
|
||||
void HandleDetachStart(void);
|
||||
void HandleChildStart(AttachMode aMode);
|
||||
void HandleSecurityPolicyChanged(void);
|
||||
void HandleLinkRequest(RxInfo &aRxInfo);
|
||||
void HandleLinkAccept(RxInfo &aRxInfo);
|
||||
void HandleLinkAcceptAndRequest(RxInfo &aRxInfo);
|
||||
void HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType);
|
||||
Error HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData);
|
||||
void HandleParentRequest(RxInfo &aRxInfo);
|
||||
void HandleChildIdRequest(RxInfo &aRxInfo);
|
||||
void HandleChildUpdateRequestOnParent(RxInfo &aRxInfo);
|
||||
void HandleChildUpdateResponseOnParent(RxInfo &aRxInfo);
|
||||
void HandleDataRequest(RxInfo &aRxInfo);
|
||||
void HandleNetworkDataUpdateRouter(void);
|
||||
void HandleDiscoveryRequest(RxInfo &aRxInfo);
|
||||
void EstablishRouterLinkOnFtdChild(Router &aRouter, RxInfo &aRxInfo, uint8_t aLinkMargin);
|
||||
Error ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo);
|
||||
Error ReadAndProcessRouteTlvOnFtdChild(RxInfo &aRxInfo, uint8_t aParentId);
|
||||
void StopAdvertiseTrickleTimer(void);
|
||||
uint32_t DetermineAdvertiseIntervalMax(void) const;
|
||||
Error SendAddressSolicit(ThreadStatusTlv::Status aStatus);
|
||||
void SendAddressSolicitResponse(const Coap::Message &aRequest,
|
||||
ThreadStatusTlv::Status aResponseStatus,
|
||||
const Router *aRouter,
|
||||
const Ip6::MessageInfo &aMessageInfo);
|
||||
void SendAddressRelease(void);
|
||||
void SendMulticastAdvertisement(void);
|
||||
void SendAdvertisement(const Ip6::Address &aDestination);
|
||||
void SendLinkRequest(Router *aRouter);
|
||||
Error SendLinkAccept(const LinkAcceptInfo &aInfo);
|
||||
void SendParentResponse(const ParentResponseInfo &aInfo);
|
||||
Error SendChildIdResponse(Child &aChild);
|
||||
Error SendChildUpdateRequestToChild(Child &aChild);
|
||||
void SendChildUpdateResponseToChild(Child *aChild,
|
||||
const Ip6::MessageInfo &aMessageInfo,
|
||||
const TlvList &aTlvList,
|
||||
const RxChallenge &aChallenge);
|
||||
void SendMulticastDataResponse(void);
|
||||
void SendDataResponse(const Ip6::Address &aDestination,
|
||||
const TlvList &aTlvList,
|
||||
const Message *aRequestMessage = nullptr);
|
||||
Error SendDiscoveryResponse(const Ip6::Address &aDestination, const DiscoveryResponseInfo &aInfo);
|
||||
void SetStateRouter(uint16_t aRloc16);
|
||||
void SetStateLeader(uint16_t aRloc16, LeaderStartMode aStartMode);
|
||||
void SetStateRouterOrLeader(DeviceRole aRole, uint16_t aRloc16, LeaderStartMode aStartMode);
|
||||
void StopLeader(void);
|
||||
void SynchronizeChildNetworkData(void);
|
||||
Error ProcessAddressRegistrationTlv(RxInfo &aRxInfo, Child &aChild);
|
||||
bool HasNeighborWithGoodLinkQuality(void) const;
|
||||
void HandlePartitionChange(void);
|
||||
void SetChildStateToValid(Child &aChild);
|
||||
bool HasChildren(void);
|
||||
void RemoveChildren(void);
|
||||
bool ShouldDowngrade(uint8_t aNeighborId, const RouteTlv &aRouteTlv) const;
|
||||
bool NeighborHasComparableConnectivity(const RouteTlv &aRouteTlv, uint8_t aNeighborId) const;
|
||||
void HandleAdvertiseTrickleTimer(void);
|
||||
void HandleAddressSolicitResponse(Coap::Message *aMessage, const Ip6::MessageInfo *aMessageInfo, Error aResult);
|
||||
void HandleTimeTick(void);
|
||||
|
||||
template <Uri kUri> void HandleTmf(Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
|
||||
|
||||
#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);
|
||||
static void HandleAddressSolicitResponse(void *aContext,
|
||||
otMessage *aMessage,
|
||||
const otMessageInfo *aMessageInfo,
|
||||
otError aResult);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Variables
|
||||
|
||||
bool mRouterEligible : 1;
|
||||
bool mAddressSolicitPending : 1;
|
||||
bool mAddressSolicitRejected : 1;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
bool mCcmEnabled : 1;
|
||||
bool mThreadVersionCheckEnabled : 1;
|
||||
#endif
|
||||
|
||||
uint8_t mRouterId;
|
||||
uint8_t mPreviousRouterId;
|
||||
uint8_t mNetworkIdTimeout;
|
||||
uint8_t mRouterUpgradeThreshold;
|
||||
uint8_t mRouterDowngradeThreshold;
|
||||
uint8_t mLeaderWeight;
|
||||
uint8_t mPreviousPartitionRouterIdSequence;
|
||||
uint8_t mPreviousPartitionIdTimeout;
|
||||
uint8_t mChildRouterLinks;
|
||||
uint8_t mAlternateRloc16Timeout;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
uint8_t mMaxChildIpAddresses;
|
||||
#endif
|
||||
int8_t mParentPriority;
|
||||
uint16_t mNextChildId;
|
||||
uint32_t mPreviousPartitionIdRouter;
|
||||
uint32_t mPreviousPartitionId;
|
||||
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
|
||||
uint32_t mPreferredLeaderPartitionId;
|
||||
#endif
|
||||
|
||||
TrickleTimer mAdvertiseTrickleTimer;
|
||||
ChildTable mChildTable;
|
||||
RouterTable mRouterTable;
|
||||
RouterRoleRestorer mRouterRoleRestorer;
|
||||
RouterRoleTransition mRouterRoleTransition;
|
||||
Ip6::Netif::UnicastAddress mLeaderAloc;
|
||||
#if OPENTHREAD_CONFIG_MLE_DEVICE_PROPERTY_LEADER_WEIGHT_ENABLE
|
||||
DeviceProperties mDeviceProperties;
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
MeshCoP::SteeringData mSteeringData;
|
||||
#endif
|
||||
Callback<otThreadDiscoveryRequestCallback> mDiscoveryRequestCallback;
|
||||
};
|
||||
|
||||
DeclareTmfHandler(MleRouter, kUriAddressSolicit);
|
||||
DeclareTmfHandler(MleRouter, kUriAddressRelease);
|
||||
|
||||
#endif // OPENTHREAD_FTD
|
||||
|
||||
#if OPENTHREAD_MTD
|
||||
|
||||
typedef Mle MleRouter;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Mle
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
} // namespace ot
|
||||
|
||||
#endif // MLE_ROUTER_HPP_
|
||||
@@ -61,7 +61,7 @@ void MlrManager::HandleNotifierEvents(Events aEvents)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aEvents.Contains(kEventThreadRoleChanged) && Get<Mle::MleRouter>().IsChild())
|
||||
if (aEvents.Contains(kEventThreadRoleChanged) && Get<Mle::Mle>().IsChild())
|
||||
{
|
||||
// Reregistration after re-attach
|
||||
UpdateReregistrationDelay(true);
|
||||
@@ -211,9 +211,9 @@ void MlrManager::UpdateTimeTickerRegistration(void)
|
||||
|
||||
void MlrManager::SendMlr(void)
|
||||
{
|
||||
Error error;
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
AddressArray addresses;
|
||||
Error error;
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
AddressArray addresses;
|
||||
|
||||
VerifyOrExit(!mMlrPending, error = kErrorBusy);
|
||||
VerifyOrExit(mle.IsAttached(), error = kErrorInvalidState);
|
||||
@@ -370,7 +370,7 @@ Error MlrManager::SendMlrMessage(const Ip6::Address *aAddresses,
|
||||
OT_UNUSED_VARIABLE(aTimeout);
|
||||
|
||||
Error error = kErrorNone;
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
Coap::Message *message = nullptr;
|
||||
Tmf::MessageInfo messageInfo(GetInstance());
|
||||
Ip6AddressesTlv addressesTlv;
|
||||
@@ -607,7 +607,7 @@ void MlrManager::Reregister(void)
|
||||
|
||||
void MlrManager::UpdateReregistrationDelay(bool aRereg)
|
||||
{
|
||||
Mle::MleRouter &mle = Get<Mle::MleRouter>();
|
||||
Mle::Mle &mle = Get<Mle::Mle>();
|
||||
|
||||
bool needSendMlr = (mle.IsFullThreadDevice() || mle.GetParent().IsThreadVersion1p1()) &&
|
||||
Get<BackboneRouter::Leader>().HasPrimary();
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#include "common/timer.hpp"
|
||||
#include "net/udp6.hpp"
|
||||
#include "thread/lowpan.hpp"
|
||||
#include "thread/mle_router.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/network_data_tlvs.hpp"
|
||||
#include "thread/network_data_types.hpp"
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ Error Leader::GetContext(const Ip6::Address &aAddress, Lowpan::Context &aContext
|
||||
|
||||
aContext.mPrefix.SetLength(0);
|
||||
|
||||
if (Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress))
|
||||
if (Get<Mle::Mle>().IsMeshLocalAddress(aAddress))
|
||||
{
|
||||
GetContextForMeshLocalPrefix(aContext);
|
||||
}
|
||||
@@ -236,7 +236,7 @@ exit:
|
||||
|
||||
void Leader::GetContextForMeshLocalPrefix(Lowpan::Context &aContext) const
|
||||
{
|
||||
aContext.mPrefix.Set(Get<Mle::MleRouter>().GetMeshLocalPrefix());
|
||||
aContext.mPrefix.Set(Get<Mle::Mle>().GetMeshLocalPrefix());
|
||||
aContext.mContextId = Mle::kMeshLocalPrefixContextId;
|
||||
aContext.mCompressFlag = true;
|
||||
aContext.mIsValid = true;
|
||||
@@ -247,7 +247,7 @@ bool Leader::IsOnMesh(const Ip6::Address &aAddress) const
|
||||
const PrefixTlv *prefixTlv = nullptr;
|
||||
bool isOnMesh = false;
|
||||
|
||||
VerifyOrExit(!Get<Mle::MleRouter>().IsMeshLocalAddress(aAddress), isOnMesh = true);
|
||||
VerifyOrExit(!Get<Mle::Mle>().IsMeshLocalAddress(aAddress), isOnMesh = true);
|
||||
|
||||
while ((prefixTlv = FindNextMatchingPrefixTlv(aAddress, prefixTlv)) != nullptr)
|
||||
{
|
||||
@@ -484,7 +484,7 @@ Error Leader::SetNetworkData(uint8_t aVersion,
|
||||
}
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
if (Get<Mle::MleRouter>().IsLeader())
|
||||
if (Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
Get<Leader>().HandleNetworkDataRestoredAfterReset();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "common/numeric_limits.hpp"
|
||||
#include "common/timer.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "thread/mle_router.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/network_data.hpp"
|
||||
#include "thread/tmf.hpp"
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ void Leader::Start(Mle::LeaderStartMode aStartMode)
|
||||
|
||||
void Leader::IncrementVersion(void)
|
||||
{
|
||||
if (Get<Mle::MleRouter>().IsLeader())
|
||||
if (Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
IncrementVersions(/* aIncludeStable */ false);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void Leader::IncrementVersion(void)
|
||||
|
||||
void Leader::IncrementVersionAndStableVersion(void)
|
||||
{
|
||||
if (Get<Mle::MleRouter>().IsLeader())
|
||||
if (Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
IncrementVersions(/* aIncludeStable */ true);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ template <> void Leader::HandleTmf<kUriCommissionerSet>(Coap::Message &aMessage,
|
||||
state = MeshCoP::StateTlv::kAccept;
|
||||
|
||||
exit:
|
||||
if (Get<Mle::MleRouter>().IsLeader())
|
||||
if (Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
SendCommissioningSetResponse(aMessage, aMessageInfo, state);
|
||||
}
|
||||
@@ -664,7 +664,7 @@ void Leader::CheckForNetDataGettingFull(const NetworkData &aNetworkData, uint16_
|
||||
// device. If provided, then entries matching old RLOC16 are first
|
||||
// removed, before checking if new entries from @p aNetworkData can fit.
|
||||
|
||||
if (!Get<Mle::MleRouter>().IsLeader())
|
||||
if (!Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
// Create a clone of the leader's network data, and try to register
|
||||
// `aNetworkData` into the copy (as if this device itself is the
|
||||
@@ -1415,7 +1415,7 @@ void Leader::HandleTimer(void)
|
||||
if (mWaitingForNetDataSync)
|
||||
{
|
||||
LogInfo("Timed out waiting for netdata on restoring leader role after reset");
|
||||
IgnoreError(Get<Mle::MleRouter>().BecomeDetached());
|
||||
IgnoreError(Get<Mle::Mle>().BecomeDetached());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ exit:
|
||||
|
||||
void Local::UpdateRloc(PrefixTlv &aPrefixTlv)
|
||||
{
|
||||
uint16_t rloc16 = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
|
||||
for (NetworkDataTlv *cur = aPrefixTlv.GetSubTlvs(); cur < aPrefixTlv.GetNext(); cur = cur->GetNext())
|
||||
{
|
||||
@@ -197,7 +197,7 @@ Error Local::AddService(uint32_t aEnterpriseNumber,
|
||||
serviceTlv->SetSubTlvsLength(sizeof(ServerTlv) + aServerData.GetLength());
|
||||
|
||||
serverTlv = As<ServerTlv>(serviceTlv->GetSubTlvs());
|
||||
serverTlv->Init(Get<Mle::MleRouter>().GetRloc16(), aServerData);
|
||||
serverTlv->Init(Get<Mle::Mle>().GetRloc16(), aServerData);
|
||||
|
||||
// According to Thread spec 1.1.1, section 5.18.6 Service TLV:
|
||||
// "The Stable flag is set if any of the included sub-TLVs have their Stable flag set."
|
||||
@@ -237,7 +237,7 @@ exit:
|
||||
|
||||
void Local::UpdateRloc(ServiceTlv &aService)
|
||||
{
|
||||
uint16_t rloc16 = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
|
||||
for (NetworkDataTlv *cur = aService.GetSubTlvs(); cur < aService.GetNext(); cur = cur->GetNext())
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ void Notifier::SynchronizeServerData(void)
|
||||
{
|
||||
Error error = kErrorNotFound;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsAttached() && !mWaitingForResponse);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsAttached() && !mWaitingForResponse);
|
||||
|
||||
VerifyOrExit((mNextDelay == 0) || !mTimer.IsRunning());
|
||||
|
||||
@@ -101,7 +101,7 @@ exit:
|
||||
break;
|
||||
#if OPENTHREAD_FTD
|
||||
case kErrorInvalidState:
|
||||
mTimer.Start(Time::SecToMsec(Get<Mle::MleRouter>().GetRouterRoleTransitionTimeout() + 1));
|
||||
mTimer.Start(Time::SecToMsec(Get<Mle::Mle>().GetRouterRoleTransitionTimeout() + 1));
|
||||
break;
|
||||
#endif
|
||||
case kErrorNotFound:
|
||||
@@ -125,7 +125,7 @@ Error Notifier::RemoveStaleChildEntries(void)
|
||||
Error error = kErrorNotFound;
|
||||
Rlocs rlocs;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsRouterOrLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsRouterOrLeader());
|
||||
|
||||
Get<Leader>().FindRlocs(kAnyBrOrServer, kAnyRole, rlocs);
|
||||
|
||||
@@ -148,13 +148,13 @@ exit:
|
||||
Error Notifier::UpdateInconsistentData(void)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
uint16_t deviceRloc = Get<Mle::MleRouter>().GetRloc16();
|
||||
uint16_t deviceRloc = Get<Mle::Mle>().GetRloc16();
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
// Don't send this Server Data Notification if the device is going
|
||||
// to upgrade to Router.
|
||||
|
||||
if (Get<Mle::MleRouter>().IsExpectedToBecomeRouterSoon())
|
||||
if (Get<Mle::Mle>().IsExpectedToBecomeRouterSoon())
|
||||
{
|
||||
ExitNow(error = kErrorInvalidState);
|
||||
}
|
||||
@@ -294,12 +294,12 @@ bool Notifier::IsEligibleForRouterRoleUpgradeAsBorderRouter(void) const
|
||||
uint16_t rloc16 = Get<Mle::Mle>().GetRloc16();
|
||||
uint8_t activeRouterCount;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsRouterEligible());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsRouterEligible());
|
||||
|
||||
// RouterUpgradeThreshold can be explicitly set to zero in some of
|
||||
// cert tests to disallow device to become router.
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().GetRouterUpgradeThreshold() != 0);
|
||||
VerifyOrExit(Get<Mle::Mle>().GetRouterUpgradeThreshold() != 0);
|
||||
|
||||
// Check that we are a border router providing IP connectivity and already
|
||||
// in the leader's network data and therefore eligible to request router
|
||||
@@ -309,7 +309,7 @@ bool Notifier::IsEligibleForRouterRoleUpgradeAsBorderRouter(void) const
|
||||
Get<Leader>().ContainsBorderRouterWithRloc(rloc16));
|
||||
|
||||
activeRouterCount = Get<RouterTable>().GetActiveRouterCount();
|
||||
VerifyOrExit((activeRouterCount >= Get<Mle::MleRouter>().GetRouterUpgradeThreshold()) &&
|
||||
VerifyOrExit((activeRouterCount >= Get<Mle::Mle>().GetRouterUpgradeThreshold()) &&
|
||||
(activeRouterCount < Mle::kMaxRouters));
|
||||
|
||||
VerifyOrExit(Get<Leader>().CountBorderRouters(kRouterRoleOnly) < Mle::kRouterUpgradeBorderRouterRequestThreshold);
|
||||
@@ -333,7 +333,7 @@ void Notifier::ScheduleRouterRoleUpgradeIfEligible(void)
|
||||
|
||||
VerifyOrExit(!mDidRequestRouterRoleUpgrade);
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsChild());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsChild());
|
||||
VerifyOrExit(IsEligibleForRouterRoleUpgradeAsBorderRouter() && (mRouterRoleUpgradeTimeout == 0));
|
||||
|
||||
mRouterRoleUpgradeTimeout = Random::NonCrypto::GetUint8InRange(1, kRouterRoleUpgradeMaxTimeout + 1);
|
||||
@@ -357,11 +357,11 @@ void Notifier::HandleTimeTick(void)
|
||||
// upgrade (note that state can change since the last time we
|
||||
// checked and registered to receive time ticks).
|
||||
|
||||
if (Get<Mle::MleRouter>().IsChild() && IsEligibleForRouterRoleUpgradeAsBorderRouter())
|
||||
if (Get<Mle::Mle>().IsChild() && IsEligibleForRouterRoleUpgradeAsBorderRouter())
|
||||
{
|
||||
LogInfo("Requesting router role as BR");
|
||||
mDidRequestRouterRoleUpgrade = true;
|
||||
IgnoreError(Get<Mle::MleRouter>().BecomeRouter(ThreadStatusTlv::kBorderRouterRequest));
|
||||
IgnoreError(Get<Mle::Mle>().BecomeRouter(ThreadStatusTlv::kBorderRouterRequest));
|
||||
}
|
||||
}
|
||||
exit:
|
||||
|
||||
@@ -143,7 +143,7 @@ bool Manager::IsBackboneRouterPreferredTo(const ServerTlv &aServerTlv,
|
||||
const BbrServerData &aOtherServerData) const
|
||||
{
|
||||
bool isPreferred;
|
||||
uint16_t leaderRloc16 = Get<Mle::MleRouter>().GetLeaderRloc16();
|
||||
uint16_t leaderRloc16 = Get<Mle::Mle>().GetLeaderRloc16();
|
||||
|
||||
VerifyOrExit(aServerTlv.GetServer16() != leaderRloc16, isPreferred = true);
|
||||
VerifyOrExit(aOtherServerTlv.GetServer16() != leaderRloc16, isPreferred = false);
|
||||
|
||||
@@ -206,7 +206,7 @@ void ExternalRouteConfig::SetFrom(Instance &aInstance,
|
||||
SetFromTlvFlags(aHasRouteEntry.GetFlags());
|
||||
mStable = aHasRouteTlv.IsStable();
|
||||
mRloc16 = aHasRouteEntry.GetRloc();
|
||||
mNextHopIsThisDevice = (aHasRouteEntry.GetRloc() == aInstance.Get<Mle::MleRouter>().GetRloc16());
|
||||
mNextHopIsThisDevice = (aHasRouteEntry.GetRloc() == aInstance.Get<Mle::Mle>().GetRloc16());
|
||||
}
|
||||
|
||||
void ExternalRouteConfig::SetFromTlvFlags(uint8_t aFlags)
|
||||
|
||||
@@ -99,7 +99,7 @@ void Server::PrepareMessageInfoForDest(const Ip6::Address &aDestination, Tmf::Me
|
||||
|
||||
if (aDestination.IsLinkLocalUnicastOrMulticast())
|
||||
{
|
||||
aMessageInfo.SetSockAddr(Get<Mle::MleRouter>().GetLinkLocalAddress());
|
||||
aMessageInfo.SetSockAddr(Get<Mle::Mle>().GetLinkLocalAddress());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -152,7 +152,7 @@ Error Server::AppendChildTable(Message &aMessage)
|
||||
Error error = kErrorNone;
|
||||
uint16_t count;
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsRouterOrLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsRouterOrLeader());
|
||||
|
||||
count = Min(Get<ChildTable>().GetNumChildren(Child::kInStateValid), kMaxChildEntries);
|
||||
|
||||
@@ -400,11 +400,11 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
||||
break;
|
||||
|
||||
case Tlv::kAddress16:
|
||||
error = Tlv::Append<Address16Tlv>(aMessage, Get<Mle::MleRouter>().GetRloc16());
|
||||
error = Tlv::Append<Address16Tlv>(aMessage, Get<Mle::Mle>().GetRloc16());
|
||||
break;
|
||||
|
||||
case Tlv::kMode:
|
||||
error = Tlv::Append<ModeTlv>(aMessage, Get<Mle::MleRouter>().GetDeviceMode().Get());
|
||||
error = Tlv::Append<ModeTlv>(aMessage, Get<Mle::Mle>().GetDeviceMode().Get());
|
||||
break;
|
||||
|
||||
case Tlv::kEui64:
|
||||
@@ -421,8 +421,8 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
||||
break;
|
||||
|
||||
case Tlv::kTimeout:
|
||||
VerifyOrExit(!Get<Mle::MleRouter>().IsRxOnWhenIdle());
|
||||
error = Tlv::Append<TimeoutTlv>(aMessage, Get<Mle::MleRouter>().GetTimeout());
|
||||
VerifyOrExit(!Get<Mle::Mle>().IsRxOnWhenIdle());
|
||||
error = Tlv::Append<TimeoutTlv>(aMessage, Get<Mle::Mle>().GetTimeout());
|
||||
break;
|
||||
|
||||
case Tlv::kLeaderData:
|
||||
@@ -430,7 +430,7 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
||||
LeaderDataTlv tlv;
|
||||
|
||||
tlv.Init();
|
||||
tlv.Set(Get<Mle::MleRouter>().GetLeaderData());
|
||||
tlv.Set(Get<Mle::Mle>().GetLeaderData());
|
||||
error = tlv.AppendTo(aMessage);
|
||||
break;
|
||||
}
|
||||
@@ -511,7 +511,7 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
||||
ConnectivityTlv tlv;
|
||||
|
||||
tlv.Init();
|
||||
Get<Mle::MleRouter>().FillConnectivityTlv(tlv);
|
||||
Get<Mle::Mle>().FillConnectivityTlv(tlv);
|
||||
error = tlv.AppendTo(aMessage);
|
||||
break;
|
||||
}
|
||||
@@ -538,7 +538,7 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
||||
{
|
||||
uint32_t maxTimeout;
|
||||
|
||||
SuccessOrExit(Get<Mle::MleRouter>().GetMaxChildTimeout(maxTimeout));
|
||||
SuccessOrExit(Get<Mle::Mle>().GetMaxChildTimeout(maxTimeout));
|
||||
error = Tlv::Append<MaxChildTimeoutTlv>(aMessage, maxTimeout);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ Router *RouterTable::Allocate(uint8_t aRouterId)
|
||||
|
||||
mRouterIdSequence++;
|
||||
mRouterIdSequenceLastUpdated = TimerMilli::GetNow();
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
|
||||
LogNote("Allocate router id %d", aRouterId);
|
||||
|
||||
@@ -190,7 +190,7 @@ Error RouterTable::Release(uint8_t aRouterId)
|
||||
|
||||
OT_ASSERT(aRouterId <= Mle::kMaxRouterId);
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader(), error = kErrorInvalidState);
|
||||
VerifyOrExit(Get<Mle::Mle>().IsLeader(), error = kErrorInvalidState);
|
||||
|
||||
router = FindRouterById(aRouterId);
|
||||
VerifyOrExit(router != nullptr, error = kErrorNotFound);
|
||||
@@ -211,7 +211,7 @@ Error RouterTable::Release(uint8_t aRouterId)
|
||||
Get<AddressResolver>().RemoveEntriesForRouterId(aRouterId);
|
||||
Get<NetworkData::Leader>().RemoveBorderRouter(Mle::Rloc16FromRouterId(aRouterId),
|
||||
NetworkData::Leader::kMatchModeRouterId);
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
|
||||
LogNote("Release router id %d", aRouterId);
|
||||
|
||||
@@ -237,14 +237,14 @@ void RouterTable::RemoveRouterLink(Router &aRouter)
|
||||
|
||||
if (GetLinkCost(router) >= Mle::kMaxRouteCost)
|
||||
{
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (aRouter.GetNextHop() == Mle::kInvalidRouterId)
|
||||
{
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
|
||||
// Clear all EID-to-RLOC entries associated with the router.
|
||||
Get<AddressResolver>().RemoveEntriesForRouterId(aRouter.GetRouterId());
|
||||
@@ -328,7 +328,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
const Router *RouterTable::GetLeader(void) const { return FindRouterById(Get<Mle::MleRouter>().GetLeaderId()); }
|
||||
const Router *RouterTable::GetLeader(void) const { return FindRouterById(Get<Mle::Mle>().GetLeaderId()); }
|
||||
|
||||
uint32_t RouterTable::GetLeaderAge(void) const
|
||||
{
|
||||
@@ -411,7 +411,7 @@ void RouterTable::GetNextHopAndPathCost(uint16_t aDestRloc16, uint16_t &aNextHop
|
||||
router = FindRouterById(Mle::RouterIdFromRloc16(aDestRloc16));
|
||||
nextHop = (router != nullptr) ? FindNextHopOf(*router) : nullptr;
|
||||
|
||||
if (Get<Mle::MleRouter>().IsChild())
|
||||
if (Get<Mle::Mle>().IsChild())
|
||||
{
|
||||
const Router &parent = Get<Mle::Mle>().GetParent();
|
||||
bool destIsParentOrItsChild;
|
||||
@@ -544,7 +544,7 @@ void RouterTable::UpdateRouterIdSet(uint8_t aRouterIdSequence, const Mle::Router
|
||||
}
|
||||
}
|
||||
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
|
||||
exit:
|
||||
return;
|
||||
@@ -613,7 +613,7 @@ void RouterTable::UpdateRoutes(const Mle::RouteTlv &aRouteTlv, uint8_t aNeighbor
|
||||
if (neighbor->IsStateValid() && (aRouteTlv.GetLinkQualityOut(index) == kLinkQuality0) &&
|
||||
(neighbor->GetTwoWayLinkQuality() >= kLinkQuality2))
|
||||
{
|
||||
Get<Mle::MleRouter>().ScheduleUnicastAdvertisementTo(*neighbor);
|
||||
Get<Mle::Mle>().ScheduleUnicastAdvertisementTo(*neighbor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,7 +684,7 @@ void RouterTable::UpdateRoutes(const Mle::RouteTlv &aRouteTlv, uint8_t aNeighbor
|
||||
|
||||
if (newCostFinite != oldCostFinite)
|
||||
{
|
||||
Get<Mle::MleRouter>().ResetAdvertiseInterval();
|
||||
Get<Mle::Mle>().ResetAdvertiseInterval();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -817,7 +817,7 @@ void RouterTable::HandleTimeTick(void)
|
||||
{
|
||||
mRouterIdMap.HandleTimeTick();
|
||||
|
||||
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
|
||||
VerifyOrExit(Get<Mle::Mle>().IsLeader());
|
||||
|
||||
// Update router id sequence
|
||||
if (GetLeaderAge() >= kRouterIdSequencePeriod)
|
||||
@@ -890,7 +890,7 @@ void RouterTable::HandleTableChanged(void)
|
||||
Get<Utils::HistoryTracker>().RecordRouterTableChange();
|
||||
#endif
|
||||
|
||||
Get<Mle::MleRouter>().UpdateAdvertiseInterval();
|
||||
Get<Mle::Mle>().UpdateAdvertiseInterval();
|
||||
}
|
||||
|
||||
#if OT_SHOULD_LOG_AT(OT_LOG_LEVEL_INFO)
|
||||
|
||||
@@ -57,7 +57,7 @@ void ThreadNetif::Up(void)
|
||||
mIsUp = true;
|
||||
|
||||
SubscribeAllNodesMulticast();
|
||||
IgnoreError(Get<Mle::MleRouter>().Enable());
|
||||
IgnoreError(Get<Mle::Mle>().Enable());
|
||||
IgnoreError(Get<Tmf::Agent>().Start());
|
||||
#if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
|
||||
IgnoreError(Get<Dns::ServiceDiscovery::Server>().Start());
|
||||
@@ -88,7 +88,7 @@ void ThreadNetif::Down(void)
|
||||
Get<Dns::ServiceDiscovery::Server>().Stop();
|
||||
#endif
|
||||
IgnoreError(Get<Tmf::Agent>().Stop());
|
||||
IgnoreError(Get<Mle::MleRouter>().Disable());
|
||||
IgnoreError(Get<Mle::Mle>().Disable());
|
||||
RemoveAllExternalUnicastAddresses();
|
||||
UnsubscribeAllExternalMulticastAddresses();
|
||||
UnsubscribeAllRoutersMulticast();
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include "common/tlvs.hpp"
|
||||
#include "meshcop/network_name.hpp"
|
||||
#include "net/ip6_address.hpp"
|
||||
#include "thread/mle.hpp"
|
||||
#include "thread/mle_types.hpp"
|
||||
|
||||
namespace ot {
|
||||
|
||||
@@ -86,7 +86,7 @@ void TimeSync::HandleTimeSyncMessage(const Message &aMessage)
|
||||
|
||||
LogInfo("Older time sync seq received:%u. Forwarding current seq:%u", aMessage.GetTimeSyncSeq(), mTimeSyncSeq);
|
||||
}
|
||||
else if (Get<Mle::MleRouter>().IsLeader() && timeSyncSeqDelta > 0)
|
||||
else if (Get<Mle::Mle>().IsLeader() && timeSyncSeqDelta > 0)
|
||||
{
|
||||
// Another device is forwarding a later time sync sequence, perhaps because it merged from a different
|
||||
// partition. The leader is authoritative, so ensure all devices synchronize to the time being seeded by this
|
||||
@@ -97,13 +97,13 @@ void TimeSync::HandleTimeSyncMessage(const Message &aMessage)
|
||||
LogInfo("Newer time sync seq:%u received by leader. Setting current seq to:%u and forwarding",
|
||||
aMessage.GetTimeSyncSeq(), mTimeSyncSeq);
|
||||
}
|
||||
else if (!Get<Mle::MleRouter>().IsLeader())
|
||||
else if (!Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
// For all devices aside from the leader, update network time in following three cases:
|
||||
// 1. During first attach.
|
||||
// 2. Already attached, and a newer time sync sequence was received.
|
||||
// 3. During reattach or migration process.
|
||||
if (mTimeSyncSeq == OT_TIME_SYNC_INVALID_SEQ || timeSyncSeqDelta > 0 || Get<Mle::MleRouter>().IsDetached())
|
||||
if (mTimeSyncSeq == OT_TIME_SYNC_INVALID_SEQ || timeSyncSeqDelta > 0 || Get<Mle::Mle>().IsDetached())
|
||||
{
|
||||
// Update network time and forward it.
|
||||
mLastTimeSyncReceived = TimerMilli::GetNow();
|
||||
@@ -137,8 +137,7 @@ void TimeSync::NotifyTimeSyncCallback(void) { mTimeSyncCallback.InvokeIfSet(); }
|
||||
#if OPENTHREAD_FTD
|
||||
void TimeSync::ProcessTimeSync(void)
|
||||
{
|
||||
if (Get<Mle::MleRouter>().IsLeader() &&
|
||||
(TimerMilli::GetNow() - mLastTimeSyncSent > Time::SecToMsec(mTimeSyncPeriod)))
|
||||
if (Get<Mle::Mle>().IsLeader() && (TimerMilli::GetNow() - mLastTimeSyncSent > Time::SecToMsec(mTimeSyncPeriod)))
|
||||
{
|
||||
IncrementTimeSyncSeq();
|
||||
mTimeSyncRequired = true;
|
||||
@@ -148,7 +147,7 @@ void TimeSync::ProcessTimeSync(void)
|
||||
|
||||
if (mTimeSyncRequired)
|
||||
{
|
||||
VerifyOrExit(Get<Mle::MleRouter>().SendTimeSync() == kErrorNone);
|
||||
VerifyOrExit(Get<Mle::Mle>().SendTimeSync() == kErrorNone);
|
||||
|
||||
mLastTimeSyncSent = TimerMilli::GetNow();
|
||||
mTimeSyncRequired = false;
|
||||
@@ -168,7 +167,7 @@ void TimeSync::HandleNotifierEvents(Events aEvents)
|
||||
stateChanged = true;
|
||||
}
|
||||
|
||||
if (aEvents.Contains(kEventThreadPartitionIdChanged) && !Get<Mle::MleRouter>().IsLeader())
|
||||
if (aEvents.Contains(kEventThreadPartitionIdChanged) && !Get<Mle::Mle>().IsLeader())
|
||||
{
|
||||
// Partition has changed. Accept any network time currently being seeded on the new partition
|
||||
// and don't attempt to forward the currently held network time from the previous partition.
|
||||
@@ -200,7 +199,7 @@ void TimeSync::CheckAndHandleChanges(bool aTimeUpdated)
|
||||
|
||||
mTimer.Stop();
|
||||
|
||||
switch (Get<Mle::MleRouter>().GetRole())
|
||||
switch (Get<Mle::Mle>().GetRole())
|
||||
{
|
||||
case Mle::kRoleDisabled:
|
||||
case Mle::kRoleDetached:
|
||||
|
||||
@@ -41,18 +41,18 @@ namespace Tmf {
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
// MessageInfo
|
||||
|
||||
void MessageInfo::SetSockAddrToRloc(void) { SetSockAddr(Get<Mle::MleRouter>().GetMeshLocalRloc()); }
|
||||
void MessageInfo::SetSockAddrToRloc(void) { SetSockAddr(Get<Mle::Mle>().GetMeshLocalRloc()); }
|
||||
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToLeaderAloc(void)
|
||||
{
|
||||
SetSockAddrToRloc();
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(GetPeerAddr());
|
||||
Get<Mle::Mle>().GetLeaderAloc(GetPeerAddr());
|
||||
}
|
||||
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToLeaderRloc(void)
|
||||
{
|
||||
SetSockAddrToRloc();
|
||||
Get<Mle::MleRouter>().GetLeaderRloc(GetPeerAddr());
|
||||
Get<Mle::Mle>().GetLeaderRloc(GetPeerAddr());
|
||||
}
|
||||
|
||||
void MessageInfo::SetSockAddrToRlocPeerAddrToRealmLocalAllRoutersMulticast(void)
|
||||
@@ -127,8 +127,8 @@ bool Agent::HandleResource(const char *aUriPath, Message &aMessage, const Ip6::M
|
||||
#if OPENTHREAD_FTD
|
||||
Case(kUriAddressQuery, AddressResolver);
|
||||
Case(kUriAddressNotify, AddressResolver);
|
||||
Case(kUriAddressSolicit, Mle::MleRouter);
|
||||
Case(kUriAddressRelease, Mle::MleRouter);
|
||||
Case(kUriAddressSolicit, Mle::Mle);
|
||||
Case(kUriAddressRelease, Mle::Mle);
|
||||
Case(kUriActiveSet, MeshCoP::ActiveDatasetManager);
|
||||
Case(kUriActiveReplace, MeshCoP::ActiveDatasetManager);
|
||||
Case(kUriPendingSet, MeshCoP::PendingDatasetManager);
|
||||
|
||||
@@ -96,7 +96,7 @@ void JamDetector::CheckState(void)
|
||||
{
|
||||
VerifyOrExit(mEnabled);
|
||||
|
||||
switch (Get<Mle::MleRouter>().GetRole())
|
||||
switch (Get<Mle::Mle>().GetRole())
|
||||
{
|
||||
case Mle::kRoleDisabled:
|
||||
VerifyOrExit(mTimer.IsRunning());
|
||||
|
||||
@@ -40,7 +40,7 @@ void Node::Form(void)
|
||||
Get<MeshCoP::ActiveDatasetManager>().SaveLocal(datasetInfo);
|
||||
|
||||
Get<ThreadNetif>().Up();
|
||||
SuccessOrQuit(Get<Mle::MleRouter>().Start());
|
||||
SuccessOrQuit(Get<Mle::Mle>().Start());
|
||||
}
|
||||
|
||||
void Node::Join(Node &aNode, JoinMode aJoinMode)
|
||||
@@ -51,7 +51,7 @@ void Node::Join(Node &aNode, JoinMode aJoinMode)
|
||||
switch (aJoinMode)
|
||||
{
|
||||
case kAsFed:
|
||||
SuccessOrQuit(Get<Mle::MleRouter>().SetRouterEligible(false));
|
||||
SuccessOrQuit(Get<Mle::Mle>().SetRouterEligible(false));
|
||||
OT_FALL_THROUGH;
|
||||
|
||||
case kAsFtd:
|
||||
@@ -72,7 +72,7 @@ void Node::Join(Node &aNode, JoinMode aJoinMode)
|
||||
Get<MeshCoP::ActiveDatasetManager>().SaveLocal(dataset);
|
||||
|
||||
Get<ThreadNetif>().Up();
|
||||
SuccessOrQuit(Get<Mle::MleRouter>().Start());
|
||||
SuccessOrQuit(Get<Mle::Mle>().Start());
|
||||
}
|
||||
|
||||
void Node::AllowList(Node &aNode)
|
||||
|
||||
@@ -866,7 +866,7 @@ void TestBorderAgentMeshCoPServiceChangedCallback(void)
|
||||
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("sb", txtEntry));
|
||||
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("pt", txtEntry));
|
||||
VerifyOrQuit(CheckObjectSameAsTxtEntryData(
|
||||
txtEntry, BigEndian::HostSwap32(node0.Get<Mle::MleRouter>().GetLeaderData().GetPartitionId())));
|
||||
txtEntry, BigEndian::HostSwap32(node0.Get<Mle::Mle>().GetLeaderData().GetPartitionId())));
|
||||
VerifyOrQuit(meshCoPServiceTester.FindTxtEntry("at", txtEntry));
|
||||
VerifyOrQuit(CheckObjectSameAsTxtEntryData(txtEntry, node0.Get<ActiveDatasetManager>().GetTimestamp()));
|
||||
|
||||
|
||||
@@ -247,12 +247,12 @@ void TestDtlsSingleSession(void)
|
||||
nexus.AdvanceTime(50 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node0.Get<Mle::Mle>().IsLeader());
|
||||
|
||||
SuccessOrQuit(node1.Get<Mle::MleRouter>().SetRouterEligible(false));
|
||||
SuccessOrQuit(node1.Get<Mle::Mle>().SetRouterEligible(false));
|
||||
node1.Join(node0);
|
||||
nexus.AdvanceTime(20 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node1.Get<Mle::Mle>().IsChild());
|
||||
|
||||
SuccessOrQuit(node2.Get<Mle::MleRouter>().SetRouterEligible(false));
|
||||
SuccessOrQuit(node2.Get<Mle::Mle>().SetRouterEligible(false));
|
||||
node2.Join(node0);
|
||||
nexus.AdvanceTime(20 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node2.Get<Mle::Mle>().IsChild());
|
||||
@@ -489,12 +489,12 @@ void TestDtlsMultiSession(void)
|
||||
nexus.AdvanceTime(50 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node0.Get<Mle::Mle>().IsLeader());
|
||||
|
||||
SuccessOrQuit(node1.Get<Mle::MleRouter>().SetRouterEligible(false));
|
||||
SuccessOrQuit(node1.Get<Mle::Mle>().SetRouterEligible(false));
|
||||
node1.Join(node0);
|
||||
nexus.AdvanceTime(20 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node1.Get<Mle::Mle>().IsChild());
|
||||
|
||||
SuccessOrQuit(node2.Get<Mle::MleRouter>().SetRouterEligible(false));
|
||||
SuccessOrQuit(node2.Get<Mle::Mle>().SetRouterEligible(false));
|
||||
node2.Join(node0);
|
||||
nexus.AdvanceTime(20 * Time::kOneSecondInMsec);
|
||||
VerifyOrQuit(node2.Get<Mle::Mle>().IsChild());
|
||||
|
||||
@@ -78,7 +78,7 @@ void VerifyChildIp6Addresses(const Child &aChild, uint8_t aAddressListLength, co
|
||||
{
|
||||
Ip6::Address address;
|
||||
|
||||
if (sInstance->Get<Mle::MleRouter>().IsMeshLocalAddress(aAddressList[index]))
|
||||
if (sInstance->Get<Mle::Mle>().IsMeshLocalAddress(aAddressList[index]))
|
||||
{
|
||||
SuccessOrQuit(aChild.GetMeshLocalIp6Address(address));
|
||||
VerifyOrQuit(address == aAddressList[index], "GetMeshLocalIp6Address() did not return expected address");
|
||||
@@ -127,7 +127,7 @@ void TestChildIp6Address(void)
|
||||
numAddresses = 0;
|
||||
|
||||
// First addresses uses the mesh local prefix (mesh-local address).
|
||||
addresses[numAddresses] = sInstance->Get<Mle::MleRouter>().GetMeshLocalEid();
|
||||
addresses[numAddresses] = sInstance->Get<Mle::Mle>().GetMeshLocalEid();
|
||||
addresses[numAddresses].SetIid(meshLocalIid);
|
||||
|
||||
numAddresses++;
|
||||
|
||||
@@ -104,7 +104,7 @@ static void Init(void)
|
||||
otMeshLocalPrefix meshLocalPrefix = {{0xfd, 0x00, 0xca, 0xfe, 0xfa, 0xce, 0x12, 0x34}};
|
||||
OffsetRange offsetRange;
|
||||
|
||||
sInstance->Get<Mle::MleRouter>().SetMeshLocalPrefix(static_cast<Ip6::NetworkPrefix &>(meshLocalPrefix));
|
||||
sInstance->Get<Mle::Mle>().SetMeshLocalPrefix(static_cast<Ip6::NetworkPrefix &>(meshLocalPrefix));
|
||||
|
||||
// Emulate global prefixes with contextes.
|
||||
uint8_t mockNetworkData[] = {
|
||||
|
||||
Reference in New Issue
Block a user