X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Finc%2Fcatcpadapter.h;h=d1e7d20e05689e14cc65ae7730d9b67d7a52dcb2;hb=fb8e0ce452952235a1f13e7d3f0da921e0dae4d6;hp=1938221135a3aaad6126e87a03537b0ac7b9f2e3;hpb=01be9765a95ede47003777ee576fe9a4de4229e5;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/inc/catcpadapter.h b/resource/csdk/connectivity/inc/catcpadapter.h index 1938221..d1e7d20 100644 --- a/resource/csdk/connectivity/inc/catcpadapter.h +++ b/resource/csdk/connectivity/inc/catcpadapter.h @@ -28,20 +28,51 @@ #include "cacommon.h" #include "caadapterinterface.h" #include "cathreadpool.h" +#include "cainterface.h" +#include #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 +{ + UNKNOWN = 0, + TLS, + COAP +} CAProtocol_t; + /** - * TCP Server Information for IPv4 TCP transport + * TCP Connection State. + */ +typedef enum +{ + CONNECTING = 0, + CONNECTED, + DISCONNECTED +} CATCPConnectionState_t; + +/** + * TCP Session Information for IPv4 TCP transport */ typedef struct { - char addr[MAX_ADDR_STR_SIZE_CA]; /**< TCP Server address */ - CASocket_t u4tcp; /**< TCP Server port */ -} CATCPServerInfo_t; + CASecureEndpoint_t sep; /**< secure endpoint information */ + int fd; /**< file descriptor info */ + unsigned char* data; /**< received data from remote device */ + size_t len; /**< received data length */ + 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; /** * API to initialize TCP Interface. @@ -50,7 +81,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. @@ -59,7 +92,8 @@ typedef struct */ CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback, CANetworkPacketReceivedCallback networkPacketCallback, - CANetworkChangeCallback netCallback, + CAAdapterChangeCallback netCallback, + CAConnectionChangeCallback connCallback, CAErrorHandleCallback errorCallback, ca_thread_pool_t handle); /** @@ -69,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 @@ -78,6 +122,15 @@ CAResult_t CAStartTCP(); CAResult_t CAStartTCPListeningServer(); /** + * Stops listening server from receiving connect requests. + * Transport Specific Behavior: + * TCP Stops Listening Server on a particular interface and prefixed port + * number and as per OIC Specification. + * @return ::CA_STATUS_OK or Appropriate error code. + */ +CAResult_t CAStopTCPListeningServer(); + +/** * Start discovery servers for receiving advertisements. * Transport Specific Behavior: * TCP Starts Discovery server on a particular interface and prefixed port @@ -93,11 +146,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. @@ -105,11 +160,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. @@ -138,6 +195,15 @@ 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" */ #endif