replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / cablockwisetransfer.h
index b9ee8a7..47cbdaa 100644 (file)
 
 #include <stdint.h>
 
-#include "coap.h"
+#include <coap/coap.h>
 #include "cathreadpool.h"
-#include "camutex.h"
+#include "octhread.h"
 #include "uarraylist.h"
 #include "cacommon.h"
 #include "caprotocolmessage.h"
+#include "camessagehandler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
 
 /**
  * Callback to send block data.
@@ -62,10 +68,10 @@ typedef struct
     u_arraylist_t *dataList;
 
     /** data list mutex for synchronization. **/
-    ca_mutex blockDataListMutex;
+    oc_mutex blockDataListMutex;
 
     /** sender mutex for synchronization. **/
-    ca_mutex blockDataSenderMutex;
+    oc_mutex blockDataSenderMutex;
 } CABlockWiseContext_t;
 
 /**
@@ -85,11 +91,12 @@ typedef struct
     coap_block_t block1;                /**< block1 option. */
     coap_block_t block2;                /**< block2 option. */
     uint16_t type;                      /**< block option type. */
-    CABlockDataID_t* blockDataId;        /**< ID set of CABlockData. */
+    CABlockDataID_t* blockDataId;       /**< ID set of CABlockData. */
     CAData_t *sentData;                 /**< sent request or response data information. */
     CAPayload_t payload;                /**< payload buffer. */
     size_t payloadLength;               /**< the total payload length to be received. */
     size_t receivedPayloadLen;          /**< currently received payload length. */
+    uint64_t ttl;                       /** The TTL for this blockData. */
 } CABlockData_t;
 
 /**
@@ -110,11 +117,6 @@ typedef enum
     CA_BLOCK_RECEIVED_ALREADY
 } CABlockState_t;
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
 /**
  * Initializes the block-wise transfer context.
  * @param[in]  CASendThreadFunc    function point to add data in send queue thread.
@@ -253,7 +255,7 @@ CAResult_t CASetNextBlockOption2(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
  * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
 CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
-                                coap_pdu_t *pdu, uint16_t blockType);
+                                const coap_pdu_t *pdu, uint16_t blockType);
 
 /**
  * Update the block option in block-wise transfer list.
@@ -492,6 +494,15 @@ uint8_t CAGetBlockOptionType(const CABlockDataID_t *blockID);
 CAData_t *CAGetDataSetFromBlockDataList(const CABlockDataID_t *blockID);
 
 /**
+ * Update the block data from block-wise transfer list.
+ * @param[in]   blockID     ID set of CABlockData.
+ * @param[in]   sendData    New block date should be sent.
+ * @return CAData structure.
+ */
+CABlockData_t *CAUpdateDataSetFromBlockDataList(const CABlockDataID_t *blockID,
+                                                const CAData_t *sendData);
+
+/**
  * Get token from block-wise transfer list.
  * @param[in]   pdu    received pdu binary data.
  * @param[in]   endpoint    remote endpoint information.
@@ -550,13 +561,32 @@ CABlockData_t *CACreateNewBlockData(const CAData_t *sendData);
 CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID);
 
 /**
- * Check if data exist in block-wise transfer list.
- * @param[in]   blockID     ID set of CABlockData.
- * @return true or false.
+ * Remove all block data in block-wise transfer list.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARemoveAllBlockDataFromList();
+
+/**
+ * Find the block data with seed info and remove it from block-wise transfer list.
+ * @param[in]   token         token of the message.
+ * @param[in]   tokenLength   token length of the message.
+ * @param[in]   portNumber    port.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  */
-bool CAIsBlockDataInList(const CABlockDataID_t *blockID);
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+                                             uint16_t portNumber);
 
+/**
+ * Reset TTL for a blockData.
+ *
+ * @param[in]   blockID     ID set of CABlockData.
+ */
+void CAResetBlockDataTTL(const CABlockDataID_t *blockID);
 
+/**
+ * Checks if the blockData is past its time to live and deletes it if timed-out.
+ */
+void CACheckAndDeleteTimedOutBlockData();
 #ifdef __cplusplus
 } /* extern "C" */
 #endif