Skip to content

Commit

Permalink
[mle] simplify handling of Link Accept variants (openthread#10919)
Browse files Browse the repository at this point in the history
This commit renames and updates `HandleLinkAcceptVariant()` used to
handle an MLE "Link Accept" or "Link Accept And Request". The method
now takes the `MessageType` directly as an input parameter.
  • Loading branch information
abtink authored Nov 13, 2024
1 parent 81f677b commit 659b427
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,22 +861,17 @@ Error MleRouter::SendLinkAccept(const LinkAcceptInfo &aInfo)
return error;
}

void MleRouter::HandleLinkAccept(RxInfo &aRxInfo)
{
Error error = HandleLinkAccept(aRxInfo, false);

LogProcessError(kTypeLinkAccept, error);
}
void MleRouter::HandleLinkAccept(RxInfo &aRxInfo) { HandleLinkAcceptVariant(aRxInfo, kTypeLinkAccept); }

void MleRouter::HandleLinkAcceptAndRequest(RxInfo &aRxInfo)
{
Error error = HandleLinkAccept(aRxInfo, true);

LogProcessError(kTypeLinkAcceptAndRequest, error);
HandleLinkAcceptVariant(aRxInfo, kTypeLinkAcceptAndRequest);
}

Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
void MleRouter::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
{
// Handles "Link Accept" or "Link Accept And Request".

Error error = kErrorNone;
Router *router;
Neighbor::State neighborState;
Expand All @@ -894,8 +889,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)

SuccessOrExit(error = Tlv::Find<SourceAddressTlv>(aRxInfo.mMessage, sourceAddress));

Log(kMessageReceive, aRequest ? kTypeLinkAcceptAndRequest : kTypeLinkAccept, aRxInfo.mMessageInfo.GetPeerAddr(),
sourceAddress);
Log(kMessageReceive, aMessageType, aRxInfo.mMessageInfo.GetPeerAddr(), sourceAddress);

VerifyOrExit(IsRouterRloc16(sourceAddress), error = kErrorParse);

Expand Down Expand Up @@ -1056,7 +1050,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
aRxInfo.mClass = RxInfo::kAuthoritativeMessage;
ProcessKeySequence(aRxInfo);

if (aRequest)
if (aMessageType == kTypeLinkAcceptAndRequest)
{
LinkAcceptInfo info;

Expand All @@ -1078,7 +1072,7 @@ Error MleRouter::HandleLinkAccept(RxInfo &aRxInfo, bool aRequest)
}

exit:
return error;
LogProcessError(aMessageType, error);
}

Error MleRouter::ProcessRouteTlv(const RouteTlv &aRouteTlv, RxInfo &aRxInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/core/thread/mle_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ class MleRouter : public Mle
void HandleSecurityPolicyChanged(void);
void HandleLinkRequest(RxInfo &aRxInfo);
void HandleLinkAccept(RxInfo &aRxInfo);
Error HandleLinkAccept(RxInfo &aRxInfo, bool aRequest);
void HandleLinkAcceptAndRequest(RxInfo &aRxInfo);
void HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType);
Error HandleAdvertisementOnFtd(RxInfo &aRxInfo, uint16_t aSourceAddress, const LeaderData &aLeaderData);
void HandleParentRequest(RxInfo &aRxInfo);
void HandleChildIdRequest(RxInfo &aRxInfo);
Expand Down

0 comments on commit 659b427

Please sign in to comment.