Update snapshot(2018-01-31)
[platform/upstream/iotivity.git] / resource / csdk / connectivity / inc / catcpadapter.h
index da1a91d..d1e7d20 100644 (file)
 #include "caadapterinterface.h"
 #include "cathreadpool.h"
 #include "cainterface.h"
-#include "pdu.h"
+#include <coap/pdu.h>
 
 #ifdef __cplusplus
 extern "C"
 {
 #endif
 
+// TLS data max size (rfc5246: TLSCiphertext max (2^14+2048+5))
+#define TLS_DATA_MAX_SIZE 18437
 
 typedef enum CAProtocol
 {
@@ -45,6 +47,16 @@ typedef enum CAProtocol
 } CAProtocol_t;
 
 /**
+ * TCP Connection State.
+ */
+typedef enum
+{
+    CONNECTING = 0,
+    CONNECTED,
+    DISCONNECTED
+} CATCPConnectionState_t;
+
+/**
  * TCP Session Information for IPv4 TCP transport
  */
 typedef struct
@@ -53,8 +65,13 @@ typedef struct
     int fd;                             /**< file descriptor info */
     unsigned char* data;                /**< received data from remote device */
     size_t len;                         /**< received data length */
-    size_t totalLen;                    /**< total data length required to receive */
+    size_t totalLen;                    /**< total coap data length required to receive */
+    size_t bufLen;                      /**< Buffer length. Buffer will be grown dynamically with respect to data received. */
+    unsigned char *tlsdata;             /**< 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;
 
 /**
@@ -86,6 +103,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
@@ -168,12 +195,14 @@ CAResult_t CAStopTCP();
  */
 void CATerminateTCP();
 
+#ifdef TCP_ADAPTER
 /**
  * Set connection status changes callback to process KeepAlive.
  * connection informations are delivered these callbacks.
  * @param[in]   ConnHandler     Connection status changes callback.
  */
 void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler);
+#endif
 
 #ifdef __cplusplus
 } /* extern "C" */