mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 16:17:47 +00:00
[mle] simplify device role checks using IsAttached method (#2975)
This commit is contained in:
committed by
Jonathan Hui
parent
f993ba5f89
commit
e731babedb
+11
-2
@@ -347,7 +347,16 @@ otError Mle::Restore(void)
|
||||
netif.GetKeyManager().SetMleFrameCounter(networkInfo.mMleFrameCounter);
|
||||
netif.GetKeyManager().SetMacFrameCounter(networkInfo.mMacFrameCounter);
|
||||
|
||||
VerifyOrExit(networkInfo.mRole >= OT_DEVICE_ROLE_CHILD);
|
||||
switch (networkInfo.mRole)
|
||||
{
|
||||
case OT_DEVICE_ROLE_CHILD:
|
||||
case OT_DEVICE_ROLE_ROUTER:
|
||||
case OT_DEVICE_ROLE_LEADER:
|
||||
break;
|
||||
|
||||
default:
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
mDeviceMode = networkInfo.mDeviceMode;
|
||||
SetRloc16(networkInfo.mRloc16);
|
||||
@@ -879,7 +888,7 @@ otError Mle::SetMeshLocalPrefix(const otMeshLocalPrefix &aMeshLocalPrefix)
|
||||
netif.SubscribeMulticast(mLinkLocalAllThreadNodes);
|
||||
netif.SubscribeMulticast(mRealmLocalAllThreadNodes);
|
||||
|
||||
if (mRole >= OT_DEVICE_ROLE_CHILD)
|
||||
if (IsAttached())
|
||||
{
|
||||
netif.AddUnicastAddress(mMeshLocal16);
|
||||
}
|
||||
|
||||
@@ -2074,7 +2074,7 @@ otError MleRouter::HandleChildIdRequest(const Message & aMessage,
|
||||
VerifyOrExit(IsRouterRoleEnabled(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
// only process message when operating as a child, router, or leader
|
||||
VerifyOrExit(mRole >= OT_DEVICE_ROLE_CHILD, error = OT_ERROR_INVALID_STATE);
|
||||
VerifyOrExit(IsAttached(), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
// Find Child
|
||||
aMessageInfo.GetPeerAddr().ToExtAddress(macAddr);
|
||||
|
||||
Reference in New Issue
Block a user