mirror of
https://github.com/espressif/openthread.git
synced 2026-09-30 12:57:38 +00:00
Do not prematurely detach when a router migrates to another partition. (#298)
Move processing the Route TLV from the new partition after successfully completing the attach.
This commit is contained in:
+17
-17
@@ -1727,21 +1727,6 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
|
||||
(mDeviceMode & ModeTlv::kModeFullNetworkData) == 0,
|
||||
networkData.GetNetworkData(), networkData.GetLength());
|
||||
|
||||
// Route
|
||||
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == kThreadError_None) &&
|
||||
(mDeviceMode & ModeTlv::kModeFFD))
|
||||
{
|
||||
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
|
||||
|
||||
for (int i = 0; i < kMaxRouterId; i++)
|
||||
{
|
||||
if (route.IsRouterIdSet(i))
|
||||
{
|
||||
numRouters++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parent Attach Success
|
||||
mParentRequestTimer.Stop();
|
||||
|
||||
@@ -1760,9 +1745,24 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
|
||||
mParent.mValid.mRloc16 = sourceAddress.GetRloc16();
|
||||
SuccessOrExit(error = SetStateChild(shortAddress.GetRloc16()));
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) && (numRouters < mMleRouter.GetRouterUpgradeThreshold()))
|
||||
// Route
|
||||
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == kThreadError_None) &&
|
||||
(mDeviceMode & ModeTlv::kModeFFD))
|
||||
{
|
||||
mMleRouter.BecomeRouter();
|
||||
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
|
||||
|
||||
for (int i = 0; i < kMaxRouterId; i++)
|
||||
{
|
||||
if (route.IsRouterIdSet(i))
|
||||
{
|
||||
numRouters++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mDeviceMode & ModeTlv::kModeFFD) && (numRouters < mMleRouter.GetRouterUpgradeThreshold()))
|
||||
{
|
||||
mMleRouter.BecomeRouter();
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
@@ -1073,7 +1073,7 @@ ThreadError MleRouter::ProcessRouteTlv(const RouteTlv &aRoute)
|
||||
bool old;
|
||||
|
||||
// check for newer route data
|
||||
if (diff > 0 || mDeviceState == kDeviceStateDetached)
|
||||
if (diff > 0 || mDeviceState == kDeviceStateDetached || mDeviceState == kDeviceStateChild)
|
||||
{
|
||||
mRouterIdSequence = aRoute.GetRouterIdSequence();
|
||||
mRouterIdSequenceLastUpdated = Timer::GetNow();
|
||||
|
||||
Reference in New Issue
Block a user