[netdata] add api to check if joiner is in steering data (#5392)

This commit is contained in:
Yakun Xu
2020-08-15 13:09:14 +08:00
committed by GitHub
parent bc195d1329
commit 16a5c52d9f
15 changed files with 213 additions and 6 deletions
+43
View File
@@ -186,6 +186,7 @@ const struct Command Interpreter::sCommands[] = {
#if OPENTHREAD_FTD
{"neighbor", &Interpreter::ProcessNeighbor},
#endif
{"netdata", &Interpreter::ProcessNetworkData},
#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
{"netdataregister", &Interpreter::ProcessNetworkDataRegister},
#endif
@@ -2236,6 +2237,48 @@ exit:
}
#endif
void Interpreter::ProcessNetworkData(uint8_t aArgsLength, char *aArgs[])
{
otError error;
if (aArgsLength > 2 && strcmp(aArgs[0], "steeringdata") == 0)
{
if (strcmp(aArgs[1], "check") == 0)
{
otExtAddress addr;
otJoinerDiscerner discerner;
discerner.mLength = 0;
error = Interpreter::ParseJoinerDiscerner(aArgs[2], discerner);
if (error == OT_ERROR_NOT_FOUND)
{
VerifyOrExit(Interpreter::Hex2Bin(aArgs[2], addr.m8, sizeof(addr)) == sizeof(addr),
error = OT_ERROR_INVALID_ARGS);
}
else if (error != OT_ERROR_NONE)
{
ExitNow();
}
if (discerner.mLength)
{
ExitNow(error = otNetDataSteeringDataCheckJoinerWithDiscerner(mInstance, &discerner));
}
else
{
ExitNow(error = otNetDataSteeringDataCheckJoiner(mInstance, &addr));
}
}
}
error = OT_ERROR_INVALID_COMMAND;
exit:
AppendResult(error);
}
#if OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE || OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
void Interpreter::ProcessNetworkDataRegister(uint8_t aArgsLength, char *aArgs[])
{