mirror of
https://github.com/espressif/openthread.git
synced 2026-08-12 21:57:47 +00:00
[commissioner] remove duplicate MGMT_COMMISSISONER_SET.req (#4902)
- Remove the unnecessary MGMT_COMMISSISONER_SET.req sent by Commissioner to Leader when a Joiner is removed only to be added back. - Use proper error codes for MleRouter::HandleDiscoveryRequest
This commit is contained in:
@@ -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() : "*");
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<NetworkData::Leader>().IsJoiningEnabled(), OT_NOOP);
|
||||
VerifyOrExit(Get<NetworkData::Leader>().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<Mac::Mac>().GetExtendedPanId() != extPanId.GetExtendedPanId(), OT_NOOP);
|
||||
VerifyOrExit(Get<Mac::Mac>().GetExtendedPanId() != extPanId.GetExtendedPanId(), error = OT_ERROR_DROP);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user