[cli] add 'childip' command to cli for getting ip addresses of MTD children (#3791)

This commit is contained in:
Ciaran Woodward
2019-04-30 18:40:40 -07:00
committed by Jonathan Hui
parent 617f8958dd
commit 267a3b3e29
5 changed files with 76 additions and 9 deletions
+16
View File
@@ -3086,6 +3086,22 @@ otThreadGetChildInfoByIndex(
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CHILD_INFO_BY_INDEX, &aChildIndex, aChildInfo));
}
OTAPI
otError
OTCALL
otThreadGetChildNextIp6Address(
_In_ otInstance *aInstance,
uint8_t aChildIndex,
_Inout_ otChildIp6AddressIterator *aIterator,
_Out_ otIp6Address *aAddress)
{
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
UNREFERENCED_PARAMETER(aChildIndex);
UNREFERENCED_PARAMETER(aIterator);
UNREFERENCED_PARAMETER(aAddress);
return OT_ERROR_NOT_IMPLEMENTED; // TODO
}
OTAPI
otError
OTCALL
+4 -4
View File
@@ -462,10 +462,10 @@ OTAPI otError OTCALL otThreadGetChildInfoByIndex(otInstance *aInstance, uint8_t
* @sa otThreadGetChildInfoByIndex
*
*/
otError otThreadGetChildNextIp6Address(otInstance * aInstance,
uint8_t aChildIndex,
otChildIp6AddressIterator *aIterator,
otIp6Address * aAddress);
OTAPI otError OTCALL otThreadGetChildNextIp6Address(otInstance * aInstance,
uint8_t aChildIndex,
otChildIp6AddressIterator *aIterator,
otIp6Address * aAddress);
/**
* Get the current Router ID Sequence.
+16 -5
View File
@@ -11,6 +11,7 @@ OpenThread test scripts use the CLI to execute test cases.
* [bufferinfo](#bufferinfo)
* [channel](#channel)
* [child](#child-list)
* [childip](#childip)
* [childmax](#childmax)
* [childtimeout](#childtimeout)
* [coap](#coap-start)
@@ -183,6 +184,16 @@ RSSI: -20
Done
```
### childip
Get the list of IP addresses stored for MTD children.
```bash
> childip
3401: fdde:ad00:beef:0:3037:3e03:8c5f:bc0c
Done
```
### childmax
Get the Thread maximum number of allowed children.
@@ -298,7 +309,7 @@ Coap Secure service stopped: Done
### coaps set psk \<preSharedKey\> \<keyIdentity\>
Set a pre-shared key with his identifier and the ciphersuite
Set a pre-shared key with his identifier and the ciphersuite
"DTLS_PSK_WITH_AES_128_CCM_8" for the dtls session.
* preSharedKey: The pre-shared key (PSK) for dtls session.
@@ -1315,7 +1326,7 @@ Done
### networkidtimeout
Get the NETWORK_ID_TIMEOUT parameter used in the Router role.
Get the NETWORK_ID_TIMEOUT parameter used in the Router role.
```bash
> networkidtimeout
@@ -1325,7 +1336,7 @@ Done
### networkidtimeout \<timeout\>
Set the NETWORK_ID_TIMEOUT parameter used in the Router role.
Set the NETWORK_ID_TIMEOUT parameter used in the Router role.
```bash
> networkidtimeout 120
@@ -1334,7 +1345,7 @@ Done
### networkname
Get the Thread Network Name.
Get the Thread Network Name.
```bash
> networkname
@@ -1344,7 +1355,7 @@ Done
### networkname \<name\>
Set the Thread Network Name.
Set the Thread Network Name.
```bash
> networkname OpenThread
+39
View File
@@ -113,6 +113,7 @@ const struct Command Interpreter::sCommands[] = {
{"channel", &Interpreter::ProcessChannel},
#if OPENTHREAD_FTD
{"child", &Interpreter::ProcessChild},
{"childip", &Interpreter::ProcessChildIp},
{"childmax", &Interpreter::ProcessChildMax},
#endif
{"childtimeout", &Interpreter::ProcessChildTimeout},
@@ -783,6 +784,44 @@ exit:
AppendResult(error);
}
void Interpreter::ProcessChildIp(int argc, char *argv[])
{
otError error = OT_ERROR_NONE;
uint8_t maxChildren;
VerifyOrExit(argc == 0, error = OT_ERROR_INVALID_ARGS);
maxChildren = otThreadGetMaxAllowedChildren(mInstance);
for (uint8_t childIndex = 0; childIndex < maxChildren; childIndex++)
{
otChildIp6AddressIterator iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT;
otIp6Address ip6Address;
otChildInfo childInfo;
if ((otThreadGetChildInfoByIndex(mInstance, childIndex, &childInfo) != OT_ERROR_NONE) ||
childInfo.mIsStateRestoring)
{
continue;
}
iterator = OT_CHILD_IP6_ADDRESS_ITERATOR_INIT;
while (otThreadGetChildNextIp6Address(mInstance, childIndex, &iterator, &ip6Address) == OT_ERROR_NONE)
{
mServer->OutputFormat("%04x: %x:%x:%x:%x:%x:%x:%x:%x\r\n", childInfo.mRloc16,
HostSwap16(ip6Address.mFields.m16[0]), HostSwap16(ip6Address.mFields.m16[1]),
HostSwap16(ip6Address.mFields.m16[2]), HostSwap16(ip6Address.mFields.m16[3]),
HostSwap16(ip6Address.mFields.m16[4]), HostSwap16(ip6Address.mFields.m16[5]),
HostSwap16(ip6Address.mFields.m16[6]), HostSwap16(ip6Address.mFields.m16[7]));
}
}
exit:
OT_UNUSED_VARIABLE(argv);
AppendResult(error);
}
void Interpreter::ProcessChildMax(int argc, char *argv[])
{
otError error = OT_ERROR_NONE;
+1
View File
@@ -195,6 +195,7 @@ private:
void ProcessChannel(int argc, char *argv[]);
#if OPENTHREAD_FTD
void ProcessChild(int argc, char *argv[]);
void ProcessChildIp(int argc, char *argv[]);
void ProcessChildMax(int argc, char *argv[]);
#endif
void ProcessChildTimeout(int argc, char *argv[]);