diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index f9cc9db4d..3737bb331 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -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); } diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 9d6db68e6..070390b97 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -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);