diff --git a/src/core/meshcop/commissioner.cpp b/src/core/meshcop/commissioner.cpp index 3bdf6b86e..51048be6d 100644 --- a/src/core/meshcop/commissioner.cpp +++ b/src/core/meshcop/commissioner.cpp @@ -287,7 +287,7 @@ otError Commissioner::AddJoiner(const Mac::ExtAddress *aEui64, const char *aPskd VerifyOrExit(StringLength(aPskd, Dtls::kPskMaxLength + 1) <= Dtls::kPskMaxLength, error = OT_ERROR_INVALID_ARGS); - RemoveJoiner(aEui64, 0); // remove immediately + RemoveJoiner(aEui64, 0, kJoinerOpFlagNotNotifyLeader); // remove immediately for (Joiner *joiner = &mJoiners[0]; joiner < OT_ARRAY_END(mJoiners); joiner++) { @@ -351,10 +351,12 @@ exit: return error; } -otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay) +otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay, JoinerOpFlag aFlags) { otError error = OT_ERROR_NOT_FOUND; + OT_ASSERT(!(aFlags & kJoinerOpFlagNotNotifyLeader) || aDelay == 0); + VerifyOrExit(mState == OT_COMMISSIONER_STATE_ACTIVE, error = OT_ERROR_INVALID_STATE); for (Joiner *joiner = &mJoiners[0]; joiner < OT_ARRAY_END(mJoiners); joiner++) @@ -392,7 +394,10 @@ otError Commissioner::RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDela joiner->mValid = false; UpdateJoinerExpirationTimer(); - SendCommissionerSet(); + if ((aFlags & kJoinerOpFlagNotNotifyLeader) == 0) + { + SendCommissionerSet(); + } otLogInfoMeshCoP("Removed Joiner (%s)", (aEui64 != NULL) ? aEui64->ToString().AsCString() : "*"); diff --git a/src/core/meshcop/commissioner.hpp b/src/core/meshcop/commissioner.hpp index aa02e6a05..6af3a013d 100644 --- a/src/core/meshcop/commissioner.hpp +++ b/src/core/meshcop/commissioner.hpp @@ -58,6 +58,16 @@ namespace MeshCoP { class Commissioner : public InstanceLocator { public: + /** + * Joiner operation flags. + * + */ + enum JoinerOpFlag + { + kJoinerOpFlagDefault = 0, ///< The default flags + kJoinerOpFlagNotNotifyLeader = 1 << 0, ///< Do not notify Leader + }; + /** * This constructor initializes the Commissioner object. * @@ -128,15 +138,17 @@ public: /** * This method removes a Joiner entry. * - * @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. - * @param[in] aDelay The delay to remove Joiner (in seconds). + * @param[in] aEui64 A pointer to the Joiner's IEEE EUI-64 or NULL for any Joiner. + * @param[in] aDelay The delay to remove Joiner (in seconds). + * @param[in] aFlags The flags for removing the Joiner. * * @retval OT_ERROR_NONE Successfully added the Joiner. * @retval OT_ERROR_NOT_FOUND The Joiner specified by @p aEui64 was not found. * @retval OT_ERROR_INVALID_STATE Commissioner service is not started. * + * @sa JoinerOpFlag */ - otError RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay); + otError RemoveJoiner(const Mac::ExtAddress *aEui64, uint32_t aDelay, JoinerOpFlag aFlags = kJoinerOpFlagDefault); /** * This method gets the Provisioning URL. diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 1f26ae979..fd719165e 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -2827,7 +2827,7 @@ otError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Me else // if steering data is not set out of band, fall back to network data #endif // OPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE { - VerifyOrExit(Get().IsJoiningEnabled(), OT_NOOP); + VerifyOrExit(Get().IsJoiningEnabled(), error = OT_ERROR_SECURITY); } } @@ -2836,7 +2836,7 @@ otError MleRouter::HandleDiscoveryRequest(const Message &aMessage, const Ip6::Me case MeshCoP::Tlv::kExtendedPanId: aMessage.Read(offset, sizeof(extPanId), &extPanId); VerifyOrExit(extPanId.IsValid(), error = OT_ERROR_PARSE); - VerifyOrExit(Get().GetExtendedPanId() != extPanId.GetExtendedPanId(), OT_NOOP); + VerifyOrExit(Get().GetExtendedPanId() != extPanId.GetExtendedPanId(), error = OT_ERROR_DROP); break;