Modified the argument in CAAddBlockOption()
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Thu, 17 Sep 2015 04:22:10 +0000 (13:22 +0900)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Thu, 17 Sep 2015 16:59:01 +0000 (16:59 +0000)
In CAAddBlockOption1 and CAAddBlockOption2 the second argument
is a CAInfo_t. but This is a large array. so we have to use pointer.
This patch addresses the first part of IOT-690.

Change-Id: I78ce8799a6db1a4a378bca016dd27c3529109e2e
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2613
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/camessagehandler.c

index d3f883c..5ef83e2 100644 (file)
@@ -303,7 +303,7 @@ CAResult_t CAGetMoreBitFromBlock(size_t payloadLen, coap_block_t *block);
  * @param[in]   endpoint    port of transport.
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t info,
+CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
                             const CAEndpoint_t *endpoint);
 
 /**
@@ -314,7 +314,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t info,
  * @param[in]   blockID     ID set of CABlockData.
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t info, size_t dataLength,
+CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
                              const CABlockDataID_t *blockID);
 
 /**
@@ -325,7 +325,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t info, size_t dataL
  * @param[in]   blockID     ID set of CABlockData.
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t info, size_t dataLength,
+CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
                              const CABlockDataID_t *blockID);
 
 /**
index bcbb025..f0b8af3 100644 (file)
@@ -1377,19 +1377,20 @@ CAResult_t CAUpdateMessageId(coap_pdu_t *pdu, const CABlockDataID_t *blockID)
     return CA_STATUS_OK;
 }
 
-CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t info,
+CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
                             const CAEndpoint_t *endpoint)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
     VERIFY_NON_NULL((*pdu), TAG, "(*pdu)");
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
+    VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(endpoint, TAG, "endpoint");
 
     size_t dataLength = 0;
-    if (info.payload)
+    if (info->payload)
     {
-        dataLength = info.payloadSize;
+        dataLength = info->payloadSize;
         OIC_LOG_V(DEBUG, TAG, "dataLength - %d", dataLength);
     }
 
@@ -1441,7 +1442,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t info,
     {
         OIC_LOG(DEBUG, TAG, "no BLOCK option");
         // if response data is so large. it have to send as block transfer
-        if (!coap_add_data(*pdu, dataLength, (const unsigned char *) info.payload))
+        if (!coap_add_data(*pdu, dataLength, (const unsigned char *) info->payload))
         {
             OIC_LOG(INFO, TAG, "it have to use block");
         }
@@ -1466,13 +1467,14 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t info,
     return CA_STATUS_OK;
 }
 
-CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t info, size_t dataLength,
+CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
                              const CABlockDataID_t *blockID)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption2");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
     VERIFY_NON_NULL((*pdu), TAG, "(*pdu)");
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
+    VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
 
     // get set block data from CABlock list-set.
@@ -1538,7 +1540,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t info, size_t dataL
             }
         }
 
-        if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info.payload,
+        if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload,
                             block2->num, block2->szx))
         {
             OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
@@ -1595,13 +1597,14 @@ error:
     return CA_STATUS_FAILED;
 }
 
-CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t info, size_t dataLength,
+CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
                              const CABlockDataID_t *blockID)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption1");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
     VERIFY_NON_NULL((*pdu), TAG, "(*pdu)");
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
+    VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
 
     // get set block data from CABlock list-set.
@@ -1661,7 +1664,7 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t info, size_t dataL
             }
         }
 
-        if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info.payload,
+        if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload,
                             block1->num, block1->szx))
         {
             OIC_LOG(ERROR, TAG, "Data length is smaller than the start index");
index 982f1a8..2343a5a 100644 (file)
@@ -471,7 +471,7 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                 // Blockwise transfer
                 if (NULL != info)
                 {
-                    CAResult_t res = CAAddBlockOption(&pdu, *info,
+                    CAResult_t res = CAAddBlockOption(&pdu, info,
                                                       data->remoteEndpoint);
                     if (CA_STATUS_OK != res)
                     {
@@ -506,8 +506,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 #endif
             {
                 // for retransmission
-                res = CARetransmissionSentData(&g_retransmissionContext, data->remoteEndpoint, pdu->hdr,
-                                               pdu->length);
+                res = CARetransmissionSentData(&g_retransmissionContext, data->remoteEndpoint,
+                                               pdu->hdr, pdu->length);
                 if ((CA_STATUS_OK != res) && (CA_NOT_SUPPORTED != res))
                 {
                     //when retransmission not supported this will return CA_NOT_SUPPORTED, ignore
@@ -545,7 +545,7 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                         )
                 {
                     // Blockwise transfer
-                    CAResult_t res = CAAddBlockOption(&pdu, data->requestInfo->info,
+                    CAResult_t res = CAAddBlockOption(&pdu, &data->requestInfo->info,
                                                       data->remoteEndpoint);
                     if (CA_STATUS_OK != res)
                     {
@@ -583,8 +583,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                     // Blockwise transfer
                     if (NULL != info)
                     {
-                        CAResult_t res = CAAddBlockOption(&pdu, *info,
-                                data->remoteEndpoint);
+                        CAResult_t res = CAAddBlockOption(&pdu, info,
+                                                          data->remoteEndpoint);
                         if (CA_STATUS_OK != res)
                         {
                             OIC_LOG(INFO, TAG, "to write block option has failed");