From a388d6ef33dc3f7307acd8f1e2564e7521371273 Mon Sep 17 00:00:00 2001 From: wgtdkp Date: Thu, 15 Aug 2019 23:43:59 +0800 Subject: [PATCH] [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. --- src/core/meshcop/border_agent.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/meshcop/border_agent.cpp b/src/core/meshcop/border_agent.cpp index 9f72ec137..acb137eb9 100644 --- a/src/core/meshcop/border_agent.cpp +++ b/src/core/meshcop/border_agent.cpp @@ -230,10 +230,10 @@ void BorderAgent::HandleCoapResponse(void * aContext, Coap::Message * message = NULL; otError error; - VerifyOrExit((message = NewMeshCoPMessage(instance.Get())) != NULL, error = OT_ERROR_NO_BUFS); SuccessOrExit(error = aResult); + VerifyOrExit((message = NewMeshCoPMessage(instance.Get())) != 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()); }