Set steering data and enable MLE discovery response filtering. (#1685)

Enable OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB to be able to set
steering data out of band on FFDs.

On joining device, enable filtering MLE discovery responses based on Factory assigned EUI64.
This commit is contained in:
Vaas Krishnamurthy
2017-05-03 13:24:02 -07:00
committed by Jonathan Hui
parent 1ea4ceb151
commit 8d5a701adb
39 changed files with 292 additions and 53 deletions
+1
View File
@@ -107,6 +107,7 @@
<ClCompile Include="..\..\src\core\meshcop\leader.cpp" />
<ClCompile Include="..\..\src\core\meshcop\panid_query_client.cpp" />
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp" />
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
<ClCompile Include="..\..\src\core\net\dhcp6_client.cpp" />
<ClCompile Include="..\..\src\core\net\dhcp6_server.cpp" />
<ClCompile Include="..\..\src\core\net\icmp6.cpp" />
@@ -279,6 +279,9 @@
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp">
<Filter>Source Files\meshcop</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp">
<Filter>Source Files\meshcop</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\crypto\aes_ecb.cpp">
<Filter>Source Files\crypto</Filter>
</ClCompile>
@@ -115,6 +115,7 @@
<ClCompile Include="..\..\src\core\meshcop\leader.cpp" />
<ClCompile Include="..\..\src\core\meshcop\panid_query_client.cpp" />
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp" />
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp" />
<ClCompile Include="..\..\src\core\net\dhcp6_client.cpp" />
<ClCompile Include="..\..\src\core\net\dhcp6_server.cpp" />
<ClCompile Include="..\..\src\core\net\icmp6.cpp" />
@@ -282,6 +282,9 @@
<ClCompile Include="..\..\src\core\meshcop\timestamp.cpp">
<Filter>Source Files\meshcop</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\meshcop\meshcop_tlvs.cpp">
<Filter>Source Files\meshcop</Filter>
</ClCompile>
<ClCompile Include="..\..\src\core\crypto\aes_ecb.cpp">
<Filter>Source Files\crypto</Filter>
</ClCompile>
+2 -1
View File
@@ -1336,6 +1336,7 @@ otThreadDiscover(
uint32_t aScanChannels,
uint16_t aPanid,
bool aJoiner,
bool aEnableEui64Filtering,
otHandleActiveScanResult aCallback,
void *aCallbackContext
)
@@ -1347,7 +1348,7 @@ otThreadDiscover(
aInstance->InterfaceGuid, aCallback, aCallbackContext
);
PackedBuffer4<GUID,uint32_t,uint16_t, bool> Buffer(aInstance->InterfaceGuid, aScanChannels, aPanid, aJoiner);
PackedBuffer5<GUID,uint32_t,uint16_t, uint8_t, uint8_t> Buffer(aInstance->InterfaceGuid, aScanChannels, aPanid, aJoiner, aEnableEui64Filtering);
return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_DISCOVER, &Buffer, sizeof(Buffer), nullptr, 0));
}
+3 -1
View File
@@ -909,13 +909,15 @@ otLwfIoCtl_otDiscover(
{
uint32_t aScanChannels = *(uint32_t*)InBuffer;
uint16_t aPanid = *(uint16_t*)(InBuffer + sizeof(uint32_t));
bool aJoiner = *(bool*)(InBuffer + sizeof(uint32_t) + sizeof(uint16_t));
bool aJoiner = *(uint8_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint16_t));
bool aEnableEui64Filtering = *(uint8_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t));
status = ThreadErrorToNtstatus(
otThreadDiscover(
pFilter->otCtx,
aScanChannels,
aPanid,
aJoiner,
aEnableEui64Filtering,
otLwfDiscoverCallback,
pFilter)
);
+1 -1
View File
@@ -124,7 +124,7 @@ OTAPI bool OTCALL otThreadIsSingleton(otInstance *aInstance);
*
*/
OTAPI ThreadError OTCALL otThreadDiscover(otInstance *aInstance, uint32_t aScanChannels, uint16_t aPanid, bool aJoiner,
otHandleActiveScanResult aCallback, void *aCallbackContext);
bool aEnableEui64Filtering, otHandleActiveScanResult aCallback, void *aCallbackContext);
/**
* This function determines if an MLE Thread Discovery is currently in progress.
+16
View File
@@ -202,6 +202,22 @@ OTAPI uint16_t OTCALL otThreadGetJoinerUdpPort(otInstance *aInstance);
*/
OTAPI ThreadError OTCALL otThreadSetJoinerUdpPort(otInstance *aInstance, uint16_t aJoinerUdpPort);
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
/**
* Set Steering data out of band
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aExtAddress Address to indicate steering data.
* All zeros indicate that there is no steering data
* All 0xFFs indicate that there is no filtering
* Specific MAC address
*
* @retval kThreadErrorNone Successfully set steering data
*
*/
ThreadError otThreadSetSteeringData(otInstance *aInstance, otExtAddress *aExtAddress);
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
/**
* @defgroup config-test Test
*
+1 -1
View File
@@ -770,7 +770,7 @@ void Interpreter::ProcessDiscover(int argc, char *argv[])
scanChannels = 1 << value;
}
SuccessOrExit(error = otThreadDiscover(mInstance, scanChannels, OT_PANID_BROADCAST, false,
SuccessOrExit(error = otThreadDiscover(mInstance, scanChannels, OT_PANID_BROADCAST, false, false,
&Interpreter::s_HandleActiveScanResult, this));
sServer->OutputFormat("| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |\r\n");
sServer->OutputFormat("+---+------------------+------------------+------+------------------+----+-----+-----+\r\n");
+2 -1
View File
@@ -148,6 +148,7 @@ SOURCES_COMMON = \
meshcop/leader.cpp \
meshcop/panid_query_client.cpp \
meshcop/timestamp.cpp \
meshcop/meshcop_tlvs.cpp \
net/dhcp6_client.cpp \
net/dhcp6_server.cpp \
net/dns_client.cpp \
@@ -246,7 +247,7 @@ HEADERS_COMMON = \
meshcop/meshcop.hpp \
meshcop/panid_query_client.hpp \
meshcop/timestamp.hpp \
meshcop/tlvs.hpp \
meshcop/meshcop_tlvs.hpp \
net/dhcp6.hpp \
net/dhcp6_client.hpp \
net/dhcp6_server.hpp \
+3 -2
View File
@@ -518,9 +518,10 @@ bool otThreadIsSingleton(otInstance *aInstance)
}
ThreadError otThreadDiscover(otInstance *aInstance, uint32_t aScanChannels, uint16_t aPanId, bool aJoiner,
otHandleActiveScanResult aCallback, void *aCallbackContext)
bool aEnableEui64Filtering, otHandleActiveScanResult aCallback, void *aCallbackContext)
{
return aInstance->mThreadNetif.GetMle().Discover(aScanChannels, aPanId, aJoiner, aCallback, aCallbackContext);
return aInstance->mThreadNetif.GetMle().Discover(aScanChannels, aPanId, aJoiner, aEnableEui64Filtering, aCallback,
aCallbackContext);
}
bool otThreadIsDiscoverInProgress(otInstance *aInstance)
+7
View File
@@ -237,4 +237,11 @@ exit:
return error;
}
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
ThreadError otThreadSetSteeringData(otInstance *aInstance, otExtAddress *aExtAddress)
{
return aInstance->mThreadNetif.GetMle().SetSteeringData(aExtAddress);
}
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
#endif // OPENTHREAD_FTD
+1 -1
View File
@@ -47,7 +47,7 @@
#include <common/logging.hpp>
#include <meshcop/announce_begin_client.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+2 -14
View File
@@ -45,14 +45,13 @@
#include "openthread/platform/random.h"
#include <coap/coap_header.hpp>
#include <common/crc16.hpp>
#include <common/encoding.hpp>
#include <common/logging.hpp>
#include <crypto/pbkdf2_cmac.h>
#include <meshcop/commissioner.hpp>
#include <meshcop/joiner_router.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_tlvs.hpp>
#include <thread/thread_uris.hpp>
@@ -167,9 +166,6 @@ ThreadError Commissioner::SendCommissionerSet(void)
for (size_t i = 0; i < sizeof(mJoiners) / sizeof(mJoiners[0]); i++)
{
Crc16 ccitt(Crc16::kCcitt);
Crc16 ansi(Crc16::kAnsi);
if (!mJoiners[i].mValid)
{
continue;
@@ -182,15 +178,7 @@ ThreadError Commissioner::SendCommissionerSet(void)
break;
}
for (size_t j = 0; j < sizeof(mJoiners[i].mExtAddress.m8); j++)
{
uint8_t byte = mJoiners[i].mExtAddress.m8[j];
ccitt.Update(byte);
ansi.Update(byte);
}
steeringData.SetBit(ccitt.Get() % steeringData.GetNumBits());
steeringData.SetBit(ansi.Get() % steeringData.GetNumBits());
steeringData.ComputeBloomFilter(&mJoiners[i].mExtAddress);
}
// set bloom filter
+1 -1
View File
@@ -45,7 +45,7 @@
#include <common/code_utils.hpp>
#include <common/settings.hpp>
#include <meshcop/dataset.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/mle_tlvs.hpp>
namespace ot {
+1 -1
View File
@@ -36,7 +36,7 @@
#define MESHCOP_DATASET_HPP_
#include <common/message.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
namespace ot {
namespace MeshCoP {
+1 -1
View File
@@ -55,7 +55,7 @@
#include <meshcop/dataset.hpp>
#include <meshcop/dataset_manager.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_tlvs.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -56,7 +56,7 @@
#include <common/timer.hpp>
#include <meshcop/dataset.hpp>
#include <meshcop/dataset_manager.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_tlvs.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -39,7 +39,7 @@
#include <common/message.hpp>
#include <common/timer.hpp>
#include <crypto/sha256.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>
+1 -1
View File
@@ -48,7 +48,7 @@
#include <common/logging.hpp>
#include <meshcop/energy_scan_client.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -117,7 +117,7 @@ ThreadError Joiner::Start(const char *aPSKd, const char *aProvisioningUrl,
SuccessOrExit(error);
mJoinerRouterPanId = Mac::kPanIdBroadcast;
SuccessOrExit(error = mNetif.GetMle().Discover(0, mNetif.GetMac().GetPanId(), true, HandleDiscoverResult, this));
SuccessOrExit(error = mNetif.GetMle().Discover(0, mNetif.GetMac().GetPanId(), true, false, HandleDiscoverResult, this));
mVendorName = aVendorName;
mVendorModel = aVendorModel;
+1 -1
View File
@@ -43,7 +43,7 @@
#include <common/crc16.hpp>
#include <net/udp6.hpp>
#include <meshcop/dtls.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
namespace ot {
+1 -1
View File
@@ -48,7 +48,7 @@
#include <common/logging.hpp>
#include <meshcop/joiner_router.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/mle.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -43,7 +43,7 @@
#include <common/message.hpp>
#include <common/timer.hpp>
#include <mac/mac_frame.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/key_manager.hpp>
+1 -1
View File
@@ -50,7 +50,7 @@
#include <common/logging.hpp>
#include <meshcop/leader.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_tlvs.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -37,7 +37,7 @@
#include <coap/coap_client.hpp>
#include <coap/coap_server.hpp>
#include <common/timer.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <net/udp6.hpp>
#include <thread/mle.hpp>
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2016-2017, 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 MechCop TLV helper functions.
*/
#include <meshcop/meshcop_tlvs.hpp>
namespace ot {
namespace MeshCoP {
bool SteeringDataTlv::IsCleared(void) const
{
bool rval = true;
for (uint8_t i = 0; i < GetLength(); i++)
{
if (mSteeringData[i] != 0)
{
rval = false;
break;
}
}
return rval;
}
void SteeringDataTlv::ComputeBloomFilter(otExtAddress *aExtAddress)
{
Crc16 ccitt(Crc16::kCcitt);
Crc16 ansi(Crc16::kAnsi);
for (size_t j = 0; j < sizeof(otExtAddress); j++)
{
uint8_t byte = aExtAddress->m8[j];
ccitt.Update(byte);
ansi.Update(byte);
}
SetBit(ccitt.Get() % GetNumBits());
SetBit(ansi.Get() % GetNumBits());
}
} // namespace ot
} // namespace Thread
@@ -39,6 +39,7 @@
#include "openthread/types.h"
#include <common/crc16.hpp>
#include <common/encoding.hpp>
#include <common/message.hpp>
#include <common/tlvs.hpp>
@@ -630,6 +631,23 @@ public:
*/
void SetBit(uint8_t aBit) { mSteeringData[GetLength() - 1 - (aBit / 8)] |= 1 << (aBit % 8); }
/**
* Ths method indicates whether or not the SteeringData is all zeros.
*
* @retval TRUE If the SteeringData is all zeros.
* @retval FALSE If the SteeringData isn't all zeros.
*
*/
bool IsCleared(void) const;
/**
* This method computes the Bloom Filter.
*
* @param[in] aExtAddress Extended address
*
*/
void ComputeBloomFilter(otExtAddress *aExtAddress);
private:
uint8_t mSteeringData[OT_STEERING_DATA_MAX_LENGTH];
} OT_TOOL_PACKED_END;
+1 -1
View File
@@ -48,7 +48,7 @@
#include <common/logging.hpp>
#include <meshcop/panid_query_client.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+10
View File
@@ -715,4 +715,14 @@
#define OPENTHREAD_CONFIG_MBEDTLS_HEAP_SIZE (2048 * sizeof(void *))
#endif
/**
* @def OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
*
* Enable setting steering data out of band.
*
*/
#ifndef OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
#define OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB 0
#endif
#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_
+1 -1
View File
@@ -45,7 +45,7 @@
#include <common/code_utils.hpp>
#include <common/debug.hpp>
#include <common/logging.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/announce_begin_server.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+1 -1
View File
@@ -46,7 +46,7 @@
#include <common/debug.hpp>
#include <common/logging.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/energy_scan_server.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>
+35 -3
View File
@@ -51,7 +51,7 @@
#include <common/settings.hpp>
#include <crypto/aes_ccm.hpp>
#include <mac/mac_frame.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <net/netif.hpp>
#include <net/udp6.hpp>
#include <thread/address_resolver.hpp>
@@ -93,6 +93,7 @@ Mle::Mle(ThreadNetif &aThreadNetif) :
mDiscoverHandler(NULL),
mDiscoverContext(NULL),
mIsDiscoverInProgress(false),
mEnableEui64Filtering(false),
mAnnounceChannel(kPhyMinChannel),
mPreviousChannel(0),
mPreviousPanId(Mac::kPanIdBroadcast)
@@ -392,8 +393,8 @@ exit:
return error;
}
ThreadError Mle::Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, DiscoverHandler aCallback,
void *aContext)
ThreadError Mle::Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, bool aEnableEui64Filtering,
DiscoverHandler aCallback, void *aContext)
{
ThreadError error = kThreadError_None;
Message *message = NULL;
@@ -404,6 +405,8 @@ ThreadError Mle::Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner,
VerifyOrExit(!mIsDiscoverInProgress, error = kThreadError_Busy);
mEnableEui64Filtering = aEnableEui64Filtering;
mDiscoverHandler = aCallback;
mDiscoverContext = aContext;
mNetif.GetMeshForwarder().SetDiscoverParameters(aScanChannels);
@@ -455,6 +458,7 @@ bool Mle::IsDiscoverInProgress(void)
void Mle::HandleDiscoverComplete(void)
{
mIsDiscoverInProgress = false;
mEnableEui64Filtering = false;
mDiscoverHandler(NULL, mDiscoverContext);
}
@@ -3103,8 +3107,36 @@ ThreadError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Mes
case MeshCoP::Tlv::kSteeringData:
aMessage.Read(offset, sizeof(steeringData), &steeringData);
VerifyOrExit(steeringData.IsValid(), error = kThreadError_Parse);
// Pass up MLE discovery responses only if the steering data is set to all 0xFFs,
// or if it matches the factory set EUI64.
if (mEnableEui64Filtering)
{
otExtAddress mfgEUI64;
Crc16 ccitt(Crc16::kCcitt);
Crc16 ansi(Crc16::kAnsi);
// Get Factory set EUI64
otPlatRadioGetIeeeEui64(GetInstance(), mfgEUI64.m8);
// Compute bloom filter
for (size_t i = 0; i < sizeof(mfgEUI64.m8); i++)
{
ccitt.Update(mfgEUI64.m8[i]);
ansi.Update(mfgEUI64.m8[i]);
}
// Drop responses that don't match the bloom filter
if (!steeringData.GetBit(ccitt.Get() % steeringData.GetNumBits()) ||
!steeringData.GetBit(ansi.Get() % steeringData.GetNumBits()))
{
ExitNow(error = kThreadError_None);
}
}
result.mSteeringData.mLength = steeringData.GetLength();
memcpy(result.mSteeringData.m8, steeringData.GetValue(), result.mSteeringData.mLength);
break;
case MeshCoP::Tlv::kJoinerUdpPort:
+9 -6
View File
@@ -563,17 +563,19 @@ public:
/**
* This method initiates a Thread Discovery.
*
* @param[in] aScanChannels A bit vector indicating which channels to scan.
* @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] aHandler A pointer to a function that is called on receiving an MLE Discovery Response.
* @param[in] aContext A pointer to arbitrary context information.
* @param[in] aScanChannels A bit vector indicating which channels to scan.
* @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] aEnableEui64Filtering Enable filtering out MLE discovery responses that don't match our 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.
*
* @retval kThreadError_None Successfully started a Thread Discovery.
* @retval kThreadError_Busy Thread Discovery is already in progress.
*
*/
ThreadError Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, DiscoverHandler aCallback,
ThreadError Discover(uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, bool aEnableEui64Filtering,
DiscoverHandler aCallback,
void *aContext);
/**
@@ -1433,6 +1435,7 @@ private:
DiscoverHandler mDiscoverHandler;
void *mDiscoverContext;
bool mIsDiscoverInProgress;
bool mEnableEui64Filtering;
uint8_t mAnnounceChannel;
uint8_t mPreviousChannel;
+60 -5
View File
@@ -2464,6 +2464,39 @@ exit:
return kThreadError_None;
}
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
ThreadError MleRouter::SetSteeringData(otExtAddress *aExtAddress)
{
ThreadError error = kThreadError_None;
uint8_t nullExtAddr[OT_EXT_ADDRESS_SIZE];
uint8_t allowAnyExtAddr[OT_EXT_ADDRESS_SIZE];
memset(nullExtAddr, 0, sizeof(nullExtAddr));
memset(allowAnyExtAddr, 0xFF, sizeof(allowAnyExtAddr));
mSteeringData.Init();
if ((aExtAddress == NULL) || (memcmp(aExtAddress, &nullExtAddr, sizeof(nullExtAddr)) == 0))
{
// Clear steering data
mSteeringData.Clear();
}
else if (memcmp(aExtAddress, &allowAnyExtAddr, sizeof(allowAnyExtAddr)) == 0)
{
// Set steering data to 0xFF
mSteeringData.SetLength(1);
mSteeringData.Set();
}
else
{
// Set bloom filter with the extended address passed in
mSteeringData.ComputeBloomFilter(aExtAddress);
}
return error;
}
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
ThreadError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
{
ThreadError error = kThreadError_None;
@@ -2512,7 +2545,17 @@ ThreadError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6
if (discoveryRequest.IsJoiner())
{
VerifyOrExit(mNetif.GetNetworkDataLeader().IsJoiningEnabled());
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
if (!mSteeringData.IsCleared())
{
break;
}
else // if steering data is not set out of band, fall back to network data
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
{
VerifyOrExit(mNetif.GetNetworkDataLeader().IsJoiningEnabled());
}
}
break;
@@ -2592,12 +2635,24 @@ ThreadError MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, u
networkName.SetNetworkName(mNetif.GetMac().GetNetworkName());
SuccessOrExit(error = message->Append(&networkName, sizeof(tlv) + networkName.GetLength()));
// Steering Data TLV
steeringData = mNetif.GetNetworkDataLeader().GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData);
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
if (steeringData != NULL)
// If steering data is set out of band, use that value.
// Otherwise use the one from commissioning data.
if (!mSteeringData.IsCleared())
{
SuccessOrExit(message->Append(steeringData, sizeof(*steeringData) + steeringData->GetLength()));
SuccessOrExit(message->Append(&mSteeringData, sizeof(mSteeringData) + mSteeringData.GetLength()));
}
else
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
{
// Steering Data TLV
steeringData = mNetif.GetNetworkDataLeader().GetCommissioningDataSubTlv(MeshCoP::Tlv::kSteeringData);
if (steeringData != NULL)
{
SuccessOrExit(message->Append(steeringData, sizeof(*steeringData) + steeringData->GetLength()));
}
}
// Joiner UDP Port TLV
+21
View File
@@ -42,6 +42,7 @@
#include <common/timer.hpp>
#include <common/trickle_timer.hpp>
#include <mac/mac_frame.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <net/icmp6.hpp>
#include <net/udp6.hpp>
#include <thread/mle.hpp>
@@ -643,6 +644,21 @@ public:
*/
void FillRouteTlv(RouteTlv &aTlv);
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
/**
* This method sets steering data out of band
*
* @param[in] aExtAddress Value used to set steering data
* All zeros clears steering data
* All 0xFFs sets steering data to 0xFF
* Anything else is used to compute the bloom filter
*
* @retval kThreadError_None Steering data was set
*
*/
ThreadError SetSteeringData(otExtAddress *aExtAddress);
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
private:
enum
{
@@ -765,6 +781,11 @@ private:
uint8_t mRouterSelectionJitter; ///< The variable to save the assigned jitter value.
uint8_t mRouterSelectionJitterTimeout; ///< The Timeout prior to request/release Router ID.
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
MeshCoP::SteeringDataTlv mSteeringData;
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
};
} // namespace Mle
+4
View File
@@ -122,6 +122,10 @@ public:
void FillConnectivityTlv(ConnectivityTlv &) { }
void FillRouteTlv(RouteTlv &) { }
#if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
ThreadError SetSteeringData(otExtAddress *) { return kThreadError_NotImplemented; };
#endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB
private:
ThreadError HandleDetachStart(void) { return kThreadError_None; }
ThreadError HandleChildStart(otMleAttachFilter) { return kThreadError_None; }
+1 -1
View File
@@ -41,7 +41,7 @@
#include <common/encoding.hpp>
#include <common/message.hpp>
#include <common/tlvs.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <net/ip6_address.hpp>
#include <thread/mle_constants.hpp>
+1 -1
View File
@@ -46,7 +46,7 @@
#include <common/debug.hpp>
#include <common/logging.hpp>
#include <meshcop/meshcop.hpp>
#include <meshcop/tlvs.hpp>
#include <meshcop/meshcop_tlvs.hpp>
#include <thread/panid_query_server.hpp>
#include <thread/thread_netif.hpp>
#include <thread/thread_uris.hpp>