Update snapshot(2018-02-07)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / catcpinterface.h
index dc86e0f..d617365 100644 (file)
@@ -44,11 +44,12 @@ extern "C"
  * @param[in]  endpoint      network endpoint description.
  * @param[in]  data          Data received from remote OIC device.
  * @param[in]  dataLength    Length of data in bytes.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
  * @pre  Callback must be registered using CAIPSetPacketReceiveCallback().
  */
-typedef void (*CATCPPacketReceivedCallback)(const CASecureEndpoint_t *endpoint,
-                                            const void *data,
-                                            size_t dataLength);
+typedef CAResult_t (*CATCPPacketReceivedCallback)(const CASecureEndpoint_t *endpoint,
+                                                  const void *data,
+                                                  size_t dataLength);
 
 /**
   * Callback to notify error in the TCP adapter.
@@ -67,9 +68,11 @@ typedef void (*CATCPErrorHandleCallback)(const CAEndpoint_t *endpoint, const voi
   *
   * @param[in]  endpoint        network endpoint description.
   * @param[in]  isConnected     Whether keepalive message needs to be sent.
+  * @param[in]  isClient        Host Mode of Operation.
   * @see  Callback must be registered using CATCPSetKeepAliveCallback().
  */
-typedef void (*CATCPConnectionHandleCallback)(const CAEndpoint_t *endpoint, bool isConnected);
+typedef void (*CATCPConnectionHandleCallback)(const CAEndpoint_t *endpoint, bool isConnected,
+                                              bool isClient);
 
 /**
  * set error callback to notify error in TCP adapter.
@@ -107,6 +110,7 @@ void CAGetTCPHeaderDetails(unsigned char *recvBuffer, coap_transport_t *transpor
 size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t size);
 
 #else
+#ifdef TCP_ADAPTER
 /**
  * set keepalive callback to notify connection information in TCP adapter.
  *
@@ -114,6 +118,7 @@ size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t
  * in the TCP adapter.
  */
 void CATCPSetKeepAliveCallback(CAKeepAliveConnectionCallback keepaliveHandler);
+#endif
 
 /**
  * Start TCP server.
@@ -232,6 +237,12 @@ CASocketFd_t CAGetSocketFDFromEndpoint(const CAEndpoint_t *endpoint);
  */
 CAResult_t CASearchAndDeleteTCPSession(const CAEndpoint_t *endpoint);
 
+
+/**
+ * Abort TCP sessions which are in progress of connecting with servers.
+ */
+void CATCPCloseInProgressConnections();
+
 /**
  * Get total payload length from CoAP over TCP header.
  *
@@ -259,6 +270,55 @@ CAResult_t CAConstructCoAP(CATCPSessionInfo_t *svritem, unsigned char **data,
  */
 void CACleanData(CATCPSessionInfo_t *svritem);
 
+/**
+ * Create a mutex object.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CATCPCreateMutex();
+
+/**
+ * Close a mutex object.
+ */
+void CATCPDestroyMutex();
+
+/**
+ * Create a mutex object for send data.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CATCPCreateSendMutex();
+
+/**
+ * Close a mutex object for send data.
+ */
+void CATCPDestroySendMutex();
+
+
+/**
+ * Initialize a condition variable.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CATCPCreateCond();
+
+/**
+ * Destroy condition variable state.
+ */
+void CATCPDestroyCond();
+
+/**
+ * Initialize a condition variable for send data.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CATCPCreateSendCond();
+
+/**
+ * Destroy condition variable state for send data.
+ */
+void CATCPDestroySendCond();
+
 #ifdef __cplusplus
 }
 #endif