From c5790f380133687616e5ec6d39709c98167f3d1f Mon Sep 17 00:00:00 2001 From: Eduardo Montoya Date: Thu, 8 Jul 2021 18:51:06 +0200 Subject: [PATCH] [mle] include the CCM flag in the Discovery Response (#6800) Commercial Commissioning Mode flag from the Security Policy has to be set in the Discovery Response TLV of the MLE Discovery Response messages. --- src/core/meshcop/meshcop_tlvs.hpp | 29 +++++++++++++++++++++++++++++ src/core/thread/mle_router.cpp | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/src/core/meshcop/meshcop_tlvs.hpp b/src/core/meshcop/meshcop_tlvs.hpp index bc1836c41..fc6deb267 100644 --- a/src/core/meshcop/meshcop_tlvs.hpp +++ b/src/core/meshcop/meshcop_tlvs.hpp @@ -2248,6 +2248,33 @@ public: } } + /** + * This method indicates whether or not the Commercial Commissioning Mode flag is set. + * + * @retval TRUE If the Commercial Commissioning Mode flag is set. + * @retval FALSE If the Commercial Commissioning Mode flag is not set. + * + */ + bool IsCommercialCommissioningMode(void) const { return (mFlags & kCCMMask) != 0; } + + /** + * This method sets the Commercial Commissioning Mode flag. + * + * @param[in] aCCM TRUE if set, FALSE otherwise. + * + */ + void SetCommercialCommissioningMode(bool aCCM) + { + if (aCCM) + { + mFlags |= kCCMMask; + } + else + { + mFlags &= ~kCCMMask; + } + } + private: enum { @@ -2255,6 +2282,8 @@ private: kVersionMask = 0xf << kVersionOffset, kNativeOffset = 3, kNativeMask = 1 << kNativeOffset, + kCCMOffset = 2, + kCCMMask = 1 << kCCMOffset, }; uint8_t mFlags; uint8_t mReserved; diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index ce80693f6..36419508b 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -2930,6 +2930,11 @@ Error MleRouter::SendDiscoveryResponse(const Ip6::Address &aDestination, const M discoveryResponse.SetNativeCommissioner(false); } + if (Get().GetSecurityPolicy().mCommercialCommissioningEnabled) + { + discoveryResponse.SetCommercialCommissioningMode(true); + } + SuccessOrExit(error = discoveryResponse.AppendTo(*message)); // Extended PAN ID TLV