SendResponse is only used to send out ACKs, RESETs and error conditions
caught by the stack. The CA layer and the C++ SDK have SendResponse.
Renamed the function in ocstack.c to make the intent clearer.
Change-Id: I00a089273fd536d6dd30ac5f9e87ea0dc9fbb8b7
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/833
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Doug Hudson <douglas.hudson@intel.com>
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest);
OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest);
-OCStackResult SendResponse(const CARemoteEndpoint_t* endPoint, const uint16_t coapID,
+OCStackResult SendDirectStackResponse(const CARemoteEndpoint_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);
const CAResponseResult_t responseResult, const CAMessageType_t type,
const uint8_t numOptions, const CAHeaderOption_t *options,
CAToken_t token, uint8_t tokenLength);
//Need to send ACK when the response is CON
if(responseInfo->info.type == CA_MSG_CONFIRM)
{
//Need to send ACK when the response is CON
if(responseInfo->info.type == CA_MSG_CONFIRM)
{
- SendResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
+ SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0);
}
}
CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0);
}
}
{
OC_LOG(INFO, TAG, PCF("Received a response or notification,\
but I do not have callback. Sending RESET"));
{
OC_LOG(INFO, TAG, PCF("Received a response or notification,\
but I do not have callback. Sending RESET"));
- SendResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
+ SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
CA_MSG_RESET, 0, NULL, NULL, 0);
}
}
CA_MSG_RESET, 0, NULL, NULL, 0);
}
}
OC_LOG(INFO, TAG, PCF("Exit HandleCAResponses"));
}
OC_LOG(INFO, TAG, PCF("Exit HandleCAResponses"));
}
-
-OCStackResult SendResponse(const CARemoteEndpoint_t* endPoint, const uint16_t coapID,
+/*
+ * This function sends out Direct Stack Responses. These are responses that are not coming
+ * from the application entity handler. These responses have no payload and are usually ACKs,
+ * RESETs or some error conditions that were caught by the stack.
+ */
+OCStackResult SendDirectStackResponse(const CARemoteEndpoint_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)
const CAResponseResult_t responseResult, const CAMessageType_t type,
const uint8_t numOptions, const CAHeaderOption_t *options,
CAToken_t token, uint8_t tokenLength)
default:
{
OC_LOG(ERROR, TAG, PCF("Received CA method %d not supported"));
default:
{
OC_LOG(ERROR, TAG, PCF("Received CA method %d not supported"));
- SendResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ,
+ 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.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);
if (!serverRequest.requestToken)
{
OC_LOG(FATAL, TAG, "Server Request Token is NULL");
if (!serverRequest.requestToken)
{
OC_LOG(FATAL, TAG, "Server Request Token is NULL");
- SendResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR,
+ 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.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);
{
OC_LOG(ERROR, TAG,
PCF("The request info numOptions is greater than MAX_HEADER_OPTIONS"));
{
OC_LOG(ERROR, TAG,
PCF("The request info numOptions is greater than MAX_HEADER_OPTIONS"));
- SendResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
+ 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.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);
// Send ACK to client as precursor to slow response
if(requestResult == OC_STACK_SLOW_RESOURCE)
{
// Send ACK to client as precursor to slow response
if(requestResult == OC_STACK_SLOW_RESOURCE)
{
- SendResponse(endPoint, requestInfo->info.messageId, CA_EMPTY,
- CA_MSG_ACKNOWLEDGE,
- 0, // numptions
- NULL, // *options
- NULL, // token
- 0);
+ SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_EMPTY,
+ CA_MSG_ACKNOWLEDGE,0, NULL, NULL, 0);
}
else if(requestResult != OC_STACK_OK)
{
}
else if(requestResult != OC_STACK_OK)
{
CAResponseResult_t stackResponse = OCToCAStackResult(requestResult);
CAResponseResult_t stackResponse = OCToCAStackResult(requestResult);
- SendResponse(endPoint, requestInfo->info.messageId, stackResponse,
+ SendDirectStackResponse(endPoint, requestInfo->info.messageId, stackResponse,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
requestInfo->info.tokenLength);