[border-agent] handle error responses from leader (#4097)

This commit removes an assumption in the border agent that COM_PET.rsp
from the leader 1is CHANGED.  It is possible for the leader to return
a 4.XX error response. In that case, the border agent should forward
the error response.
This commit is contained in:
wgtdkp
2019-08-15 08:43:59 -07:00
committed by Jonathan Hui
parent cdc3751e59
commit a388d6ef33
+3 -3
View File
@@ -230,10 +230,10 @@ void BorderAgent::HandleCoapResponse(void * aContext,
Coap::Message * message = NULL;
otError error;
VerifyOrExit((message = NewMeshCoPMessage(instance.Get<Coap::CoapSecure>())) != NULL, error = OT_ERROR_NO_BUFS);
SuccessOrExit(error = aResult);
VerifyOrExit((message = NewMeshCoPMessage(instance.Get<Coap::CoapSecure>())) != NULL, error = OT_ERROR_NO_BUFS);
if (forwardContext.IsPetition())
if (forwardContext.IsPetition() && response->GetCode() == OT_COAP_CODE_CHANGED)
{
StateTlv stateTlv;
@@ -257,7 +257,7 @@ void BorderAgent::HandleCoapResponse(void * aContext,
SuccessOrExit(error = forwardContext.ToHeader(*message, response->GetCode()));
if (response->GetLength() - response->GetOffset() > 0)
if (response->GetLength() > response->GetOffset())
{
SuccessOrExit(error = message->SetPayloadMarker());
}