diff --git a/examples/drivers/windows/otApi/otApi.cpp b/examples/drivers/windows/otApi/otApi.cpp index e952d58af..15c3643b1 100644 --- a/examples/drivers/windows/otApi/otApi.cpp +++ b/examples/drivers/windows/otApi/otApi.cpp @@ -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 diff --git a/include/openthread/thread_ftd.h b/include/openthread/thread_ftd.h index 6a25ebbb6..6fbe666e6 100644 --- a/include/openthread/thread_ftd.h +++ b/include/openthread/thread_ftd.h @@ -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. diff --git a/src/cli/README.md b/src/cli/README.md index 0e7593812..f3494b924 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -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 \ \ -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 \ -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 \ -Set the Thread Network Name. +Set the Thread Network Name. ```bash > networkname OpenThread diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 87f99bf95..2d3e49359 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -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; diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index 4ffc4fca6..594167730 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -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[]);