support blockwise-transfer on RI layer
authorminus2k <minus2k@hotmail.com>
Mon, 24 Aug 2015 01:44:27 +0000 (10:44 +0900)
committerJon A. Cruz <jonc@osg.samsung.com>
Tue, 25 Aug 2015 18:19:02 +0000 (18:19 +0000)
Change-Id: I5bb08b94bf3cf4cab3ff5878260c845bee5592a5
Signed-off-by: Myungchul Kwak <minus2k@hotmail.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2256
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Naga Ashok Jampani <jn.ashok@samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/stack/include/internal/ocstackinternal.h
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c

index 224f456..028da46 100644 (file)
@@ -87,7 +87,7 @@ typedef struct
     char query[MAX_QUERY_LENGTH];
 
     /** reqJSON is retrieved from the payload of the received request PDU.*/
-    uint8_t payload[MAX_REQUEST_LENGTH];
+    uint8_t *payload;
 
     /** qos is indicating if the request is CON or NON.*/
     OCQualityOfService qos;
index 0390061..f54d0e2 100644 (file)
@@ -527,14 +527,6 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
             OICFree(responseInfo.info.options);
             return result;
         }
-
-        if(responseInfo.info.payloadSize > MAX_RESPONSE_LENGTH)
-        {
-            OICFree(responseInfo.info.payload);
-            OC_LOG(ERROR, TAG, "Payload too long!");
-            OICFree(responseInfo.info.options);
-            return OC_STACK_INVALID_PARAM;
-        }
     }
     else
     {
index 654b785..f34cf8c 100644 (file)
@@ -1307,10 +1307,11 @@ void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
         }
     }
 
-    if (requestInfo->info.payload)
+    if ((requestInfo->info.payload) && (0 < requestInfo->info.payloadSize))
     {
         serverRequest.reqTotalSize = requestInfo->info.payloadSize;
-        memcpy (&(serverRequest.payload), requestInfo->info.payload,
+        serverRequest.payload = (uint8_t *) OICMalloc(requestInfo->info.payloadSize);
+        memcpy (serverRequest.payload, requestInfo->info.payload,
                 requestInfo->info.payloadSize);
     }
     else
@@ -1338,6 +1339,7 @@ void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
                         requestInfo->info.type, requestInfo->info.numOptions,
                         requestInfo->info.options, requestInfo->info.token,
                         requestInfo->info.tokenLength);
+            OICFree(serverRequest.payload);
             return;
     }
 
@@ -1353,6 +1355,7 @@ void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
                 requestInfo->info.type, requestInfo->info.numOptions,
                 requestInfo->info.options, requestInfo->info.token,
                 requestInfo->info.tokenLength);
+        OICFree(serverRequest.payload);
         return;
     }
     memcpy(serverRequest.requestToken, requestInfo->info.token, requestInfo->info.tokenLength);
@@ -1384,6 +1387,7 @@ void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
                 requestInfo->info.type, requestInfo->info.numOptions,
                 requestInfo->info.options, requestInfo->info.token,
                 requestInfo->info.tokenLength);
+        OICFree(serverRequest.payload);
         OICFree(serverRequest.requestToken);
         return;
     }
@@ -1415,6 +1419,7 @@ void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* reque
     }
     // requestToken is fed to HandleStackRequests, which then goes to AddServerRequest.
     // The token is copied in there, and is thus still owned by this function.
+    OICFree(serverRequest.payload);
     OICFree(serverRequest.requestToken);
     OC_LOG(INFO, TAG, PCF("Exit HandleCARequests"));
 }