mirror of
https://github.com/espressif/openthread.git
synced 2026-08-19 08:59:52 +00:00
[examples] software implementation of source match table (#3717)
* [examples] add software implementation of source match table * [efr32] modify radio driver to use generic implementation of source match table * [efr32] configure soft source match table PAN ID
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
#include "common/logging.hpp"
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#include "utils/soft_source_match_table.h"
|
||||
|
||||
#include "board_config.h"
|
||||
#include "em_core.h"
|
||||
#include "em_system.h"
|
||||
@@ -100,7 +102,6 @@ typedef enum
|
||||
ENERGY_SCAN_MODE_ASYNC
|
||||
} energyScanMode;
|
||||
|
||||
static uint16_t sPanId = 0;
|
||||
static volatile bool sTransmitBusy = false;
|
||||
static bool sPromiscuous = false;
|
||||
static bool sIsSrcMatchEnabled = false;
|
||||
@@ -114,15 +115,6 @@ static otRadioFrame sTransmitFrame;
|
||||
static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
|
||||
static volatile otError sTransmitError;
|
||||
|
||||
typedef struct srcMatchEntry
|
||||
{
|
||||
uint16_t checksum;
|
||||
bool allocated;
|
||||
} sSrcMatchEntry;
|
||||
|
||||
static sSrcMatchEntry srcMatchShortEntry[RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM];
|
||||
static sSrcMatchEntry srcMatchExtEntry[RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM];
|
||||
|
||||
static efr32BandConfig sBandConfigs[EFR32_NUM_BAND_CONFIGS];
|
||||
|
||||
static volatile energyScanStatus sEnergyScanStatus;
|
||||
@@ -376,7 +368,7 @@ void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanId)
|
||||
|
||||
otLogInfoPlat("PANID=%X", aPanId);
|
||||
|
||||
sPanId = aPanId;
|
||||
utilsSoftSrcMatchSetPanId(aPanId);
|
||||
|
||||
for (uint8_t i = 0; i < EFR32_NUM_BAND_CONFIGS; i++)
|
||||
{
|
||||
@@ -612,108 +604,6 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
|
||||
}
|
||||
}
|
||||
|
||||
static int8_t findSrcMatchAvailEntry(bool aShortAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
|
||||
if (aShortAddress)
|
||||
{
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (!srcMatchShortEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (!srcMatchExtEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static int8_t findSrcMatchShortEntry(const uint16_t aShortAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchShortEntry[i].checksum && srcMatchShortEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = sPanId;
|
||||
|
||||
checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8);
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchExtEntry[i].checksum && srcMatchExtEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static void addToSrcMatchShortIndirect(uint8_t entry, const uint16_t aShortAddress)
|
||||
{
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
srcMatchShortEntry[entry].checksum = checksum;
|
||||
srcMatchShortEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
static void addToSrcMatchExtIndirect(uint8_t entry, const otExtAddress *aExtAddress)
|
||||
{
|
||||
uint16_t checksum = sPanId;
|
||||
|
||||
checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8);
|
||||
|
||||
srcMatchExtEntry[entry].checksum = checksum;
|
||||
srcMatchExtEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
static void removeFromSrcMatchShortIndirect(uint8_t entry)
|
||||
{
|
||||
srcMatchShortEntry[entry].allocated = false;
|
||||
srcMatchShortEntry[entry].checksum = 0;
|
||||
}
|
||||
|
||||
static void removeFromSrcMatchExtIndirect(uint8_t entry)
|
||||
{
|
||||
srcMatchExtEntry[entry].allocated = false;
|
||||
srcMatchExtEntry[entry].checksum = 0;
|
||||
}
|
||||
|
||||
void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
@@ -722,96 +612,6 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
|
||||
sIsSrcMatchEnabled = aEnable;
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchAvailEntry(true);
|
||||
otLogDebgPlat("Add ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchShortIndirect(entry, aShortAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchAvailEntry(false);
|
||||
otLogDebgPlat("Add ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchExtIndirect(entry, aExtAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchShortEntry(aShortAddress);
|
||||
otLogDebgPlat("Clear ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchShortIndirect(entry);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchExtEntry(aExtAddress);
|
||||
otLogDebgPlat("Clear ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchExtIndirect(entry);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Clear ShortAddr entries", NULL);
|
||||
|
||||
memset(srcMatchShortEntry, 0, sizeof(srcMatchShortEntry));
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Clear ExtAddr entries", NULL);
|
||||
|
||||
memset(srcMatchExtEntry, 0, sizeof(srcMatchExtEntry));
|
||||
}
|
||||
|
||||
static void processNextRxPacket(otInstance *aInstance, RAIL_Handle_t aRailHandle)
|
||||
{
|
||||
RAIL_RxPacketHandle_t packetHandle = RAIL_RX_PACKET_HANDLE_INVALID;
|
||||
@@ -919,9 +719,9 @@ static void ieee802154DataRequestCommand(RAIL_Handle_t aRailHandle)
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
if ((sourceAddress.length == RAIL_IEEE802154_LongAddress &&
|
||||
findSrcMatchExtEntry((otExtAddress *)sourceAddress.longAddress) >= 0) ||
|
||||
utilsSoftSrcMatchExtFindEntry((otExtAddress *)sourceAddress.longAddress) >= 0) ||
|
||||
(sourceAddress.length == RAIL_IEEE802154_ShortAddress &&
|
||||
findSrcMatchShortEntry(sourceAddress.shortAddress) >= 0))
|
||||
utilsSoftSrcMatchShortFindEntry(sourceAddress.shortAddress) >= 0))
|
||||
{
|
||||
status = RAIL_IEEE802154_SetFramePending(aRailHandle);
|
||||
assert(status == RAIL_STATUS_NO_ERROR);
|
||||
|
||||
@@ -41,12 +41,14 @@ libopenthread_platform_utils_a_SOURCES = \
|
||||
debug_uart.c \
|
||||
logging_rtt.c \
|
||||
settings_flash.c \
|
||||
soft_source_match_table.c \
|
||||
$(NULL)
|
||||
|
||||
noinst_HEADERS = \
|
||||
code_utils.h \
|
||||
flash.h \
|
||||
logging_rtt.h \
|
||||
soft_source_match_table.h \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements a software Source Match table, for radios that don't have
|
||||
* such hardware acceleration. It supports only the single-instance build of
|
||||
* OpenThread.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils/soft_source_match_table.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common/logging.hpp"
|
||||
#include "utils/code_utils.h"
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
static uint16_t sPanId = 0;
|
||||
|
||||
void utilsSoftSrcMatchSetPanId(uint16_t aPanId)
|
||||
{
|
||||
sPanId = aPanId;
|
||||
}
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
|
||||
typedef struct srcMatchShortEntry
|
||||
{
|
||||
uint16_t checksum;
|
||||
bool allocated;
|
||||
} sSrcMatchShortEntry;
|
||||
|
||||
static sSrcMatchShortEntry srcMatchShortEntry[RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM];
|
||||
|
||||
int8_t utilsSoftSrcMatchShortFindEntry(const uint16_t aShortAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchShortEntry[i].checksum && srcMatchShortEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static inline int8_t findSrcMatchShortAvailEntry(void)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (!srcMatchShortEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static inline void addToSrcMatchShortIndirect(uint8_t entry, const uint16_t aShortAddress)
|
||||
{
|
||||
uint16_t checksum = aShortAddress + sPanId;
|
||||
|
||||
srcMatchShortEntry[entry].checksum = checksum;
|
||||
srcMatchShortEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
static inline void removeFromSrcMatchShortIndirect(uint8_t entry)
|
||||
{
|
||||
srcMatchShortEntry[entry].allocated = false;
|
||||
srcMatchShortEntry[entry].checksum = 0;
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchShortAvailEntry();
|
||||
otLogDebgPlat("Add ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchShortIndirect(entry, aShortAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = utilsSoftSrcMatchShortFindEntry(aShortAddress);
|
||||
otLogDebgPlat("Clear ShortAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchShortIndirect(entry);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Clear ShortAddr entries", NULL);
|
||||
|
||||
memset(srcMatchShortEntry, 0, sizeof(srcMatchShortEntry));
|
||||
}
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
typedef struct srcMatchExtEntry
|
||||
{
|
||||
uint16_t checksum;
|
||||
bool allocated;
|
||||
} sSrcMatchExtEntry;
|
||||
|
||||
static sSrcMatchExtEntry srcMatchExtEntry[RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM];
|
||||
|
||||
int8_t utilsSoftSrcMatchExtFindEntry(const otExtAddress *aExtAddress)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
uint16_t checksum = sPanId;
|
||||
|
||||
checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8);
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (checksum == srcMatchExtEntry[i].checksum && srcMatchExtEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static inline int8_t findSrcMatchExtAvailEntry(void)
|
||||
{
|
||||
int8_t entry = -1;
|
||||
|
||||
for (uint8_t i = 0; i < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM; i++)
|
||||
{
|
||||
if (!srcMatchExtEntry[i].allocated)
|
||||
{
|
||||
entry = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static inline void addToSrcMatchExtIndirect(uint8_t entry, const otExtAddress *aExtAddress)
|
||||
{
|
||||
uint16_t checksum = sPanId;
|
||||
|
||||
checksum += (uint16_t)aExtAddress->m8[0] | (uint16_t)(aExtAddress->m8[1] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[2] | (uint16_t)(aExtAddress->m8[3] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[4] | (uint16_t)(aExtAddress->m8[5] << 8);
|
||||
checksum += (uint16_t)aExtAddress->m8[6] | (uint16_t)(aExtAddress->m8[7] << 8);
|
||||
|
||||
srcMatchExtEntry[entry].checksum = checksum;
|
||||
srcMatchExtEntry[entry].allocated = true;
|
||||
}
|
||||
|
||||
static inline void removeFromSrcMatchExtIndirect(uint8_t entry)
|
||||
{
|
||||
srcMatchExtEntry[entry].allocated = false;
|
||||
srcMatchExtEntry[entry].checksum = 0;
|
||||
}
|
||||
|
||||
otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = findSrcMatchExtAvailEntry();
|
||||
otLogDebgPlat("Add ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_BUFS);
|
||||
|
||||
addToSrcMatchExtIndirect(entry, aExtAddress);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
int8_t entry = -1;
|
||||
|
||||
entry = utilsSoftSrcMatchExtFindEntry(aExtAddress);
|
||||
otLogDebgPlat("Clear ExtAddr entry: %d", entry);
|
||||
|
||||
otEXPECT_ACTION(entry >= 0 && entry < RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM, error = OT_ERROR_NO_ADDRESS);
|
||||
|
||||
removeFromSrcMatchExtIndirect(entry);
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
otLogDebgPlat("Clear ExtAddr entries", NULL);
|
||||
|
||||
memset(srcMatchExtEntry, 0, sizeof(srcMatchExtEntry));
|
||||
}
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2019, The OpenThread Authors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file defines the software source match table interfaces used by
|
||||
* soft_source_match_table.c.
|
||||
*/
|
||||
|
||||
#ifndef SOFT_SOURCE_MATCH_TABLE_H
|
||||
#define SOFT_SOURCE_MATCH_TABLE_H
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
#include <openthread/platform/radio.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
|
||||
#define RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM 0
|
||||
#endif
|
||||
|
||||
#ifndef RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
#define RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM 0
|
||||
#endif
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
void utilsSoftSrcMatchSetPanId(uint16_t aPanId);
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
|
||||
int8_t utilsSoftSrcMatchShortFindEntry(const uint16_t aShortAddress);
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
|
||||
|
||||
#if RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
int8_t utilsSoftSrcMatchExtFindEntry(const otExtAddress *aExtAddress);
|
||||
#endif // RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // SOFT_SOURCE_MATCH_TABLE_H
|
||||
Reference in New Issue
Block a user