[mle] enhance ChildUpdateResponse content (#12048)

This change refines the content of the `ChildUpdateResponse` message
to avoid sending additional TLVs when rejecting a request.

The `ChildUpdateResponse` message is now tailored based on the
triggering `ChildUpdateRequest`. Specifically:

- When rejecting a `ChildUpdateRequest` (and including a Status TLV),
  the response will only include a Source Address TLV, a Status TLV,
  and, if sent in response to a `ChildUpdateRequest` that contained a
  Challenge TLV, a Response TLV.

- The reject response will no longer include the Leader Data, MLE
  Frame Counter, and Link Frame Counter TLVs.

- Any requested TLVs (from the `TLV Request TLV` in the
  `ChildUpdateRequest`) are now only included in the response when
  the request is accepted.
This commit is contained in:
Abtin Keshavarzian
2025-10-21 08:01:59 +08:00
committed by GitHub
parent 4fde897064
commit 8e58e8a8ca
+35 -14
View File
@@ -1264,13 +1264,19 @@ Error Mle::SendChildUpdateResponse(const TlvList &aTlvList,
bool checkAddress = false;
VerifyOrExit((message = NewMleMessage(kCommandChildUpdateResponse)) != nullptr, error = kErrorNoBufs);
SuccessOrExit(error = message->AppendSourceAddressTlv());
SuccessOrExit(error = message->AppendLeaderDataTlv());
for (uint8_t tlvType : aTlvList)
{
switch (tlvType)
{
case Tlv::kSourceAddress:
SuccessOrExit(error = message->AppendSourceAddressTlv());
break;
case Tlv::kLeaderData:
SuccessOrExit(error = message->AppendLeaderDataTlv());
break;
case Tlv::kTimeout:
SuccessOrExit(error = message->AppendTimeoutTlv(mTimeout));
break;
@@ -2219,6 +2225,9 @@ void Mle::HandleChildUpdateRequestOnChild(RxInfo &aRxInfo)
Log(kMessageReceive, kTypeChildUpdateRequestAsChild, aRxInfo.mMessageInfo.GetPeerAddr(), sourceAddress);
tlvList.Add(Tlv::kSourceAddress);
tlvList.Add(Tlv::kLeaderData);
switch (aRxInfo.mMessage.ReadChallengeTlv(challenge))
{
case kErrorNone:
@@ -2282,22 +2291,34 @@ void Mle::HandleChildUpdateRequestOnChild(RxInfo &aRxInfo)
}
}
#endif
switch (aRxInfo.mMessage.ReadTlvRequestTlv(requestedTlvList))
{
case kErrorNone:
tlvList.AddElementsFrom(requestedTlvList);
break;
case kErrorNotFound:
break;
default:
ExitNow(error = kErrorParse);
}
}
else
{
// This device is not a child of the Child Update Request source
tlvList.Add(Tlv::kStatus);
}
// This device is not a child of the Child Update Request source.
//
// Send a reject response which only includes a Source Address TLV,
// a Status TLV, and a Response TLV when request contained a
// Challenge TLV.
switch (aRxInfo.mMessage.ReadTlvRequestTlv(requestedTlvList))
{
case kErrorNone:
tlvList.AddElementsFrom(requestedTlvList);
break;
case kErrorNotFound:
break;
default:
ExitNow(error = kErrorParse);
tlvList.Clear();
tlvList.Add(Tlv::kSourceAddress);
tlvList.Add(Tlv::kStatus);
if (!challenge.IsEmpty())
{
tlvList.Add(Tlv::kResponse);
}
}
aRxInfo.mClass = RxInfo::kPeerMessage;