mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
[cli] networkdiagnostic: pass tlv types directly (#2261)
This commit is contained in:
+14
-16
@@ -3387,36 +3387,34 @@ exit:
|
||||
void Interpreter::ProcessNetworkDiagnostic(int argc, char *argv[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
struct otIp6Address address;
|
||||
uint8_t payload[2 + OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES]; // TypeList Type(1B), len(1B), type list
|
||||
uint8_t payloadIndex = 0;
|
||||
uint8_t paramIndex = 0;
|
||||
struct otIp6Address address;
|
||||
uint8_t tlvTypes[OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES];
|
||||
uint8_t count = 0;
|
||||
uint8_t argvIndex = 0;
|
||||
|
||||
VerifyOrExit(argc > 1 + 1, error = OT_ERROR_PARSE);
|
||||
// Include operation, address and type tlv list.
|
||||
VerifyOrExit(argc > 2, error = OT_ERROR_PARSE);
|
||||
|
||||
SuccessOrExit(error = otIp6AddressFromString(argv[1], &address));
|
||||
|
||||
payloadIndex = 2;
|
||||
paramIndex = 2;
|
||||
argvIndex = 2;
|
||||
|
||||
while (paramIndex < argc && payloadIndex < sizeof(payload))
|
||||
while (argvIndex < argc && count < sizeof(tlvTypes))
|
||||
{
|
||||
long value;
|
||||
SuccessOrExit(error = ParseLong(argv[paramIndex++], value));
|
||||
payload[payloadIndex++] = static_cast<uint8_t>(value);
|
||||
SuccessOrExit(error = ParseLong(argv[argvIndex++], value));
|
||||
tlvTypes[count++] = static_cast<uint8_t>(value);
|
||||
}
|
||||
|
||||
payload[0] = OT_NETWORK_DIAGNOSTIC_TYPELIST_TYPE; // TypeList TLV Type
|
||||
payload[1] = payloadIndex - 2; // length
|
||||
|
||||
if (strcmp(argv[0], "get") == 0)
|
||||
{
|
||||
otThreadSendDiagnosticGet(mInstance, &address, payload, payloadIndex);
|
||||
otThreadSendDiagnosticGet(mInstance, &address, tlvTypes, count);
|
||||
// Intentionally exit here for display response.
|
||||
return;
|
||||
}
|
||||
else if (strcmp(argv[0], "reset") == 0)
|
||||
{
|
||||
otThreadSendDiagnosticReset(mInstance, &address, payload, payloadIndex);
|
||||
otThreadSendDiagnosticReset(mInstance, &address, tlvTypes, count);
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -3439,7 +3437,7 @@ void Interpreter::HandleDiagnosticGetResponse(Message &aMessage, const Ip6::Mess
|
||||
uint16_t bytesPrinted = 0;
|
||||
uint16_t length = aMessage.GetLength() - aMessage.GetOffset();
|
||||
|
||||
mServer->OutputFormat("DIAG_GET.rsp: ");
|
||||
mServer->OutputFormat("DIAG_GET.rsp/ans: ");
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user