VERIFY_NON_NULL(data, TAG, "data");
VERIFY_NON_NULL(data->remoteEndpoint, TAG, "remoteEndpoint");
- CAResult_t res = CA_STATUS_FAILED;
-
coap_pdu_t *pdu = NULL;
CAInfo_t *info = NULL;
coap_list_t *options = NULL;
coap_transport_type transport;
+ CAResult_t res = CA_SEND_FAILED;
if (NULL != data->requestInfo)
{
OIC_LOG(DEBUG, TAG, "requestInfo is available..");
)
{
// Blockwise transfer
- CAResult_t res = CAAddBlockOption(&pdu, info,
- data->remoteEndpoint,
- &options);
+ res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
if (CA_STATUS_OK != res)
{
OIC_LOG(DEBUG, TAG, "CAAddBlockOption has failed");
- CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
- coap_delete_list(options);
- coap_delete_pdu(pdu);
- return res;
+ goto exit;
}
}
#endif // WITH_BWT
{
OIC_LOG(ERROR,TAG,"Failed to generate multicast PDU");
CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
- return CA_SEND_FAILED;
+ return res;
}
}
else if (NULL != data->responseInfo)
// Blockwise transfer
if (NULL != info)
{
- CAResult_t res = CAAddBlockOption(&pdu, info,
- data->remoteEndpoint,
- &options);
+ res = CAAddBlockOption(&pdu, info, data->remoteEndpoint, &options);
if (CA_STATUS_OK != res)
{
OIC_LOG(INFO, TAG, "to write block option has failed");
- CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
- coap_delete_list(options);
- coap_delete_pdu(pdu);
- return res;
+ goto exit;
}
}
}
{
OIC_LOG(ERROR,TAG,"Failed to generate multicast PDU");
CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
- return CA_SEND_FAILED;
+ return res;
}
}
else
{
OIC_LOG(ERROR, TAG, "request or response info is empty");
- return CA_SEND_FAILED;
+ return res;
}
CALogPDUInfo(pdu, data->remoteEndpoint);
if (CA_STATUS_OK != res)
{
OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
- CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
- coap_delete_list(options);
- coap_delete_pdu(pdu);
- return res;
+ goto exit;
}
coap_delete_list(options);
coap_delete_pdu(pdu);
- return CA_STATUS_OK;
+ return res;
+
+exit:
+ CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+ return res;
}
static CAResult_t CAProcessSendData(const CAData_t *data)
if(!request)
{
OIC_LOG(ERROR, TAG, "CACloneRequestInfo failed");
- OICFree(cadata);
- return NULL;
+ goto exit;
}
cadata->type = request->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
if(!response)
{
OIC_LOG(ERROR, TAG, "CACloneResponseInfo failed");
- OICFree(cadata);
- return NULL;
+ goto exit;
}
cadata->type = response->isMulticast ? SEND_TYPE_MULTICAST : SEND_TYPE_UNICAST;
else
{
OIC_LOG(ERROR, TAG, "CAPrepareSendData unknown data type");
- OICFree(cadata);
- return NULL;
+ goto exit;
}
CAEndpoint_t* ep = CACloneEndpoint(endpoint);
cadata->remoteEndpoint = ep;
cadata->dataType = dataType;
return cadata;
+
+exit:
+ OICFree(cadata);
+ return NULL;
}
CAResult_t CADetachSendMessage(const CAEndpoint_t *endpoint, const void *sendMsg,
return CA_STATUS_OK;
}
-CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t token,
- uint8_t tokenLength, const CAHeaderOption_t *options,
- uint8_t numOptions)
-{
- (void)resourceUri;
- (void)token;
- (void)tokenLength;
- (void)options;
- (void)numOptions;
- return CA_NOT_SUPPORTED;
-}
-
void CASetInterfaceCallbacks(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
CAErrorCallback errorHandler)
{