1 /* 2 * Copyright (c) 2016, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @file 31 * This file includes definitions for generating and processing MeshCoP TLVs. 32 */ 33 34 #ifndef MESHCOP_TLVS_HPP_ 35 #define MESHCOP_TLVS_HPP_ 36 37 #include "openthread-core-config.h" 38 39 #include <openthread/commissioner.h> 40 #include <openthread/dataset.h> 41 #include <openthread/platform/radio.h> 42 43 #include "common/const_cast.hpp" 44 #include "common/encoding.hpp" 45 #include "common/message.hpp" 46 #include "common/num_utils.hpp" 47 #include "common/string.hpp" 48 #include "common/tlvs.hpp" 49 #include "mac/mac_types.hpp" 50 #include "meshcop/extended_panid.hpp" 51 #include "meshcop/network_name.hpp" 52 #include "meshcop/timestamp.hpp" 53 #include "net/ip6_address.hpp" 54 #include "radio/radio.hpp" 55 #include "thread/key_manager.hpp" 56 #include "thread/mle_tlvs.hpp" 57 #include "thread/mle_types.hpp" 58 59 namespace ot { 60 namespace MeshCoP { 61 62 /** 63 * Implements MeshCoP TLV generation and parsing. 64 */ 65 OT_TOOL_PACKED_BEGIN 66 class Tlv : public ot::Tlv 67 { 68 public: 69 /** 70 * MeshCoP TLV Types. 71 */ 72 enum Type : uint8_t 73 { 74 kChannel = OT_MESHCOP_TLV_CHANNEL, ///< Channel TLV 75 kPanId = OT_MESHCOP_TLV_PANID, ///< PAN ID TLV 76 kExtendedPanId = OT_MESHCOP_TLV_EXTPANID, ///< Extended PAN ID TLV 77 kNetworkName = OT_MESHCOP_TLV_NETWORKNAME, ///< Network Name TLV 78 kPskc = OT_MESHCOP_TLV_PSKC, ///< PSKc TLV 79 kNetworkKey = OT_MESHCOP_TLV_NETWORKKEY, ///< Network Network Key TLV 80 kNetworkKeySequence = OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE, ///< Network Key Sequence TLV 81 kMeshLocalPrefix = OT_MESHCOP_TLV_MESHLOCALPREFIX, ///< Mesh Local Prefix TLV 82 kSteeringData = OT_MESHCOP_TLV_STEERING_DATA, ///< Steering Data TLV 83 kBorderAgentLocator = OT_MESHCOP_TLV_BORDER_AGENT_RLOC, ///< Border Agent Locator TLV 84 kCommissionerId = OT_MESHCOP_TLV_COMMISSIONER_ID, ///< Commissioner ID TLV 85 kCommissionerSessionId = OT_MESHCOP_TLV_COMM_SESSION_ID, ///< Commissioner Session ID TLV 86 kSecurityPolicy = OT_MESHCOP_TLV_SECURITYPOLICY, ///< Security Policy TLV 87 kGet = OT_MESHCOP_TLV_GET, ///< Get TLV 88 kActiveTimestamp = OT_MESHCOP_TLV_ACTIVETIMESTAMP, ///< Active Timestamp TLV 89 kCommissionerUdpPort = OT_MESHCOP_TLV_COMMISSIONER_UDP_PORT, ///< Commissioner UDP Port TLV 90 kState = OT_MESHCOP_TLV_STATE, ///< State TLV 91 kJoinerDtlsEncapsulation = OT_MESHCOP_TLV_JOINER_DTLS, ///< Joiner DTLS Encapsulation TLV 92 kJoinerUdpPort = OT_MESHCOP_TLV_JOINER_UDP_PORT, ///< Joiner UDP Port TLV 93 kJoinerIid = OT_MESHCOP_TLV_JOINER_IID, ///< Joiner IID TLV 94 kJoinerRouterLocator = OT_MESHCOP_TLV_JOINER_RLOC, ///< Joiner Router Locator TLV 95 kJoinerRouterKek = OT_MESHCOP_TLV_JOINER_ROUTER_KEK, ///< Joiner Router KEK TLV 96 kProvisioningUrl = OT_MESHCOP_TLV_PROVISIONING_URL, ///< Provisioning URL TLV 97 kVendorName = OT_MESHCOP_TLV_VENDOR_NAME_TLV, ///< meshcop Vendor Name TLV 98 kVendorModel = OT_MESHCOP_TLV_VENDOR_MODEL_TLV, ///< meshcop Vendor Model TLV 99 kVendorSwVersion = OT_MESHCOP_TLV_VENDOR_SW_VERSION_TLV, ///< meshcop Vendor SW Version TLV 100 kVendorData = OT_MESHCOP_TLV_VENDOR_DATA_TLV, ///< meshcop Vendor Data TLV 101 kVendorStackVersion = OT_MESHCOP_TLV_VENDOR_STACK_VERSION_TLV, ///< meshcop Vendor Stack Version TLV 102 kUdpEncapsulation = OT_MESHCOP_TLV_UDP_ENCAPSULATION_TLV, ///< meshcop UDP encapsulation TLV 103 kIp6Address = OT_MESHCOP_TLV_IPV6_ADDRESS_TLV, ///< meshcop IPv6 address TLV 104 kPendingTimestamp = OT_MESHCOP_TLV_PENDINGTIMESTAMP, ///< Pending Timestamp TLV 105 kDelayTimer = OT_MESHCOP_TLV_DELAYTIMER, ///< Delay Timer TLV 106 kChannelMask = OT_MESHCOP_TLV_CHANNELMASK, ///< Channel Mask TLV 107 kCount = OT_MESHCOP_TLV_COUNT, ///< Count TLV 108 kPeriod = OT_MESHCOP_TLV_PERIOD, ///< Period TLV 109 kScanDuration = OT_MESHCOP_TLV_SCAN_DURATION, ///< Scan Duration TLV 110 kEnergyList = OT_MESHCOP_TLV_ENERGY_LIST, ///< Energy List TLV 111 kThreadDomainName = OT_MESHCOP_TLV_THREAD_DOMAIN_NAME, ///< Thread Domain Name TLV 112 kWakeupChannel = OT_MESHCOP_TLV_WAKEUP_CHANNEL, ///< Wakeup Channel TLV 113 kDiscoveryRequest = OT_MESHCOP_TLV_DISCOVERYREQUEST, ///< Discovery Request TLV 114 kDiscoveryResponse = OT_MESHCOP_TLV_DISCOVERYRESPONSE, ///< Discovery Response TLV 115 kJoinerAdvertisement = OT_MESHCOP_TLV_JOINERADVERTISEMENT, ///< Joiner Advertisement TLV 116 }; 117 118 /** 119 * Max length of Provisioning URL TLV. 120 */ 121 static constexpr uint8_t kMaxProvisioningUrlLength = OT_PROVISIONING_URL_MAX_SIZE; 122 123 static constexpr uint8_t kMaxCommissionerIdLength = 64; ///< Max length of Commissioner ID TLV. 124 static constexpr uint8_t kMaxVendorNameLength = 32; ///< Max length of Vendor Name TLV. 125 static constexpr uint8_t kMaxVendorModelLength = 32; ///< Max length of Vendor Model TLV. 126 static constexpr uint8_t kMaxVendorSwVersionLength = 16; ///< Max length of Vendor SW Version TLV. 127 static constexpr uint8_t kMaxVendorDataLength = 64; ///< Max length of Vendor Data TLV. 128 static constexpr uint8_t kMaxThreadDomainNameLength = 16; ///< Max length of Thread Domain Name TLV. 129 130 /** 131 * Returns the Type value. 132 * 133 * @returns The Type value. 134 */ GetType(void) const135 Type GetType(void) const { return static_cast<Type>(ot::Tlv::GetType()); } 136 137 /** 138 * Sets the Type value. 139 * 140 * @param[in] aType The Type value. 141 */ SetType(Type aType)142 void SetType(Type aType) { ot::Tlv::SetType(static_cast<uint8_t>(aType)); } 143 144 /** 145 * Returns a pointer to the next TLV. 146 * 147 * @returns A pointer to the next TLV. 148 */ GetNext(void)149 Tlv *GetNext(void) { return As<Tlv>(ot::Tlv::GetNext()); } 150 151 /** 152 * Returns a pointer to the next TLV. 153 * 154 * @returns A pointer to the next TLV. 155 */ GetNext(void) const156 const Tlv *GetNext(void) const { return As<Tlv>(ot::Tlv::GetNext()); } 157 158 } OT_TOOL_PACKED_END; 159 160 /** 161 * Implements extended MeshCoP TLV generation and parsing. 162 */ 163 OT_TOOL_PACKED_BEGIN 164 class ExtendedTlv : public ot::ExtendedTlv 165 { 166 public: 167 /** 168 * Returns the Type value. 169 * 170 * @returns The Type value. 171 */ GetType(void) const172 MeshCoP::Tlv::Type GetType(void) const { return static_cast<MeshCoP::Tlv::Type>(ot::ExtendedTlv::GetType()); } 173 174 /** 175 * Sets the Type value. 176 * 177 * @param[in] aType The Type value. 178 */ SetType(MeshCoP::Tlv::Type aType)179 void SetType(MeshCoP::Tlv::Type aType) { ot::ExtendedTlv::SetType(static_cast<uint8_t>(aType)); } 180 } OT_TOOL_PACKED_END; 181 182 /** 183 * Defines Commissioner UDP Port TLV constants and types. 184 */ 185 typedef UintTlvInfo<Tlv::kCommissionerUdpPort, uint16_t> CommissionerUdpPortTlv; 186 187 /** 188 * Defines IPv6 Address TLV constants and types. 189 */ 190 typedef SimpleTlvInfo<Tlv::kIp6Address, Ip6::Address> Ip6AddressTlv; 191 192 /** 193 * Defines Joiner IID TLV constants and types. 194 */ 195 typedef SimpleTlvInfo<Tlv::kJoinerIid, Ip6::InterfaceIdentifier> JoinerIidTlv; 196 197 /** 198 * Defines Joiner Router Locator TLV constants and types. 199 */ 200 typedef UintTlvInfo<Tlv::kJoinerRouterLocator, uint16_t> JoinerRouterLocatorTlv; 201 202 /** 203 * Defines Joiner Router KEK TLV constants and types. 204 */ 205 typedef SimpleTlvInfo<Tlv::kJoinerRouterKek, Kek> JoinerRouterKekTlv; 206 207 /** 208 * Defines Count TLV constants and types. 209 */ 210 typedef UintTlvInfo<Tlv::kCount, uint8_t> CountTlv; 211 212 /** 213 * Defines Period TLV constants and types. 214 */ 215 typedef UintTlvInfo<Tlv::kPeriod, uint16_t> PeriodTlv; 216 217 /** 218 * Defines Scan Duration TLV constants and types. 219 */ 220 typedef UintTlvInfo<Tlv::kScanDuration, uint16_t> ScanDurationTlv; 221 222 /** 223 * Defines Commissioner ID TLV constants and types. 224 */ 225 typedef StringTlvInfo<Tlv::kCommissionerId, Tlv::kMaxCommissionerIdLength> CommissionerIdTlv; 226 227 /** 228 * Implements Channel TLV value format. 229 */ 230 typedef Mle::ChannelTlvValue ChannelTlvValue; 231 232 /** 233 * Defines Channel TLV constants and types. 234 */ 235 typedef SimpleTlvInfo<Tlv::kChannel, ChannelTlvValue> ChannelTlv; 236 237 /** 238 * Defines Wake-up Channel TLV constants and types. 239 */ 240 typedef SimpleTlvInfo<Tlv::kWakeupChannel, ChannelTlvValue> WakeupChannelTlv; 241 242 /** 243 * Defines PAN ID TLV constants and types. 244 */ 245 typedef UintTlvInfo<Tlv::kPanId, uint16_t> PanIdTlv; 246 247 /** 248 * Defines Extended PAN ID TLV constants and types. 249 */ 250 typedef SimpleTlvInfo<Tlv::kExtendedPanId, ExtendedPanId> ExtendedPanIdTlv; 251 252 /** 253 * Implements Network Name TLV generation and parsing. 254 */ 255 OT_TOOL_PACKED_BEGIN 256 class NetworkNameTlv : public Tlv, public StringTlvInfo<Tlv::kNetworkName, NetworkName::kMaxSize> 257 { 258 public: 259 /** 260 * Initializes the TLV. 261 */ Init(void)262 void Init(void) 263 { 264 SetType(kNetworkName); 265 SetLength(sizeof(*this) - sizeof(Tlv)); 266 } 267 268 /** 269 * Indicates whether or not the TLV appears to be well-formed. 270 * 271 * @retval TRUE If the TLV appears to be well-formed. 272 * @retval FALSE If the TLV does not appear to be well-formed. 273 */ 274 bool IsValid(void) const; 275 276 /** 277 * Gets the Network Name value. 278 * 279 * @returns The Network Name value (as `NameData`). 280 */ 281 NameData GetNetworkName(void) const; 282 283 /** 284 * Sets the Network Name value. 285 * 286 * @param[in] aNameData A Network Name value (as `NameData`). 287 */ 288 void SetNetworkName(const NameData &aNameData); 289 290 private: 291 char mNetworkName[NetworkName::kMaxSize]; 292 } OT_TOOL_PACKED_END; 293 294 /** 295 * Defines PSKc TLV constants and types. 296 */ 297 typedef SimpleTlvInfo<Tlv::kPskc, Pskc> PskcTlv; 298 299 /** 300 * Defines Network Key TLV constants and types. 301 */ 302 typedef SimpleTlvInfo<Tlv::kNetworkKey, NetworkKey> NetworkKeyTlv; 303 304 /** 305 * Defines Network Key Sequence TLV constants and types. 306 */ 307 typedef UintTlvInfo<Tlv::kNetworkKeySequence, uint32_t> NetworkKeySequenceTlv; 308 309 /** 310 * Defines Mesh Local Prefix TLV constants and types. 311 */ 312 typedef SimpleTlvInfo<Tlv::kMeshLocalPrefix, Ip6::NetworkPrefix> MeshLocalPrefixTlv; 313 314 class SteeringData; 315 316 /** 317 * Implements Steering Data TLV generation and parsing. 318 */ 319 OT_TOOL_PACKED_BEGIN 320 class SteeringDataTlv : public Tlv, public TlvInfo<Tlv::kSteeringData> 321 { 322 public: 323 /** 324 * Initializes the TLV. 325 */ Init(void)326 void Init(void) 327 { 328 SetType(kSteeringData); 329 SetLength(sizeof(*this) - sizeof(Tlv)); 330 Clear(); 331 } 332 333 /** 334 * Indicates whether or not the TLV appears to be well-formed. 335 * 336 * @retval TRUE If the TLV appears to be well-formed. 337 * @retval FALSE If the TLV does not appear to be well-formed. 338 */ IsValid(void) const339 bool IsValid(void) const { return GetLength() > 0; } 340 341 /** 342 * Returns the Steering Data length. 343 * 344 * @returns The Steering Data length. 345 */ GetSteeringDataLength(void) const346 uint8_t GetSteeringDataLength(void) const 347 { 348 return GetLength() <= sizeof(mSteeringData) ? GetLength() : sizeof(mSteeringData); 349 } 350 351 /** 352 * Sets all bits in the Bloom Filter to zero. 353 */ Clear(void)354 void Clear(void) { memset(mSteeringData, 0, GetSteeringDataLength()); } 355 356 /** 357 * Copies the Steering Data from the TLV into a given `SteeringData` variable. 358 * 359 * @param[out] aSteeringData A reference to a `SteeringData` to copy into. 360 */ 361 void CopyTo(SteeringData &aSteeringData) const; 362 363 private: 364 uint8_t mSteeringData[OT_STEERING_DATA_MAX_LENGTH]; 365 } OT_TOOL_PACKED_END; 366 367 /** 368 * Implements Border Agent Locator TLV generation and parsing. 369 */ 370 OT_TOOL_PACKED_BEGIN 371 class BorderAgentLocatorTlv : public Tlv, public UintTlvInfo<Tlv::kBorderAgentLocator, uint16_t> 372 { 373 public: 374 /** 375 * Initializes the TLV. 376 */ Init(void)377 void Init(void) 378 { 379 SetType(kBorderAgentLocator); 380 SetLength(sizeof(*this) - sizeof(Tlv)); 381 } 382 383 /** 384 * Indicates whether or not the TLV appears to be well-formed. 385 * 386 * @retval TRUE If the TLV appears to be well-formed. 387 * @retval FALSE If the TLV does not appear to be well-formed. 388 */ IsValid(void) const389 bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } 390 391 /** 392 * Returns the Border Agent Locator value. 393 * 394 * @returns The Border Agent Locator value. 395 */ GetBorderAgentLocator(void) const396 uint16_t GetBorderAgentLocator(void) const { return BigEndian::HostSwap16(mLocator); } 397 398 /** 399 * Sets the Border Agent Locator value. 400 * 401 * @param[in] aLocator The Border Agent Locator value. 402 */ SetBorderAgentLocator(uint16_t aLocator)403 void SetBorderAgentLocator(uint16_t aLocator) { mLocator = BigEndian::HostSwap16(aLocator); } 404 405 private: 406 uint16_t mLocator; 407 } OT_TOOL_PACKED_END; 408 409 /** 410 * Implements Commissioner Session ID TLV generation and parsing. 411 */ 412 OT_TOOL_PACKED_BEGIN 413 class CommissionerSessionIdTlv : public Tlv, public UintTlvInfo<Tlv::kCommissionerSessionId, uint16_t> 414 { 415 public: 416 /** 417 * Initializes the TLV. 418 */ Init(void)419 void Init(void) 420 { 421 SetType(kCommissionerSessionId); 422 SetLength(sizeof(*this) - sizeof(Tlv)); 423 } 424 425 /** 426 * Indicates whether or not the TLV appears to be well-formed. 427 * 428 * @retval TRUE If the TLV appears to be well-formed. 429 * @retval FALSE If the TLV does not appear to be well-formed. 430 */ IsValid(void) const431 bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } 432 433 /** 434 * Returns the Commissioner Session ID value. 435 * 436 * @returns The Commissioner Session ID value. 437 */ GetCommissionerSessionId(void) const438 uint16_t GetCommissionerSessionId(void) const { return BigEndian::HostSwap16(mSessionId); } 439 440 /** 441 * Sets the Commissioner Session ID value. 442 * 443 * @param[in] aSessionId The Commissioner Session ID value. 444 */ SetCommissionerSessionId(uint16_t aSessionId)445 void SetCommissionerSessionId(uint16_t aSessionId) { mSessionId = BigEndian::HostSwap16(aSessionId); } 446 447 private: 448 uint16_t mSessionId; 449 } OT_TOOL_PACKED_END; 450 451 /** 452 * Implements Security Policy TLV generation and parsing. 453 */ 454 OT_TOOL_PACKED_BEGIN 455 class SecurityPolicyTlv : public Tlv, public TlvInfo<Tlv::kSecurityPolicy> 456 { 457 public: 458 /** 459 * Initializes the TLV. 460 */ Init(void)461 void Init(void) 462 { 463 SetType(kSecurityPolicy); 464 SetLength(sizeof(*this) - sizeof(Tlv)); 465 } 466 467 /** 468 * Indicates whether or not the TLV appears to be well-formed. 469 * 470 * @retval TRUE If the TLV appears to be well-formed. 471 * @retval FALSE If the TLV does not appear to be well-formed. 472 */ 473 bool IsValid(void) const; 474 475 /** 476 * Returns the Security Policy. 477 * 478 * @returns The Security Policy. 479 */ 480 SecurityPolicy GetSecurityPolicy(void) const; 481 482 /** 483 * Sets the Security Policy. 484 * 485 * @param[in] aSecurityPolicy The Security Policy which will be set. 486 */ 487 void SetSecurityPolicy(const SecurityPolicy &aSecurityPolicy); 488 489 private: 490 static constexpr uint8_t kThread11FlagsLength = 1; // The Thread 1.1 Security Policy Flags length. 491 static constexpr uint8_t kThread12FlagsLength = 2; // The Thread 1.2 Security Policy Flags length. 492 SetRotationTime(uint16_t aRotationTime)493 void SetRotationTime(uint16_t aRotationTime) { mRotationTime = BigEndian::HostSwap16(aRotationTime); } GetRotationTime(void) const494 uint16_t GetRotationTime(void) const { return BigEndian::HostSwap16(mRotationTime); } GetFlagsLength(void) const495 uint8_t GetFlagsLength(void) const { return GetLength() - sizeof(mRotationTime); } 496 497 uint16_t mRotationTime; 498 #if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2 499 uint8_t mFlags[kThread12FlagsLength]; 500 #else 501 uint8_t mFlags[kThread11FlagsLength]; 502 #endif 503 } OT_TOOL_PACKED_END; 504 505 /** 506 * Defines Active Timestamp TLV constants and types. 507 */ 508 typedef SimpleTlvInfo<Tlv::kActiveTimestamp, Timestamp> ActiveTimestampTlv; 509 510 /** 511 * Implements State TLV generation and parsing. 512 */ 513 class StateTlv : public UintTlvInfo<Tlv::kState, uint8_t> 514 { 515 public: 516 StateTlv(void) = delete; 517 518 /** 519 * State values. 520 */ 521 enum State : uint8_t 522 { 523 kReject = 0xff, ///< Reject (-1) 524 kPending = 0, ///< Pending 525 kAccept = 1, ///< Accept 526 }; 527 528 /** 529 * Converts a `State` to a string. 530 * 531 * @param[in] aState An item state. 532 * 533 * @returns A string representation of @p aState. 534 */ 535 static const char *StateToString(State aState); 536 }; 537 538 /** 539 * Defines Joiner UDP Port TLV constants and types. 540 */ 541 typedef UintTlvInfo<Tlv::kJoinerUdpPort, uint16_t> JoinerUdpPortTlv; 542 543 /** 544 * Defines Pending Timestamp TLV constants and types. 545 */ 546 typedef SimpleTlvInfo<Tlv::kPendingTimestamp, Timestamp> PendingTimestampTlv; 547 548 /** 549 * Defines Delay Timer TLV constants and types. 550 */ 551 class DelayTimerTlv : public UintTlvInfo<Tlv::kDelayTimer, uint32_t> 552 { 553 public: 554 /** 555 * Minimum Delay Timer value (in msec). 556 */ 557 static constexpr uint32_t kMinDelay = OPENTHREAD_CONFIG_TMF_PENDING_DATASET_MINIMUM_DELAY; 558 559 /** 560 * Maximum Delay Timer value (in msec). 561 */ 562 static constexpr uint32_t kMaxDelay = (72 * Time::kOneHourInMsec); 563 564 /** 565 * Default Delay Timer value (in msec). 566 */ 567 static constexpr uint32_t kDefaultDelay = OPENTHREAD_CONFIG_TMF_PENDING_DATASET_DEFAULT_DELAY; 568 569 /** 570 * Calculates the remaining delay in milliseconds, based on the value read from a Delay Timer TLV and the specified 571 * update time. 572 * 573 * Ensures that the calculated delay does not exceed `kMaxDelay`. Also accounts for time already elapsed since 574 * @p aUpdateTime. 575 * 576 * Caller MUST ensure that @p aDelayTimerTlv is a Delay Timer TLV, otherwise behavior is undefined. 577 * 578 * @param[in] aDelayTimerTlv The delay timer TLV to read delay from. 579 * @param[in] aUpdateTimer The update time of the Dataset. 580 * 581 * @return The remaining delay (in msec). 582 */ 583 static uint32_t CalculateRemainingDelay(const Tlv &aDelayTimerTlv, TimeMilli aUpdateTime); 584 585 static_assert(kMinDelay <= kMaxDelay, "TMF_PENDING_DATASET_MINIMUM_DELAY is larger than max allowed"); 586 static_assert(kDefaultDelay <= kMaxDelay, "TMF_PENDING_DATASET_DEFAULT_DELAY is larger than max allowed"); 587 static_assert(kDefaultDelay >= kMinDelay, "TMF_PENDING_DATASET_DEFAULT_DELAY is smaller than min allowed"); 588 }; 589 590 /** 591 * Implements Channel Mask TLV generation and parsing. 592 */ 593 OT_TOOL_PACKED_BEGIN 594 class ChannelMaskTlv : public Tlv, public TlvInfo<Tlv::kChannelMask> 595 { 596 static constexpr uint8_t kEntryHeaderSize = 2; // Two bytes: mChannelPage and mMaskLength 597 static constexpr uint8_t kEntrySize = kEntryHeaderSize + sizeof(uint32_t); 598 599 public: 600 /** 601 * Represents Channel Mask TLV value to append. 602 */ 603 struct Value 604 { 605 static constexpr uint16_t kMaxLength = (kEntrySize * Radio::kNumChannelPages); ///< Max value length. 606 607 uint8_t mData[kMaxLength]; ///< Array to store TLV value (encoded as one or more Channel Mask TLV Entry) 608 uint8_t mLength; ///< Value length in bytes. 609 }; 610 611 ChannelMaskTlv(void) = delete; 612 613 /** 614 * Parses the Channel Mask TLV value and validates that all the included entries are well-formed. 615 * 616 * @returns TRUE if the TLV is well-formed, FALSE otherwise. 617 */ 618 bool IsValid(void) const; 619 620 /** 621 * Parses and retrieves the combined channel mask for all supported channel pages from entries in the TLV. 622 * 623 * @param[out] aChannelMask A reference to return the channel mask. 624 * 625 * @retval kErrorNone Successfully parsed the TLV value, @p aChannelMask is updated. 626 * @retval kErrorParse TLV value is not well-formed. 627 */ 628 Error ReadChannelMask(uint32_t &aChannelMask) const; 629 630 /** 631 * Searches within a given message for Channel Mask TLV, parses and validates the TLV value and returns the 632 * combined channel mask for all supported channel pages included in the TLV. 633 * 634 * @param[in] aMessage The message to search in. 635 * @param[out] aChannelMask A reference to return the channel mask. 636 * 637 * @retval kErrorNone Found the TLV, successfully parsed its value, @p aChannelMask is updated. 638 * @retval kErrorNotFound No Channel Mask TLV found in the @p aMessage. 639 * @retval kErrorParse Found the TLV, but failed to parse it. 640 */ 641 static Error FindIn(const Message &aMessage, uint32_t &aChannelMask); 642 643 /** 644 * Prepares Channel Mask TLV value for appending/writing. 645 * 646 * @param[out] aValue A reference to `Value` structure to populate. 647 * @param[in] aChannelMask The combined channel mask for all supported channel pages. 648 */ 649 static void PrepareValue(Value &aValue, uint32_t aChannelMask); 650 651 /** 652 * Prepares a Channel Mask TLV value and appends the TLV to a given message. 653 * 654 * @param[in] aMessage The message to append to. 655 * @param[in] aChannelMask The combined channel mask for all supported channel pages. 656 * 657 * @retval kErrorNone Successfully prepared the Channel Mask TLV and appended it to @p aMessage. 658 * @retval kErrorNoBufs Insufficient available buffers to grow the message. 659 */ 660 static Error AppendTo(Message &aMessage, uint32_t aChannelMask); 661 662 private: 663 static constexpr uint8_t kMaskLength = sizeof(uint32_t); 664 665 OT_TOOL_PACKED_BEGIN 666 class Entry 667 { 668 public: GetChannelPage(void) const669 uint8_t GetChannelPage(void) const { return mChannelPage; } SetChannelPage(uint8_t aChannelPage)670 void SetChannelPage(uint8_t aChannelPage) { mChannelPage = aChannelPage; } GetMaskLength(void) const671 uint8_t GetMaskLength(void) const { return mMaskLength; } SetMaskLength(uint8_t aMaskLength)672 void SetMaskLength(uint8_t aMaskLength) { mMaskLength = aMaskLength; } GetMask(void) const673 uint32_t GetMask(void) const { return Reverse32(BigEndian::HostSwap32(mMask)); } SetMask(uint32_t aMask)674 void SetMask(uint32_t aMask) { mMask = BigEndian::HostSwap32(Reverse32(aMask)); } 675 676 private: 677 uint8_t mChannelPage; 678 uint8_t mMaskLength; 679 uint32_t mMask; 680 } OT_TOOL_PACKED_END; 681 682 struct EntriesData : public Clearable<EntriesData> 683 { 684 // Represents received Channel Mask TLV Entries data which 685 // is either contained in `mData` buffer, or in `mMessage` 686 // at `mOffset`. 687 688 Error Parse(uint32_t &aChannelMask); 689 690 const uint8_t *mData; 691 const Message *mMessage; 692 OffsetRange mOffsetRange; 693 }; 694 695 uint8_t mEntriesStart; 696 } OT_TOOL_PACKED_BEGIN; 697 698 /** 699 * Implements Energy List TLV generation and parsing. 700 */ 701 OT_TOOL_PACKED_BEGIN 702 class EnergyListTlv : public Tlv, public TlvInfo<Tlv::kEnergyList> 703 { 704 public: 705 /** 706 * Initializes the TLV. 707 */ Init(void)708 void Init(void) 709 { 710 SetType(kEnergyList); 711 SetLength(sizeof(*this) - sizeof(Tlv)); 712 } 713 714 /** 715 * Indicates whether or not the TLV appears to be well-formed. 716 * 717 * @retval TRUE If the TLV appears to be well-formed. 718 * @retval FALSE If the TLV does not appear to be well-formed. 719 */ IsValid(void) const720 bool IsValid(void) const { return true; } 721 722 /** 723 * Returns a pointer to the start of energy measurement list. 724 * 725 * @returns A pointer to the start start of energy energy measurement list. 726 */ GetEnergyList(void) const727 const uint8_t *GetEnergyList(void) const { return mEnergyList; } 728 729 /** 730 * Returns the length of energy measurement list. 731 * 732 * @returns The length of energy measurement list. 733 */ GetEnergyListLength(void) const734 uint8_t GetEnergyListLength(void) const { return Min(kMaxListLength, GetLength()); } 735 736 private: 737 static constexpr uint8_t kMaxListLength = OPENTHREAD_CONFIG_TMF_ENERGY_SCAN_MAX_RESULTS; 738 739 uint8_t mEnergyList[kMaxListLength]; 740 } OT_TOOL_PACKED_END; 741 742 /** 743 * Defines Provisioning TLV constants and types. 744 */ 745 typedef StringTlvInfo<Tlv::kProvisioningUrl, Tlv::kMaxProvisioningUrlLength> ProvisioningUrlTlv; 746 747 /** 748 * Defines Vendor Name TLV constants and types. 749 */ 750 typedef StringTlvInfo<Tlv::kVendorName, Tlv::kMaxVendorNameLength> VendorNameTlv; 751 752 /** 753 * Defines Vendor Model TLV constants and types. 754 */ 755 typedef StringTlvInfo<Tlv::kVendorModel, Tlv::kMaxVendorModelLength> VendorModelTlv; 756 757 /** 758 * Defines Vendor SW Version TLV constants and types. 759 */ 760 typedef StringTlvInfo<Tlv::kVendorSwVersion, Tlv::kMaxVendorSwVersionLength> VendorSwVersionTlv; 761 762 /** 763 * Defines Vendor Data TLV constants and types. 764 */ 765 typedef StringTlvInfo<Tlv::kVendorData, Tlv::kMaxVendorDataLength> VendorDataTlv; 766 767 /** 768 * Implements Vendor Stack Version TLV generation and parsing. 769 */ 770 OT_TOOL_PACKED_BEGIN 771 class VendorStackVersionTlv : public Tlv, public TlvInfo<Tlv::kVendorStackVersion> 772 { 773 public: 774 /** 775 * Default constructor. 776 */ VendorStackVersionTlv(void)777 VendorStackVersionTlv(void) 778 : mBuildRevision(0) 779 , mMinorMajor(0) 780 { 781 } 782 783 /** 784 * Initializes the TLV. 785 */ Init(void)786 void Init(void) 787 { 788 SetType(kVendorStackVersion); 789 SetLength(sizeof(*this) - sizeof(Tlv)); 790 } 791 792 /** 793 * Indicates whether or not the TLV appears to be well-formed. 794 * 795 * @retval TRUE If the TLV appears to be well-formed. 796 * @retval FALSE If the TLV does not appear to be well-formed. 797 */ IsValid(void) const798 bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } 799 800 /** 801 * Returns the Stack Vendor OUI value. 802 * 803 * @returns The Vendor Stack Vendor OUI value. 804 */ GetOui(void) const805 uint32_t GetOui(void) const { return BigEndian::ReadUint24(mOui); } 806 807 /** 808 * Returns the Stack Vendor OUI value. 809 * 810 * @param[in] aOui The Vendor Stack Vendor OUI value. 811 */ SetOui(uint32_t aOui)812 void SetOui(uint32_t aOui) { BigEndian::WriteUint24(aOui, mOui); } 813 814 /** 815 * Returns the Build value. 816 * 817 * @returns The Build value. 818 */ GetBuild(void) const819 uint16_t GetBuild(void) const { return (BigEndian::HostSwap16(mBuildRevision) & kBuildMask) >> kBuildOffset; } 820 821 /** 822 * Sets the Build value. 823 * 824 * @param[in] aBuild The Build value. 825 */ SetBuild(uint16_t aBuild)826 void SetBuild(uint16_t aBuild) 827 { 828 mBuildRevision = BigEndian::HostSwap16((BigEndian::HostSwap16(mBuildRevision) & ~kBuildMask) | 829 ((aBuild << kBuildOffset) & kBuildMask)); 830 } 831 832 /** 833 * Returns the Revision value. 834 * 835 * @returns The Revision value. 836 */ GetRevision(void) const837 uint8_t GetRevision(void) const { return (BigEndian::HostSwap16(mBuildRevision) & kRevMask) >> kRevOffset; } 838 839 /** 840 * Sets the Revision value. 841 * 842 * @param[in] aRevision The Revision value. 843 */ SetRevision(uint8_t aRevision)844 void SetRevision(uint8_t aRevision) 845 { 846 mBuildRevision = BigEndian::HostSwap16((BigEndian::HostSwap16(mBuildRevision) & ~kRevMask) | 847 ((aRevision << kRevOffset) & kRevMask)); 848 } 849 850 /** 851 * Returns the Minor value. 852 * 853 * @returns The Minor value. 854 */ GetMinor(void) const855 uint8_t GetMinor(void) const { return (mMinorMajor & kMinorMask) >> kMinorOffset; } 856 857 /** 858 * Sets the Minor value. 859 * 860 * @param[in] aMinor The Minor value. 861 */ SetMinor(uint8_t aMinor)862 void SetMinor(uint8_t aMinor) 863 { 864 mMinorMajor = (mMinorMajor & ~kMinorMask) | ((aMinor << kMinorOffset) & kMinorMask); 865 } 866 867 /** 868 * Returns the Major value. 869 * 870 * @returns The Major value. 871 */ GetMajor(void) const872 uint8_t GetMajor(void) const { return (mMinorMajor & kMajorMask) >> kMajorOffset; } 873 874 /** 875 * Sets the Major value. 876 * 877 * @param[in] aMajor The Major value. 878 */ SetMajor(uint8_t aMajor)879 void SetMajor(uint8_t aMajor) 880 { 881 mMinorMajor = (mMinorMajor & ~kMajorMask) | ((aMajor << kMajorOffset) & kMajorMask); 882 } 883 884 private: 885 // For `mBuildRevision` 886 static constexpr uint8_t kBuildOffset = 4; 887 static constexpr uint16_t kBuildMask = 0xfff << kBuildOffset; 888 static constexpr uint8_t kRevOffset = 0; 889 static constexpr uint16_t kRevMask = 0xf << kBuildOffset; 890 891 // For `mMinorMajor` 892 static constexpr uint8_t kMinorOffset = 4; 893 static constexpr uint8_t kMinorMask = 0xf << kMinorOffset; 894 static constexpr uint8_t kMajorOffset = 0; 895 static constexpr uint8_t kMajorMask = 0xf << kMajorOffset; 896 897 uint8_t mOui[3]; 898 uint16_t mBuildRevision; 899 uint8_t mMinorMajor; 900 } OT_TOOL_PACKED_END; 901 902 /** 903 * Defines UDP Encapsulation TLV types and constants. 904 */ 905 typedef TlvInfo<MeshCoP::Tlv::kUdpEncapsulation> UdpEncapsulationTlv; 906 907 /** 908 * Represents UDP Encapsulation TLV value header (source and destination ports). 909 */ 910 OT_TOOL_PACKED_BEGIN 911 class UdpEncapsulationTlvHeader 912 { 913 public: 914 /** 915 * Returns the source port. 916 * 917 * @returns The source port. 918 */ GetSourcePort(void) const919 uint16_t GetSourcePort(void) const { return BigEndian::HostSwap16(mSourcePort); } 920 921 /** 922 * Updates the source port. 923 * 924 * @param[in] aSourcePort The source port. 925 */ SetSourcePort(uint16_t aSourcePort)926 void SetSourcePort(uint16_t aSourcePort) { mSourcePort = BigEndian::HostSwap16(aSourcePort); } 927 928 /** 929 * Returns the destination port. 930 * 931 * @returns The destination port. 932 */ GetDestinationPort(void) const933 uint16_t GetDestinationPort(void) const { return BigEndian::HostSwap16(mDestinationPort); } 934 935 /** 936 * Updates the destination port. 937 * 938 * @param[in] aDestinationPort The destination port. 939 */ SetDestinationPort(uint16_t aDestinationPort)940 void SetDestinationPort(uint16_t aDestinationPort) { mDestinationPort = BigEndian::HostSwap16(aDestinationPort); } 941 942 private: 943 uint16_t mSourcePort; 944 uint16_t mDestinationPort; 945 // Followed by the UDP Payload. 946 } OT_TOOL_PACKED_END; 947 948 /** 949 * Implements Thread Domain Name TLV type. 950 */ 951 typedef StringTlvInfo<Tlv::kThreadDomainName, Tlv::kMaxThreadDomainNameLength> ThreadDomainNameTlv; 952 953 /** 954 * Implements Discovery Request TLV generation and parsing. 955 */ 956 OT_TOOL_PACKED_BEGIN 957 class DiscoveryRequestTlv : public Tlv, public TlvInfo<Tlv::kDiscoveryRequest> 958 { 959 public: 960 /** 961 * Initializes the TLV. 962 */ Init(void)963 void Init(void) 964 { 965 SetType(kDiscoveryRequest); 966 SetLength(sizeof(*this) - sizeof(Tlv)); 967 mFlags = 0; 968 mReserved = 0; 969 } 970 971 /** 972 * Indicates whether or not the TLV appears to be well-formed. 973 * 974 * @retval TRUE If the TLV appears to be well-formed. 975 * @retval FALSE If the TLV does not appear to be well-formed. 976 */ IsValid(void) const977 bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } 978 979 /** 980 * Returns the Version value. 981 * 982 * @returns The Version value. 983 */ GetVersion(void) const984 uint8_t GetVersion(void) const { return mFlags >> kVersionOffset; } 985 986 /** 987 * Sets the Version value. 988 * 989 * @param[in] aVersion The Version value. 990 */ SetVersion(uint8_t aVersion)991 void SetVersion(uint8_t aVersion) 992 { 993 mFlags = (mFlags & ~kVersionMask) | ((aVersion << kVersionOffset) & kVersionMask); 994 } 995 996 /** 997 * Indicates whether or not the Joiner flag is set. 998 * 999 * @retval TRUE If the Joiner flag is set. 1000 * @retval FALSE If the Joiner flag is not set. 1001 */ IsJoiner(void) const1002 bool IsJoiner(void) const { return (mFlags & kJoinerMask) != 0; } 1003 1004 /** 1005 * Sets the Joiner flag. 1006 * 1007 * @param[in] aJoiner TRUE if set, FALSE otherwise. 1008 */ SetJoiner(bool aJoiner)1009 void SetJoiner(bool aJoiner) 1010 { 1011 if (aJoiner) 1012 { 1013 mFlags |= kJoinerMask; 1014 } 1015 else 1016 { 1017 mFlags &= ~kJoinerMask; 1018 } 1019 } 1020 1021 private: 1022 static constexpr uint8_t kVersionOffset = 4; 1023 static constexpr uint8_t kVersionMask = 0xf << kVersionOffset; 1024 static constexpr uint8_t kJoinerOffset = 3; 1025 static constexpr uint8_t kJoinerMask = 1 << kJoinerOffset; 1026 1027 uint8_t mFlags; 1028 uint8_t mReserved; 1029 } OT_TOOL_PACKED_END; 1030 1031 /** 1032 * Implements Discovery Response TLV generation and parsing. 1033 */ 1034 OT_TOOL_PACKED_BEGIN 1035 class DiscoveryResponseTlv : public Tlv, public TlvInfo<Tlv::kDiscoveryResponse> 1036 { 1037 public: 1038 /** 1039 * Initializes the TLV. 1040 */ Init(void)1041 void Init(void) 1042 { 1043 SetType(kDiscoveryResponse); 1044 SetLength(sizeof(*this) - sizeof(Tlv)); 1045 mFlags = 0; 1046 mReserved = 0; 1047 } 1048 1049 /** 1050 * Indicates whether or not the TLV appears to be well-formed. 1051 * 1052 * @retval TRUE If the TLV appears to be well-formed. 1053 * @retval FALSE If the TLV does not appear to be well-formed. 1054 */ IsValid(void) const1055 bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); } 1056 1057 /** 1058 * Returns the Version value. 1059 * 1060 * @returns The Version value. 1061 */ GetVersion(void) const1062 uint8_t GetVersion(void) const { return mFlags >> kVersionOffset; } 1063 1064 /** 1065 * Sets the Version value. 1066 * 1067 * @param[in] aVersion The Version value. 1068 */ SetVersion(uint8_t aVersion)1069 void SetVersion(uint8_t aVersion) 1070 { 1071 mFlags = (mFlags & ~kVersionMask) | ((aVersion << kVersionOffset) & kVersionMask); 1072 } 1073 1074 /** 1075 * Indicates whether or not the Native Commissioner flag is set. 1076 * 1077 * @retval TRUE If the Native Commissioner flag is set. 1078 * @retval FALSE If the Native Commissioner flag is not set. 1079 */ IsNativeCommissioner(void) const1080 bool IsNativeCommissioner(void) const { return (mFlags & kNativeMask) != 0; } 1081 1082 /** 1083 * Sets the Native Commissioner flag. 1084 * 1085 * @param[in] aNativeCommissioner TRUE if set, FALSE otherwise. 1086 */ SetNativeCommissioner(bool aNativeCommissioner)1087 void SetNativeCommissioner(bool aNativeCommissioner) 1088 { 1089 if (aNativeCommissioner) 1090 { 1091 mFlags |= kNativeMask; 1092 } 1093 else 1094 { 1095 mFlags &= ~kNativeMask; 1096 } 1097 } 1098 1099 /** 1100 * Indicates whether or not the Commercial Commissioning Mode flag is set. 1101 * 1102 * @retval TRUE If the Commercial Commissioning Mode flag is set. 1103 * @retval FALSE If the Commercial Commissioning Mode flag is not set. 1104 */ IsCommercialCommissioningMode(void) const1105 bool IsCommercialCommissioningMode(void) const { return (mFlags & kCcmMask) != 0; } 1106 1107 /** 1108 * Sets the Commercial Commissioning Mode flag. 1109 * 1110 * @param[in] aCcm TRUE if set, FALSE otherwise. 1111 */ SetCommercialCommissioningMode(bool aCcm)1112 void SetCommercialCommissioningMode(bool aCcm) 1113 { 1114 if (aCcm) 1115 { 1116 mFlags |= kCcmMask; 1117 } 1118 else 1119 { 1120 mFlags &= ~kCcmMask; 1121 } 1122 } 1123 1124 private: 1125 static constexpr uint8_t kVersionOffset = 4; 1126 static constexpr uint8_t kVersionMask = 0xf << kVersionOffset; 1127 static constexpr uint8_t kNativeOffset = 3; 1128 static constexpr uint8_t kNativeMask = 1 << kNativeOffset; 1129 static constexpr uint8_t kCcmOffset = 2; 1130 static constexpr uint8_t kCcmMask = 1 << kCcmOffset; 1131 1132 uint8_t mFlags; 1133 uint8_t mReserved; 1134 } OT_TOOL_PACKED_END; 1135 1136 /** 1137 * Implements Joiner Advertisement TLV generation and parsing. 1138 */ 1139 OT_TOOL_PACKED_BEGIN 1140 class JoinerAdvertisementTlv : public Tlv, public TlvInfo<Tlv::kJoinerAdvertisement> 1141 { 1142 public: 1143 static constexpr uint8_t kAdvDataMaxLength = OT_JOINER_ADVDATA_MAX_LENGTH; ///< The Max Length of AdvData 1144 1145 /** 1146 * Initializes the TLV. 1147 */ Init(void)1148 void Init(void) 1149 { 1150 SetType(kJoinerAdvertisement); 1151 SetLength(sizeof(*this) - sizeof(Tlv)); 1152 } 1153 1154 /** 1155 * Indicates whether or not the TLV appears to be well-formed. 1156 * 1157 * @retval TRUE If the TLV appears to be well-formed. 1158 * @retval FALSE If the TLV does not appear to be well-formed. 1159 */ IsValid(void) const1160 bool IsValid(void) const { return GetLength() >= sizeof(mOui) && GetLength() <= sizeof(mOui) + sizeof(mAdvData); } 1161 1162 /** 1163 * Returns the Vendor OUI value. 1164 * 1165 * @returns The Vendor OUI value. 1166 */ GetOui(void) const1167 uint32_t GetOui(void) const { return BigEndian::ReadUint24(mOui); } 1168 1169 /** 1170 * Sets the Vendor OUI value. 1171 * 1172 * @param[in] aOui The Vendor OUI value. 1173 */ SetOui(uint32_t aOui)1174 void SetOui(uint32_t aOui) { return BigEndian::WriteUint24(aOui, mOui); } 1175 1176 /** 1177 * Returns the Adv Data length. 1178 * 1179 * @returns The AdvData length. 1180 */ GetAdvDataLength(void) const1181 uint8_t GetAdvDataLength(void) const { return GetLength() - sizeof(mOui); } 1182 1183 /** 1184 * Returns the Adv Data value. 1185 * 1186 * @returns A pointer to the Adv Data value. 1187 */ GetAdvData(void) const1188 const uint8_t *GetAdvData(void) const { return mAdvData; } 1189 1190 /** 1191 * Sets the Adv Data value. 1192 * 1193 * @param[in] aAdvData A pointer to the AdvData value. 1194 * @param[in] aAdvDataLength The length of AdvData in bytes. 1195 */ SetAdvData(const uint8_t * aAdvData,uint8_t aAdvDataLength)1196 void SetAdvData(const uint8_t *aAdvData, uint8_t aAdvDataLength) 1197 { 1198 OT_ASSERT((aAdvData != nullptr) && (aAdvDataLength > 0) && (aAdvDataLength <= kAdvDataMaxLength)); 1199 1200 SetLength(aAdvDataLength + sizeof(mOui)); 1201 memcpy(mAdvData, aAdvData, aAdvDataLength); 1202 } 1203 1204 private: 1205 uint8_t mOui[3]; 1206 uint8_t mAdvData[kAdvDataMaxLength]; 1207 } OT_TOOL_PACKED_END; 1208 1209 } // namespace MeshCoP 1210 1211 } // namespace ot 1212 1213 #endif // MESHCOP_TLVS_HPP_ 1214