mirror of
https://github.com/espressif/openthread.git
synced 2026-08-08 11:47:46 +00:00
[discover-scanner] allow filtering based on a user given bloom filter indexes (#5075)
This commit enhances the filtering behavior of Discover Scan. When filtering is enabled, MLE Discovery Responses with steering data (bloom filter) not containing a set of bloom filter indexes are filtered. This commit updates the `DiscoverScanner::Discover()` to allow filter indexes used for filtering to be optionally specified by the caller. It can be set to NULL (for default behavior) where the hash of factory-assigned EUI64 of the device would be used to derive the bloom filter indexes
This commit is contained in:
committed by
Jonathan Hui
parent
6094db2b96
commit
55785040c9
@@ -457,8 +457,9 @@ otError otThreadDiscover(otInstance * aInstance,
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<Mle::DiscoverScanner>().Discover(static_cast<Mac::ChannelMask>(aScanChannels), aPanId, aJoiner,
|
||||
aEnableEui64Filtering, aCallback, aCallbackContext);
|
||||
return instance.Get<Mle::DiscoverScanner>().Discover(
|
||||
static_cast<Mac::ChannelMask>(aScanChannels), aPanId, aJoiner, aEnableEui64Filtering,
|
||||
/* aFilterIndexes (use hash of factory EUI64) */ NULL, aCallback, aCallbackContext);
|
||||
}
|
||||
|
||||
bool otThreadIsDiscoverInProgress(otInstance *aInstance)
|
||||
|
||||
@@ -124,6 +124,7 @@ otError Joiner::Start(const char * aPskd,
|
||||
|
||||
SuccessOrExit(error = Get<Mle::DiscoverScanner>().Discover(Mac::ChannelMask(0), Get<Mac::Mac>().GetPanId(),
|
||||
/* aJoiner */ true, /* aEnableFiltering */ true,
|
||||
/* aFilterIndexes (use hash of factory EUI64) */ NULL,
|
||||
HandleDiscoverResult, this));
|
||||
mCallback = aCallback;
|
||||
mContext = aContext;
|
||||
|
||||
@@ -62,6 +62,7 @@ otError DiscoverScanner::Discover(const Mac::ChannelMask &aScanChannels,
|
||||
uint16_t aPanId,
|
||||
bool aJoiner,
|
||||
bool aEnableFiltering,
|
||||
const FilterIndexes * aFilterIndexes,
|
||||
Handler aCallback,
|
||||
void * aContext)
|
||||
{
|
||||
@@ -76,12 +77,18 @@ otError DiscoverScanner::Discover(const Mac::ChannelMask &aScanChannels,
|
||||
|
||||
if (mEnableFiltering)
|
||||
{
|
||||
Mac::ExtAddress extAddress;
|
||||
if (aFilterIndexes == NULL)
|
||||
{
|
||||
Mac::ExtAddress extAddress;
|
||||
|
||||
Get<Radio>().GetIeeeEui64(extAddress);
|
||||
MeshCoP::ComputeJoinerId(extAddress, extAddress);
|
||||
|
||||
MeshCoP::SteeringData::CalculateHashBitIndexes(extAddress, mFilterIndexes);
|
||||
Get<Radio>().GetIeeeEui64(extAddress);
|
||||
MeshCoP::ComputeJoinerId(extAddress, extAddress);
|
||||
MeshCoP::SteeringData::CalculateHashBitIndexes(extAddress, mFilterIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFilterIndexes = *aFilterIndexes;
|
||||
}
|
||||
}
|
||||
|
||||
mHandler = aCallback;
|
||||
|
||||
@@ -82,6 +82,16 @@ public:
|
||||
*/
|
||||
typedef otHandleActiveScanResult Handler;
|
||||
|
||||
/**
|
||||
* This type represents the filter indexes, i.e., hash bit index values for the bloom filter (calculated from a
|
||||
* Joiner ID).
|
||||
*
|
||||
* This is used when filtering is enabled during Discover Scan, i.e., received MLE Discovery Responses with steering
|
||||
* data (bloom filter) not containing the given indexes are filtered.
|
||||
*
|
||||
*/
|
||||
typedef MeshCoP::SteeringData::HashBitIndexes FilterIndexes;
|
||||
|
||||
/**
|
||||
* This constructor initializes the object.
|
||||
*
|
||||
@@ -96,7 +106,10 @@ public:
|
||||
* @param[in] aScanChannels Channel mask listing channels to scan (if empty, use all supported channels).
|
||||
* @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter).
|
||||
* @param[in] aJoiner Value of the Joiner Flag in the Discovery Request TLV.
|
||||
* @param[in] aEnableFiltering Enable filtering MLE Discovery Responses that don't match our factory EUI64.
|
||||
* @param[in] aEnableFiltering Enable filtering MLE Discovery Responses with steering data not containing a
|
||||
* given filter indexes.
|
||||
* @param[in] aFilterIndexes A pointer to `FilterIndexes` to use for filtering (when enabled).
|
||||
* If set to NULL, filter indexes are derived from hash of factory-assigned EUI64.
|
||||
* @param[in] aHandler A pointer to a function that is called on receiving an MLE Discovery Response.
|
||||
* @param[in] aContext A pointer to arbitrary context information.
|
||||
*
|
||||
@@ -109,6 +122,7 @@ public:
|
||||
Mac::PanId aPanId,
|
||||
bool aJoiner,
|
||||
bool aEnableFiltering,
|
||||
const FilterIndexes * aFilterIndexes,
|
||||
Handler aHandler,
|
||||
void * aContext);
|
||||
|
||||
@@ -140,15 +154,15 @@ private:
|
||||
static void HandleTimer(Timer &aTimer);
|
||||
void HandleTimer(void);
|
||||
|
||||
Handler mHandler;
|
||||
void * mHandlerContext;
|
||||
TimerMilli mTimer;
|
||||
MeshCoP::SteeringData::HashBitIndexes mFilterIndexes;
|
||||
Mac::ChannelMask mScanChannels;
|
||||
State mState;
|
||||
uint8_t mScanChannel;
|
||||
bool mEnableFiltering : 1;
|
||||
bool mShouldRestorePanId : 1;
|
||||
Handler mHandler;
|
||||
void * mHandlerContext;
|
||||
TimerMilli mTimer;
|
||||
FilterIndexes mFilterIndexes;
|
||||
Mac::ChannelMask mScanChannels;
|
||||
State mState;
|
||||
uint8_t mScanChannel;
|
||||
bool mEnableFiltering : 1;
|
||||
bool mShouldRestorePanId : 1;
|
||||
};
|
||||
|
||||
} // namespace Mle
|
||||
|
||||
Reference in New Issue
Block a user