[meshcop] do not check keep-alive timeout when active commissioner re-petitions (#1931)

* Do not check keep-alive timeout when a recorded active commissioner re-petitions

* Force resign before accepting when active commissioner re-petitions

* Reduce duplicate code by putting mTimer.stop() inside of ResignCommissioner()
This commit is contained in:
Yuwen Lan
2017-06-26 22:11:41 -07:00
committed by Jonathan Hui
parent 6ca25d4d03
commit f27654ec36
+8 -2
View File
@@ -91,7 +91,13 @@ void Leader::HandlePetition(Coap::Header &aHeader, Message &aMessage, const Ip6:
SuccessOrExit(Tlv::GetTlv(aMessage, Tlv::kCommissionerId, sizeof(commissionerId), commissionerId));
VerifyOrExit(commissionerId.IsValid());
VerifyOrExit(!mTimer.IsRunning());
if (mTimer.IsRunning())
{
VerifyOrExit(!strncmp(commissionerId.GetCommissionerId(), mCommissionerId.GetCommissionerId(),
sizeof(mCommissionerId)));
ResignCommissioner();
}
data.mBorderAgentLocator.Init();
data.mBorderAgentLocator.SetBorderAgentLocator(HostSwap16(aMessageInfo.GetPeerAddr().mFields.m16[7]));
@@ -189,7 +195,6 @@ void Leader::HandleKeepAlive(Coap::Header &aHeader, Message &aMessage, const Ip6
else if (state.GetState() != StateTlv::kAccept)
{
responseState = StateTlv::kReject;
mTimer.Stop();
ResignCommissioner();
}
else
@@ -310,6 +315,7 @@ void Leader::SetEmptyCommissionerData(void)
void Leader::ResignCommissioner(void)
{
mTimer.Stop();
SetEmptyCommissionerData();
otLogInfoMeshCoP(GetInstance(), "commissioner inactive");