[dua] support to specify iid for domain unicast address (#4900)

This commit is contained in:
Rongli Sun
2020-06-10 01:38:13 +08:00
committed by GitHub
parent b28d7c4a45
commit b51d9100e6
15 changed files with 779 additions and 15 deletions
+48
View File
@@ -147,6 +147,9 @@ const struct Command Interpreter::sCommands[] = {
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
{"domainname", &Interpreter::ProcessDomainName},
#endif
#if OPENTHREAD_CONFIG_DUA_ENABLE
{"dua", &Interpreter::ProcessDua},
#endif
#if OPENTHREAD_FTD
{"eidcache", &Interpreter::ProcessEidCache},
#endif
@@ -609,6 +612,51 @@ exit:
AppendResult(error);
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
void Interpreter::ProcessDua(uint8_t aArgsLength, char *aArgs[])
{
otError error = OT_ERROR_NONE;
VerifyOrExit(aArgsLength >= 1 && strcmp(aArgs[0], "iid") == 0, error = OT_ERROR_INVALID_COMMAND);
switch (aArgsLength)
{
case 1:
{
const otIp6InterfaceIdentifier *iid = otThreadGetFixedDuaInterfaceIdentifier(mInstance);
if (iid != NULL)
{
OutputBytes(iid->m8, sizeof(otIp6InterfaceIdentifier));
mServer->OutputFormat("\r\n");
}
break;
}
case 2:
if (strcmp(aArgs[1], "clear") == 0)
{
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, NULL));
}
else
{
otIp6InterfaceIdentifier iid;
VerifyOrExit(Hex2Bin(aArgs[1], iid.m8, sizeof(otIp6InterfaceIdentifier)) ==
sizeof(otIp6InterfaceIdentifier),
error = OT_ERROR_INVALID_ARGS);
SuccessOrExit(error = otThreadSetFixedDuaInterfaceIdentifier(mInstance, &iid));
}
break;
default:
error = OT_ERROR_INVALID_ARGS;
break;
}
exit:
AppendResult(error);
}
#endif // OPENTHREAD_CONFIG_DUA_ENABLE
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
void Interpreter::ProcessBufferInfo(uint8_t aArgsLength, char *aArgs[])