From cba0f5ca2bc7bad04a06ae6ac66084699123cfe2 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 14 Jun 2024 10:05:40 -0700 Subject: [PATCH] [mle] use `RouterIdMatch()` to compare Router IDs of two RLOC16 values (#10384) This commit updates the code to use `RouterIdMatch()` for comparing the Router IDs of two given RLOC16 values. Additionally, it simplifies the `IsMinimalChild()` method. --- src/core/thread/mle.cpp | 2 +- src/core/thread/mle_router.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index b3ba28076..2fea5db79 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -3582,7 +3582,7 @@ void Mle::HandleChildUpdateResponse(RxInfo &aRxInfo) case kRoleChild: SuccessOrExit(error = Tlv::Find(aRxInfo.mMessage, sourceAddress)); - if (RouterIdFromRloc16(sourceAddress) != RouterIdFromRloc16(GetRloc16())) + if (!RouterIdMatch(sourceAddress, GetRloc16())) { IgnoreError(BecomeDetached()); ExitNow(); diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index df6c28903..bfef47222 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -3109,18 +3109,18 @@ exit: bool MleRouter::IsMinimalChild(uint16_t aRloc16) { - bool rval = false; + bool isMinimalChild = false; + Neighbor *neighbor; - if (RouterIdFromRloc16(aRloc16) == RouterIdFromRloc16(Get().GetShortAddress())) - { - Neighbor *neighbor; + VerifyOrExit(RouterIdMatch(aRloc16, GetRloc16())); - neighbor = mNeighborTable.FindNeighbor(aRloc16); + neighbor = mNeighborTable.FindNeighbor(aRloc16); + VerifyOrExit(neighbor != nullptr); - rval = (neighbor != nullptr) && (!neighbor->IsFullThreadDevice()); - } + isMinimalChild = !neighbor->IsFullThreadDevice(); - return rval; +exit: + return isMinimalChild; } void MleRouter::RemoveRouterLink(Router &aRouter)