X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Finc%2Fcatcpadapter.h;h=536f8f61110ad0a138b3ab36ab019627d7a15f37;hb=3c093548382bb2542c87a67e6e5fa32552c29cb3;hp=2528df13191a1eabce8a7ac6d268382225169c1c;hpb=657acd6a0722145ffd5d5933b37f4646c7d47cbc;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/inc/catcpadapter.h b/resource/csdk/connectivity/inc/catcpadapter.h index 2528df1..536f8f6 100644 --- a/resource/csdk/connectivity/inc/catcpadapter.h +++ b/resource/csdk/connectivity/inc/catcpadapter.h @@ -29,12 +29,31 @@ #include "caadapterinterface.h" #include "cathreadpool.h" #include "cainterface.h" +#include #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; /** @@ -54,7 +78,9 @@ typedef struct * @param[in] networkPacketCallback Callback to notify request and * response messages from server(s) * started at Connectivity Abstraction Layer. - * @param[in] netCallback Callback to notify the network additions + * @param[in] netCallback Callback to notify the adapter changes + * to Connectivity Abstraction Layer. + * @param[in] connCallback Callback to notify the connection changes * to Connectivity Abstraction Layer. * @param[in] errorCallback Callback to notify the network errors to * Connectivity Abstraction Layer. @@ -63,7 +89,8 @@ typedef struct */ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback, CANetworkPacketReceivedCallback networkPacketCallback, - CANetworkChangeCallback netCallback, + CAAdapterChangeCallback netCallback, + CAConnectionChangeCallback connCallback, CAErrorHandleCallback errorCallback, ca_thread_pool_t handle); /** @@ -73,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 @@ -106,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. @@ -118,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. @@ -152,13 +193,11 @@ CAResult_t CAStopTCP(); void CATerminateTCP(); /** - * Set connected callback and disconnected callback to process KeepAlive. + * Set connection status changes callback to process KeepAlive. * connection informations are delivered these callbacks. - * @param[in] ConnHandler Connected callback. - * @param[in] DisconnHandler Disconnected Callback. + * @param[in] ConnHandler Connection status changes callback. */ -void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectedCallback ConnHandler, - CAKeepAliveDisconnectedCallback DisconnHandler); +void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler); #ifdef __cplusplus } /* extern "C" */