From 6897dffb57ee89f8d8f2e52977d3886df9142bcf Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 17 Jun 2020 14:35:33 -0700 Subject: [PATCH] [network-data] fix IsOnMesh() to check on-mesh flags (#5116) --- src/core/thread/network_data_leader.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/thread/network_data_leader.cpp b/src/core/thread/network_data_leader.cpp index 5a0e60635..4497f3797 100644 --- a/src/core/thread/network_data_leader.cpp +++ b/src/core/thread/network_data_leader.cpp @@ -260,12 +260,25 @@ bool LeaderBase::IsOnMesh(const Ip6::Address &aAddress) const while ((prefix = FindNextMatchingPrefix(aAddress, prefix)) != nullptr) { - if (FindBorderRouter(*prefix) == nullptr) + // check both stable and temporary Border Router TLVs + for (int i = 0; i < 2; i++) { - continue; - } + const BorderRouterTlv *borderRouter = FindBorderRouter(*prefix, /* aStable */ (i == 0)); - ExitNow(rval = true); + if (borderRouter == nullptr) + { + continue; + } + + for (const BorderRouterEntry *entry = borderRouter->GetFirstEntry(); entry <= borderRouter->GetLastEntry(); + entry = entry->GetNext()) + { + if (entry->IsOnMesh()) + { + ExitNow(rval = true); + } + } + } } exit: