34 #ifndef OTBR_COMMON_TLV_HPP_
35 #define OTBR_COMMON_TLV_HPP_
62 uint8_t
GetType(
void)
const {
return mType; }
68 void SetType(uint8_t aType) { mType = aType; }
78 return (mLength != kLengthEscape ? mLength :
static_cast<uint16_t
>((&mLength)[1] << 8 | (&mLength)[2]));
84 void SetLength(uint16_t aLength,
bool aForceExtended =
false)
86 if (aLength >= kLengthEscape || aForceExtended)
88 mLength = kLengthEscape;
89 (&mLength)[1] = (aLength >> 8);
90 (&mLength)[2] = (aLength & 0xff);
94 mLength =
static_cast<uint8_t
>(aLength);
106 return reinterpret_cast<const uint8_t *
>(
this) +
sizeof(mType) +
107 (mLength != kLengthEscape ?
sizeof(mLength) : (
sizeof(uint16_t) +
sizeof(mLength)));
118 const uint8_t *p =
static_cast<const uint8_t *
>(
GetValue());
120 return static_cast<uint16_t
>(p[0] << 8 | p[1]);
142 value =
static_cast<uint8_t *
>(
GetValue());
143 for (
int i = 0; i <
int{
sizeof(aValue)}; ++i)
145 value[i] = (aValue >> (8 * (
sizeof(aValue) - i - 1))) & 0xff;
160 value =
static_cast<uint8_t *
>(
GetValue());
161 for (
int i = 0; i <
int{
sizeof(aValue)}; ++i)
163 value[i] = (aValue >> (8 * (
sizeof(aValue) - i - 1))) & 0xff;
178 value =
static_cast<uint8_t *
>(
GetValue());
179 value[0] = (aValue >> 8);
180 value[1] = (aValue & 0xff);
192 *
static_cast<uint8_t *
>(
GetValue()) = aValue;
204 *
static_cast<int8_t *
>(
GetValue()) = aValue;
210 void SetValue(
const void *aValue, uint16_t aLength,
bool aForceExtended =
false)
213 memcpy(
GetValue(), aValue, aLength);
238 return reinterpret_cast<uint8_t *
>(
this) +
sizeof(mType) +
239 (mLength != kLengthEscape ?
sizeof(mLength) : (
sizeof(uint16_t) +
sizeof(mLength)));
250 kCommissionerId = 10,
251 kCommissionerSessionId = 11,
252 kJoinerDtlsEncapsulation = 17,
256 kJoinerRouterLocator = 20,
257 kJoinerRouterKek = 21,
258 kUdpEncapsulation = 48,
273 #endif // OTBR_COMMON_TLV_HPP_