Skip to content

Commit

Permalink
[mle] rename SendChildUpdateRequest/Response() methods (#10853)
Browse files Browse the repository at this point in the history
This commit renames the `SendChildUpdateRequest/Response()`  methods
to distinguish between those sending (from a child) to its parent and
those sending (from a parent node) to a child. This improves the
readability of the code.
  • Loading branch information
abtink authored and jwhui committed Nov 11, 2024
1 parent 7f81453 commit 169ac65
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/core/thread/child_supervision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void SupervisionListener::SetInterval(uint16_t aInterval)

if (Get<Mle::Mle>().IsChild())
{
IgnoreError(Get<Mle::Mle>().SendChildUpdateRequest());
IgnoreError(Get<Mle::Mle>().SendChildUpdateRequestToParent());
}

exit:
Expand Down Expand Up @@ -210,7 +210,7 @@ void SupervisionListener::HandleTimer(void)
LogWarn("Supervision timeout. No frame from parent in %u sec", mTimeout);
mCounter++;

IgnoreError(Get<Mle::MleRouter>().SendChildUpdateRequest());
IgnoreError(Get<Mle::Mle>().SendChildUpdateRequestToParent());

exit:
RestartTimer();
Expand Down
20 changes: 10 additions & 10 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Error Mle::Start(StartMode aMode)
else
{
mChildUpdateAttempts = 0;
IgnoreError(SendChildUpdateRequest());
IgnoreError(SendChildUpdateRequestToParent());
}

exit:
Expand Down Expand Up @@ -786,7 +786,7 @@ void Mle::SetTimeout(uint32_t aTimeout)

if (IsChild())
{
IgnoreError(SendChildUpdateRequest());
IgnoreError(SendChildUpdateRequestToParent());
}

exit:
Expand Down Expand Up @@ -864,7 +864,7 @@ Error Mle::SetDeviceMode(DeviceMode aDeviceMode)
else if (IsChild())
{
SetStateChild(GetRloc16());
IgnoreError(SendChildUpdateRequest());
IgnoreError(SendChildUpdateRequestToParent());
}

exit:
Expand Down Expand Up @@ -1909,7 +1909,7 @@ void Mle::HandleMessageTransmissionTimer(void)

VerifyOrExit(mChildUpdateAttempts < kMaxChildKeepAliveAttempts, IgnoreError(BecomeDetached()));

if (SendChildUpdateRequest() == kErrorNone)
if (SendChildUpdateRequestToParent() == kErrorNone)
{
mChildUpdateAttempts++;
}
Expand All @@ -1918,9 +1918,9 @@ void Mle::HandleMessageTransmissionTimer(void)
return;
}

Error Mle::SendChildUpdateRequest(void) { return SendChildUpdateRequest(kNormalChildUpdateRequest); }
Error Mle::SendChildUpdateRequestToParent(void) { return SendChildUpdateRequestToParent(kNormalChildUpdateRequest); }

