let FFD child successfully ProcessRouteTLV when HandleChildIdResponse (#240)

This commit is contained in:
rongli
2016-07-04 13:26:53 -07:00
committed by Jonathan Hui
parent 59af30249d
commit 8ef67d223b
2 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ Mac::Mac(ThreadNetif &aThreadNetif):
SetExtendedPanId(sExtendedPanidInit);
SetNetworkName(sNetworkNameInit);
SetPanId(kPanIdBroadcast);
SetPanId(mPanId);
SetExtAddress(mExtAddress);
SetShortAddress(kShortAddrInvalid);
+18 -18
View File
@@ -1731,6 +1731,22 @@ 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))
{
numRouters = 0;
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
for (int i = 0; i < kMaxRouterId; i++)
{
if (route.IsRouterIdSet(i))
{
numRouters++;
}
}
}
// Parent Attach Success
mParentRequestTimer.Stop();
@@ -1749,25 +1765,9 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
mParent.mValid.mRloc16 = sourceAddress.GetRloc16();
SuccessOrExit(error = SetStateChild(shortAddress.GetRloc16()));
// Route
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == kThreadError_None) &&
(mDeviceMode & ModeTlv::kModeFFD))
if ((mDeviceMode & ModeTlv::kModeFFD) && (numRouters < mMleRouter.GetRouterUpgradeThreshold()))
{
numRouters = 0;
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
for (int i = 0; i < kMaxRouterId; i++)
{
if (route.IsRouterIdSet(i))
{
numRouters++;
}
}
if (numRouters < mMleRouter.GetRouterUpgradeThreshold())
{
mMleRouter.BecomeRouter();
}
mMleRouter.BecomeRouter();
}
exit: