Merged "fixed the dependency issue between RM and BWT (IOT-731/IOT-712)"
authorjihwan.seo <jihwan.seo@samsung.com>
Mon, 5 Oct 2015 13:35:46 +0000 (22:35 +0900)
committerPatrick Lankswert <patrick.lankswert@intel.com>
Mon, 5 Oct 2015 22:15:20 +0000 (22:15 +0000)
I have fixed to conflict with Change 2825,
when Change 3347 is failed to merge for v1.0.0 branch.

https://gerrit.iotivity.org/gerrit/#/c/2825/
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Change-Id: I5b781d24ff8a7c18f4e479e854cd416b9d173b29
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3497
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
resource/csdk/connectivity/inc/cablockwisetransfer.h
resource/csdk/connectivity/inc/caprotocolmessage.h
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/connectivity/src/caprotocolmessage.c

index 5ef83e2..49461f8 100644 (file)
@@ -304,7 +304,7 @@ CAResult_t CAGetMoreBitFromBlock(size_t payloadLen, coap_block_t *block);
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
 CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
-                            const CAEndpoint_t *endpoint);
+                            const CAEndpoint_t *endpoint, coap_list_t **options);
 
 /**
  * Write the block option2 in pdu binary data.
@@ -315,7 +315,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
  * @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,
-                             const CABlockDataID_t *blockID);
+                             const CABlockDataID_t *blockID, coap_list_t **options);
 
 /**
  * Write the block option1 in pdu binary data.
@@ -326,7 +326,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
  * @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,
-                             const CABlockDataID_t *blockID);
+                             const CABlockDataID_t *blockID, coap_list_t **options);
 
 /**
  * Add the block option in pdu data.
@@ -335,7 +335,8 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
  * @param[in]   blockType   block option type.
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t blockType);
+CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t blockType,
+                                coap_list_t **options);
 
 /**
  * Add the size option in pdu data.
@@ -344,7 +345,8 @@ CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t bl
  * @param[in]   dataLength the total payload length to be sent.
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength);
+CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength,
+                                coap_list_t **options);
 
 /**
  * Get the size option from pdu data.
index 1da4209..29b5478 100644 (file)
@@ -57,7 +57,8 @@ static const uint8_t PAYLOAD_MARKER = 1;
  * @param[in]   endpoint             endpoint information.
  * @return  generated pdu.
  */
-coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint);
+coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint,
+                          coap_list_t **optlist, coap_transport_type *transport);
 
 /**
  * extracts request information from received pdu.
@@ -98,7 +99,8 @@ CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endp
  * @return  generated pdu.
  */
 coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
