From ab648c6c55e36a29685e0797d9e86927048e62d5 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Sat, 18 Nov 2017 06:26:36 -0800 Subject: [PATCH] [child-info] add mIsStateRestoring to otChildInfo and filter restoring child in NcpBase (#2355) This commit adds a new field `mIsStateRestoring` to `otChildInfo` struct to inform the if the child is being restored. This field is used in `NcpBase` to filter child entries in restoring state. --- include/openthread/types.h | 1 + src/core/thread/mle_router.cpp | 1 + src/ncp/ncp_base_ftd.cpp | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/openthread/types.h b/include/openthread/types.h index f5dcfcae6..0102664ba 100644 --- a/include/openthread/types.h +++ b/include/openthread/types.h @@ -963,6 +963,7 @@ typedef struct bool mSecureDataRequest : 1; ///< Secure Data Requests bool mFullFunction : 1; ///< Full Function Device bool mFullNetworkData : 1; ///< Full Network Data + bool mIsStateRestoring : 1; ///< Is in restoring state uint8_t mIp6AddressesLength; ///< Number of entries in IPv6 address array. const otIp6Address *mIp6Addresses; ///< Array of IPv6 addresses (unused entries contain unspecified address). } otChildInfo; diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index a79efd980..a317d08d7 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -3766,6 +3766,7 @@ otError MleRouter::GetChildInfo(Child &aChild, otChildInfo &aChildInfo) aChildInfo.mSecureDataRequest = aChild.IsSecureDataRequest(); aChildInfo.mFullFunction = aChild.IsFullThreadDevice(); aChildInfo.mFullNetworkData = aChild.IsFullNetworkData(); + aChildInfo.mIsStateRestoring = aChild.IsStateRestoring(); aChildInfo.mIp6AddressesLength = Child::kMaxIp6AddressPerChild; aChildInfo.mIp6Addresses = aChild.GetIp6Addresses(); diff --git a/src/ncp/ncp_base_ftd.cpp b/src/ncp/ncp_base_ftd.cpp index 33a991065..1220938ff 100644 --- a/src/ncp/ncp_base_ftd.cpp +++ b/src/ncp/ncp_base_ftd.cpp @@ -100,6 +100,8 @@ void NcpBase::HandleChildTableChanged(otThreadChildTableEvent aEvent, const otCh VerifyOrExit(!mChangedPropsSet.IsPropertyFiltered(SPINEL_PROP_THREAD_CHILD_TABLE)); + VerifyOrExit(!aChildInfo.mIsStateRestoring); + switch (aEvent) { case OT_THREAD_CHILD_TABLE_EVENT_CHILD_ADDED: @@ -159,7 +161,8 @@ otError NcpBase::GetPropertyHandler_THREAD_CHILD_TABLE(void) for (uint8_t index = 0; index < maxChildren; index++) { - if (otThreadGetChildInfoByIndex(mInstance, index, &childInfo) != OT_ERROR_NONE) + if ((otThreadGetChildInfoByIndex(mInstance, index, &childInfo) != OT_ERROR_NONE) || + childInfo.mIsStateRestoring) { continue; }