[domain] add domain name (#4815)

This commit is contained in:
Rongli Sun
2020-04-15 00:08:42 +08:00
committed by GitHub
parent c024fac54c
commit 854a2309bd
13 changed files with 357 additions and 106 deletions
+22 -1
View File
@@ -141,6 +141,9 @@ const struct Command Interpreter::sCommands[] = {
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
{"dns", &Interpreter::ProcessDns},
#endif
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
{"domainname", &Interpreter::ProcessDomainName},
#endif
#if OPENTHREAD_FTD
{"eidcache", &Interpreter::ProcessEidCache},
#endif
@@ -579,6 +582,24 @@ exit:
}
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
void Interpreter::ProcessDomainName(uint8_t aArgsLength, char *aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
const char *domainName = otThreadGetDomainName(mInstance);
mServer->OutputFormat("%s\r\n", static_cast<const char *>(domainName));
}
else
{
SuccessOrExit(error = otThreadSetDomainName(mInstance, aArgs[0]));
}
exit:
AppendResult(error);
}
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
void Interpreter::ProcessBufferInfo(uint8_t aArgsLength, char *aArgs[])
@@ -2061,7 +2082,7 @@ void Interpreter::ProcessNetworkName(uint8_t aArgsLength, char *aArgs[])
if (aArgsLength == 0)
{
const char *networkName = otThreadGetNetworkName(mInstance);
mServer->OutputFormat("%.*s\r\n", OT_NETWORK_NAME_MAX_SIZE, static_cast<const char *>(networkName));
mServer->OutputFormat("%s\r\n", static_cast<const char *>(networkName));
}
else
{