[ncp] adding new spinel property to get EID address cache table (#2788)

This commit adds a new spinel property `THREAD_ADDRESS_CACHE_TABLE`
to get the Thread EID IPv6 Address cache table.
This commit is contained in:
Abtin Keshavarzian
2018-06-15 10:25:36 -07:00
committed by Jonathan Hui
parent 380cfb8ae0
commit 13a40c8bcf
6 changed files with 60 additions and 0 deletions
@@ -562,3 +562,17 @@ Data per item is:
* `S`: Message error rate (0 -> 0%, 0xffff -> 100%)
* `c`: Average RSSI (in dBm)
* `c`: Last RSSI (in dBm)
### PROP 5411: SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE (#prop-thread-address-cache-table)
* Type: Read-Only
* Packing-Encoding: `A(t(6SC))`
This property provides Thread EID IPv6 address cache table.
Data per item is:
* `6` : Target IPv6 address
* `S` : RLOC16 of target
* `C` : Age (order of use, 0 indicates most recently used entry)
+1
View File
@@ -232,6 +232,7 @@ const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
NCP_GET_PROP_HANDLER_ENTRY(THREAD_NETWORK_ID_TIMEOUT),
NCP_GET_PROP_HANDLER_ENTRY(THREAD_ROUTER_SELECTION_JITTER),
NCP_GET_PROP_HANDLER_ENTRY(THREAD_PREFERRED_ROUTER_ID),
NCP_GET_PROP_HANDLER_ENTRY(THREAD_ADDRESS_CACHE_TABLE),
#if OPENTHREAD_ENABLE_COMMISSIONER
NCP_GET_PROP_HANDLER_ENTRY(THREAD_COMMISSIONER_ENABLED),
#endif
+1
View File
@@ -670,6 +670,7 @@ protected:
NCP_SET_PROP_HANDLER(THREAD_PENDING_DATASET);
NCP_SET_PROP_HANDLER(THREAD_MGMT_ACTIVE_DATASET);
NCP_SET_PROP_HANDLER(THREAD_MGMT_PENDING_DATASET);
NCP_GET_PROP_HANDLER(THREAD_ADDRESS_CACHE_TABLE);
#if OPENTHREAD_ENABLE_CHANNEL_MANAGER
NCP_GET_PROP_HANDLER(CHANNEL_MANAGER_NEW_CHANNEL);
NCP_SET_PROP_HANDLER(CHANNEL_MANAGER_NEW_CHANNEL);
+25
View File
@@ -528,6 +528,31 @@ exit:
return error;
}
otError NcpBase::GetPropertyHandler_THREAD_ADDRESS_CACHE_TABLE(void)
{
otError error = OT_ERROR_NONE;
otEidCacheEntry entry;
for (uint8_t index = 0; ; index++)
{
SuccessOrExit(otThreadGetEidCacheEntry(mInstance, index, &entry));
if (!entry.mValid)
{
continue;
}
SuccessOrExit(error = mEncoder.OpenStruct());
SuccessOrExit(error = mEncoder.WriteIp6Address(entry.mTarget));
SuccessOrExit(error = mEncoder.WriteUint16(entry.mRloc16));
SuccessOrExit(error = mEncoder.WriteUint8(entry.mAge));
SuccessOrExit(error = mEncoder.CloseStruct());
}
exit:
return error;
}
#if OPENTHREAD_ENABLE_TMF_PROXY
otError NcpBase::GetPropertyHandler_THREAD_TMF_PROXY_ENABLED(void)
{
+4
View File
@@ -1545,6 +1545,10 @@ spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
ret = "PROP_THREAD_NEIGHBOR_TABLE_ERROR_RATES";
break;
case SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE:
ret = "PROP_THREAD_ADDRESS_CACHE_TABLE";
break;
case SPINEL_PROP_IPV6_LL_ADDR:
ret = "PROP_IPV6_LL_ADDR";
break;
+15
View File
@@ -1416,6 +1416,21 @@ typedef enum
SPINEL_PROP_THREAD_NEIGHBOR_TABLE_ERROR_RATES
= SPINEL_PROP_THREAD_EXT__BEGIN + 34,
/// EID (Endpoint Identifier) IPv6 Address Cache Table
/** Format `A(t(6SC))`
*
* This property provides Thread EID address cache table.
*
* Data per item is:
*
* `6` : Target IPv6 address
* `S` : RLOC16 of target
* `C` : Age (order of use, 0 indicates most recently used entry)
*
*/
SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE
= SPINEL_PROP_THREAD_EXT__BEGIN + 35,
SPINEL_PROP_THREAD_EXT__END = 0x1600,
SPINEL_PROP_IPV6__BEGIN = 0x60,