From faeea3d2b9df48dd769592b7c5a85609c0c48389 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 18 Nov 2022 19:49:20 -0800 Subject: [PATCH] [tlv] helper methods to read/find/append TLVs with UTF8 string value (#8417) This commit adds new methods in `Tlv` to read, find, or append simple TLVs with a UTF8 string value. `StringTlvInfo` can be used to define constants and types for such TLVs. This helps simplify implementation of many such TLVs, e.g., Vendor Name TLV, Provisioning URL TLV, Network Name TLV, etc. --- src/core/backbone_router/bbr_manager.cpp | 7 +- src/core/common/tlvs.cpp | 69 ++++- src/core/common/tlvs.hpp | 91 +++++++ src/core/meshcop/commissioner.cpp | 19 +- src/core/meshcop/joiner.cpp | 30 +-- src/core/meshcop/meshcop_tlvs.hpp | 322 ++--------------------- src/core/thread/thread_tlvs.hpp | 3 +- 7 files changed, 192 insertions(+), 349 deletions(-) diff --git a/src/core/backbone_router/bbr_manager.cpp b/src/core/backbone_router/bbr_manager.cpp index bc712a4b8..aff5b4338 100644 --- a/src/core/backbone_router/bbr_manager.cpp +++ b/src/core/backbone_router/bbr_manager.cpp @@ -664,11 +664,8 @@ Error Manager::SendBackboneAnswer(const Ip6::Address & aDstAddr, SuccessOrExit(error = Tlv::Append(*message, aTimeSinceLastTransaction)); - { - const MeshCoP::NameData nameData = Get().GetNetworkName().GetAsData(); - - SuccessOrExit(error = Tlv::Append(*message, nameData.GetBuffer(), nameData.GetLength())); - } + SuccessOrExit(error = Tlv::Append( + *message, Get().GetNetworkName().GetAsCString())); if (aSrcRloc16 != Mac::kShortAddrInvalid) { diff --git a/src/core/common/tlvs.cpp b/src/core/common/tlvs.cpp index 47bdd8239..0ce2eb37e 100644 --- a/src/core/common/tlvs.cpp +++ b/src/core/common/tlvs.cpp @@ -176,6 +176,23 @@ exit: return error; } +Error Tlv::ReadStringTlv(const Message &aMessage, uint16_t aOffset, uint8_t aMaxStringLength, char *aValue) +{ + Error error = kErrorNone; + uint16_t valueOffset; + uint16_t length; + + SuccessOrExit(error = ReadTlv(aMessage, aOffset, length, valueOffset)); + + length = Min(length, static_cast(aMaxStringLength)); + + aMessage.ReadBytes(valueOffset, aValue, length); + aValue[length + 1] = '\0'; + +exit: + return error; +} + template Error Tlv::ReadUintTlv(const Message &aMessage, uint16_t aOffset, UintType &aValue) { Error error; @@ -192,41 +209,64 @@ template Error Tlv::ReadUintTlv(const Message &aMessage, uint16_t aOffs template Error Tlv::ReadUintTlv(const Message &aMessage, uint16_t aOffset, uint16_t &aValue); template Error Tlv::ReadUintTlv(const Message &aMessage, uint16_t aOffset, uint32_t &aValue); -Error Tlv::ReadTlvValue(const Message &aMessage, uint16_t aOffset, void *aValue, uint8_t aMinLength) +Error Tlv::ReadTlv(const Message &aMessage, uint16_t aOffset, uint16_t &aLength, uint16_t &aValueOffset) { - Error error = kErrorNone; + Error error; Tlv tlv; - uint16_t valueOffset; - uint16_t length; uint32_t size; SuccessOrExit(error = aMessage.Read(aOffset, tlv)); if (!tlv.IsExtended()) { - valueOffset = aOffset + sizeof(Tlv); - length = tlv.GetLength(); - size = sizeof(Tlv) + length; + aValueOffset = aOffset + sizeof(Tlv); + aLength = tlv.GetLength(); + size = sizeof(Tlv) + aLength; } else { ExtendedTlv extTlv; SuccessOrExit(error = aMessage.Read(aOffset, extTlv)); - valueOffset = aOffset + sizeof(ExtendedTlv); - length = extTlv.GetLength(); - size = sizeof(ExtendedTlv) + length; + aValueOffset = aOffset + sizeof(ExtendedTlv); + aLength = extTlv.GetLength(); + size = sizeof(ExtendedTlv) + aLength; } - VerifyOrExit(length >= aMinLength, error = kErrorParse); VerifyOrExit(aOffset + size <= aMessage.GetLength(), error = kErrorParse); +exit: + return error; +} + +Error Tlv::ReadTlvValue(const Message &aMessage, uint16_t aOffset, void *aValue, uint8_t aMinLength) +{ + Error error; + uint16_t valueOffset; + uint16_t length; + + SuccessOrExit(error = ReadTlv(aMessage, aOffset, length, valueOffset)); + + VerifyOrExit(length >= aMinLength, error = kErrorParse); + aMessage.ReadBytes(valueOffset, aValue, aMinLength); exit: return error; } +Error Tlv::FindStringTlv(const Message &aMessage, uint8_t aType, uint8_t aMaxStringLength, char *aValue) +{ + Error error = kErrorNone; + uint16_t offset; + + SuccessOrExit(error = FindTlvOffset(aMessage, aType, offset)); + error = ReadStringTlv(aMessage, offset, aMaxStringLength, aValue); + +exit: + return error; +} + template Error Tlv::FindUintTlv(const Message &aMessage, uint8_t aType, UintType &aValue) { Error error = kErrorNone; @@ -258,6 +298,13 @@ exit: return error; } +Error Tlv::AppendStringTlv(Message &aMessage, uint8_t aType, uint8_t aMaxStringLength, const char *aValue) +{ + uint16_t length = (aValue == nullptr) ? 0 : StringLength(aValue, aMaxStringLength); + + return AppendTlv(aMessage, aType, aValue, static_cast(length)); +} + template Error Tlv::AppendUintTlv(Message &aMessage, uint8_t aType, UintType aValue) { UintType value = Encoding::BigEndian::HostSwap(aValue); diff --git a/src/core/common/tlvs.hpp b/src/core/common/tlvs.hpp index 68f28c063..5cab6a7eb 100644 --- a/src/core/common/tlvs.hpp +++ b/src/core/common/tlvs.hpp @@ -228,6 +228,25 @@ public: return ReadUintTlv(aMessage, aOffset, aValue); } + /** + * This static method reads a simple TLV with a UTF-8 string value in a message at a given offset. + * + * @tparam StringTlvType The simple TLV type to read (must be a sub-class of `StringTlvInfo`). + * + * @param[in] aMessage The message to read from. + * @param[in] aOffset The offset into the message pointing to the start of the TLV. + * @param[out] aValue A reference to the string buffer to output the read value. + * + * @retval kErrorNone Successfully read the TLV and updated the @p aValue. + * @retval kErrorParse The TLV was not well-formed and could not be parsed. + * + */ + template + static Error Read(const Message &aMessage, uint16_t aOffset, typename StringTlvType::StringType &aValue) + { + return ReadStringTlv(aMessage, aOffset, StringTlvType::kMaxStringLength, aValue); + } + /** * This static method searches for and reads a requested TLV out of a given message. * @@ -369,6 +388,32 @@ public: return FindUintTlv(aMessage, UintTlvType::kType, aValue); } + /** + * This static method searches for a simple TLV with a UTF-8 string value in a message, and then reads its value + * into a given string buffer. + * + * If the TLV length is longer than maximum string length specified by `StringTlvType::kMaxStringLength` then + * only up to maximum length is read and returned. In this case `kErrorNone` is returned. + * + * The returned string in @p aValue is always null terminated.`StringTlvType::StringType` MUST have at least + * `kMaxStringLength + 1` chars. + * + * @tparam StringTlvType The simple TLV type to find (must be a sub-class of `StringTlvInfo`) + * + * @param[in] aMessage A reference to the message. + * @param[out] aValue A reference to a string buffer to output the TLV's value. + * + * @retval kErrorNone The TLV was found and read successfully. @p aValue is updated. + * @retval kErrorNotFound Could not find the TLV with Type @p aType. + * @retval kErrorParse TLV was found but it was not well-formed and could not be parsed. + * + */ + template + static Error Find(const Message &aMessage, typename StringTlvType::StringType &aValue) + { + return FindStringTlv(aMessage, StringTlvType::kType, StringTlvType::kMaxStringLength, aValue); + } + /** * This static method appends a TLV with a given type and value to a message. * @@ -428,13 +473,41 @@ public: return AppendUintTlv(aMessage, UintTlvType::kType, aValue); } + /** + * This static method appends a simple TLV with a single UTF-8 string value to a message. + * + * On success this method grows the message by the size of the TLV. + * + * If the passed in @p aValue string length is longer than the maximum allowed length for the TLV as specified by + * `StringTlvType::kMaxStringLength`, the first maximum length chars are appended. + * + * The @p aValue can be `nullptr` in which case it is treated as an empty string. + * + * @tparam StringTlvType The simple TLV type to append (must be a sub-class of `StringTlvInfo`) + * + * @param[in] aMessage A reference to the message to append to. + * @param[in] aValue A pointer to a C string to append as TLV's value. + * + * @retval kErrorNone Successfully appended the TLV to the message. + * @retval kErrorNoBufs Insufficient available buffers to grow the message. + * + */ + template static Error Append(Message &aMessage, const char *aValue) + { + return AppendStringTlv(aMessage, StringTlvType::kType, StringTlvType::kMaxStringLength, aValue); + } + protected: static const uint8_t kExtendedLength = 255; // Extended Length value. private: + static Error ReadTlv(const Message &aMessage, uint16_t aOffset, uint16_t &aLength, uint16_t &aValueOffset); static Error Find(const Message &aMessage, uint8_t aType, uint16_t *aOffset, uint16_t *aSize, bool *aIsExtendedTlv); static Error FindTlv(const Message &aMessage, uint8_t aType, void *aValue, uint8_t aLength); static Error AppendTlv(Message &aMessage, uint8_t aType, const void *aValue, uint8_t aLength); + static Error ReadStringTlv(const Message &aMessage, uint16_t aOffset, uint8_t aMaxStringLength, char *aValue); + static Error FindStringTlv(const Message &aMessage, uint8_t aType, uint8_t aMaxStringLength, char *aValue); + static Error AppendStringTlv(Message &aMessage, uint8_t aType, uint8_t aMaxStringLength, const char *aValue); template static Error ReadUintTlv(const Message &aMessage, uint16_t aOffset, UintType &aValue); template static Error FindUintTlv(const Message &aMessage, uint8_t aType, UintType &aValue); template static Error AppendUintTlv(Message &aMessage, uint8_t aType, UintType aValue); @@ -585,6 +658,24 @@ public: typedef TlvValueType ValueType; ///< The TLV Value type. }; +/** + * This class defines constants and types for a simple TLV with a UTF-8 string value. + * + * This class and its sub-classes are intended to be used as the template type in `Tlv::Append()`, + * and the related `Tlv::Find()` and `Tlv::Read()`. + * + * @tparam kTlvTypeValue The TLV Type value. + * @tparam kTlvMaxValueLength The maximum allowed string length (as TLV value). + * + */ +template class StringTlvInfo : public TlvInfo +{ +public: + static constexpr uint8_t kMaxStringLength = kTlvMaxValueLength; ///< Maximum string length. + + typedef char StringType[kMaxStringLength + 1]; ///< String buffer for TLV value. +}; + } // namespace ot #endif // TLVS_HPP_ diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index f20fd71dc..8744a3f1f 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -1033,22 +1033,27 @@ void Commissioner::HandleTmf(Coap::Message &aMessage, const { OT_UNUSED_VARIABLE(aMessageInfo); - StateTlv::State state = StateTlv::kAccept; - ProvisioningUrlTlv provisioningUrl; + StateTlv::State state = StateTlv::kAccept; + ProvisioningUrlTlv::StringType provisioningUrl; VerifyOrExit(mState == kStateActive); LogInfo("received joiner finalize"); - if (Tlv::FindTlv(aMessage, provisioningUrl) == kErrorNone) + switch (Tlv::Find(aMessage, provisioningUrl)) { - uint8_t len = static_cast(StringLength(mProvisioningUrl, sizeof(mProvisioningUrl))); - - if ((provisioningUrl.GetProvisioningUrlLength() != len) || - (memcmp(provisioningUrl.GetProvisioningUrl(), mProvisioningUrl, len) != 0)) + case kErrorNone: + if (!StringMatch(provisioningUrl, mProvisioningUrl)) { state = StateTlv::kReject; } + break; + + case kErrorNotFound: + break; + + default: + ExitNow(); } #if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp index a04ab673d..c2ae16eee 100644 --- a/src/core/meshcop/joiner.cpp +++ b/src/core/meshcop/joiner.cpp @@ -434,11 +434,7 @@ Error Joiner::PrepareJoinerFinalizeMessage(const char *aProvisioningUrl, const char *aVendorData) { Error error = kErrorNone; - VendorNameTlv vendorNameTlv; - VendorModelTlv vendorModelTlv; - VendorSwVersionTlv vendorSwVersionTlv; VendorStackVersionTlv vendorStackVersionTlv; - ProvisioningUrlTlv provisioningUrlTlv; mFinalizeMessage = Get().NewPriorityConfirmablePostMessage(kUriJoinerFinalize); VerifyOrExit(mFinalizeMessage != nullptr, error = kErrorNoBufs); @@ -447,17 +443,9 @@ Error Joiner::PrepareJoinerFinalizeMessage(const char *aProvisioningUrl, SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, StateTlv::kAccept)); - vendorNameTlv.Init(); - vendorNameTlv.SetVendorName(aVendorName); - SuccessOrExit(error = vendorNameTlv.AppendTo(*mFinalizeMessage)); - - vendorModelTlv.Init(); - vendorModelTlv.SetVendorModel(aVendorModel); - SuccessOrExit(error = vendorModelTlv.AppendTo(*mFinalizeMessage)); - - vendorSwVersionTlv.Init(); - vendorSwVersionTlv.SetVendorSwVersion(aVendorSwVersion); - SuccessOrExit(error = vendorSwVersionTlv.AppendTo(*mFinalizeMessage)); + SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, aVendorName)); + SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, aVendorModel)); + SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, aVendorSwVersion)); vendorStackVersionTlv.Init(); vendorStackVersionTlv.SetOui(OPENTHREAD_CONFIG_STACK_VENDOR_OUI); @@ -468,18 +456,12 @@ Error Joiner::PrepareJoinerFinalizeMessage(const char *aProvisioningUrl, if (aVendorData != nullptr) { - VendorDataTlv vendorDataTlv; - vendorDataTlv.Init(); - vendorDataTlv.SetVendorData(aVendorData); - SuccessOrExit(error = vendorDataTlv.AppendTo(*mFinalizeMessage)); + SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, aVendorData)); } - provisioningUrlTlv.Init(); - provisioningUrlTlv.SetProvisioningUrl(aProvisioningUrl); - - if (provisioningUrlTlv.GetLength() > 0) + if (aProvisioningUrl != nullptr) { - SuccessOrExit(error = provisioningUrlTlv.AppendTo(*mFinalizeMessage)); + SuccessOrExit(error = Tlv::Append(*mFinalizeMessage, aProvisioningUrl)); } exit: diff --git a/src/core/meshcop/meshcop_tlvs.hpp b/src/core/meshcop/meshcop_tlvs.hpp index 0f4247857..462eaa0ca 100644 --- a/src/core/meshcop/meshcop_tlvs.hpp +++ b/src/core/meshcop/meshcop_tlvs.hpp @@ -120,6 +120,17 @@ public: kJoinerAdvertisement = OT_MESHCOP_TLV_JOINERADVERTISEMENT, ///< Joiner Advertisement TLV }; + /** + * Max length of Provisioning URL TLV. + * + */ + static constexpr uint8_t kMaxkProvisioningUrlLength = OT_PROVISIONING_URL_MAX_SIZE; + + static constexpr uint8_t kMaxVendorNameLength = 32; ///< Max length of Vendor Name TLV. + static constexpr uint8_t kMaxVendorModelLength = 32; ///< Max length of Vendor Model TLV. + static constexpr uint8_t kMaxVendorSwVersionLength = 16; ///< Max length of Vendor SW Version TLV. + static constexpr uint8_t kMaxVendorDataLength = 64; ///< Max length of Vendor Data TLV. + /** * This method returns the Type value. * @@ -1545,325 +1556,34 @@ private: } OT_TOOL_PACKED_END; /** - * This class implements Provisioning URL TLV generation and parsing. + * This class defines Provisioning TLV constants and types. * */ -OT_TOOL_PACKED_BEGIN -class ProvisioningUrlTlv : public Tlv, public TlvInfo -{ -public: - /** - * Maximum number of chars in the Provisioning URL string. - * - */ - static constexpr uint16_t kMaxLength = OT_PROVISIONING_URL_MAX_SIZE; - - /** - * This method initializes the TLV. - * - */ - void Init(void) - { - SetType(kProvisioningUrl); - SetLength(0); - } - - /* - * This method returns the Provisioning URL length. - * - * @returns The Provisioning URL length. - * - */ - uint8_t GetProvisioningUrlLength(void) const - { - return GetLength() <= sizeof(mProvisioningUrl) ? GetLength() : sizeof(mProvisioningUrl); - } - - /** - * This method indicates whether or not the TLV appears to be well-formed. - * - * @retval TRUE If the TLV appears to be well-formed. - * @retval FALSE If the TLV does not appear to be well-formed. - * - */ - bool IsValid(void) const - { - return GetType() == kProvisioningUrl && mProvisioningUrl[GetProvisioningUrlLength()] == '\0'; - } - - /** - * This method returns the Provisioning URL value. - * - * @returns The Provisioning URL value. - * - */ - const char *GetProvisioningUrl(void) const { return mProvisioningUrl; } - - /** - * This method sets the Provisioning URL value. - * - * @param[in] aProvisioningUrl A pointer to the Provisioning URL value. - * - */ - void SetProvisioningUrl(const char *aProvisioningUrl) - { - uint16_t len = aProvisioningUrl ? StringLength(aProvisioningUrl, kMaxLength) : 0; - - SetLength(static_cast(len)); - - if (len > 0) - { - memcpy(mProvisioningUrl, aProvisioningUrl, len); - } - } - -private: - char mProvisioningUrl[kMaxLength]; -} OT_TOOL_PACKED_END; +typedef StringTlvInfo ProvisioningUrlTlv; /** - * This class implements Vendor Name TLV generation and parsing. + * This class defines Vendor Name TLV constants and types. * */ -OT_TOOL_PACKED_BEGIN -class VendorNameTlv : public Tlv, public TlvInfo -{ -public: - /** - * This method initializes the TLV. - * - */ - void Init(void) - { - SetType(kVendorName); - SetLength(0); - } - - /** - * This method returns the Vendor Name length. - * - * @returns The Vendor Name length. - * - */ - uint8_t GetVendorNameLength(void) const - { - return GetLength() <= sizeof(mVendorName) ? GetLength() : sizeof(mVendorName); - } - - /** - * This method returns the Vendor Name value. - * - * @returns The Vendor Name value. - * - */ - const char *GetVendorName(void) const { return mVendorName; } - - /** - * This method sets the Vendor Name value. - * - * @param[in] aVendorName A pointer to the Vendor Name value. - * - */ - void SetVendorName(const char *aVendorName) - { - uint16_t len = (aVendorName == nullptr) ? 0 : StringLength(aVendorName, sizeof(mVendorName)); - - SetLength(static_cast(len)); - - if (len > 0) - { - memcpy(mVendorName, aVendorName, len); - } - } - -private: - static constexpr uint8_t kMaxLength = 32; - - char mVendorName[kMaxLength]; -} OT_TOOL_PACKED_END; +typedef StringTlvInfo VendorNameTlv; /** - * This class implements Vendor Model TLV generation and parsing. + * This class defines Vendor Model TLV constants and types. * */ -OT_TOOL_PACKED_BEGIN -class VendorModelTlv : public Tlv, public TlvInfo -{ -public: - /** - * This method initializes the TLV. - * - */ - void Init(void) - { - SetType(kVendorModel); - SetLength(0); - } - - /** - * This method returns the Vendor Model length. - * - * @returns The Vendor Model length. - * - */ - uint8_t GetVendorModelLength(void) const - { - return GetLength() <= sizeof(mVendorModel) ? GetLength() : sizeof(mVendorModel); - } - - /** - * This method returns the Vendor Model value. - * - * @returns The Vendor Model value. - * - */ - const char *GetVendorModel(void) const { return mVendorModel; } - - /** - * This method sets the Vendor Model value. - * - * @param[in] aVendorModel A pointer to the Vendor Model value. - * - */ - void SetVendorModel(const char *aVendorModel) - { - uint16_t len = (aVendorModel == nullptr) ? 0 : StringLength(aVendorModel, sizeof(mVendorModel)); - - SetLength(static_cast(len)); - - if (len > 0) - { - memcpy(mVendorModel, aVendorModel, len); - } - } - -private: - static constexpr uint8_t kMaxLength = 32; - - char mVendorModel[kMaxLength]; -} OT_TOOL_PACKED_END; +typedef StringTlvInfo VendorModelTlv; /** - * This class implements Vendor SW Version TLV generation and parsing. + * This class defines Vendor SW Version TLV constants and types. * */ -OT_TOOL_PACKED_BEGIN -class VendorSwVersionTlv : public Tlv, public TlvInfo -{ -public: - /** - * This method initializes the TLV. - * - */ - void Init(void) - { - SetType(kVendorSwVersion); - SetLength(0); - } - - /** - * This method returns the Vendor SW Version length. - * - * @returns The Vendor SW Version length. - * - */ - uint8_t GetVendorSwVersionLength(void) const - { - return GetLength() <= sizeof(mVendorSwVersion) ? GetLength() : sizeof(mVendorSwVersion); - } - - /** - * This method returns the Vendor SW Version value. - * - * @returns The Vendor SW Version value. - * - */ - const char *GetVendorSwVersion(void) const { return mVendorSwVersion; } - - /** - * This method sets the Vendor SW Version value. - * - * @param[in] aVendorSwVersion A pointer to the Vendor SW Version value. - * - */ - void SetVendorSwVersion(const char *aVendorSwVersion) - { - uint16_t len = (aVendorSwVersion == nullptr) ? 0 : StringLength(aVendorSwVersion, sizeof(mVendorSwVersion)); - - SetLength(static_cast(len)); - - if (len > 0) - { - memcpy(mVendorSwVersion, aVendorSwVersion, len); - } - } - -private: - static constexpr uint8_t kMaxLength = 16; - - char mVendorSwVersion[kMaxLength]; -} OT_TOOL_PACKED_END; +typedef StringTlvInfo VendorSwVersionTlv; /** - * This class implements Vendor Data TLV generation and parsing. + * This class defines Vendor Data TLV constants and types. * */ -OT_TOOL_PACKED_BEGIN -class VendorDataTlv : public Tlv, public TlvInfo -{ -public: - /** - * This method initializes the TLV. - * - */ - void Init(void) - { - SetType(kVendorData); - SetLength(0); - } - - /** - * This method returns the Vendor Data length. - * - * @returns The Vendor Data length. - * - */ - uint8_t GetVendorDataLength(void) const - { - return GetLength() <= sizeof(mVendorData) ? GetLength() : sizeof(mVendorData); - } - - /** - * This method returns the Vendor Data value. - * - * @returns The Vendor Data value. - * - */ - const char *GetVendorData(void) const { return mVendorData; } - - /** - * This method sets the Vendor Data value. - * - * @param[in] aVendorData A pointer to the Vendor Data value. - * - */ - void SetVendorData(const char *aVendorData) - { - uint16_t len = (aVendorData == nullptr) ? 0 : StringLength(aVendorData, sizeof(mVendorData)); - - SetLength(static_cast(len)); - - if (len > 0) - { - memcpy(mVendorData, aVendorData, len); - } - } - -private: - static constexpr uint8_t kMaxLength = 64; - - char mVendorData[kMaxLength]; -} OT_TOOL_PACKED_END; +typedef StringTlvInfo VendorDataTlv; /** * This class implements Vendor Stack Version TLV generation and parsing. diff --git a/src/core/thread/thread_tlvs.hpp b/src/core/thread/thread_tlvs.hpp index f092c5f3d..5319da287 100644 --- a/src/core/thread/thread_tlvs.hpp +++ b/src/core/thread/thread_tlvs.hpp @@ -39,6 +39,7 @@ #include "common/encoding.hpp" #include "common/message.hpp" #include "common/tlvs.hpp" +#include "meshcop/network_name.hpp" #include "net/ip6_address.hpp" #include "thread/mle.hpp" #include "thread/mle_types.hpp" @@ -136,7 +137,7 @@ typedef UintTlvInfo ThreadTimeoutTlv; * This class defines Network Name TLV constants and types. * */ -typedef TlvInfo ThreadNetworkNameTlv; +typedef StringTlvInfo ThreadNetworkNameTlv; /** * This class defines Commissioner Session ID TLV constants and types.