From debf68dd09da9a8c08e3567e884e2dc81414bd77 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 20 Dec 2017 05:32:04 +0000 Subject: [PATCH] [meshcop] use joiner id when enabling discovery response filter (#2426) --- src/core/api/thread_ftd_api.cpp | 2 +- src/core/thread/mle.cpp | 14 ++++++++------ src/core/thread/mle_router.cpp | 15 ++++++++++----- src/core/thread/mle_router_ftd.hpp | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/core/api/thread_ftd_api.cpp b/src/core/api/thread_ftd_api.cpp index 415dcfa17..5c8f47af0 100644 --- a/src/core/api/thread_ftd_api.cpp +++ b/src/core/api/thread_ftd_api.cpp @@ -303,7 +303,7 @@ otError otThreadSetSteeringData(otInstance *aInstance, const otExtAddress *aExtA #if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB Instance &instance = *static_cast(aInstance); - error = instance.GetThreadNetif().GetMle().SetSteeringData(aExtAddress); + error = instance.GetThreadNetif().GetMle().SetSteeringData(static_cast(aExtAddress)); #else OT_UNUSED_VARIABLE(aInstance); OT_UNUSED_VARIABLE(aExtAddress); diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index bcf517b20..49454d8fd 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -48,6 +48,7 @@ #include "common/settings.hpp" #include "crypto/aes_ccm.hpp" #include "mac/mac_frame.hpp" +#include "meshcop/meshcop.hpp" #include "meshcop/meshcop_tlvs.hpp" #include "net/netif.hpp" #include "net/udp6.hpp" @@ -3249,18 +3250,19 @@ otError Mle::HandleDiscoveryResponse(const Message &aMessage, const Ip6::Message // or if it matches the factory set EUI64. if (mEnableEui64Filtering) { - otExtAddress mfgEUI64; + Mac::ExtAddress extaddr; Crc16 ccitt(Crc16::kCcitt); Crc16 ansi(Crc16::kAnsi); - // Get Factory set EUI64 - otPlatRadioGetIeeeEui64(&GetInstance(), mfgEUI64.m8); + otPlatRadioGetIeeeEui64(&GetInstance(), extaddr.m8); + + MeshCoP::ComputeJoinerId(extaddr, extaddr); // Compute bloom filter - for (size_t i = 0; i < sizeof(mfgEUI64.m8); i++) + for (size_t i = 0; i < sizeof(extaddr.m8); i++) { - ccitt.Update(mfgEUI64.m8[i]); - ansi.Update(mfgEUI64.m8[i]); + ccitt.Update(extaddr.m8[i]); + ansi.Update(extaddr.m8[i]); } // Drop responses that don't match the bloom filter diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index e0d9b4e13..e8d534bb7 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -47,6 +47,7 @@ #include "common/owner-locator.hpp" #include "common/settings.hpp" #include "mac/mac_frame.hpp" +#include "meshcop/meshcop.hpp" #include "net/icmp6.hpp" #include "thread/thread_netif.hpp" #include "thread/thread_tlvs.hpp" @@ -2635,11 +2636,11 @@ exit: } #if OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB -otError MleRouter::SetSteeringData(const otExtAddress *aExtAddress) +otError MleRouter::SetSteeringData(const Mac::ExtAddress *aExtAddress) { otError error = OT_ERROR_NONE; - ExtAddress nullExtAddr; - ExtAddress allowAnyExtAddr; + Mac::ExtAddress nullExtAddr; + Mac::ExtAddress allowAnyExtAddr; memset(nullExtAddr.m8, 0, sizeof(nullExtAddr.m8)); memset(allowAnyExtAddr.m8, 0xFF, sizeof(allowAnyExtAddr.m8)); @@ -2659,8 +2660,12 @@ otError MleRouter::SetSteeringData(const otExtAddress *aExtAddress) } else { - // Set bloom filter with the extended address passed in - mSteeringData.ComputeBloomFilter(*aExtAddress); + Mac::ExtAddress joinerId; + + // compute Joiner ID + MeshCoP::ComputeJoinerId(*aExtAddress, joinerId); + // compute Bloom Filter + mSteeringData.ComputeBloomFilter(joinerId); } return error; diff --git a/src/core/thread/mle_router_ftd.hpp b/src/core/thread/mle_router_ftd.hpp index 3bb30e31a..9a529b895 100644 --- a/src/core/thread/mle_router_ftd.hpp +++ b/src/core/thread/mle_router_ftd.hpp @@ -674,7 +674,7 @@ public: * @retval OT_ERROR_NONE Steering data was set * */ - otError SetSteeringData(const otExtAddress *aExtAddress); + otError SetSteeringData(const Mac::ExtAddress *aExtAddress); #endif // OPENTHREAD_CONFIG_ENABLE_STEERING_DATA_SET_OOB /**