mirror of
https://github.com/espressif/openthread.git
synced 2026-08-15 23:27:47 +00:00
[commissioner] add error checking to GetLeaderAloc and SendPetition in Start (#3949)
Adding the SendPetition error handling in Start and moving it before updating the state fixes the potential issue of locking up the commissioner in the OT_COMMISSIONER_STATE_PETITION state without having actually sent the petition.
This commit is contained in:
committed by
Jonathan Hui
parent
016b1b1523
commit
3fded34be1
@@ -154,10 +154,9 @@ otError Commissioner::Start(otCommissionerStateCallback aStateCallback,
|
||||
mCallbackContext = aCallbackContext;
|
||||
mTransmitAttempts = 0;
|
||||
|
||||
SuccessOrExit(error = SendPetition());
|
||||
SetState(OT_COMMISSIONER_STATE_PETITION);
|
||||
|
||||
SendPetition();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
@@ -507,7 +506,7 @@ otError Commissioner::SendMgmtCommissionerGetRequest(const uint8_t *aTlvs, uint8
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
SuccessOrExit(error = Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr()));
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleMgmtCommissionerGetResponse, this));
|
||||
@@ -604,7 +603,7 @@ otError Commissioner::SendMgmtCommissionerSetRequest(const otCommissioningDatase
|
||||
}
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
SuccessOrExit(error = Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr()));
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleMgmtCommissionerSetResponse, this));
|
||||
@@ -662,7 +661,7 @@ otError Commissioner::SendPetition(void)
|
||||
|
||||
SuccessOrExit(error = message->AppendTlv(commissionerId));
|
||||
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
SuccessOrExit(error = Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr()));
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
SuccessOrExit(
|
||||
@@ -759,7 +758,7 @@ otError Commissioner::SendKeepAlive(void)
|
||||
SuccessOrExit(error = message->AppendTlv(sessionId));
|
||||
|
||||
messageInfo.SetSockAddr(Get<Mle::MleRouter>().GetMeshLocal16());
|
||||
Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr());
|
||||
SuccessOrExit(error = Get<Mle::MleRouter>().GetLeaderAloc(messageInfo.GetPeerAddr()));
|
||||
messageInfo.SetPeerPort(kCoapUdpPort);
|
||||
SuccessOrExit(error = Get<Coap::Coap>().SendMessage(*message, messageInfo,
|
||||
Commissioner::HandleLeaderKeepAliveResponse, this));
|
||||
|
||||
Reference in New Issue
Block a user