mirror of
https://github.com/espressif/openthread.git
synced 2026-08-22 18:39:50 +00:00
[mac filter] add rssfilter support and integrate whitelist/blacklist to AddressFilter (#1967)
* [mac filter] add rssfilter support and integrate whitelist/blacklist - provide RssIn filter function to fix the received signal strength for test purpose. - provide Address filter function which integrates whitelist and blacklist, save (~300B) RAM. - update cli and spinel-cli to reflect new otLinkFilterX() APIs. - keep whitelist/blacklist spinel properties the same as before while implemented with new otLinkFilterX() APIs. - THCI: add setOutBoundLinkQuality() API for DEV-1530 - THCI: update Allow/Block relative APIs - update some test scripts due to new OT_ERROR_ALEADY when adding duplicate address to whitelist * update for comments * add MAC_FIXED_RSS spinel property * rebase and apply new OutboundFrameBegin(aHeader) * update OpenThread.py
This commit is contained in:
@@ -350,11 +350,12 @@ typedef enum _OTLWF_NOTIF_TYPE
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aExtAddr
|
||||
|
||||
#define IOCTL_OTLWF_OT_MAC_WHITELIST_ENTRY \
|
||||
#define IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST \
|
||||
OTLWF_CTL_CODE(137, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// uint8_t - aIndex (input)
|
||||
// otMacWhitelistEntry - aEntry (output)
|
||||
// uint8_t - aIterator (input)
|
||||
// uint8_t - aNewIterator (output)
|
||||
// otMacFilterEntry - aEntry (output)
|
||||
|
||||
#define IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST \
|
||||
OTLWF_CTL_CODE(138, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
@@ -445,11 +446,12 @@ typedef enum _OTLWF_NOTIF_TYPE
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aExtAddr
|
||||
|
||||
#define IOCTL_OTLWF_OT_MAC_BLACKLIST_ENTRY \
|
||||
#define IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST \
|
||||
OTLWF_CTL_CODE(155, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// uint8_t - aIndex (input)
|
||||
// otMacBlacklistEntry - aEntry (output)
|
||||
// uint8_t - aIterator (input)
|
||||
// uint8_t - aNewIterator (output)
|
||||
// otMacFilterEntry - aEntry (output)
|
||||
|
||||
#define IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST \
|
||||
OTLWF_CTL_CODE(156, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
@@ -478,12 +480,6 @@ typedef enum _OTLWF_NOTIF_TYPE
|
||||
// GUID - InterfaceGuid
|
||||
// uint32_t - aPartitionId
|
||||
|
||||
#define IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY \
|
||||
OTLWF_CTL_CODE(161, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aExtAddr (input)
|
||||
// uint8_t - aLinkQuality (input or output)
|
||||
|
||||
#define IOCTL_OTLWF_OT_PLATFORM_RESET \
|
||||
OTLWF_CTL_CODE(162, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
@@ -699,8 +695,30 @@ typedef struct otCommissionConfig
|
||||
// GUID - InterfaceGuid
|
||||
// int8_t - aParentPriority
|
||||
|
||||
#define IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS \
|
||||
OTLWF_CTL_CODE(197, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aExtAddr (optional)
|
||||
// int8_t - aRssi
|
||||
|
||||
#define IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS \
|
||||
OTLWF_CTL_CODE(198, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// otExtAddress - aExtAddr (optional)
|
||||
|
||||
#define IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS \
|
||||
OTLWF_CTL_CODE(199, METHOD_BUFFERED, FILE_READ_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
// uint8_t - aIterator (input)
|
||||
// uint8_t - aNewIterator (output)
|
||||
// otMacFilterEntry - aEntry (output)
|
||||
|
||||
#define IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS \
|
||||
OTLWF_CTL_CODE(200, METHOD_BUFFERED, FILE_WRITE_DATA)
|
||||
// GUID - InterfaceGuid
|
||||
|
||||
// OpenThread function IOCTL codes
|
||||
#define MIN_OTLWF_IOCTL_FUNC_CODE 100
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 196
|
||||
#define MAX_OTLWF_IOCTL_FUNC_CODE 200
|
||||
|
||||
#endif //__OTLWFIOCTL_H__
|
||||
|
||||
@@ -2731,90 +2731,6 @@ otThreadReleaseRouterId(
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_RELEASE_ROUTER_ID, aRouterId));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkAddWhitelist(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_MAC_WHITELIST, (const otExtAddress*)aExtAddr));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkAddWhitelistRssi(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr,
|
||||
int8_t aRssi
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
|
||||
PackedBuffer3<GUID,otExtAddress,int8_t> Buffer(aInstance->InterfaceGuid, *(otExtAddress*)aExtAddr, aRssi);
|
||||
return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ADD_MAC_WHITELIST, &Buffer, sizeof(Buffer), nullptr, 0));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkRemoveWhitelist(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST, (const otExtAddress*)aExtAddr);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkGetWhitelistEntry(
|
||||
_In_ otInstance *aInstance,
|
||||
uint8_t aIndex,
|
||||
_Out_ otMacWhitelistEntry *aEntry
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENTRY, &aIndex, aEntry));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkClearWhitelist(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkSetWhitelistEnabled(
|
||||
_In_ otInstance *aInstance,
|
||||
bool aEnabled
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, (BOOLEAN)aEnabled);
|
||||
}
|
||||
|
||||
OTAPI
|
||||
bool
|
||||
OTCALL
|
||||
otLinkIsWhitelistEnabled(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
BOOLEAN Result = 0;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, &Result);
|
||||
return Result != FALSE;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
@@ -2860,99 +2776,262 @@ otThreadBecomeLeader(
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
otMacFilterAddressMode
|
||||
OTCALL
|
||||
otLinkAddBlacklist(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr
|
||||
otLinkFilterGetAddressMode(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST, (const otExtAddress*)aExtAddr));
|
||||
}
|
||||
otMacFilterAddressMode mode = OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
|
||||
BOOLEAN enabled = 0;
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkRemoveBlacklist(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST, (const otExtAddress*)aExtAddr);
|
||||
if (aInstance)
|
||||
{
|
||||
(void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, &enabled);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
mode = OT_MAC_FILTER_ADDRESS_MODE_WHITELIST;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, &enabled);
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
mode = OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkGetBlacklistEntry(
|
||||
_In_ otInstance *aInstance,
|
||||
uint8_t aIndex,
|
||||
_Out_ otMacBlacklistEntry *aEntry
|
||||
otLinkFilterSetAddressMode(
|
||||
_In_ otInstance *aInstance,
|
||||
otMacFilterAddressMode aMode
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENTRY, &aIndex, aEntry));
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool enabled = false;
|
||||
|
||||
if (aMode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST)
|
||||
{
|
||||
enabled = true;
|
||||
error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, (BOOLEAN)enabled));
|
||||
}
|
||||
else if (aMode == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST)
|
||||
{
|
||||
enabled = true;
|
||||
error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, (BOOLEAN)enabled));
|
||||
}
|
||||
else
|
||||
{
|
||||
error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, (BOOLEAN)enabled));
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
otError
|
||||
OTCALL
|
||||
otLinkClearBlacklist(
|
||||
otLinkFilterAddAddress(
|
||||
_In_ otInstance *aInstance,
|
||||
const otExtAddress *aExtAddr
|
||||
)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr || aExtAddr == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// same effect to add an address to the address filter with IOCTL_OTLWF_OT_ADD_MAC_WHITELIST or
|
||||
// IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST.
|
||||
error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_MAC_WHITELIST, aExtAddr));
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkFilterRemoveAddress(
|
||||
_In_ otInstance *aInstance,
|
||||
const otExtAddress *aExtAddr
|
||||
)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr || aExtAddr == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// same effect to remove an address from the address filter with IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST or
|
||||
// IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST.
|
||||
error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST, aExtAddr));
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkFilterClearAddresses(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST);
|
||||
if (aInstance)
|
||||
{
|
||||
// same effect to clear the addresses from the address filter with IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST or
|
||||
// IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST.
|
||||
(void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST);
|
||||
}
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
otError
|
||||
OTCALL
|
||||
otLinkSetBlacklistEnabled(
|
||||
otLinkFilterGetNextAddress(
|
||||
_In_ otInstance *aInstance,
|
||||
bool aEnabled
|
||||
_Inout_ otMacFilterIterator *aIterator,
|
||||
_Out_ otMacFilterEntry *aEntry
|
||||
)
|
||||
{
|
||||
if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, (BOOLEAN)aEnabled);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr || aIterator == nullptr|| aEntry == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// same effect to get an in-use address filter entry with IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST or
|
||||
// IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST.
|
||||
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST, aIterator, aEntry));
|
||||
}
|
||||
return OT_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkFilterAddRssIn(
|
||||
_In_ otInstance *aInstance,
|
||||
const otExtAddress *aExtAddr,
|
||||
int8_t aRss
|
||||
)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aExtAddr == nullptr)
|
||||
{
|
||||
PackedBuffer2<GUID,int8_t> Buffer(aInstance->InterfaceGuid, aRss);
|
||||
|
||||
error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS,
|
||||
&Buffer, sizeof(Buffer), nullptr, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
PackedBuffer3<GUID,otExtAddress,int8_t> Buffer(aInstance->InterfaceGuid, *aExtAddr, aRss);
|
||||
|
||||
error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS,
|
||||
&Buffer, sizeof(Buffer), nullptr, 0));
|
||||
}
|
||||
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
bool
|
||||
otError
|
||||
OTCALL
|
||||
otLinkIsBlacklistEnabled(
|
||||
otLinkFilterRemoveRssIn(
|
||||
_In_ otInstance *aInstance,
|
||||
const otExtAddress *aExtAddr
|
||||
)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aExtAddr == nullptr)
|
||||
{
|
||||
error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS,
|
||||
nullptr, 0, nullptr, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
PackedBuffer2<GUID,otExtAddress> Buffer(aInstance->InterfaceGuid, *aExtAddr);
|
||||
error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS,
|
||||
&Buffer, sizeof(Buffer), nullptr, 0));
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkFilterClearRssIn(
|
||||
_In_ otInstance *aInstance
|
||||
)
|
||||
{
|
||||
BOOLEAN Result = 0;
|
||||
if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, &Result);
|
||||
return Result != FALSE;
|
||||
if (aInstance)
|
||||
{
|
||||
(void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS);
|
||||
}
|
||||
}
|
||||
|
||||
OTAPI
|
||||
otError
|
||||
OTAPI
|
||||
otError
|
||||
OTCALL
|
||||
otLinkGetAssignLinkQuality(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr,
|
||||
_Out_ uint8_t *aLinkQuality
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
|
||||
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY, (otExtAddress*)aExtAddr, aLinkQuality));
|
||||
}
|
||||
|
||||
OTAPI
|
||||
void
|
||||
OTCALL
|
||||
otLinkSetAssignLinkQuality(
|
||||
otLinkFilterGetNextRssIn(
|
||||
_In_ otInstance *aInstance,
|
||||
const uint8_t *aExtAddr,
|
||||
uint8_t aLinkQuality
|
||||
_Inout_ otMacFilterIterator *aIterator,
|
||||
_Out_ otMacFilterEntry *aEntry
|
||||
)
|
||||
{
|
||||
if (aInstance == nullptr) return;
|
||||
PackedBuffer3<GUID,otExtAddress,uint8_t> Buffer(aInstance->InterfaceGuid, *(otExtAddress*)aExtAddr, aLinkQuality);
|
||||
(void)SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY, &Buffer, sizeof(Buffer), nullptr, 0);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
if (aInstance == nullptr || aIterator == nullptr|| aEntry == nullptr)
|
||||
{
|
||||
error = OT_ERROR_INVALID_ARGS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS, aIterator, aEntry));
|
||||
}
|
||||
return OT_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
OTAPI
|
||||
|
||||
@@ -82,7 +82,7 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED", REF_IOCTL_FUNC_WITH_TUN(otMacWhitelistEnabled) },
|
||||
{ "IOCTL_OTLWF_OT_ADD_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otAddMacWhitelist) },
|
||||
{ "IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otRemoveMacWhitelist) },
|
||||
{ "IOCTL_OTLWF_OT_MAC_WHITELIST_ENTRY", REF_IOCTL_FUNC(otMacWhitelistEntry) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST", REF_IOCTL_FUNC(otNextMacWhitelist) },
|
||||
{ "IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otClearMacWhitelist) },
|
||||
{ "IOCTL_OTLWF_OT_DEVICE_ROLE", REF_IOCTL_FUNC_WITH_TUN(otDeviceRole) },
|
||||
{ "IOCTL_OTLWF_OT_CHILD_INFO_BY_ID", REF_IOCTL_FUNC(otChildInfoById) },
|
||||
@@ -100,13 +100,12 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED", REF_IOCTL_FUNC(otMacBlacklistEnabled) },
|
||||
{ "IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST", REF_IOCTL_FUNC(otAddMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST", REF_IOCTL_FUNC(otRemoveMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_MAC_BLACKLIST_ENTRY", REF_IOCTL_FUNC(otMacBlacklistEntry) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST", REF_IOCTL_FUNC(otNextMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST", REF_IOCTL_FUNC(otClearMacBlacklist) },
|
||||
{ "IOCTL_OTLWF_OT_MAX_TRANSMIT_POWER", REF_IOCTL_FUNC(otMaxTransmitPower) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX", REF_IOCTL_FUNC(otNextOnMeshPrefix) },
|
||||
{ "IOCTL_OTLWF_OT_POLL_PERIOD", REF_IOCTL_FUNC(otPollPeriod) },
|
||||
{ "IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID", REF_IOCTL_FUNC(otLocalLeaderPartitionId) },
|
||||
{ "IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY", REF_IOCTL_FUNC(otAssignLinkQuality) },
|
||||
{ "IOCTL_OTLWF_OT_PLATFORM_RESET", REF_IOCTL_FUNC_WITH_TUN(otPlatformReset) },
|
||||
{ "IOCTL_OTLWF_OT_PARENT_INFO", REF_IOCTL_FUNC_WITH_TUN(otParentInfo) },
|
||||
{ "IOCTL_OTLWF_OT_SINGLETON", REF_IOCTL_FUNC(otSingleton) },
|
||||
@@ -142,9 +141,14 @@ OTLWF_IOCTL_HANDLER IoCtls[] =
|
||||
{ "IOCTL_OTLWF_OT_PREFERRED_ROUTER_ID", REF_IOCTL_FUNC(otThreadPreferredRouterId) },
|
||||
{ "IOCTL_OTLWF_OT_PSKC", REF_IOCTL_FUNC_WITH_TUN(otPSKc) },
|
||||
{ "IOCTL_OTLWF_OT_PARENT_PRIORITY", REF_IOCTL_FUNC(otParentPriority) },
|
||||
{ "IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otAddMacFixedRss) },
|
||||
{ "IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otRemoveMacFixedRss) },
|
||||
{ "IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS", REF_IOCTL_FUNC(otNextMacFixedRss) },
|
||||
{ "IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss) },
|
||||
};
|
||||
|
||||
static_assert(ARRAYSIZE(IoCtls) == (MAX_OTLWF_IOCTL_FUNC_CODE - MIN_OTLWF_IOCTL_FUNC_CODE) + 1,
|
||||
// intentionally -1 in the end due to that IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY (#161) is removed now.
|
||||
static_assert(ARRAYSIZE(IoCtls) == (MAX_OTLWF_IOCTL_FUNC_CODE - MIN_OTLWF_IOCTL_FUNC_CODE) + 1 - 1,
|
||||
"The IoCtl strings should be up to date with the actual IoCtl list.");
|
||||
|
||||
const char*
|
||||
@@ -3440,13 +3444,15 @@ otLwfIoCtl_otMacWhitelistEnabled(
|
||||
if (InBufferLength >= sizeof(BOOLEAN))
|
||||
{
|
||||
BOOLEAN aEnabled = *(BOOLEAN*)InBuffer;
|
||||
otLinkSetWhitelistEnabled(pFilter->otCtx, aEnabled);
|
||||
status = STATUS_SUCCESS;
|
||||
otMacFilterAddressMode mode =
|
||||
aEnabled ? OT_MAC_FILTER_ADDRESS_MODE_WHITELIST : OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
|
||||
status = ThreadErrorToNtstatus(otLinkFilterSetAddressMode(pFilter->otCtx, mode));
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(BOOLEAN))
|
||||
{
|
||||
*(BOOLEAN*)OutBuffer = otLinkIsWhitelistEnabled(pFilter->otCtx) ? TRUE : FALSE;
|
||||
otMacFilterAddressMode mode = otLinkFilterGetAddressMode(pFilter->otCtx);
|
||||
*(BOOLEAN*)OutBuffer = (mode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST) ? TRUE : FALSE;
|
||||
status = STATUS_SUCCESS;
|
||||
*OutBufferLength = sizeof(BOOLEAN);
|
||||
}
|
||||
@@ -3536,25 +3542,29 @@ otLwfIoCtl_otAddMacWhitelist(
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
UNREFERENCED_PARAMETER(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
|
||||
{
|
||||
int8_t aRssi = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
status = ThreadErrorToNtstatus(otLinkAddWhitelistRssi(pFilter->otCtx, (uint8_t*)InBuffer, aRssi));
|
||||
aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
}
|
||||
else if (InBufferLength >= sizeof(otExtAddress))
|
||||
|
||||
otError error = otLinkFilterAddAddress(pFilter->otCtx, (otExtAddress *)InBuffer);
|
||||
|
||||
if ((error == OT_ERROR_NONE || error == OT_ERROR_ALREADY) &&
|
||||
(aRss != OT_MAC_FILTER_FIXED_RSS_DISABLED))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otLinkAddWhitelist(pFilter->otCtx, (uint8_t*)InBuffer));
|
||||
|
||||
error = otLinkFilterAddRssIn(pFilter->otCtx, (otExtAddress *)InBuffer, aRss);
|
||||
}
|
||||
|
||||
status = ThreadErrorToNtstatus(error);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#define RSSI_OVERRIDE_DISABLED 127 // Used for PROP_MAC_WHITELIST
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfTunIoCtl_otAddMacWhitelist(
|
||||
@@ -3572,10 +3582,10 @@ otLwfTunIoCtl_otAddMacWhitelist(
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
int8_t aRssi = RSSI_OVERRIDE_DISABLED;
|
||||
int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
|
||||
if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
|
||||
{
|
||||
aRssi = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
}
|
||||
|
||||
status =
|
||||
@@ -3588,7 +3598,7 @@ otLwfTunIoCtl_otAddMacWhitelist(
|
||||
sizeof(otExtAddress) + sizeof(int8_t),
|
||||
"Ec",
|
||||
(otExtAddress*)InBuffer,
|
||||
&aRssi);
|
||||
&aRss);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -3613,8 +3623,8 @@ otLwfIoCtl_otRemoveMacWhitelist(
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
otLinkRemoveWhitelist(pFilter->otCtx, (uint8_t*)InBuffer);
|
||||
status = STATUS_SUCCESS;
|
||||
status = ThreadErrorToNtstatus(otLinkFilterRemoveAddress(pFilter->otCtx,
|
||||
(otExtAddress *)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -3654,7 +3664,7 @@ otLwfTunIoCtl_otRemoveMacWhitelist(
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otMacWhitelistEntry(
|
||||
otLwfIoCtl_otNextMacWhitelist(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
@@ -3667,15 +3677,25 @@ otLwfIoCtl_otMacWhitelistEntry(
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (InBufferLength >= sizeof(uint8_t) &&
|
||||
*OutBufferLength >= sizeof(otMacWhitelistEntry))
|
||||
*OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
|
||||
{
|
||||
uint8_t aIterator = *(uint8_t*)(InBuffer);
|
||||
otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
|
||||
|
||||
status = ThreadErrorToNtstatus(
|
||||
otLinkGetWhitelistEntry(
|
||||
otLinkFilterGetNextAddress(
|
||||
pFilter->otCtx,
|
||||
*(uint8_t*)InBuffer,
|
||||
(otMacWhitelistEntry*)OutBuffer)
|
||||
&aIterator,
|
||||
aEntry
|
||||
)
|
||||
);
|
||||
*OutBufferLength = sizeof(otMacWhitelistEntry);
|
||||
|
||||
*OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
*(uint8_t*)OutBuffer = aIterator;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3704,7 +3724,7 @@ otLwfIoCtl_otClearMacWhitelist(
|
||||
UNREFERENCED_PARAMETER(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
otLinkClearWhitelist(pFilter->otCtx);
|
||||
otLinkFilterClearAddresses(pFilter->otCtx);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -4625,13 +4645,15 @@ otLwfIoCtl_otMacBlacklistEnabled(
|
||||
if (InBufferLength >= sizeof(BOOLEAN))
|
||||
{
|
||||
BOOLEAN aEnabled = *(BOOLEAN*)InBuffer;
|
||||
otLinkSetBlacklistEnabled(pFilter->otCtx, aEnabled);
|
||||
status = STATUS_SUCCESS;
|
||||
otMacFilterAddressMode mode =
|
||||
aEnabled ? OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST : OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
|
||||
status = ThreadErrorToNtstatus(otLinkFilterSetAddressMode(pFilter->otCtx, mode));
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (*OutBufferLength >= sizeof(BOOLEAN))
|
||||
{
|
||||
*(BOOLEAN*)OutBuffer = otLinkIsBlacklistEnabled(pFilter->otCtx) ? TRUE : FALSE;
|
||||
otMacFilterAddressMode mode = otLinkFilterGetAddressMode(pFilter->otCtx);
|
||||
*(BOOLEAN*)OutBuffer = mode == (OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST) ? TRUE : FALSE;
|
||||
status = STATUS_SUCCESS;
|
||||
*OutBufferLength = sizeof(BOOLEAN);
|
||||
}
|
||||
@@ -4662,7 +4684,8 @@ otLwfIoCtl_otAddMacBlacklist(
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otLinkAddBlacklist(pFilter->otCtx, (uint8_t*)InBuffer));
|
||||
status = ThreadErrorToNtstatus(otLinkFilterAddAddress(pFilter->otCtx,
|
||||
(otExtAddress *)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -4687,8 +4710,8 @@ otLwfIoCtl_otRemoveMacBlacklist(
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
otLinkRemoveBlacklist(pFilter->otCtx, (uint8_t*)InBuffer);
|
||||
status = STATUS_SUCCESS;
|
||||
status = ThreadErrorToNtstatus(otLinkFilterRemoveAddress(pFilter->otCtx,
|
||||
(otExtAddress *)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -4696,7 +4719,7 @@ otLwfIoCtl_otRemoveMacBlacklist(
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otMacBlacklistEntry(
|
||||
otLwfIoCtl_otNextMacBlacklist(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
@@ -4709,16 +4732,27 @@ otLwfIoCtl_otMacBlacklistEntry(
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (InBufferLength >= sizeof(uint8_t) &&
|
||||
*OutBufferLength >= sizeof(otMacBlacklistEntry))
|
||||
*OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
|
||||
{
|
||||
uint8_t aIterator = *(uint8_t*)(InBuffer);
|
||||
otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
|
||||
|
||||
status = ThreadErrorToNtstatus(
|
||||
otLinkGetBlacklistEntry(
|
||||
otLinkFilterGetNextAddress(
|
||||
pFilter->otCtx,
|
||||
*(uint8_t*)InBuffer,
|
||||
(otMacBlacklistEntry*)OutBuffer)
|
||||
&aIterator,
|
||||
aEntry
|
||||
)
|
||||
);
|
||||
*OutBufferLength = sizeof(otMacBlacklistEntry);
|
||||
|
||||
*OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
*(uint8_t*)OutBuffer = aIterator;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
@@ -4746,7 +4780,7 @@ otLwfIoCtl_otClearMacBlacklist(
|
||||
UNREFERENCED_PARAMETER(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
otLinkClearBlacklist(pFilter->otCtx);
|
||||
otLinkFilterClearAddresses(pFilter->otCtx);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -4905,48 +4939,6 @@ otLwfIoCtl_otLocalLeaderPartitionId(
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otAssignLinkQuality(
|
||||
_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;
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress) + sizeof(uint8_t))
|
||||
{
|
||||
otLinkSetAssignLinkQuality(
|
||||
pFilter->otCtx,
|
||||
(uint8_t*)InBuffer,
|
||||
*(uint8_t*)(InBuffer + sizeof(otExtAddress)));
|
||||
status = STATUS_SUCCESS;
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
else if (InBufferLength >= sizeof(otExtAddress) &&
|
||||
*OutBufferLength >= sizeof(uint8_t))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(
|
||||
otLinkGetAssignLinkQuality(
|
||||
pFilter->otCtx,
|
||||
(uint8_t*)InBuffer,
|
||||
(uint8_t*)OutBuffer)
|
||||
);
|
||||
*OutBufferLength = sizeof(uint32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otPlatformReset(
|
||||
@@ -6261,3 +6253,253 @@ otLwfIoCtl_otParentPriority(
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otAddMacFixedRss(
|
||||
_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(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
|
||||
{
|
||||
int8_t aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
status = ThreadErrorToNtstatus(otLinkFilterAddRssIn(pFilter->otCtx,
|
||||
(otExtAddress *)InBuffer, aRss));
|
||||
}
|
||||
else if (InBufferLength >= sizeof(int8_t))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otLinkFilterAddRssIn(pFilter->otCtx, NULL,
|
||||
*(int8_t *)InBuffer));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfTunIoCtl_otAddMacFixedRss(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_ PIRP pIrp,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
_In_ ULONG InBufferLength,
|
||||
_In_ ULONG OutBufferLength
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
UNREFERENCED_PARAMETER(OutBufferLength);
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
|
||||
{
|
||||
int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
|
||||
aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
|
||||
status =
|
||||
otLwfTunSendCommandForIrp(
|
||||
pFilter,
|
||||
pIrp,
|
||||
NULL,
|
||||
SPINEL_CMD_PROP_VALUE_INSERT,
|
||||
SPINEL_PROP_MAC_FIXED_RSS,
|
||||
sizeof(otExtAddress) + sizeof(int8_t),
|
||||
"Ec",
|
||||
(otExtAddress*)InBuffer,
|
||||
&aRss);
|
||||
}
|
||||
else
|
||||
{
|
||||
status =
|
||||
otLwfTunSendCommandForIrp(
|
||||
pFilter,
|
||||
pIrp,
|
||||
NULL,
|
||||
SPINEL_CMD_PROP_VALUE_INSERT,
|
||||
SPINEL_PROP_MAC_FIXED_RSS,
|
||||
sizeof(int8_t),
|
||||
"c",
|
||||
(int8_t*)InBuffer);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otRemoveMacFixedRss(
|
||||
_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(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otLinkFilterRemoveRssIn(pFilter->otCtx, (otExtAddress *)InBuffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
status = ThreadErrorToNtstatus(otLinkFilterRemoveRssIn(pFilter->otCtx, NULL));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfTunIoCtl_otRemoveMacFixedRss(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_ PIRP pIrp,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
_In_ ULONG InBufferLength,
|
||||
_In_ ULONG OutBufferLength
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
UNREFERENCED_PARAMETER(OutBufferLength);
|
||||
|
||||
if (InBufferLength >= sizeof(otExtAddress))
|
||||
{
|
||||
status =
|
||||
otLwfTunSendCommandForIrp(
|
||||
pFilter,
|
||||
pIrp,
|
||||
NULL,
|
||||
SPINEL_CMD_PROP_VALUE_REMOVE,
|
||||
SPINEL_PROP_MAC_FIXED_RSS,
|
||||
sizeof(otExtAddress),
|
||||
"E",
|
||||
(otExtAddress*)InBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
status =
|
||||
otLwfTunSendCommandForIrp(
|
||||
pFilter,
|
||||
pIrp,
|
||||
NULL,
|
||||
SPINEL_CMD_PROP_VALUE_REMOVE,
|
||||
SPINEL_PROP_MAC_FIXED_RSS,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otClearMacFixedRss(
|
||||
_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_SUCCESS;
|
||||
|
||||
UNREFERENCED_PARAMETER(InBuffer);
|
||||
UNREFERENCED_PARAMETER(InBufferLength);
|
||||
UNREFERENCED_PARAMETER(OutBuffer);
|
||||
*OutBufferLength = 0;
|
||||
|
||||
otLinkFilterClearRssIn(pFilter->otCtx);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfTunIoCtl_otClearMacFixedRss(
|
||||
_In_ PMS_FILTER pFilter,
|
||||
_In_ PIRP pIrp,
|
||||
_In_reads_bytes_(InBufferLength)
|
||||
PUCHAR InBuffer,
|
||||
_In_ ULONG InBufferLength,
|
||||
_In_ ULONG OutBufferLength
|
||||
)
|
||||
{
|
||||
NTSTATUS status = STATUS_INVALID_PARAMETER;
|
||||
|
||||
UNREFERENCED_PARAMETER(InBuffer);
|
||||
UNREFERENCED_PARAMETER(InBufferLength);
|
||||
UNREFERENCED_PARAMETER(OutBufferLength);
|
||||
|
||||
status =
|
||||
otLwfTunSendCommandForIrp(
|
||||
pFilter,
|
||||
pIrp,
|
||||
NULL,
|
||||
SPINEL_CMD_PROP_VALUE_SET,
|
||||
SPINEL_PROP_MAC_FIXED_RSS,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
_IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
NTSTATUS
|
||||
otLwfIoCtl_otNextMacFixedRss(
|
||||
_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;
|
||||
|
||||
if (InBufferLength >= sizeof(uint8_t) &&
|
||||
*OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
|
||||
{
|
||||
uint8_t aIterator = *(uint8_t*)(InBuffer);
|
||||
otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
|
||||
|
||||
status = ThreadErrorToNtstatus(
|
||||
otLinkFilterGetNextRssIn(
|
||||
pFilter->otCtx,
|
||||
&aIterator,
|
||||
aEntry
|
||||
)
|
||||
);
|
||||
|
||||
*OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
|
||||
|
||||
if (status == STATUS_SUCCESS)
|
||||
{
|
||||
*(uint8_t*)OutBuffer = aIterator;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*OutBufferLength = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ DECL_IOCTL_FUNC_WITH_TUN(otReleaseRouterId);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otMacWhitelistEnabled);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otAddMacWhitelist);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otRemoveMacWhitelist);
|
||||
DECL_IOCTL_FUNC(otMacWhitelistEntry);
|
||||
DECL_IOCTL_FUNC(otNextMacWhitelist);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otClearMacWhitelist);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otDeviceRole);
|
||||
DECL_IOCTL_FUNC(otChildInfoById);
|
||||
@@ -186,13 +186,12 @@ DECL_IOCTL_FUNC_WITH_TUN2(otStableNetworkDataVersion);
|
||||
DECL_IOCTL_FUNC(otMacBlacklistEnabled);
|
||||
DECL_IOCTL_FUNC(otAddMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otRemoveMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otMacBlacklistEntry);
|
||||
DECL_IOCTL_FUNC(otNextMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otClearMacBlacklist);
|
||||
DECL_IOCTL_FUNC(otMaxTransmitPower);
|
||||
DECL_IOCTL_FUNC(otNextOnMeshPrefix);
|
||||
DECL_IOCTL_FUNC(otPollPeriod);
|
||||
DECL_IOCTL_FUNC(otLocalLeaderPartitionId);
|
||||
DECL_IOCTL_FUNC(otAssignLinkQuality);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otPlatformReset);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otParentInfo);
|
||||
DECL_IOCTL_FUNC(otSingleton);
|
||||
@@ -228,5 +227,9 @@ DECL_IOCTL_FUNC(otThreadAutoStart);
|
||||
DECL_IOCTL_FUNC(otThreadPreferredRouterId);
|
||||
DECL_IOCTL_FUNC_WITH_TUN2(otPSKc);
|
||||
DECL_IOCTL_FUNC(otParentPriority);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otAddMacFixedRss);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otRemoveMacFixedRss);
|
||||
DECL_IOCTL_FUNC(otNextMacFixedRss);
|
||||
DECL_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss);
|
||||
|
||||
#endif // _IOCONTROL_H
|
||||
|
||||
@@ -1069,7 +1069,7 @@ OTNODEAPI int32_t OTCALL otNodeClearWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist clear\r\n", aNode->mId);
|
||||
|
||||
otLinkClearWhitelist(aNode->mInstance);
|
||||
otLinkFilterClearAddresses(aNode->mInstance);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
}
|
||||
@@ -1079,9 +1079,9 @@ OTNODEAPI int32_t OTCALL otNodeEnableWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist enable\r\n", aNode->mId);
|
||||
|
||||
otLinkSetWhitelistEnabled(aNode->mInstance, true);
|
||||
otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_WHITELIST);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode)
|
||||
@@ -1089,31 +1089,36 @@ OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode)
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist disable\r\n", aNode->mId);
|
||||
|
||||
otLinkSetWhitelistEnabled(aNode->mInstance, false);
|
||||
otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_DISABLED);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode, const char *aExtAddr, int8_t aRssi)
|
||||
OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode,
|
||||
const char *aExtAddr, int8_t aRssi = OT_MAC_FILTER_FIXED_RSS_DISABLED)
|
||||
{
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
if (aRssi == 0)
|
||||
printf("%d: whitelist add %s\r\n", aNode->mId, aExtAddr);
|
||||
else printf("%d: whitelist add %s %d\r\n", aNode->mId, aExtAddr, aRssi);
|
||||
otError error = OT_ERROR_NONE;
|
||||
|
||||
uint8_t extAddr[8];
|
||||
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
|
||||
otExtAddress extAddress;
|
||||
if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
|
||||
return OT_ERROR_PARSE;
|
||||
|
||||
otError error;
|
||||
if (aRssi == 0)
|
||||
printf("%d: whitelist add %s", aNode->mId, aExtAddr);
|
||||
|
||||
error = otLinkFilterAddAddress(aNode->mInstance, &extAddress);
|
||||
|
||||
if (error == OT_ERROR_NONE || error == OT_ERROR_ALREADY)
|
||||
{
|
||||
error = otLinkAddWhitelist(aNode->mInstance, extAddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = otLinkAddWhitelistRssi(aNode->mInstance, extAddr, aRssi);
|
||||
if (aRssi != OT_MAC_FILTER_FIXED_RSS_DISABLED)
|
||||
{
|
||||
error = otLinkFilterAddRssIn(aNode->mInstance, &extAddress, aRssi);
|
||||
printf(" %d", aRssi);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
|
||||
otLogFuncExit();
|
||||
return error;
|
||||
}
|
||||
@@ -1123,13 +1128,13 @@ OTNODEAPI int32_t OTCALL otNodeRemoveWhitelist(otNode* aNode, const char *aExtAd
|
||||
otLogFuncEntryMsg("[%d]", aNode->mId);
|
||||
printf("%d: whitelist remove %s\r\n", aNode->mId, aExtAddr);
|
||||
|
||||
uint8_t extAddr[8];
|
||||
if (Hex2Bin(aExtAddr, extAddr, sizeof(extAddr)) != sizeof(extAddr))
|
||||
return OT_ERROR_INVALID_ARGS;
|
||||
otExtAddress extAddress;
|
||||
if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
|
||||
return OT_ERROR_PARSE;
|
||||
|
||||
otLinkRemoveWhitelist(aNode->mInstance, extAddr);
|
||||
otError error = otLinkFilterRemoveAddress(aNode->mInstance, &extAddress);
|
||||
otLogFuncExit();
|
||||
return 0;
|
||||
return error;
|
||||
}
|
||||
|
||||
OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode)
|
||||
|
||||
@@ -55,6 +55,7 @@ using namespace std;
|
||||
#include <openthread/thread_ftd.h>
|
||||
#include <openthread/commissioner.h>
|
||||
#include <openthread/joiner.h>
|
||||
#include <openthread/link.h>
|
||||
#include <openthread/platform/logging-windows.h>
|
||||
#include <otNode.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user