diff --git a/etc/visual-studio/libopenthread.vcxproj b/etc/visual-studio/libopenthread.vcxproj
index 27beb76fb..5444fff36 100644
--- a/etc/visual-studio/libopenthread.vcxproj
+++ b/etc/visual-studio/libopenthread.vcxproj
@@ -107,6 +107,7 @@
+
diff --git a/etc/visual-studio/libopenthread.vcxproj.filters b/etc/visual-studio/libopenthread.vcxproj.filters
index 42c6fd63d..193a486bb 100644
--- a/etc/visual-studio/libopenthread.vcxproj.filters
+++ b/etc/visual-studio/libopenthread.vcxproj.filters
@@ -279,6 +279,9 @@
Source Files\meshcop
+
+ Source Files\meshcop
+
Source Files\crypto
diff --git a/etc/visual-studio/libopenthread_k.vcxproj b/etc/visual-studio/libopenthread_k.vcxproj
index 7b44163d6..82a21be8d 100644
--- a/etc/visual-studio/libopenthread_k.vcxproj
+++ b/etc/visual-studio/libopenthread_k.vcxproj
@@ -115,6 +115,7 @@
+
diff --git a/etc/visual-studio/libopenthread_k.vcxproj.filters b/etc/visual-studio/libopenthread_k.vcxproj.filters
index a3dd892d2..0d2f01f64 100644
--- a/etc/visual-studio/libopenthread_k.vcxproj.filters
+++ b/etc/visual-studio/libopenthread_k.vcxproj.filters
@@ -282,6 +282,9 @@
Source Files\meshcop
+
+ Source Files\meshcop
+
Source Files\crypto
diff --git a/examples/drivers/windows/otApi/otApi.cpp b/examples/drivers/windows/otApi/otApi.cpp
index 7a0b10d31..21e16beeb 100644
--- a/examples/drivers/windows/otApi/otApi.cpp
+++ b/examples/drivers/windows/otApi/otApi.cpp
@@ -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 Buffer(aInstance->InterfaceGuid, aScanChannels, aPanid, aJoiner);
+ PackedBuffer5 Buffer(aInstance->InterfaceGuid, aScanChannels, aPanid, aJoiner, aEnableEui64Filtering);
return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_DISCOVER, &Buffer, sizeof(Buffer), nullptr, 0));
}
diff --git a/examples/drivers/windows/otLwf/iocontrol.c b/examples/drivers/windows/otLwf/iocontrol.c
index 7011b4c4e..c40d3750c 100644
--- a/examples/drivers/windows/otLwf/iocontrol.c
+++ b/examples/drivers/windows/otLwf/iocontrol.c
@@ -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)
);
diff --git a/include/openthread/thread.h b/include/openthread/thread.h
index a9401a584..a4b3a1e90 100644
--- a/include/openthread/thread.h
+++ b/include/openthread/thread.h
@@ -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.
diff --git a/include/openthread/thread_ftd.h b/include/openthread/thread_ftd.h
index 2d9ef64f4..7340b90af 100644
--- a/include/openthread/thread_ftd.h
+++ b/include/openthread/thread_ftd.h
@@ -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
*
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index c74650331..bd8727efd 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -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");
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 248e34cda..e6d225f42 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -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 \
diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp
index c5a3c9e99..1eca5b19c 100644
--- a/src/core/api/thread_api.cpp
+++ b/src/core/api/thread_api.cpp
@@ -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)
diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp
index a4b44c959..7c500e802 100644
--- a/src/core/api/thread_ftd_api.cpp
+++ b/src/core/api/thread_ftd_api.cpp
@@ -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
diff --git a/src/core/meshcop/announce_begin_client.cpp b/src/core/meshcop/announce_begin_client.cpp
index 4081ebc4a..813161fb0 100644
--- a/src/core/meshcop/announce_begin_client.cpp
+++ b/src/core/meshcop/announce_begin_client.cpp
@@ -47,7 +47,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp
index 9ab8a336a..a40f8a9b4 100644
--- a/src/core/meshcop/commissioner.cpp
+++ b/src/core/meshcop/commissioner.cpp
@@ -45,14 +45,13 @@
#include "openthread/platform/random.h"
#include
-#include
#include
#include
#include
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -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
diff --git a/src/core/meshcop/dataset.cpp b/src/core/meshcop/dataset.cpp
index 9a6649a1e..4f013b21a 100644
--- a/src/core/meshcop/dataset.cpp
+++ b/src/core/meshcop/dataset.cpp
@@ -45,7 +45,7 @@
#include
#include
#include
-#include
+#include
#include
namespace ot {
diff --git a/src/core/meshcop/dataset.hpp b/src/core/meshcop/dataset.hpp
index 380521932..a41e20e61 100644
--- a/src/core/meshcop/dataset.hpp
+++ b/src/core/meshcop/dataset.hpp
@@ -36,7 +36,7 @@
#define MESHCOP_DATASET_HPP_
#include
-#include
+#include
namespace ot {
namespace MeshCoP {
diff --git a/src/core/meshcop/dataset_manager.cpp b/src/core/meshcop/dataset_manager.cpp
index 724a9c4b8..24cf39935 100644
--- a/src/core/meshcop/dataset_manager.cpp
+++ b/src/core/meshcop/dataset_manager.cpp
@@ -55,7 +55,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/meshcop/dataset_manager_ftd.cpp b/src/core/meshcop/dataset_manager_ftd.cpp
index cd2c3c0a4..dbe964809 100644
--- a/src/core/meshcop/dataset_manager_ftd.cpp
+++ b/src/core/meshcop/dataset_manager_ftd.cpp
@@ -56,7 +56,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/meshcop/dtls.hpp b/src/core/meshcop/dtls.hpp
index f6ec2175f..e5a742b42 100644
--- a/src/core/meshcop/dtls.hpp
+++ b/src/core/meshcop/dtls.hpp
@@ -39,7 +39,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/meshcop/energy_scan_client.cpp b/src/core/meshcop/energy_scan_client.cpp
index 207a13605..bb1099b7b 100644
--- a/src/core/meshcop/energy_scan_client.cpp
+++ b/src/core/meshcop/energy_scan_client.cpp
@@ -48,7 +48,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/meshcop/joiner.cpp b/src/core/meshcop/joiner.cpp
index 926b98f13..d620ec08e 100644
--- a/src/core/meshcop/joiner.cpp
+++ b/src/core/meshcop/joiner.cpp
@@ -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;
diff --git a/src/core/meshcop/joiner.hpp b/src/core/meshcop/joiner.hpp
index f226d46eb..e7efc61d5 100644
--- a/src/core/meshcop/joiner.hpp
+++ b/src/core/meshcop/joiner.hpp
@@ -43,7 +43,7 @@
#include
#include
#include
-#include
+#include
namespace ot {
diff --git a/src/core/meshcop/joiner_router.cpp b/src/core/meshcop/joiner_router.cpp
index 81736cd59..f74ff65a4 100644
--- a/src/core/meshcop/joiner_router.cpp
+++ b/src/core/meshcop/joiner_router.cpp
@@ -48,7 +48,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/meshcop/joiner_router.hpp b/src/core/meshcop/joiner_router.hpp
index 6a4cdcb73..386411069 100644
--- a/src/core/meshcop/joiner_router.hpp
+++ b/src/core/meshcop/joiner_router.hpp
@@ -43,7 +43,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/meshcop/leader.cpp b/src/core/meshcop/leader.cpp
index 1c2f63aa2..3e455ac9e 100644
--- a/src/core/meshcop/leader.cpp
+++ b/src/core/meshcop/leader.cpp
@@ -50,7 +50,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/meshcop/leader.hpp b/src/core/meshcop/leader.hpp
index b0f1d524b..f4a8ba628 100644
--- a/src/core/meshcop/leader.hpp
+++ b/src/core/meshcop/leader.hpp
@@ -37,7 +37,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/meshcop/meshcop_tlvs.cpp b/src/core/meshcop/meshcop_tlvs.cpp
new file mode 100644
index 000000000..14ebabad7
--- /dev/null
+++ b/src/core/meshcop/meshcop_tlvs.cpp
@@ -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
+
+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
diff --git a/src/core/meshcop/tlvs.hpp b/src/core/meshcop/meshcop_tlvs.hpp
similarity index 99%
rename from src/core/meshcop/tlvs.hpp
rename to src/core/meshcop/meshcop_tlvs.hpp
index fe1d81e09..b34a92c5e 100644
--- a/src/core/meshcop/tlvs.hpp
+++ b/src/core/meshcop/meshcop_tlvs.hpp
@@ -39,6 +39,7 @@
#include "openthread/types.h"
+#include
#include
#include
#include
@@ -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;
diff --git a/src/core/meshcop/panid_query_client.cpp b/src/core/meshcop/panid_query_client.cpp
index 3bffbf30f..3f196ad6a 100644
--- a/src/core/meshcop/panid_query_client.cpp
+++ b/src/core/meshcop/panid_query_client.cpp
@@ -48,7 +48,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h
index e8f4babbf..c47994d08 100644
--- a/src/core/openthread-core-default-config.h
+++ b/src/core/openthread-core-default-config.h
@@ -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_
diff --git a/src/core/thread/announce_begin_server.cpp b/src/core/thread/announce_begin_server.cpp
index 1aedc2ad7..a38a6adcb 100644
--- a/src/core/thread/announce_begin_server.cpp
+++ b/src/core/thread/announce_begin_server.cpp
@@ -45,7 +45,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/thread/energy_scan_server.cpp b/src/core/thread/energy_scan_server.cpp
index 146fc56ba..21149e411 100644
--- a/src/core/thread/energy_scan_server.cpp
+++ b/src/core/thread/energy_scan_server.cpp
@@ -46,7 +46,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp
index 27b1f35ec..dc5d67346 100644
--- a/src/core/thread/mle.cpp
+++ b/src/core/thread/mle.cpp
@@ -51,7 +51,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -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:
diff --git a/src/core/thread/mle.hpp b/src/core/thread/mle.hpp
index b89acf2a6..ad845b080 100644
--- a/src/core/thread/mle.hpp
+++ b/src/core/thread/mle.hpp
@@ -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;
diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp
index 8229c9bec..a58646c00 100644
--- a/src/core/thread/mle_router.cpp
+++ b/src/core/thread/mle_router.cpp
@@ -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
diff --git a/src/core/thread/mle_router_ftd.hpp b/src/core/thread/mle_router_ftd.hpp
index 0d0a25bd8..6f0392c60 100644
--- a/src/core/thread/mle_router_ftd.hpp
+++ b/src/core/thread/mle_router_ftd.hpp
@@ -42,6 +42,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -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
diff --git a/src/core/thread/mle_router_mtd.hpp b/src/core/thread/mle_router_mtd.hpp
index ad2cfd100..eb292e6b5 100644
--- a/src/core/thread/mle_router_mtd.hpp
+++ b/src/core/thread/mle_router_mtd.hpp
@@ -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; }
diff --git a/src/core/thread/network_diagnostic_tlvs.hpp b/src/core/thread/network_diagnostic_tlvs.hpp
index e7e15fc71..4e5ac29ac 100644
--- a/src/core/thread/network_diagnostic_tlvs.hpp
+++ b/src/core/thread/network_diagnostic_tlvs.hpp
@@ -41,7 +41,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/core/thread/panid_query_server.cpp b/src/core/thread/panid_query_server.cpp
index bb9cbeb94..15abc4bf9 100644
--- a/src/core/thread/panid_query_server.cpp
+++ b/src/core/thread/panid_query_server.cpp
@@ -46,7 +46,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include