mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[cli] add cli command to clear EID-RLOC cache (#9985)
Co-authored-by: Abtin Keshavarzian <abtink@google.com>
This commit is contained in:
@@ -52,7 +52,7 @@ extern "C" {
|
||||
*
|
||||
* @note This number versions both OpenThread platform and user APIs.
|
||||
*/
|
||||
#define OPENTHREAD_API_VERSION (596)
|
||||
#define OPENTHREAD_API_VERSION (597)
|
||||
|
||||
/**
|
||||
* @addtogroup api-instance
|
||||
|
||||
@@ -629,6 +629,15 @@ otError otThreadGetRouterInfo(otInstance *aInstance, uint16_t aRouterId, otRoute
|
||||
*/
|
||||
otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntryInfo, otCacheEntryIterator *aIterator);
|
||||
|
||||
/**
|
||||
* Clears the EID cache.
|
||||
*
|
||||
* Intended for testing only.
|
||||
*
|
||||
* @param[in] aInstance A pointer to an OpenThread instance.
|
||||
*/
|
||||
void otThreadClearEidCache(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* Get the Thread PSKc
|
||||
*
|
||||
|
||||
+41
-23
@@ -2938,35 +2938,53 @@ void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry)
|
||||
OutputNewLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* @cli eidcache
|
||||
* @code
|
||||
* eidcache
|
||||
* fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d 2000 cache canEvict=1 transTime=0 eid=fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d
|
||||
* fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7f fffe retry canEvict=1 timeout=10 retryDelay=30
|
||||
* Done
|
||||
* @endcode
|
||||
* @par
|
||||
* Returns the EID-to-RLOC cache entries.
|
||||
* @sa otThreadGetNextCacheEntry
|
||||
*/
|
||||
template <> otError Interpreter::Process<Cmd("eidcache")>(Arg aArgs[])
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aArgs);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
otCacheEntryIterator iterator;
|
||||
otCacheEntryInfo entry;
|
||||
|
||||
ClearAllBytes(iterator);
|
||||
|
||||
while (true)
|
||||
/**
|
||||
* @cli eidcache
|
||||
* @code
|
||||
* eidcache
|
||||
* fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d 2000 cache canEvict=1 transTime=0
|
||||
* eid=fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7f fffe retry
|
||||
* canEvict=1 timeout=10 retryDelay=30 Done
|
||||
* @endcode
|
||||
* @par
|
||||
* Returns the EID-to-RLOC cache entries.
|
||||
* @sa otThreadGetNextCacheEntry
|
||||
*/
|
||||
if (aArgs[0].IsEmpty())
|
||||
{
|
||||
SuccessOrExit(otThreadGetNextCacheEntry(GetInstancePtr(), &entry, &iterator));
|
||||
OutputEidCacheEntry(entry);
|
||||
}
|
||||
otCacheEntryIterator iterator;
|
||||
otCacheEntryInfo entry;
|
||||
|
||||
ClearAllBytes(iterator);
|
||||
while (true)
|
||||
{
|
||||
SuccessOrExit(otThreadGetNextCacheEntry(GetInstancePtr(), &entry, &iterator));
|
||||
OutputEidCacheEntry(entry);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @cli eidcache clear
|
||||
* @code
|
||||
* eidcache clear
|
||||
* Done
|
||||
* @endcode
|
||||
* @par api_copy
|
||||
* #otThreadClearEidCache
|
||||
*/
|
||||
else if (aArgs[0] == "clear")
|
||||
{
|
||||
otThreadClearEidCache(GetInstancePtr());
|
||||
}
|
||||
else
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
exit:
|
||||
return OT_ERROR_NONE;
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -259,6 +259,8 @@ otError otThreadGetNextCacheEntry(otInstance *aInstance, otCacheEntryInfo *aEntr
|
||||
AsCoreType(aIterator));
|
||||
}
|
||||
|
||||
void otThreadClearEidCache(otInstance *aInstance) { AsCoreType(aInstance).Get<AddressResolver>().Clear(); }
|
||||
|
||||
#if OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE
|
||||
void otThreadSetSteeringData(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user