if(responseInfo->info.type == CA_MSG_CONFIRM)
{
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
- CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0);
+ CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0, NULL);
}
OCPayloadDestroy(response.payload);
{
OC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
- CA_MSG_RESET, 0, NULL, NULL, 0);
+ CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
}
}
OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
const CAResponseResult_t responseResult, const CAMessageType_t type,
const uint8_t numOptions, const CAHeaderOption_t *options,
- CAToken_t token, uint8_t tokenLength)
+ CAToken_t token, uint8_t tokenLength, const char *resourceUri)
{
CAResponseInfo_t respInfo = {
.result = responseResult
respInfo.info.token = token;
respInfo.info.tokenLength = tokenLength;
respInfo.info.type = type;
+ respInfo.info.resourceUri = OICStrdup (resourceUri);
CAResult_t caResult = CASendResponse(endPoint, &respInfo);
+
+ // resourceUri in the info field is cloned in the CA layer and
+ // thus ownership is still here.
+ OICFree (respInfo.info.resourceUri);
+
if(caResult != CA_STATUS_OK)
{
OC_LOG(ERROR, TAG, "CASendResponse error");
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri);
OICFree(serverRequest.payload);
return;
}
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri);
OICFree(serverRequest.payload);
return;
}
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri);
OICFree(serverRequest.payload);
OICFree(serverRequest.requestToken);
return;
if(requestResult == OC_STACK_SLOW_RESOURCE)
{
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_EMPTY,
- CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0);
+ CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0, NULL);
}
else if(requestResult != OC_STACK_OK)
{
SendDirectStackResponse(endPoint, requestInfo->info.messageId, stackResponse,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
- requestInfo->info.tokenLength);
+ requestInfo->info.tokenLength, requestInfo->info.resourceUri);
}
// requestToken is fed to HandleStackRequests, which then goes to AddServerRequest.
// The token is copied in there, and is thus still owned by this function.