Skip to content

Commit

Permalink
[mle] define IsRouterIdValid() helper in mle_types.hpp (#9598)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtink authored Nov 14, 2023
1 parent 588d55c commit 86215fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core/thread/mesh_forwarder_ftd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
13 changes: 0 additions & 13 deletions src/core/thread/mle_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,6 @@ class MleRouter : public Mle
*/
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.
*
Expand Down Expand Up @@ -799,8 +788,6 @@ class MleRouter : public Mle
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)
Expand Down
11 changes: 11 additions & 0 deletions src/core/thread/mle_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 86215fc

Please sign in to comment.