[mle] simplify MLE StatusTlv (#12064)

This commit simplifies the `StatusTlv` definitions. It introduces a
new `Status` enum representing the the MLE status values.
This commit is contained in:
Abtin Keshavarzian
2025-10-27 10:30:28 -07:00
committed by GitHub
parent ed0a6d46a5
commit 9520760ff1
5 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -1282,7 +1282,7 @@ Error Mle::SendChildUpdateResponse(const TlvList &aTlvList,
break;
case Tlv::kStatus:
SuccessOrExit(error = message->AppendStatusTlv(StatusTlv::kError));
SuccessOrExit(error = message->AppendStatusTlv(kStatusError));
break;
case Tlv::kAddressRegistration:
@@ -2249,7 +2249,7 @@ void Mle::HandleChildUpdateRequestOnChild(RxInfo &aRxInfo)
switch (Tlv::Find<StatusTlv>(aRxInfo.mMessage, status))
{
case kErrorNone:
VerifyOrExit(status != StatusTlv::kError, IgnoreError(BecomeDetached()));
VerifyOrExit(status != kStatusError, IgnoreError(BecomeDetached()));
break;
case kErrorNotFound:
break;
@@ -3539,7 +3539,7 @@ Error Mle::TxMessage::AppendSourceAddressTlv(void)
return Tlv::Append<SourceAddressTlv>(*this, Get<Mle>().GetRloc16());
}
Error Mle::TxMessage::AppendStatusTlv(StatusTlv::Status aStatus) { return Tlv::Append<StatusTlv>(*this, aStatus); }
Error Mle::TxMessage::AppendStatusTlv(Status aStatus) { return Tlv::Append<StatusTlv>(*this, aStatus); }
Error Mle::TxMessage::AppendModeTlv(DeviceMode aMode) { return Tlv::Append<ModeTlv>(*this, aMode.Get()); }
+1 -1
View File
@@ -1542,7 +1542,7 @@ private:
Error AppendTlvRequestTlv(const uint8_t *aTlvs, uint8_t aTlvsLength);
Error AppendLeaderDataTlv(void);
Error AppendScanMaskTlv(uint8_t aScanMask);
Error AppendStatusTlv(StatusTlv::Status aStatus);
Error AppendStatusTlv(Status aStatus);
Error AppendLinkMarginTlv(uint8_t aLinkMargin);
Error AppendVersionTlv(void);
Error AppendAddressRegistrationTlv(AddressRegistrationMode aMode = kAppendAllAddresses);
+2 -2
View File
@@ -2488,7 +2488,7 @@ void Mle::HandleChildUpdateResponseOnParent(RxInfo &aRxInfo)
switch (Tlv::Find<StatusTlv>(aRxInfo.mMessage, status))
{
case kErrorNone:
VerifyOrExit(status != StatusTlv::kError, RemoveNeighbor(*child));
VerifyOrExit(status != kStatusError, RemoveNeighbor(*child));
break;
case kErrorNotFound:
break;
@@ -3029,7 +3029,7 @@ void Mle::SendChildUpdateResponseToChild(Child *aChild,
switch (tlvType)
{
case Tlv::kStatus:
SuccessOrExit(error = message->AppendStatusTlv(StatusTlv::kError));
SuccessOrExit(error = message->AppendStatusTlv(kStatusError));
break;
case Tlv::kLeaderData:
+5 -14
View File
@@ -189,6 +189,11 @@ typedef TlvInfo<Tlv::kTlvRequest> TlvRequestTlv;
*/
typedef UintTlvInfo<Tlv::kLinkMargin, uint8_t> LinkMarginTlv;
/**
* Defines Status TLV constants and types.
*/
typedef UintTlvInfo<Tlv::kStatus, uint8_t> StatusTlv;
/**
* Defines Version TLV constants and types.
*/
@@ -881,20 +886,6 @@ private:
uint8_t mSedDatagramCount;
} OT_TOOL_PACKED_END;
/**
* Specifies Status TLV status values.
*/
struct StatusTlv : public UintTlvInfo<Tlv::kStatus, uint8_t>
{
/**
* Status values.
*/
enum Status : uint8_t
{
kError = 1, ///< Error.
};
};
/**
* Provides constants and methods for generation and parsing of Address Registration TLV.
*/
+9
View File
@@ -130,6 +130,15 @@ enum DeviceRole : uint8_t
kRoleLeader = OT_DEVICE_ROLE_LEADER, ///< The Thread Leader role.
};
/**
* Represents a status value in an MLE Status TLV.
*/
enum Status : uint8_t
{
kStatusSuccess = 0, ///< Success status.
kStatusError = 1, ///< Error status.
};
/**
* Represents MLE commands.
*/