replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / catcpadapter.h
index e3da369..536f8f6 100644 (file)
 #include "caadapterinterface.h"
 #include "cathreadpool.h"
 #include "cainterface.h"
+#include <coap/pdu.h>
 
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
+
+typedef enum CAProtocol
+{
+    UNKNOWN = 0,
+    TLS,
+    COAP
+} CAProtocol_t;
+
+/**
+ * TCP Connection State.
+ */
+typedef enum
+{
+    CONNECTING = 0,
+    CONNECTED,
+    DISCONNECTED
+} CATCPConnectionState_t;
+
 /**
  * TCP Session Information for IPv4 TCP transport
  */
@@ -42,9 +61,14 @@ typedef struct
 {
     CASecureEndpoint_t sep;             /**< secure endpoint information */
     int fd;                             /**< file descriptor info */
-    void *recvData;                     /**< received data from remote device*/
-    size_t recvDataLen;                 /**< received data length */
-    size_t totalDataLen;                /**< total data length */
+    unsigned char* data;                /**< received data from remote device */
+    size_t len;                         /**< received data length */
+    size_t totalLen;                    /**< total coap data length required to receive */
+    unsigned char tlsdata[18437];       /**< tls data(rfc5246: TLSCiphertext max (2^14+2048+5)) */
+    size_t tlsLen;                      /**< received tls data length */
+    CAProtocol_t protocol;              /**< application-level protocol */
+    CATCPConnectionState_t state;       /**< current tcp session state */
+    bool isClient;                      /**< Host Mode of Operation. */
 } CATCPSessionInfo_t;
 
 /**
@@ -76,6 +100,16 @@ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
 CAResult_t CAStartTCP();
 
 /**
+ * Disconnect TCP session.
+ * When there is no transmission for a long time.
+ * Some carrier Vendor is blocking data.
+ * Thur, TCP Session is cleaned through this function.
+ * @param[in]   endpoint       Remote Endpoint information (like ipaddress,
+ *                             port)
+ */
+CAResult_t CATCPDisconnectSession(const CAEndpoint_t *endpoint);
+
+/**
  * Start listening server for receiving connect requests.
  * Transport Specific Behavior:
  * TCP Starts Listening Server on a particular interface and prefixed port
@@ -109,11 +143,13 @@ CAResult_t CAStartTCPDiscoveryServer();
  *                              which the unicast data has to be sent.
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
-                             const void *data, uint32_t dataLen);
+                             const void *data, uint32_t dataLen,
+                             CADataType_t dataType);
 
 /**
  * Send Multicast data to the endpoint using the TCP connectivity.
@@ -121,11 +157,13 @@ int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
  *                              port)
  * @param[in]   data           Data which is required to be sent.
  * @param[in]   dataLen        Size of data to be sent.
+ * @param[in]   dataType       Data type which is REQUEST or RESPONSE.
  * @note  dataLen must be > 0.
  * @return  The number of bytes sent on the network, or -1 upon error.
  */
 int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
-                               const void *data, uint32_t dataLen);
+                               const void *data, uint32_t dataLen,
+                               CADataType_t dataType);
 
 /**
  * Get TCP Connectivity network information.