mirror of
https://github.com/espressif/openthread.git
synced 2026-08-17 07:59:51 +00:00
[cli] add more output to eidcache command (#6408)
This commit is contained in:
+2
-2
@@ -1071,8 +1071,8 @@ Print the EID-to-RLOC cache entries.
|
||||
|
||||
```bash
|
||||
> eidcache
|
||||
fdde:ad00:beef:0:bb1:ebd6:ad10:f33 ac00
|
||||
fdde:ad00:beef:0:110a:e041:8399:17cd 6000
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
+41
-3
@@ -1630,6 +1630,46 @@ void Interpreter::HandleDnsServiceResponse(otError aError, const otDnsServiceRes
|
||||
#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
|
||||
|
||||
#if OPENTHREAD_FTD
|
||||
const char *EidCacheStateToString(otCacheEntryState aState)
|
||||
{
|
||||
static const char *const kStateStrings[4] = {
|
||||
"cache",
|
||||
"snoop",
|
||||
"query",
|
||||
"retry",
|
||||
};
|
||||
|
||||
return static_cast<uint8_t>(aState) < OT_ARRAY_LENGTH(kStateStrings) ? kStateStrings[aState] : "unknown";
|
||||
}
|
||||
|
||||
void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry)
|
||||
{
|
||||
OutputIp6Address(aEntry.mTarget);
|
||||
OutputFormat(" %04x", aEntry.mRloc16);
|
||||
OutputFormat(" %s", EidCacheStateToString(aEntry.mState));
|
||||
OutputFormat(" canEvict=%d", aEntry.mCanEvict);
|
||||
|
||||
if (aEntry.mState == OT_CACHE_ENTRY_STATE_CACHED)
|
||||
{
|
||||
if (aEntry.mValidLastTrans)
|
||||
{
|
||||
OutputFormat(" transTime=%u eid=", aEntry.mLastTransTime);
|
||||
OutputIp6Address(aEntry.mMeshLocalEid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputFormat(" timeout=%u", aEntry.mTimeout);
|
||||
}
|
||||
|
||||
if (aEntry.mState == OT_CACHE_ENTRY_STATE_RETRY_QUERY)
|
||||
{
|
||||
OutputFormat(" retryDelay=%u", aEntry.mRetryDelay);
|
||||
}
|
||||
|
||||
OutputLine("");
|
||||
}
|
||||
|
||||
otError Interpreter::ProcessEidCache(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aArgsLength);
|
||||
@@ -1643,9 +1683,7 @@ otError Interpreter::ProcessEidCache(uint8_t aArgsLength, char *aArgs[])
|
||||
for (uint8_t i = 0;; i++)
|
||||
{
|
||||
SuccessOrExit(otThreadGetNextCacheEntry(mInstance, &entry, &iterator));
|
||||
|
||||
OutputIp6Address(entry.mTarget);
|
||||
OutputLine(" %04x", entry.mRloc16);
|
||||
OutputEidCacheEntry(entry);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
||||
@@ -376,6 +376,7 @@ private:
|
||||
otError ProcessDiscover(uint8_t aArgsLength, char *aArgs[]);
|
||||
otError ProcessDns(uint8_t aArgsLength, char *aArgs[]);
|
||||
#if OPENTHREAD_FTD
|
||||
void OutputEidCacheEntry(const otCacheEntryInfo &aEntry);
|
||||
otError ProcessEidCache(uint8_t aArgsLength, char *aArgs[]);
|
||||
#endif
|
||||
otError ProcessEui64(uint8_t aArgsLength, char *aArgs[]);
|
||||
|
||||
@@ -1681,7 +1681,7 @@ class OTCI(object):
|
||||
cache = {}
|
||||
|
||||
for line in output:
|
||||
ip, rloc16 = line.split()
|
||||
ip, rloc16, _ = line.split(" ", 2)
|
||||
|
||||
cache[Ip6Addr(ip)] = Rloc16(rloc16, 16)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user