mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 22:37:45 +00:00
[cli] fix router table command (#2747)
This commit is contained in:
@@ -725,8 +725,13 @@ typedef struct otCommissionConfig
|
||||
// uint8_t - aNewIterator (output)
|
||||
// otExternalRouteConfig - aConfig (output)
|
||||
|
||||
#define IOCTL_OTLWF_OT_MAX_ROUTER_ID \
|
||||
OTLWF_CTL_CODE(202, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// uint8_t - aMaxRouterId
|
||||
|
||||
// OpenThread function IOCTL codes
|
||||
#define MIN_OTLWF_IOCTL_FUNC_CODE 100
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 201
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 202
|
||||
|
||||
#endif //__OTLWFIOCTL_H__
|
||||
|
||||
@@ -3205,6 +3205,18 @@ otThreadGetRouterIdSequence(
|
||||
return Result;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
uint8_t
|
||||
OTCALL
|
||||
otThreadGetMaxRouterId(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
uint8_t Result = 0;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_ROUTER_ID, &Result);
|
||||
return Result;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
|
||||
@@ -95,6 +95,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_PARTITION_ID", REF_IOCTL_FUNC_WITH_TUN(otPartitionId) },
|
||||
{ "IOCTL_OTLWF_OT_RLOC16", REF_IOCTL_FUNC_WITH_TUN(otRloc16) },
|
||||
{ "IOCTL_OTLWF_OT_ROUTER_ID_SEQUENCE", REF_IOCTL_FUNC(otRouterIdSequence) },
|
||||
{ "IOCTL_OTLWF_OT_MAX_ROUTER_ID", REF_IOCTL_FUNC(otMaxRouterId) },
|
||||
{ "IOCTL_OTLWF_OT_ROUTER_INFO", REF_IOCTL_FUNC(otRouterInfo) },
|
||||
{ "IOCTL_OTLWF_OT_STABLE_NETWORK_DATA_VERSION", REF_IOCTL_FUNC_WITH_TUN(otStableNetworkDataVersion) },
|
||||
{ "IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED", REF_IOCTL_FUNC(otMacBlacklistEnabled) },
|
||||
@@ -4509,6 +4510,37 @@ otLwfIoCtl_otRouterIdSequence(
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otMaxRouterId(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
_In_ ULONG InBufferLength,
|
||||
_Out_writes_bytes_(*OutBufferLength)
|
||||
PVOID OutBuffer,
|
||||
_Inout_ PULONG OutBufferLength
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
UNREFERENCED_PARAMETER(InBuffer);
|
||||
UNREFERENCED_PARAMETER(InBufferLength);
|
||||
|
||||
if (*OutBufferLength >= sizeof(uint8_t))
|
||||
{
|
||||
*(uint8_t*)OutBuffer = otThreadGetMaxRouterId(pFilter->otCtx);
|
||||
*OutBufferLength = sizeof(uint8_t);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otRouterInfo(
|
||||
|
||||
@@ -181,6 +181,7 @@ DECL_IOCTL_FUNC_WITH_TUN2(otNetworkDataVersion);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otPartitionId);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otRloc16);
|
||||
DECL_IOCTL_FUNC(otRouterIdSequence);
|
||||
DECL_IOCTL_FUNC(otMaxRouterId);
|
||||
DECL_IOCTL_FUNC(otRouterInfo);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otStableNetworkDataVersion);
|
||||
DECL_IOCTL_FUNC(otMacBlacklistEnabled);
|
||||
|
||||
@@ -406,7 +406,7 @@ OTAPI uint8_t OTCALL otThreadGetRouterIdSequence(otInstance *aInstance);
|
||||
* @returns The maximum allowed router ID.
|
||||
*
|
||||
*/
|
||||
uint8_t otThreadGetMaxRouterId(otInstance *aInstance);
|
||||
OTAPI uint8_t OTCALL otThreadGetMaxRouterId(otInstance *aInstance);
|
||||
|
||||
/**
|
||||
* The function retains diagnostic information for a given Thread Router.
|
||||
|
||||
+26
-23
@@ -2333,6 +2333,8 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
|
||||
if (isTable || strcmp(argv[0], "list") == 0)
|
||||
{
|
||||
uint8_t maxRouterId;
|
||||
|
||||
if (isTable)
|
||||
{
|
||||
mServer->OutputFormat(
|
||||
@@ -2341,40 +2343,41 @@ void Interpreter::ProcessRouter(int argc, char *argv[])
|
||||
"+----+--------+----------+-----------+-------+--------+-----+------------------+\r\n");
|
||||
}
|
||||
|
||||
for (uint8_t i = 0;; i++)
|
||||
maxRouterId = otThreadGetMaxRouterId(mInstance);
|
||||
|
||||
for (uint8_t i = 0; i <= maxRouterId; i++)
|
||||
{
|
||||
if (otThreadGetRouterInfo(mInstance, i, &routerInfo) != OT_ERROR_NONE)
|
||||
{
|
||||
mServer->OutputFormat("\r\n");
|
||||
ExitNow();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (routerInfo.mAllocated)
|
||||
if (isTable)
|
||||
{
|
||||
if (isTable)
|
||||
{
|
||||
mServer->OutputFormat("| %2d ", routerInfo.mRouterId);
|
||||
mServer->OutputFormat("| 0x%04x ", routerInfo.mRloc16);
|
||||
mServer->OutputFormat("| %8d ", routerInfo.mNextHop);
|
||||
mServer->OutputFormat("| %9d ", routerInfo.mPathCost);
|
||||
mServer->OutputFormat("| %5d ", routerInfo.mLinkQualityIn);
|
||||
mServer->OutputFormat("| %6d ", routerInfo.mLinkQualityOut);
|
||||
mServer->OutputFormat("| %3d ", routerInfo.mAge);
|
||||
mServer->OutputFormat("| ");
|
||||
mServer->OutputFormat("| %2d ", routerInfo.mRouterId);
|
||||
mServer->OutputFormat("| 0x%04x ", routerInfo.mRloc16);
|
||||
mServer->OutputFormat("| %8d ", routerInfo.mNextHop);
|
||||
mServer->OutputFormat("| %9d ", routerInfo.mPathCost);
|
||||
mServer->OutputFormat("| %5d ", routerInfo.mLinkQualityIn);
|
||||
mServer->OutputFormat("| %6d ", routerInfo.mLinkQualityOut);
|
||||
mServer->OutputFormat("| %3d ", routerInfo.mAge);
|
||||
mServer->OutputFormat("| ");
|
||||
|
||||
for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++)
|
||||
{
|
||||
mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]);
|
||||
}
|
||||
|
||||
mServer->OutputFormat(" |\r\n");
|
||||
}
|
||||
else
|
||||
for (size_t j = 0; j < sizeof(routerInfo.mExtAddress); j++)
|
||||
{
|
||||
mServer->OutputFormat("%d ", i);
|
||||
mServer->OutputFormat("%02x", routerInfo.mExtAddress.m8[j]);
|
||||
}
|
||||
|
||||
mServer->OutputFormat(" |\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
mServer->OutputFormat("%d ", i);
|
||||
}
|
||||
}
|
||||
|
||||
mServer->OutputFormat("\r\n");
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
|
||||
Reference in New Issue
Block a user