From c4eff620241d95c0e502cf7cf98cb857b0cc5954 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 8 Nov 2016 15:39:08 -0800 Subject: [PATCH] Schedule MLE Data Response messages to SEDs on network data change. (#946) --- src/core/thread/mesh_forwarder.cpp | 2 - src/core/thread/mle_router.cpp | 59 +++++++++++++++--------------- src/core/thread/mle_router.hpp | 8 ---- 3 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/core/thread/mesh_forwarder.cpp b/src/core/thread/mesh_forwarder.cpp index c0bddbcec..de8560701 100644 --- a/src/core/thread/mesh_forwarder.cpp +++ b/src/core/thread/mesh_forwarder.cpp @@ -1780,8 +1780,6 @@ void MeshForwarder::HandleDataRequest(const Mac::Address &aMacSource, const Thre child->mLastHeard = Timer::GetNow(); child->mLinkFailures = 0; - mMle.HandleMacDataRequest(*child); - if (child->mQueuedIndirectMessageCnt > 0) { child->mDataRequest = true; diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 82e341d4f..1d0745a35 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -2276,6 +2276,35 @@ ThreadError MleRouter::HandleNetworkDataUpdateRouter(void) SendDataResponse(destination, tlvs, sizeof(tlvs)); + for (uint8_t i = 0; i < mMaxChildrenAllowed; i++) + { + Child *child = &mChildren[i]; + + if (child->mState != Neighbor::kStateValid || (child->mMode & ModeTlv::kModeRxOnWhenIdle) != 0) + { + continue; + } + + memset(&destination, 0, sizeof(destination)); + destination.mFields.m16[0] = HostSwap16(0xfe80); + destination.SetIid(child->mMacAddr); + + if (child->mMode & ModeTlv::kModeFullNetworkData) + { + if (child->mNetworkDataVersion != mNetworkData.GetVersion()) + { + SendDataResponse(destination, tlvs, sizeof(tlvs)); + } + } + else + { + if (child->mNetworkDataVersion != mNetworkData.GetStableVersion()) + { + SendDataResponse(destination, tlvs, sizeof(tlvs)); + } + } + } + exit: return kThreadError_None; } @@ -2859,36 +2888,6 @@ exit: return error; } -void MleRouter::HandleMacDataRequest(const Child &aChild) -{ - static const uint8_t tlvs[] = {Tlv::kLeaderData, Tlv::kNetworkData}; - Ip6::Address destination; - - VerifyOrExit(aChild.mState == Neighbor::kStateValid && (aChild.mMode & ModeTlv::kModeRxOnWhenIdle) == 0, ;); - - memset(&destination, 0, sizeof(destination)); - destination.mFields.m16[0] = HostSwap16(0xfe80); - destination.SetIid(aChild.mMacAddr); - - if (aChild.mMode & ModeTlv::kModeFullNetworkData) - { - if (aChild.mNetworkDataVersion != mNetworkData.GetVersion()) - { - SendDataResponse(destination, tlvs, sizeof(tlvs)); - } - } - else - { - if (aChild.mNetworkDataVersion != mNetworkData.GetStableVersion()) - { - SendDataResponse(destination, tlvs, sizeof(tlvs)); - } - } - -exit: - {} -} - Router *MleRouter::GetRouters(uint8_t *aNumRouters) { if (aNumRouters != NULL) diff --git a/src/core/thread/mle_router.hpp b/src/core/thread/mle_router.hpp index 9f2aa3299..cc7c5b502 100644 --- a/src/core/thread/mle_router.hpp +++ b/src/core/thread/mle_router.hpp @@ -559,14 +559,6 @@ public: */ ThreadError GetRouterInfo(uint16_t aRouterId, otRouterInfo &aRouterInfo); - /** - * This method handles MAC Data Poll messages. - * - * @param[in] aChild The Child that sent the MAC Data Poll message. - * - */ - void HandleMacDataRequest(const Child &aChild); - /** * This method indicates whether or not the given Thread partition attributes are preferred. *