[tlv] update Append<Tlv>() to use uint16_t for aLength (#12728)

This commit updates the `Tlv::Append()` method template to accept a
`uint16_t` for the `aLength` parameter instead of `uint8_t`. This
change aligns the template method with the underlying `AppendTlv()`
method, allowing it to correctly append both regular and extended
TLVs based on the provided length.

The Doxygen comments are also updated to clarify that the TLV is
appended as either a regular or an extended TLV depending on whether
the length is greater than `kBaseTlvMaxLength`.
This commit is contained in:
Abtin Keshavarzian
2026-03-20 20:40:35 -05:00
committed by GitHub
parent 05e7eb7e7a
commit c66c6e41d4
+6 -3
View File
@@ -666,8 +666,8 @@ public:
/**
* Appends a TLV with a given type and value to a message.
*
* If the TLV length is longer than maximum base TLV size defined by `kBaseTlvMaxLength` then
* appends extended TLV.
* The TLV is appended as either a regular or an extended TLV based on the given @p aLength. If the length
* is greater than `kBaseTlvMaxLength`, an extended TLV is used.
*
* On success this method grows the message by the size of the TLV.
*
@@ -684,6 +684,9 @@ public:
/**
* Appends a TLV with a given type and value to a message.
*
* The TLV is appended as either a regular or an extended TLV based on the given @p aLength. If the length
* is greater than `kBaseTlvMaxLength`, an extended TLV is used.
*
* On success this method grows the message by the size of the TLV.
*
* @tparam TlvType The TLV type to append.
@@ -695,7 +698,7 @@ public:
* @retval kErrorNone Successfully appended the TLV to the message.
* @retval kErrorNoBufs Insufficient available buffers to grow the message.
*/
template <typename TlvType> static Error Append(Message &aMessage, const void *aValue, uint8_t aLength)
template <typename TlvType> static Error Append(Message &aMessage, const void *aValue, uint16_t aLength)
{
return AppendTlv(aMessage, TlvType::kType, aValue, aLength);
}