Skip to content

Commit

Permalink
[mle] rename Mle::Handle{Command}() methods to indicate constraints (
Browse files Browse the repository at this point in the history
…openthread#10721)

This commit renames `Mle::Handle{Command}()` methods where different
overloads are provided (e.g. in `Mle` and `MleRouter`) based on
device role or being an FTD. The method names now explicitly mention
the constraints (e.g. `HandleChildUpdateRequestOnChild()` or
`HandleAdvertisementOnFtd()`). This change aims to improve code
readability, making it easier to determine the purpose of each
method.
  • Loading branch information
abtink authored Sep 18, 2024
1 parent 62df7e9 commit f07bcc2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 29 deletions.
54 changes: 31 additions & 23 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2567,31 +2567,11 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
break;

case kCommandChildUpdateRequest:
#if OPENTHREAD_FTD
if (IsRouterOrLeader())
{
Get<MleRouter>().HandleChildUpdateRequest(rxInfo);
}
else
#endif
{
HandleChildUpdateRequest(rxInfo);
}

HandleChildUpdateRequest(rxInfo);
break;

case kCommandChildUpdateResponse:
#if OPENTHREAD_FTD
if (IsRouterOrLeader())
{
Get<MleRouter>().HandleChildUpdateResponse(rxInfo);
}
else
#endif
{
HandleChildUpdateResponse(rxInfo);
}

HandleChildUpdateResponse(rxInfo);
break;

#if OPENTHREAD_FTD
Expand Down Expand Up @@ -2786,7 +2766,7 @@ void Mle::HandleAdvertisement(RxInfo &aRxInfo)
#if OPENTHREAD_FTD
if (IsFullThreadDevice())
{
SuccessOrExit(error = Get<MleRouter>().HandleAdvertisement(aRxInfo, sourceAddress, leaderData));
SuccessOrExit(error = Get<MleRouter>().HandleAdvertisementOnFtd(aRxInfo, sourceAddress, leaderData));
}
#endif

Expand Down Expand Up @@ -3389,6 +3369,20 @@ void Mle::HandleChildIdResponse(RxInfo &aRxInfo)
}

void Mle::HandleChildUpdateRequest(RxInfo &aRxInfo)
{
#if OPENTHREAD_FTD
if (IsRouterOrLeader())
{
Get<MleRouter>().HandleChildUpdateRequestOnParent(aRxInfo);
}
else
#endif
{
HandleChildUpdateRequestOnChild(aRxInfo);
}
}

void Mle::HandleChildUpdateRequestOnChild(RxInfo &aRxInfo)
{
Error error = kErrorNone;
uint16_t sourceAddress;
Expand Down Expand Up @@ -3498,6 +3492,20 @@ void Mle::HandleChildUpdateRequest(RxInfo &aRxInfo)
}

void Mle::HandleChildUpdateResponse(RxInfo &aRxInfo)
{
#if OPENTHREAD_FTD
if (IsRouterOrLeader())
{
Get<MleRouter>().HandleChildUpdateResponseOnParent(aRxInfo);
}
else
#endif
{
HandleChildUpdateResponseOnChild(aRxInfo);
}
}

void Mle::HandleChildUpdateResponseOnChild(RxInfo &aRxInfo)
{
Error error = kErrorNone;
uint8_t status;
Expand Down
2 changes: 2 additions & 0 deletions src/core/thread/mle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,9 @@ class Mle : public InstanceLocator, private NonCopyable
void HandleAdvertisement(RxInfo &aRxInfo);
void HandleChildIdResponse(RxInfo &aRxInfo);
void HandleChildUpdateRequest(RxInfo &aRxInfo);
void HandleChildUpdateRequestOnChild(RxInfo &aRxInfo);
void HandleChildUpdateResponse(RxInfo &aRxInfo);
void HandleChildUpdateResponseOnChild(RxInfo &aRxInfo);
void HandleDataResponse(RxInfo &aRxInfo);
void HandleParentResponse(RxInfo &aRxInfo);
void HandleAnnounce(RxInfo &aRxInfo);
Expand Down
6 changes: 3 additions & 3 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ int MleRouter::ComparePartitions(bool aSingletonA,
return rval;
}

Error MleRouter::HandleAdvertisement(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData)
Error MleRouter::HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData)
{
// This method processes a received MLE Advertisement message on
// an FTD device. It is called from `Mle::HandleAdvertisement()`
Expand Down Expand Up @@ -2149,7 +2149,7 @@ void MleRouter::HandleChildIdRequest(RxInfo &aRxInfo)
LogProcessError(kTypeChildIdRequest, error);
}

void MleRouter::HandleChildUpdateRequest(RxInfo &aRxInfo)
void MleRouter::HandleChildUpdateRequestOnParent(RxInfo &aRxInfo)
{
Error error = kErrorNone;
Mac::ExtAddress extAddr;
Expand Down Expand Up @@ -2367,7 +2367,7 @@ void MleRouter::HandleChildUpdateRequest(RxInfo &aRxInfo)
LogProcessError(kTypeChildUpdateRequestOfChild, error);
}

void MleRouter::HandleChildUpdateResponse(RxInfo &aRxInfo)
void MleRouter::HandleChildUpdateResponseOnParent(RxInfo &aRxInfo)
{
Error error = kErrorNone;
uint16_t sourceAddress;
Expand Down
6 changes: 3 additions & 3 deletions src/core/thread/mle_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,11 @@ class MleRouter : public Mle
void HandleLinkAccept(RxInfo &aRxInfo);
Error HandleLinkAccept(RxInfo &aRxInfo, bool aRequest);
void HandleLinkAcceptAndRequest(RxInfo &aRxInfo);
Error HandleAdvertisement(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData);
Error HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData);
void HandleParentRequest(RxInfo &aRxInfo);
void HandleChildIdRequest(RxInfo &aRxInfo);
void HandleChildUpdateRequest(RxInfo &aRxInfo);
void HandleChildUpdateResponse(RxInfo &aRxInfo);
void HandleChildUpdateRequestOnParent(RxInfo &aRxInfo);
void HandleChildUpdateResponseOnParent(RxInfo &aRxInfo);
void HandleDataRequest(RxInfo &aRxInfo);
void HandleNetworkDataUpdateRouter(void);
void HandleDiscoveryRequest(RxInfo &aRxInfo);
Expand Down

0 comments on commit f07bcc2

Please sign in to comment.