diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index fc8c9177a..a38f55b22 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -247,6 +247,25 @@ exit: return; } +void AddressResolver::RestartAddressQueries(void) +{ + for (int i = 0; i < kCacheEntries; i++) + { + Cache &entry = mCache[i]; + + if (entry.mState != Cache::kStateQuery) + { + continue; + } + + SendAddressQuery(entry.mTarget); + + entry.mTimeout = kAddressQueryTimeout; + entry.mFailures = 0; + entry.mRetryTimeout = kAddressQueryInitialRetryDelay; + } +} + otError AddressResolver::Resolve(const Ip6::Address &aEid, uint16_t &aRloc16) { otError error = OT_ERROR_NONE; diff --git a/src/core/thread/address_resolver.hpp b/src/core/thread/address_resolver.hpp index dc83a018d..5fa3e4e89 100644 --- a/src/core/thread/address_resolver.hpp +++ b/src/core/thread/address_resolver.hpp @@ -125,6 +125,14 @@ public: */ otError Resolve(const Ip6::Address &aEid, Mac::ShortAddress &aRloc16); + /** + * This method restarts any ongoing address queries. + * + * Any existing address queries will be restarted as if they are being sent for the first time. + * + */ + void RestartAddressQueries(void); + private: enum { diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index cac8b44e7..88bb21510 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -968,15 +968,18 @@ void Mle::SetRloc16(uint16_t aRloc16) { Get().RemoveUnicastAddress(mMeshLocal16); + Get().SetShortAddress(aRloc16); + Get().SetSeedId(aRloc16); + if (aRloc16 != Mac::kShortAddrInvalid) { // mesh-local 16 mMeshLocal16.GetAddress().mFields.m16[7] = HostSwap16(aRloc16); Get().AddUnicastAddress(mMeshLocal16); +#ifdef OPENTHREAD_FTD + Get().RestartAddressQueries(); +#endif } - - Get().SetShortAddress(aRloc16); - Get().SetSeedId(aRloc16); } void Mle::SetLeaderData(uint32_t aPartitionId, uint8_t aWeighting, uint8_t aLeaderRouterId)