[cli] IPv6 counters (#6771)

Add CLI command for IPv6 packet success and failures during
transmission and reception.
This commit is contained in:
arun-mahasenan
2021-07-12 12:54:39 -07:00
committed by GitHub
parent 5d54dc2c5b
commit f86ceb43ce
3 changed files with 50 additions and 0 deletions
+9
View File
@@ -770,6 +770,7 @@ Get the supported counter names.
```bash
> counters
ip
mac
mle
Done
@@ -824,6 +825,12 @@ Partition Id Changes: 1
Better Partition Attach Attempts: 0
Parent Changes: 0
Done
> counters ip
TxSuccess: 10
TxFailed: 0
RxSuccess: 5
RxFailed: 0
Done
```
### counters \<countername\> reset
@@ -835,6 +842,8 @@ Reset the counter value.
Done
> counters mle reset
Done
> counters ip reset
Done
```
### csl
+34
View File
@@ -1117,6 +1117,7 @@ otError Interpreter::ProcessCounters(Arg aArgs[])
if (aArgs[0].IsEmpty())
{
OutputLine("ip");
OutputLine("mac");
OutputLine("mle");
}
@@ -1228,6 +1229,39 @@ otError Interpreter::ProcessCounters(Arg aArgs[])
ExitNow(error = OT_ERROR_INVALID_ARGS);
}
}
else if (aArgs[0] == "ip")
{
if (aArgs[1].IsEmpty())
{
struct IpCounterName
{
const uint32_t otIpCounters::*mValuePtr;
const char * mName;
};
static const IpCounterName kCounterNames[] = {
{&otIpCounters::mTxSuccess, "TxSuccess"},
{&otIpCounters::mTxFailure, "TxFailed"},
{&otIpCounters::mRxSuccess, "RxSuccess"},
{&otIpCounters::mRxFailure, "RxFailed"},
};
const otIpCounters *ipCounters = otThreadGetIp6Counters(mInstance);
for (const IpCounterName &counter : kCounterNames)
{
OutputLine("%s: %d", counter.mName, ipCounters->*counter.mValuePtr);
}
}
else if ((aArgs[1] == "reset") && aArgs[2].IsEmpty())
{
otThreadResetIp6Counters(mInstance);
}
else
{
ExitNow(error = OT_ERROR_INVALID_ARGS);
}
}
else
{
ExitNow(error = OT_ERROR_INVALID_ARGS);
+7
View File
@@ -34,19 +34,26 @@ spawn_node 1
send "counters\n"
expect "mac"
expect "mle"
expect "ip"
expect_line "Done"
send "counters mac\n"
expect_line "Done"
send "counters mle\n"
expect_line "Done"
send "counters ip\n"
expect_line "Done"
send "counters mac reset\n"
expect_line "Done"
send "counters mle reset\n"
expect_line "Done"
send "counters ip reset\n"
expect_line "Done"
send "counters mac 1\n"
expect "Error 7: InvalidArgs"
send "counters mle 1\n"
expect "Error 7: InvalidArgs"
send "counters ip 1\n"
expect "Error 7: InvalidArgs"
send "counters other\n"
expect "Error 7: InvalidArgs"