-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tlv] add new tlvs for network diagnostic #266
Changes from 1 commit
f0bbe33
1cc8322
af7f86f
8ada05f
57bd5f1
6561ae7
397114d
1913f47
62a1b82
384ec58
af15906
e0820a3
70c626d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,6 +220,71 @@ bool Tlv::IsValid() const | |
{ | ||
return false; | ||
} | ||
else if (mScope == Scope::kNetworkDiag) | ||
{ | ||
switch (mType) | ||
{ | ||
// Network disgnostic layer TLVs | ||
case Type::kNetworkDiagExtMacAddress: | ||
return length == 8; | ||
case Type::kNetworkDiagMacAddress: | ||
return length == 2; | ||
case Type::kNetworkDiagMode: | ||
return length == 1; | ||
case Type::kNetworkDiagTimeout: | ||
return length == 4; | ||
case Type::kNetworkDiagRoute64: | ||
return length >= 4; | ||
case Type::kNetworkDiagLeaderData: | ||
return length == 8; | ||
case Type::kNetworkDiagNetworkData: | ||
return true; | ||
case Type::kNetworkDiagIpv6Address: | ||
return (length % 16 == 0) && (length / 16 >= 1 && length / 16 <= 15); | ||
case Type::kNetworkDiagMacCounters: | ||
return length <= 36; | ||
case Type::kNetworkDiagBatteryLevel: | ||
return length == 1; | ||
case Type::kNetworkDiagSupplyVoltage: | ||
return length == 2; | ||
case Type::kNetworkDiagChildTable: | ||
return true; // list of 0 or more child entry data | ||
case Type::kNetworkDiagChannelPages: | ||
return length >= 1; // 1 or more 8-bit integers | ||
case Type::kNetworkDiagTypeList: | ||
return length >= 1; // 1 or more 8-bit integers | ||
case Type::kNetworkDiagMaxChildTimeout: | ||
return length == 4; | ||
case Type::kNetworkDiagLDevIDSubjectPubKeyInfo: | ||
return true; | ||
case Type::kNetworkDiagIDevIDCert: | ||
return true; | ||
case Type::kNetworkDiagEui64: | ||
return length == 8; | ||
case Type::kNetworkDiagVersion: | ||
return length == 2; | ||
case Type::kNetworkDiagVendorName: | ||
return length <= 4; | ||
case Type::kNetworkDiagVendorModel: | ||
return length <= 4; | ||
case Type::kNetworkDiagVendorSWVersion: | ||
return length <= 2; | ||
case Type::kNetworkDiagChild: | ||
return length <= 43; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understand it, the TLV will only have content when the queried device has children. If the queried device has no children, the value of TLV is empty, so the length should be 0. If we check the length to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TLV |
||
case Type::kNetworkDiagChildIpv6Address: | ||
return (length % 16 == 0) && (length / 16 >= 1 && length / 16 <= 15); | ||
case Type::kNetworkDiagRouterNeighbor: | ||
return length <= 24; | ||
case Type::kNetworkDiagAnswer: | ||
return length == 2; | ||
case Type::kNetworkDiagQueryID: | ||
return length == 2; | ||
case Type::kNetworkDiagMleCounters: | ||
return length <= 66; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
switch (mType) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally consider a TLV valid if its length is at least as long as the currently defined value length. This accommodates potential future extensions of the TLV format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abtink Thank you for your review. I have clarified the length of TLVs as per the definition in the spec. For instance, the length of the extended MAC address TLV in spec 5.19.2 is 8. Could you please kindly indicate any other inappropriate definitions in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @abtink wants you to change the check to
return length >= 8;
so that the extended MAC address can be extended to maybe 16 bytes in Thread 2.0 or whatever later versionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, Thanks @wgtdkp clarification. Let me update check condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wgtdkp :). Yes. Exactly.
Thank @ZhangLe2016 for changing.