-                              const CAEndpoint_t *endpoint, coap_list_t *options);
+                              const CAEndpoint_t *endpoint, coap_list_t *options,
+                              coap_transport_type *transport);
 
 /**
  * parse the URI and creates the options.
index 9d66075..488686c 100644 (file)
@@ -118,8 +118,6 @@ CAResult_t CATerminateBlockWiseTransfer()
 
 CAResult_t CAInitBlockWiseMutexVariables()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!g_context.blockDataListMutex)
     {
         g_context.blockDataListMutex = ca_mutex_new();
@@ -146,8 +144,6 @@ CAResult_t CAInitBlockWiseMutexVariables()
 
 void CATerminateBlockWiseMutexVariables()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (g_context.blockDataListMutex)
     {
         ca_mutex_free(g_context.blockDataListMutex);
@@ -1390,7 +1386,7 @@ CAResult_t CAUpdateMessageId(coap_pdu_t *pdu, const CABlockDataID_t *blockID)
 }
 
 CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
-                            const CAEndpoint_t *endpoint)
+                            const CAEndpoint_t *endpoint, coap_list_t **options)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
@@ -1398,6 +1394,7 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(endpoint, TAG, "endpoint");
+    VERIFY_NON_NULL(options, TAG, "options");
 
     size_t dataLength = 0;
     if (info->payload)
@@ -1408,11 +1405,12 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
 
     OIC_LOG_V(DEBUG, TAG, "previous payload - %s", (*pdu)->data);
 
+    CAResult_t res = CA_STATUS_OK;
     uint32_t code = CA_RESPONSE_CODE((*pdu)->hdr->coap_hdr_udp_t.code);
     if (CA_REQUEST_ENTITY_INCOMPLETE == code)
     {
         OIC_LOG(INFO, TAG, "don't use option");
-        return CA_STATUS_OK;
+        return res;
     }
 
     CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
@@ -1423,36 +1421,50 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
     if(NULL == blockDataID || NULL == blockDataID->id || blockDataID->idLength < 1)
     {
         OIC_LOG(ERROR, TAG, "blockId is null");
-        CADestroyBlockID(blockDataID);
-        return CA_STATUS_FAILED;
+        res = CA_STATUS_FAILED;
+        goto exit;
     }
 
     uint8_t blockType = CAGetBlockOptionType(blockDataID);
     if (COAP_OPTION_BLOCK2 == blockType)
     {
-        CAResult_t res = CAAddBlockOption2(pdu, info, dataLength,
-                                           blockDataID);
+        res = CAAddBlockOption2(pdu, info, dataLength, blockDataID, options);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "add has failed");
-            CADestroyBlockID(blockDataID);
-            return res;
+            goto exit;
         }
     }
     else if (COAP_OPTION_BLOCK1 == blockType)
     {
-        CAResult_t res = CAAddBlockOption1(pdu, info, dataLength,
-                                           blockDataID);
+        res = CAAddBlockOption1(pdu, info, dataLength, blockDataID, options);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "add has failed");
-            CADestroyBlockID(blockDataID);
-            return res;
+            goto exit;
         }
     }
     else
     {
         OIC_LOG(DEBUG, TAG, "no BLOCK option");
+
+        // in case it is not large data, add option list to pdu.
+        if (*options)
+        {
+            for (coap_list_t *opt = *options; opt; opt = opt->next)
+            {
+                OIC_LOG_V(DEBUG, TAG, "[%s] opt will be added.",
+                          COAP_OPTION_DATA(*(coap_option *) opt->data));
+
+                OIC_LOG_V(DEBUG, TAG, "[%d] pdu length", (*pdu)->length);
+                coap_add_option(*pdu, COAP_OPTION_KEY(*(coap_option *) opt->data),
+                                COAP_OPTION_LENGTH(*(coap_option *) opt->data),
+                                COAP_OPTION_DATA(*(coap_option *) opt->data), coap_udp);
+            }
+        }
+
+        OIC_LOG_V(DEBUG, TAG, "[%d] pdu length after option", (*pdu)->length);
+
         // if response data is so large. it have to send as block transfer
         if (!coap_add_data(*pdu, dataLength, (const unsigned char *) info->payload))
         {
@@ -1461,26 +1473,31 @@ CAResult_t CAAddBlockOption(coap_pdu_t **pdu, const CAInfo_t *info,
         else
         {
             OIC_LOG(INFO, TAG, "not Blockwise Transfer");
-            CADestroyBlockID(blockDataID);
-            return CA_STATUS_OK;
+            goto exit;
         }
     }
 
-    CAResult_t res = CAUpdateMessageId(*pdu, blockDataID);
+    // if received message type is RESET from remote device,
+    // we have to use the updated message id to find token.
+    res = CAUpdateMessageId(*pdu, blockDataID);
     if (CA_STATUS_OK != res)
     {
         OIC_LOG(ERROR, TAG, "fail to update CON message id ");
-        CADestroyBlockID(blockDataID);
-        return res;
+        goto exit;
     }
 
+exit:
+    if (CA_ADAPTER_IP == endpoint->adapter && 0 == endpoint->port)
+    {
+        CARemoveBlockDataFromList(blockDataID);
+    }
     CADestroyBlockID(blockDataID);
     OIC_LOG(DEBUG, TAG, "OUT-AddBlockOption");
-    return CA_STATUS_OK;
+    return res;
 }
 
 CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
-                             const CABlockDataID_t *blockID)
+                             const CABlockDataID_t *blockID, coap_list_t **options)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption2");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
@@ -1488,6 +1505,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
+    VERIFY_NON_NULL(options, TAG, "options");
 
     // get set block data from CABlock list-set.
     coap_block_t *block1 = CAGetBlockOption(blockID,
@@ -1526,30 +1544,30 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
         }
         CALogBlockInfo(block2);
 
-        if (block1->num)
+        // if block number is 0, add size2 option
+        if (0 == block2->num)
         {
-            OIC_LOG(DEBUG, TAG, "combining block1 and block2");
-            CAResult_t res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1);
+            res = CAAddBlockSizeOption(*pdu, COAP_OPTION_SIZE2, dataLength, options);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG(ERROR, TAG, "add has failed");
                 CARemoveBlockDataFromList(blockID);
                 return res;
             }
-            // initialize block number
-            block1->num = 0;
         }
 
-        // if block number is 0, add size2 option
-        if (0 == block2->num)
+        if (block1->num)
         {
-            res = CAAddBlockSizeOption(*pdu, COAP_OPTION_SIZE2, dataLength);
+            OIC_LOG(DEBUG, TAG, "combining block1 and block2");
+            CAResult_t res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1, options);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG(ERROR, TAG, "add has failed");
                 CARemoveBlockDataFromList(blockID);
                 return res;
             }
+            // initialize block number
+            block1->num = 0;
         }
 
         if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload,
@@ -1586,7 +1604,7 @@ CAResult_t CAAddBlockOption2(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     else
     {
         OIC_LOG(DEBUG, TAG, "option2, not ACK msg");
-        CAResult_t res = CAAddBlockOptionImpl(*pdu, block2, COAP_OPTION_BLOCK2);
+        CAResult_t res = CAAddBlockOptionImpl(*pdu, block2, COAP_OPTION_BLOCK2, options);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "add has failed");
@@ -1610,7 +1628,7 @@ error:
 }
 
 CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t dataLength,
-                             const CABlockDataID_t *blockID)
+                             const CABlockDataID_t *blockID, coap_list_t **options)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOption1");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
@@ -1618,6 +1636,7 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     VERIFY_NON_NULL((*pdu)->hdr, TAG, "(*pdu)->hdr");
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(blockID, TAG, "blockID");
+    VERIFY_NON_NULL(options, TAG, "options");
 
     // get set block data from CABlock list-set.
     coap_block_t *block1 = CAGetBlockOption(blockID, COAP_OPTION_BLOCK1);
@@ -1632,7 +1651,7 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     if (CA_MSG_ACKNOWLEDGE == (*pdu)->hdr->coap_hdr_udp_t.type)
     {
         OIC_LOG(DEBUG, TAG, "option1 and ACK msg..");
-        CAResult_t res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1);
+        CAResult_t res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1, options);
         if (CA_STATUS_OK != res)
         {
             OIC_LOG(ERROR, TAG, "add has failed");
@@ -1661,19 +1680,12 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     else
     {
         CAGetMoreBitFromBlock(dataLength, block1);
-        CAResult_t res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1);
-        if (CA_STATUS_OK != res)
-        {
-            OIC_LOG(ERROR, TAG, "add has failed");
-            CARemoveBlockDataFromList(blockID);
-            return res;
-        }
-        CALogBlockInfo(block1);
 
+        CAResult_t res = CA_STATUS_OK;
         // if block number is 0, add size1 option
         if (0 == block1->num)
         {
-            res = CAAddBlockSizeOption(*pdu, COAP_OPTION_SIZE1, dataLength);
+            res = CAAddBlockSizeOption(*pdu, COAP_OPTION_SIZE1, dataLength, options);
             if (CA_STATUS_OK != res)
             {
                 OIC_LOG(ERROR, TAG, "add has failed");
@@ -1682,6 +1694,15 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
             }
         }
 
+        res = CAAddBlockOptionImpl(*pdu, block1, COAP_OPTION_BLOCK1, options);
+        if (CA_STATUS_OK != res)
+        {
+            OIC_LOG(ERROR, TAG, "add has failed");
+            CARemoveBlockDataFromList(blockID);
+            return res;
+        }
+        CALogBlockInfo(block1);
+
         if (!coap_add_block(*pdu, dataLength, (const unsigned char *) info->payload,
                             block1->num, block1->szx))
         {
@@ -1719,41 +1740,55 @@ CAResult_t CAAddBlockOption1(coap_pdu_t **pdu, const CAInfo_t *info, size_t data
     return CA_STATUS_OK;
 }
 
-CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t blockType)
+CAResult_t CAAddBlockOptionImpl(coap_pdu_t *pdu, coap_block_t *block, uint8_t blockType,
+                                coap_list_t **options)
 {
     OIC_LOG(DEBUG, TAG, "IN-AddBlockOptionImpl");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
     VERIFY_NON_NULL(block, TAG, "block");
+    VERIFY_NON_NULL(options, TAG, "options");
+
+    unsigned char buf[BLOCKWISE_OPTION_BUFFER] = { 0 };
+    unsigned int optionLength = coap_encode_var_bytes(buf,
+                                                      ((block->num << BLOCK_NUMBER_IDX)
+                                                       | (block->m << BLOCK_M_BIT_IDX)
+                                                       | block->szx));
 
-    coap_option *option = (coap_option *) OICMalloc(sizeof(coap_option));
-    if (!option)
+    int ret = coap_insert(options,
+                          CACreateNewOptionNode(blockType, optionLength, (char *) buf),
+                          CAOrderOpts);
+    if (ret <= 0)
     {
-        OIC_LOG(ERROR, TAG, "out of memory");
-        return CA_MEMORY_ALLOC_FAILED;
+        return CA_STATUS_INVALID_PARAM;
     }
 
-    unsigned char buf[BLOCKWISE_OPTION_BUFFER] = { 0 };
-    option->key = blockType;
-    option->length = coap_encode_var_bytes(buf,
-                                           ((block->num << BLOCK_NUMBER_IDX)
-                                            | (block->m << BLOCK_M_BIT_IDX) | block->szx));
-    if (!coap_add_option(pdu, option->key, option->length, buf, coap_udp))
-    {
-        OIC_LOG(ERROR, TAG, "coap_add_option has failed");
-        OICFree(option);
-        return CA_STATUS_FAILED;
+    // after adding the block option to option list, add option list to pdu.
+    if (*options)
+    {
+        for (coap_list_t *opt = *options; opt; opt = opt->next)
+        {
+            OIC_LOG_V(DEBUG, TAG, "[%s] opt will be added.",
+                      COAP_OPTION_DATA(*(coap_option *) opt->data));
+
+            OIC_LOG_V(DEBUG, TAG, "[%d] pdu length", pdu->length);
+            coap_add_option(pdu, COAP_OPTION_KEY(*(coap_option *) opt->data),
+                            COAP_OPTION_LENGTH(*(coap_option *) opt->data),
+                            COAP_OPTION_DATA(*(coap_option *) opt->data), coap_udp);
+        }
     }
 
-    OICFree(option);
+    OIC_LOG_V(DEBUG, TAG, "[%d] pdu length after option", pdu->length);
 
     OIC_LOG(DEBUG, TAG, "OUT-AddBlockOptionImpl");
     return CA_STATUS_OK;
 }
 
-CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength)
+CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataLength,
+                                coap_list_t **options)
 {
     OIC_LOG(DEBUG, TAG, "IN-CAAddBlockSizeOption");
     VERIFY_NON_NULL(pdu, TAG, "pdu");
+    VERIFY_NON_NULL(options, TAG, "options");
 
     if (sizeType != COAP_OPTION_SIZE1 && sizeType != COAP_OPTION_SIZE2)
     {
@@ -1764,10 +1799,12 @@ CAResult_t CAAddBlockSizeOption(coap_pdu_t *pdu, uint16_t sizeType, size_t dataL
     unsigned char value[BLOCKWISE_OPTION_BUFFER] = { 0 };
     unsigned int optionLength = coap_encode_var_bytes(value, dataLength);
 
-    if (!coap_add_option(pdu, sizeType, optionLength, value, coap_udp))
+    int ret = coap_insert(options,
+                          CACreateNewOptionNode(sizeType, optionLength, (char *) value),
+                          CAOrderOpts);
+    if (ret <= 0)
     {
-        OIC_LOG(ERROR, TAG, "failed to add size option");
-        return CA_STATUS_FAILED;
+        return CA_STATUS_INVALID_PARAM;
     }
 
     OIC_LOG(DEBUG, TAG, "OUT-CAAddBlockSizeOption");
index 2343a5a..04dec57 100644 (file)
@@ -89,24 +89,18 @@ static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *endpoi
 #ifdef WITH_BWT
 void CAAddDataToSendThread(CAData_t *data)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_VOID(data, TAG, "data");
 
     // add thread
     CAQueueingThreadAddData(&g_sendThread, data, sizeof(CAData_t));
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 void CAAddDataToReceiveThread(CAData_t *data)
 {
-    OIC_LOG(DEBUG, TAG, "IN - CAAddDataToReceiveThread");
     VERIFY_NON_NULL_VOID(data, TAG, "data");
 
     // add thread
     CAQueueingThreadAddData(&g_receiveThread, data, sizeof(CAData_t));
-
-    OIC_LOG(DEBUG, TAG, "OUT - CAAddDataToReceiveThread");
 }
 #endif
 
@@ -256,7 +250,6 @@ static CAData_t* CAGenerateHandlerData(const CAEndpoint_t *endpoint,
 
 static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uint32_t size)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint");
     VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");
 
@@ -309,8 +302,6 @@ static void CATimeoutCallback(const CAEndpoint_t *endpoint, const void *pdu, uin
 #else
     CAQueueingThreadAddData(&g_receiveThread, cadata, sizeof(CAData_t));
 #endif
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 static void CADestroyData(void *data, uint32_t size)
@@ -397,20 +388,17 @@ static void CAProcessReceivedData(CAData_t *data)
 
 static void CAReceiveThreadProcess(void *threadData)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
 #ifndef SINGLE_HANDLE
     CAData_t *data = (CAData_t *) threadData;
     CAProcessReceivedData(data);
 #else
     (void)threadData;
 #endif
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 #endif
 
 static CAResult_t CAProcessSendData(const CAData_t *data)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL(data, TAG, "data");
     VERIFY_NON_NULL(data->remoteEndpoint, TAG, "remoteEndpoint");
 
@@ -420,6 +408,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 
     coap_pdu_t *pdu = NULL;
     CAInfo_t *info = NULL;
+    coap_list_t *options = NULL;
+    coap_transport_type transport;
 
     if (SEND_TYPE_UNICAST == type)
     {
@@ -440,7 +430,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 #ifdef ROUTING_GATEWAY
             skipRetransmission = data->requestInfo->info.skipRetransmission;
 #endif
-            pdu = CAGeneratePDU(data->requestInfo->method, info, data->remoteEndpoint);
+            pdu = CAGeneratePDU(data->requestInfo->method, info, data->remoteEndpoint,
+                                &options, &transport);
         }
         else if (NULL != data->responseInfo)
         {
@@ -450,7 +441,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
 #ifdef ROUTING_GATEWAY
             skipRetransmission = data->responseInfo->info.skipRetransmission;
 #endif
-            pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint);
+            pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint,
+                                &options, &transport);
         }
         else
         {
@@ -472,11 +464,13 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                 if (NULL != info)
                 {
                     CAResult_t res = CAAddBlockOption(&pdu, info,
-                                                      data->remoteEndpoint);
+                                                      data->remoteEndpoint,
+                                                      &options);
                     if (CA_STATUS_OK != res)
                     {
                         OIC_LOG(INFO, TAG, "to write block option has failed");
                         CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+                        coap_delete_list(options);
                         coap_delete_pdu(pdu);
                         return res;
                     }
@@ -490,6 +484,7 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
             {
                 OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
                 CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+                coap_delete_list(options);
                 coap_delete_pdu(pdu);
                 return res;
             }
@@ -512,11 +507,13 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                 {
                     //when retransmission not supported this will return CA_NOT_SUPPORTED, ignore
                     OIC_LOG_V(INFO, TAG, "retransmission is not enabled due to error, res : %d", res);
+                    coap_delete_list(options);
                     coap_delete_pdu(pdu);
                     return res;
                 }
             }
 
+            coap_delete_list(options);
             coap_delete_pdu(pdu);
         }
         else
@@ -534,7 +531,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
             OIC_LOG(DEBUG, TAG, "requestInfo is available..");
 
             info = &data->requestInfo->info;
-            pdu = CAGeneratePDU(CA_GET, info, data->remoteEndpoint);
+            pdu = CAGeneratePDU(CA_GET, info, data->remoteEndpoint, &options, &transport);
+
             if (NULL != pdu)
             {
 #ifdef WITH_BWT
@@ -546,11 +544,13 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                 {
                     // Blockwise transfer
                     CAResult_t res = CAAddBlockOption(&pdu, &data->requestInfo->info,
-                                                      data->remoteEndpoint);
+                                                      data->remoteEndpoint,
+                                                      &options);
                     if (CA_STATUS_OK != res)
                     {
                         OIC_LOG(DEBUG, TAG, "CAAddBlockOption has failed");
                         CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+                        coap_delete_list(options);
                         coap_delete_pdu(pdu);
                         return res;
                     }
@@ -569,7 +569,8 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
             OIC_LOG(DEBUG, TAG, "responseInfo is available..");
 
             info = &data->responseInfo->info;
-            pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint);
+            pdu = CAGeneratePDU(data->responseInfo->result, info, data->remoteEndpoint,
+                                &options, &transport);
 
             if (NULL != pdu)
             {
@@ -584,11 +585,13 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
                     if (NULL != info)
                     {
                         CAResult_t res = CAAddBlockOption(&pdu, info,
-                                                          data->remoteEndpoint);
+                                                          data->remoteEndpoint,
+                                                          &options);
                         if (CA_STATUS_OK != res)
                         {
                             OIC_LOG(INFO, TAG, "to write block option has failed");
                             CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+                            coap_delete_list(options);
                             coap_delete_pdu(pdu);
                             return res;
                         }
@@ -619,10 +622,12 @@ static CAResult_t CAProcessSendData(const CAData_t *data)
         {
             OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
             CAErrorHandler(data->remoteEndpoint, pdu->hdr, pdu->length, res);
+            coap_delete_list(options);
             coap_delete_pdu(pdu);
             return res;
         }
 
+        coap_delete_list(options);
         coap_delete_pdu(pdu);
     }
 
@@ -705,7 +710,6 @@ static bool CADropSecondMessage(CAHistory_t *history, const CAEndpoint_t *ep, ui
 static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
                                      const void *data, uint32_t dataLen)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_VOID(sep, TAG, "remoteEndpoint");
     VERIFY_NON_NULL_VOID(data, TAG, "data");
 
@@ -808,8 +812,6 @@ static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
 #endif
 
     coap_delete_pdu(pdu);
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 static void CANetworkChangedCallback(const CAEndpoint_t *info, CANetworkStatus_t status)
@@ -941,8 +943,6 @@ static CAData_t* CAPrepareSendData(const CAEndpoint_t *endpoint, const void *sen
 
 CAResult_t CADetachRequestMessage(const CAEndpoint_t *object, const CARequestInfo_t *request)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     VERIFY_NON_NULL(object, TAG, "object");
     VERIFY_NON_NULL(request, TAG, "request");
 
@@ -1005,14 +1005,12 @@ CAResult_t CADetachRequestMessage(const CAEndpoint_t *object, const CARequestInf
     }
 #endif
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 CAResult_t CADetachResponseMessage(const CAEndpoint_t *object,
                                    const CAResponseInfo_t *response)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL(object, TAG, "object");
     VERIFY_NON_NULL(response, TAG, "response");
 
@@ -1066,7 +1064,6 @@ CAResult_t CADetachResponseMessage(const CAEndpoint_t *object,
     }
 #endif
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
@@ -1085,16 +1082,13 @@ CAResult_t CADetachMessageResourceUri(const CAURI_t resourceUri, const CAToken_t
 void CASetInterfaceCallbacks(CARequestCallback ReqHandler, CAResponseCallback RespHandler,
                              CAErrorCallback errorHandler)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     g_requestHandler = ReqHandler;
     g_responseHandler = RespHandler;
     g_errorHandler = errorHandler;
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 CAResult_t CAInitializeMessageHandler()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     CASetPacketReceivedCallback(CAReceivedPacketCallback);
 
     CASetNetworkChangeCallback(CANetworkChangedCallback);
@@ -1175,13 +1169,11 @@ CAResult_t CAInitializeMessageHandler()
     CAInitializeAdapters();
 #endif
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 void CATerminateMessageHandler()
 {
-    OIC_LOG(DEBUG, TAG, "IN");
 #ifndef SINGLE_THREAD
     CATransportAdapter_t connType;
     u_arraylist_t *list = CAGetSelectedNetworkList();
@@ -1247,8 +1239,6 @@ void CATerminateMessageHandler()
     CARetransmissionStop(&g_retransmissionContext);
     CARetransmissionDestroy(&g_retransmissionContext);
 #endif
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 void CALogPDUInfo(coap_pdu_t *pdu, const CAEndpoint_t *endpoint)
index 382c090..227543d 100644 (file)
@@ -70,8 +70,6 @@ static unsigned int SEED = 0;
 CAResult_t CAGetRequestInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                                    CARequestInfo_t *outReqInfo)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (NULL == pdu || NULL == outReqInfo)
     {
         OIC_LOG(ERROR, TAG, "parameter is null");
@@ -82,15 +80,12 @@ CAResult_t CAGetRequestInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *en
     CAResult_t ret = CAGetInfoFromPDU(pdu, endpoint, &code, &(outReqInfo->info));
     outReqInfo->method = code;
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return ret;
 }
 
 CAResult_t CAGetResponseInfoFromPDU(const coap_pdu_t *pdu, CAResponseInfo_t *outResInfo,
                                     const CAEndpoint_t *endpoint)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (NULL == pdu || NULL == outResInfo)
     {
         OIC_LOG(ERROR, TAG, "parameter is null");
@@ -101,15 +96,12 @@ CAResult_t CAGetResponseInfoFromPDU(const coap_pdu_t *pdu, CAResponseInfo_t *out
     CAResult_t ret = CAGetInfoFromPDU(pdu, endpoint, &code, &(outResInfo->info));
     outResInfo->result = code;
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return ret;
 }
 
 CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                                  CAErrorInfo_t *errorInfo)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!pdu)
     {
         OIC_LOG(ERROR, TAG, "parameter is null");
@@ -118,16 +110,16 @@ CAResult_t CAGetErrorInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endp
 
     uint32_t code = 0;
     CAResult_t ret = CAGetInfoFromPDU(pdu, endpoint, &code, &errorInfo->info);
-    OIC_LOG(DEBUG, TAG, "OUT");
+
     return ret;
 }
 
-coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint)
+coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_t *endpoint,
+                          coap_list_t **optlist, coap_transport_type *transport)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     VERIFY_NON_NULL_RET(info, TAG, "info", NULL);
     VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint", NULL);
+    VERIFY_NON_NULL_RET(optlist, TAG, "optlist", NULL);
 
     coap_pdu_t *pdu = NULL;
 
@@ -136,7 +128,7 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_
     if (CA_MSG_RESET == info->type || (CA_EMPTY == code && CA_MSG_ACKNOWLEDGE == info->type))
     {
         OIC_LOG(DEBUG, TAG, "code is empty");
-        if (!(pdu = CAGeneratePDUImpl((code_t) code, info, endpoint, NULL)))
+        if (!(pdu = CAGeneratePDUImpl((code_t) code, info, endpoint, NULL, transport)))
         {
             OIC_LOG(ERROR, TAG, "pdu NULL");
             return NULL;
@@ -144,8 +136,6 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_
     }
     else
     {
-        coap_list_t *optlist = NULL;
-
         if (CA_MSG_ACKNOWLEDGE != info->type && info->resourceUri)
         {
             uint32_t length = strlen(info->resourceUri);
@@ -166,13 +156,9 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_
             OICStrcat(coapUri, uriLength, info->resourceUri);
 
             // parsing options in URI
-            CAResult_t res = CAParseURI(coapUri, &optlist);
+            CAResult_t res = CAParseURI(coapUri, optlist);
             if (CA_STATUS_OK != res)
             {
-                if (optlist)
-                {
-                    coap_delete_list(optlist);
-                }
                 OICFree(coapUri);
                 return NULL;
             }
@@ -180,35 +166,27 @@ coap_pdu_t *CAGeneratePDU(uint32_t code, const CAInfo_t *info, const CAEndpoint_
             OICFree(coapUri);
         }
         // parsing options in HeadOption
-        CAResult_t ret = CAParseHeadOption(code, info, &optlist);
+        CAResult_t ret = CAParseHeadOption(code, info, optlist);
         if (CA_STATUS_OK != ret)
         {
-            coap_delete_list(optlist);
             return NULL;
         }
 
-        pdu = CAGeneratePDUImpl((code_t) code, info, endpoint, optlist);
+        pdu = CAGeneratePDUImpl((code_t) code, info, endpoint, *optlist, transport);
         if (NULL == pdu)
         {
             OIC_LOG(ERROR, TAG, "pdu NULL");
-            coap_delete_list(optlist);
             return NULL;
         }
-
-        // free option list
-        coap_delete_list(optlist);
     }
 
     // pdu print method : coap_show_pdu(pdu);
-    OIC_LOG(DEBUG, TAG, "OUT");
     return pdu;
 }
 
 coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode,
                        const CAEndpoint_t *endpoint)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (NULL == data)
     {
         OIC_LOG(ERROR, TAG, "data is null");
@@ -274,18 +252,17 @@ coap_pdu_t *CAParsePDU(const char *data, uint32_t length, uint32_t *outCode,
         (*outCode) = (uint32_t) CA_RESPONSE_CODE(coap_get_code(outpdu, transport));
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return outpdu;
 }
 
 coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
-                              const CAEndpoint_t *endpoint, coap_list_t *options)
+                              const CAEndpoint_t *endpoint, coap_list_t *options,
+                              coap_transport_type *transport)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(info, TAG, "info", NULL);
     VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint", NULL);
+    VERIFY_NON_NULL_RET(transport, TAG, "transport", NULL);
 
-    coap_transport_type transport;
     unsigned int length = COAP_MAX_PDU_SIZE;
 #ifdef TCP_ADAPTER
     unsigned int msgLength = 0;
@@ -322,17 +299,17 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
         {
             msgLength = msgLength + info->payloadSize + PAYLOAD_MARKER;
         }
-        transport = coap_get_tcp_header_type_from_size(msgLength);
-        length = msgLength + coap_get_tcp_header_length_for_transport(transport)
+        *transport = coap_get_tcp_header_type_from_size(msgLength);
+        length = msgLength + coap_get_tcp_header_length_for_transport(*transport)
                 + info->tokenLength;
     }
     else
 #endif
     {
-        transport = coap_udp;
+        *transport = coap_udp;
     }
 
-    coap_pdu_t *pdu = coap_new_pdu(transport, length);
+    coap_pdu_t *pdu = coap_new_pdu(*transport, length);
 
     if (NULL == pdu)
     {
@@ -341,12 +318,12 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
     }
 
     OIC_LOG_V(DEBUG, TAG, "transport type: %d, payload size: %d",
-              transport, info->payloadSize);
+              *transport, info->payloadSize);
 
 #ifdef TCP_ADAPTER
     if (CA_ADAPTER_TCP == endpoint->adapter)
     {
-        coap_add_length(pdu, transport, msgLength);
+        coap_add_length(pdu, *transport, msgLength);
     }
     else
 #endif
@@ -371,7 +348,7 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
         pdu->hdr->coap_hdr_udp_t.type = info->type;
     }
 
-    coap_add_code(pdu, transport, code);
+    coap_add_code(pdu, *transport, code);
 
     if (info->token && CA_EMPTY != code)
     {
@@ -379,13 +356,25 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
         OIC_LOG_V(DEBUG, TAG, "token info token length: %d, token :", tokenLength);
         OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *)info->token, tokenLength);
 
-        int32_t ret = coap_add_token(pdu, tokenLength, (unsigned char *)info->token, transport);
+        int32_t ret = coap_add_token(pdu, tokenLength, (unsigned char *)info->token, *transport);
         if (0 == ret)
         {
             OIC_LOG(ERROR, TAG, "can't add token");
         }
     }
 
+#ifdef WITH_BWT
+    if (CA_ADAPTER_GATT_BTLE != endpoint->adapter
+#ifdef TCP_ADAPTER
+            && CA_ADAPTER_TCP != endpoint->adapter
+#endif
+            )
+    {
+        // option list will be added in blockwise-transfer
+        return pdu;
+    }
+#endif
+
     if (options)
     {
         for (coap_list_t *opt = options; opt; opt = opt->next)
@@ -396,38 +385,23 @@ coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
             OIC_LOG_V(DEBUG, TAG, "[%d] pdu length", pdu->length);
             coap_add_option(pdu, COAP_OPTION_KEY(*(coap_option *) opt->data),
                             COAP_OPTION_LENGTH(*(coap_option *) opt->data),
-                            COAP_OPTION_DATA(*(coap_option *) opt->data), transport);
+                            COAP_OPTION_DATA(*(coap_option *) opt->data), *transport);
         }
     }
 
     OIC_LOG_V(DEBUG, TAG, "[%d] pdu length after option", pdu->length);
 
-    bool enabledPayload = false;
-#ifndef WITH_BWT
-    enabledPayload = true;
-#endif
-
-    if (enabledPayload || CA_ADAPTER_GATT_BTLE == endpoint->adapter
-#ifdef TCP_ADAPTER
-            || CA_ADAPTER_TCP == endpoint->adapter
-#endif
-            )
+    if (NULL != info->payload && 0 < info->payloadSize)
     {
-        if (NULL != info->payload && 0 < info->payloadSize)
-        {
-            OIC_LOG(DEBUG, TAG, "payload is added");
-            coap_add_data(pdu, info->payloadSize, (const unsigned char *) info->payload);
-        }
+        OIC_LOG(DEBUG, TAG, "payload is added");
+        coap_add_data(pdu, info->payloadSize, (const unsigned char *) info->payload);
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return pdu;
 }
 
 CAResult_t CAParseURI(const char *uriInfo, coap_list_t **optlist)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (NULL == uriInfo)
     {
         OIC_LOG(ERROR, TAG, "uriInfo is null");
@@ -482,7 +456,6 @@ CAResult_t CAParseURI(const char *uriInfo, coap_list_t **optlist)
         }
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
@@ -549,7 +522,6 @@ CAResult_t CAParseUriPartial(const unsigned char *str, size_t length, int target
 CAResult_t CAParseHeadOption(uint32_t code, const CAInfo_t *info, coap_list_t **optlist)
 {
     (void)code;
-    OIC_LOG(DEBUG, TAG, "IN");
     VERIFY_NON_NULL_RET(info, TAG, "info is NULL", CA_STATUS_INVALID_PARAM);
 
     OIC_LOG_V(DEBUG, TAG, "parse Head Opt: %d", info->numOptions);
@@ -645,14 +617,11 @@ CAResult_t CAParseHeadOption(uint32_t code, const CAInfo_t *info, coap_list_t **
         }
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 coap_list_t *CACreateNewOptionNode(uint16_t key, uint32_t length, const char *data)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!data)
     {
         OIC_LOG(ERROR, TAG, "invalid pointer parameter");
@@ -703,13 +672,11 @@ coap_list_t *CACreateNewOptionNode(uint16_t key, uint32_t length, const char *da
         return NULL;
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return node;
 }
 
 int CAOrderOpts(void *a, void *b)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     if (!a || !b)
     {
         return a < b ? -1 : 1;
@@ -720,13 +687,11 @@ int CAOrderOpts(void *a, void *b)
         return -1;
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return COAP_OPTION_KEY(*(coap_option *) a) == COAP_OPTION_KEY(*(coap_option * ) b);
 }
 
 uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     uint32_t count = 0;
     coap_opt_t *option;
 
@@ -742,15 +707,12 @@ uint32_t CAGetOptionCount(coap_opt_iterator_t opt_iter)
         }
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return count;
 }
 
 CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                             uint32_t *outCode, CAInfo_t *outInfo)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!pdu || !outCode || !outInfo)
     {
         OIC_LOG(ERROR, TAG, "NULL pointer param");
@@ -1002,7 +964,6 @@ CAResult_t CAGetInfoFromPDU(const coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
         }
     }
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 
 exit:
@@ -1014,7 +975,6 @@ exit:
 CAResult_t CAGetTokenFromPDU(const coap_hdr_t *pdu_hdr, CAInfo_t *outInfo,
                              const CAEndpoint_t *endpoint)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     if (NULL == pdu_hdr)
     {
         OIC_LOG(ERROR, TAG, "pdu_hdr is null");
@@ -1058,15 +1018,11 @@ CAResult_t CAGetTokenFromPDU(const coap_hdr_t *pdu_hdr, CAInfo_t *outInfo,
 
     outInfo->tokenLength = token_length;
 
-    OIC_LOG(DEBUG, TAG, "OUT");
-
     return CA_STATUS_OK;
 }
 
 CAResult_t CAGenerateTokenInternal(CAToken_t *token, uint8_t tokenLength)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (!token)
     {
         OIC_LOG(ERROR, TAG, "invalid token pointer");
@@ -1124,21 +1080,16 @@ CAResult_t CAGenerateTokenInternal(CAToken_t *token, uint8_t tokenLength)
     OIC_LOG_V(DEBUG, TAG, "token len:%d, token:", tokenLength);
     OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *)(*token), tokenLength);
 
-    OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
 }
 
 void CADestroyTokenInternal(CAToken_t token)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
     OICFree(token);
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 void CADestroyInfo(CAInfo_t *info)
 {
-    OIC_LOG(DEBUG, TAG, "IN");
-
     if (NULL != info)
     {
         OIC_LOG(DEBUG, TAG, "free options");
@@ -1150,8 +1101,6 @@ void CADestroyInfo(CAInfo_t *info)
         OIC_LOG(DEBUG, TAG, "free payload");
         OICFree(info->payload);
     }
-
-    OIC_LOG(DEBUG, TAG, "OUT");
 }
 
 uint32_t CAGetOptionData(uint16_t key, const uint8_t *data, uint32_t len,