From 86215fc31c43759f172241255d717eb5b7301eea Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 14 Nov 2023 02:43:21 -0800 Subject: [PATCH] [mle] define `IsRouterIdValid()` helper in `mle_types.hpp` (#9598) --- src/core/thread/mesh_forwarder_ftd.cpp | 2 +- src/core/thread/mle_router.hpp | 13 ------------- src/core/thread/mle_types.hpp | 11 +++++++++++ 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/core/thread/mesh_forwarder_ftd.cpp b/src/core/thread/mesh_forwarder_ftd.cpp index 12accafa4..4001bbeb5 100644 --- a/src/core/thread/mesh_forwarder_ftd.cpp +++ b/src/core/thread/mesh_forwarder_ftd.cpp @@ -511,7 +511,7 @@ Error MeshForwarder::UpdateIp6RouteFtd(const Ip6::Header &aIp6Header, Message &a else if (mle.IsRoutingLocator(aIp6Header.GetDestination())) { uint16_t rloc16 = aIp6Header.GetDestination().GetIid().GetLocator(); - VerifyOrExit(mle.IsRouterIdValid(Mle::RouterIdFromRloc16(rloc16)), error = kErrorDrop); + VerifyOrExit(Mle::IsRouterIdValid(Mle::RouterIdFromRloc16(rloc16)), error = kErrorDrop); mMeshDest = rloc16; } else if (mle.IsAnycastLocator(aIp6Header.GetDestination())) diff --git a/src/core/thread/mle_router.hpp b/src/core/thread/mle_router.hpp index fd876044a..048d901d9 100644 --- a/src/core/thread/mle_router.hpp +++ b/src/core/thread/mle_router.hpp @@ -421,17 +421,6 @@ public: */ void ResolveRoutingLoops(uint16_t aSourceMac, uint16_t aDestRloc16); - /** - * Checks if a given Router ID has correct value. - * - * @param[in] aRouterId The Router ID value. - * - * @retval TRUE If @p aRouterId is in correct range [0..62]. - * @retval FALSE If @p aRouterId is not a valid Router ID. - * - */ - static bool IsRouterIdValid(uint8_t aRouterId) { return aRouterId <= kMaxRouterId; } - /** * Fills an ConnectivityTlv. * @@ -799,8 +788,6 @@ public: Error RemoveNeighbor(Neighbor &) { return BecomeDetached(); } void RemoveRouterLink(Router &) { IgnoreError(BecomeDetached()); } - static bool IsRouterIdValid(uint8_t aRouterId) { return aRouterId <= kMaxRouterId; } - Error SendChildUpdateRequest(void) { return Mle::SendChildUpdateRequest(); } Error CheckReachability(uint16_t aMeshDest, const Ip6::Header &aIp6Header) diff --git a/src/core/thread/mle_types.hpp b/src/core/thread/mle_types.hpp index ae4dfdfa3..ab2a7b02d 100644 --- a/src/core/thread/mle_types.hpp +++ b/src/core/thread/mle_types.hpp @@ -616,6 +616,17 @@ inline uint16_t ChildIdFromRloc16(uint16_t aRloc16) { return aRloc16 & kMaxChild */ inline uint8_t RouterIdFromRloc16(uint16_t aRloc16) { return aRloc16 >> kRouterIdOffset; } +/** + * Indicates whether or not a given Router ID is valid. + * + * @param[in] aRouterId The Router ID value to check. + * + * @retval TRUE If @p aRouterId is in correct range [0..62]. + * @retval FALSE If @p aRouterId is not a valid Router ID. + * + */ +inline bool IsRouterIdValid(uint8_t aRouterId) { return aRouterId <= kMaxRouterId; } + /** * Returns whether the two RLOC16 have the same Router ID. *