Error Mle::SendChildUpdateRequest(ChildUpdateRequestMode aMode)
Error Mle::SendChildUpdateRequestToParent(ChildUpdateRequestMode aMode)
{
Error error = kErrorNone;
Ip6::Address destination;
Expand Down Expand Up @@ -2077,7 +2077,7 @@ Error Mle::SendChildUpdateResponse(const TlvList &aTlvList,

if (checkAddress && HasUnregisteredAddress())
{
IgnoreError(SendChildUpdateRequest());
IgnoreError(SendChildUpdateRequestToParent());
}

exit:
Expand Down Expand Up @@ -2629,7 +2629,7 @@ void Mle::ReestablishLinkWithNeighbor(Neighbor &aNeighbor)

if (IsChild() && (&aNeighbor == &mParent))
{
IgnoreError(SendChildUpdateRequest(kAppendChallengeTlv));
IgnoreError(SendChildUpdateRequestToParent(kAppendChallengeTlv));
ExitNow();
}

Expand All @@ -2645,7 +2645,7 @@ void Mle::ReestablishLinkWithNeighbor(Neighbor &aNeighbor)
Child &child = static_cast<Child &>(aNeighbor);

child.SetState(Child::kStateChildUpdateRequest);
IgnoreError(Get<MleRouter>().SendChildUpdateRequest(child));
IgnoreError(Get<MleRouter>().SendChildUpdateRequestToChild(child));
}
#endif

Expand Down Expand Up @@ -4263,7 +4263,7 @@ Error Mle::DetachGracefully(DetachCallback aCallback, void *aContext)
break;

case kRoleChild:
IgnoreError(SendChildUpdateRequest(kAppendZeroTimeout));
IgnoreError(SendChildUpdateRequestToParent(kAppendZeroTimeout));
break;

case kRoleDisabled:
Expand Down
11 changes: 9 additions & 2 deletions src/core/thread/mle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ class Mle : public InstanceLocator, private NonCopyable
*/
void ScheduleChildUpdateRequest(void);

/**
* Sends a Child Update Request to the parent.
*
* @retval kErrorNone Successfully prepared and sent an MLE Child Update Request message.
* @retval kErrorNoBufs Insufficient buffers to construct the MLE Child Update Request message.
*/
Error SendChildUpdateRequestToParent(void);

/*
* Indicates whether or not the device has restored the network information from
* non-volatile settings after boot.
Expand Down Expand Up @@ -1262,8 +1270,7 @@ class Mle : public InstanceLocator, private NonCopyable
void HandleNotifierEvents(Events aEvents);
void HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
void ReestablishLinkWithNeighbor(Neighbor &aNeighbor);
Error SendChildUpdateRequest(ChildUpdateRequestMode aMode);
Error SendChildUpdateRequest(void);
Error SendChildUpdateRequestToParent(ChildUpdateRequestMode aMode);
Error SendChildUpdateResponse(const TlvList &aTlvList,
const RxChallenge &aChallenge,
const Ip6::Address &aDestination);
Expand Down
18 changes: 9 additions & 9 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ void MleRouter::HandleTimeTick(void)
}
else if (IsRouterOrLeader() && child.IsStateRestored())
{
IgnoreError(SendChildUpdateRequest(child));
IgnoreError(SendChildUpdateRequestToChild(child));
}
}

Expand Down Expand Up @@ -2180,7 +2180,7 @@ void MleRouter::HandleChildUpdateRequestOnParent(RxInfo &aRxInfo)
if (mode.IsRxOnWhenIdle())
{
tlvList.Add(Tlv::kStatus);
SendChildUpdateResponse(nullptr, aRxInfo.mMessageInfo, tlvList, challenge);
SendChildUpdateResponseToChild(nullptr, aRxInfo.mMessageInfo, tlvList, challenge);
}

ExitNow();
Expand Down Expand Up @@ -2347,7 +2347,7 @@ void MleRouter::HandleChildUpdateRequestOnParent(RxInfo &aRxInfo)
}
#endif

SendChildUpdateResponse(child, aRxInfo.mMessageInfo, tlvList, challenge);
SendChildUpdateResponseToChild(child, aRxInfo.mMessageInfo, tlvList, challenge);

aRxInfo.mClass = RxInfo::kPeerMessage;

Expand Down Expand Up @@ -2595,7 +2595,7 @@ void MleRouter::SynchronizeChildNetworkData(void)
continue;
}

SuccessOrExit(SendChildUpdateRequest(child));
SuccessOrExit(SendChildUpdateRequestToChild(child));
}

exit:
Expand Down Expand Up @@ -2886,7 +2886,7 @@ Error MleRouter::SendChildIdResponse(Child &aChild)
return error;
}

Error MleRouter::SendChildUpdateRequest(Child &aChild)
Error MleRouter::SendChildUpdateRequestToChild(Child &aChild)
{
static const uint8_t kTlvs[] = {Tlv::kTimeout, Tlv::kAddressRegistration};

Expand Down Expand Up @@ -2955,10 +2955,10 @@ Error MleRouter::SendChildUpdateRequest(Child &aChild)
return error;
}

void MleRouter::SendChildUpdateResponse(Child *aChild,
const Ip6::MessageInfo &aMessageInfo,
const TlvList &aTlvList,
const RxChallenge &aChallenge)
void MleRouter::SendChildUpdateResponseToChild(Child *aChild,
const Ip6::MessageInfo &aMessageInfo,
const TlvList &aTlvList,
const RxChallenge &aChallenge)
{
Error error = kErrorNone;
TxMessage *message;
Expand Down
18 changes: 5 additions & 13 deletions src/core/thread/mle_router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,6 @@ class MleRouter : public Mle
*/
void FillConnectivityTlv(ConnectivityTlv &aTlv);

/**
* Generates an MLE Child Update Request message to be sent to the parent.
*
* @retval kErrorNone Successfully generated an MLE Child Update Request message.
* @retval kErrorNoBufs Insufficient buffers to generate the MLE Child Update Request message.
*/
Error SendChildUpdateRequest(void) { return Mle::SendChildUpdateRequest(); }

Error SendLinkRequest(Neighbor *aNeighbor);

#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
Expand Down Expand Up @@ -619,11 +611,11 @@ class MleRouter : public Mle
Error SendLinkAccept(const LinkAcceptInfo &aInfo);
void SendParentResponse(const ParentResponseInfo &aInfo);
Error SendChildIdResponse(Child &aChild);
Error SendChildUpdateRequest(Child &aChild);
void SendChildUpdateResponse(Child *aChild,
const Ip6::MessageInfo &aMessageInfo,
const TlvList &aTlvList,
const RxChallenge &aChallenge);
Error SendChildUpdateRequestToChild(Child &aChild);
void SendChildUpdateResponseToChild(Child *aChild,
const Ip6::MessageInfo &aMessageInfo,
const TlvList &aTlvList,
const RxChallenge &aChallenge);
void SendMulticastDataResponse(void);
void SendDataResponse(const Ip6::Address &aDestination,
const TlvList &aTlvList,
Expand Down

0 comments on commit 169ac65

Please sign in to comment.