mirror of
https://github.com/espressif/openthread.git
synced 2026-09-09 02:30:11 +00:00
[cli] add command to retrieve mle counters (#3605)
This commit is contained in:
committed by
Jonathan Hui
parent
403f7f8109
commit
8c13df5a51
@@ -728,8 +728,13 @@ typedef struct otCommissionConfig
|
||||
// GUID - InterfaceGuid
|
||||
// uint8_t - aMaxRouterId
|
||||
|
||||
#define IOCTL_OTLWF_OT_MLE_COUNTERS \
|
||||
OTLWF_CTL_CODE(203, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otMleCounters - aCounters
|
||||
|
||||
// OpenThread function IOCTL codes
|
||||
#define MIN_OTLWF_IOCTL_FUNC_CODE 100
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 202
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 203
|
||||
|
||||
#endif //__OTLWFIOCTL_H__
|
||||
|
||||
@@ -3977,3 +3977,24 @@ otThreadSetParentPriority(
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_PRIORITY, aParentPriority));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
const otMleCounters*
|
||||
OTCALL
|
||||
otThreadGetMleCounters(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return nullptr;
|
||||
|
||||
otMleCounters* aCounters = (otMleCounters*)malloc(sizeof(otMleCounters));
|
||||
if (aCounters)
|
||||
{
|
||||
if (ERROR_SUCCESS != QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MLE_COUNTERS, aCounters))
|
||||
{
|
||||
free(aCounters);
|
||||
aCounters = nullptr;
|
||||
}
|
||||
}
|
||||
return aCounters;
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS", REF_IOCTL_FUNC(otNextMacFixedRss) },
|
||||
{ "IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_ROUTE", REF_IOCTL_FUNC(otNextRoute) },
|
||||
{ "IOCTL_OTLWF_OT_MLE_COUNTERS", REF_IOCTL_FUNC(otMleCounters) },
|
||||
};
|
||||
|
||||
// intentionally -1 in the end due to that IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY (#161) is removed now.
|
||||
@@ -6590,3 +6591,34 @@ otLwfIoCtl_otNextMacFixedRss(
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otMleCounters(
|
||||
_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(otMleCounters))
|
||||
{
|
||||
memcpy_s(OutBuffer, *OutBufferLength, otThreadGetMleCounters(pFilter->otCtx), sizeof(otMleCounters));
|
||||
*OutBufferLength = sizeof(otMleCounters);
|
||||
status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -233,5 +233,6 @@ DECL_IOCTL_FUNC_WITH_TUN(otRemoveMacFixedRss);
|
||||
DECL_IOCTL_FUNC(otNextMacFixedRss);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss);
|
||||
DECL_IOCTL_FUNC(otNextRoute);
|
||||
DECL_IOCTL_FUNC(otMleCounters);
|
||||
|
||||
#endif // _IOCONTROL_H
|
||||
|
||||
Reference in New Issue
Block a user