From: Mandeep Shetty Date: Wed, 8 Apr 2015 23:20:45 +0000 (-0700) Subject: Added token length to direct stack responses. X-Git-Tag: 1.2.0+RC1~1855^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f034f4702f0970dfb7c56361d5aafc24f2fd13e;p=platform%2Fupstream%2Fiotivity.git Added token length to direct stack responses. Token length is required because the stack at the client side looks at the token field only if token length is non zero. Without the token, client application will not receive responses. Change-Id: If1f9e85473bd964651669640d2fe48c1821600d5 Signed-off-by: Mandeep Shetty Reviewed-on: https://gerrit.iotivity.org/gerrit/682 Tested-by: jenkins-iotivity Reviewed-by: Sakthivel Samidurai Reviewed-by: Erich Keane --- diff --git a/resource/csdk/stack/include/internal/ocstackinternal.h b/resource/csdk/stack/include/internal/ocstackinternal.h index 71d3e56..3518729 100644 --- a/resource/csdk/stack/include/internal/ocstackinternal.h +++ b/resource/csdk/stack/include/internal/ocstackinternal.h @@ -138,7 +138,7 @@ OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest); OCStackResult SendResponse(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); + CAToken_t token, uint8_t tokenLength); #ifdef WITH_PRESENCE diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 784ef52..233c46a 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -1112,7 +1112,7 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_ if(responseInfo->info.type == CA_MSG_CONFIRM) { SendResponse(endPoint, responseInfo->info.messageId, CA_EMPTY, - CA_MSG_ACKNOWLEDGE, 0, NULL, NULL); + CA_MSG_ACKNOWLEDGE, 0, NULL, NULL, 0); } } return; @@ -1160,7 +1160,7 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_ 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, - CA_MSG_RESET, 0, NULL, NULL); + CA_MSG_RESET, 0, NULL, NULL, 0); } } @@ -1189,7 +1189,7 @@ void HandleCAResponses(const CARemoteEndpoint_t* endPoint, const CAResponseInfo_ OCStackResult SendResponse(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) + CAToken_t token, uint8_t tokenLength) { CAResponseInfo_t respInfo = {}; respInfo.result = responseResult; @@ -1198,6 +1198,7 @@ OCStackResult SendResponse(const CARemoteEndpoint_t* endPoint, const uint16_t co respInfo.info.options = (CAHeaderOption_t*)options; respInfo.info.payload = NULL; respInfo.info.token = token; + respInfo.info.tokenLength = tokenLength; respInfo.info.type = type; CAResult_t caResult = CASendResponse(endPoint, &respInfo); @@ -1319,7 +1320,8 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t* OC_LOG(ERROR, TAG, PCF("Received CA method %d not supported")); SendResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ, requestInfo->info.type, requestInfo->info.numOptions, - requestInfo->info.options, requestInfo->info.token); + requestInfo->info.options, requestInfo->info.token, + requestInfo->info.tokenLength); return; } } @@ -1336,7 +1338,8 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t* OC_LOG(FATAL, TAG, "Server Request Token is NULL"); SendResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR, requestInfo->info.type, requestInfo->info.numOptions, - requestInfo->info.options, requestInfo->info.token); + requestInfo->info.options, requestInfo->info.token, + requestInfo->info.tokenLength); return; } memcpy(serverRequest.requestToken, requestInfo->info.token, requestInfo->info.tokenLength); @@ -1369,7 +1372,8 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t* PCF("The request info numOptions is greater than MAX_HEADER_OPTIONS")); SendResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT, requestInfo->info.type, requestInfo->info.numOptions, - requestInfo->info.options, requestInfo->info.token); + requestInfo->info.options, requestInfo->info.token, + requestInfo->info.tokenLength); return; } serverRequest.numRcvdVendorSpecificHeaderOptions = tempNum; @@ -1388,15 +1392,16 @@ void HandleCARequests(const CARemoteEndpoint_t* endPoint, const CARequestInfo_t* CA_MSG_ACKNOWLEDGE, 0, // numptions NULL, // *options - NULL // token - ); + NULL, // token + 0); } else if(requestResult != OC_STACK_OK) { OC_LOG(ERROR, TAG, PCF("HandleStackRequests failed")); SendResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ, requestInfo->info.type, requestInfo->info.numOptions, - requestInfo->info.options, requestInfo->info.token); + requestInfo->info.options, requestInfo->info.token, + requestInfo->info.tokenLength); } // requestToken is fed to HandleStackRequests, which then goes to AddServerRequest. // The token is copied in there, and is thus still owned by this function.