X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fapi%2Fcacommon.h;h=fc47ed1be999851a54e416e628c29df24f8d3a16;hb=refs%2Ftags%2Fsubmit%2Ftizen_4.0%2F20171010.021147;hp=58f8744d37193ad959afa6163e9d9615faf55652;hpb=ec3cb98be11c5a3cc0f98e8c6a475ae498323970;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/api/cacommon.h b/resource/csdk/connectivity/api/cacommon.h old mode 100644 new mode 100755 index 58f8744..fc47ed1 --- a/resource/csdk/connectivity/api/cacommon.h +++ b/resource/csdk/connectivity/api/cacommon.h @@ -26,6 +26,8 @@ #ifndef CA_COMMON_H_ #define CA_COMMON_H_ +#include "iotivity_config.h" + #ifndef WITH_ARDUINO #ifdef TCP_ADAPTER #define HAVE_SYS_POLL_H @@ -36,9 +38,13 @@ #include #include +#ifdef __TIZENRT__ +#include +#else #ifdef HAVE_SYS_POLL_H #include #endif +#endif #ifdef HAVE_WINSOCK2_H #include @@ -51,7 +57,16 @@ extern "C" #endif /** - * IP address Length + * TAG of Analyzer log. + */ +#define ANALYZER_TAG "OIC_CA_ANALYZER_071801" +#define BLE_CLIENT_TAG "OIC_CA_LE_CLIENT_0718" +#define BLE_SERVER_MCD_TAG "OIC_CA_LE_SER_MC_0718" +#define IP_SERVER_TAG "OIC_CA_IP_SERVER_0718" +#define TCP_SERVER_TAG "OIC_CA_TCP_SERVER_0718" + +/** + * IP address Length. */ #define CA_IPADDR_SIZE 16 @@ -61,22 +76,26 @@ extern "C" #define CA_RAJABBERID_SIZE 256 /** - * Mac address length for BT port + * Mac address length for BT port. */ #define CA_MACADDR_SIZE 18 /** - * Max header options data length + * Max header options data length. */ +#if defined(ARDUINO) || defined(__TIZENRT__) #define CA_MAX_HEADER_OPTION_DATA_LENGTH 20 +#else +#define CA_MAX_HEADER_OPTION_DATA_LENGTH 1024 +#endif /** -* Max token length +* Max token length. */ #define CA_MAX_TOKEN_LEN (8) /** - * Max URI length + * Max URI length. */ #ifdef ARDUINO #define CA_MAX_URI_LENGTH 128 /* maximum size of URI for embedded platforms*/ @@ -85,7 +104,7 @@ extern "C" #endif /** - * Max PDU length supported + * Max PDU length supported. */ #ifdef ARDUINO #define COAP_MAX_PDU_SIZE 320 /* maximum size of a CoAP PDU for embedded platforms*/ @@ -98,12 +117,17 @@ extern "C" #endif /** - *Maximum length of the remoteEndpoint identity + *Maximum length of the remoteEndpoint identity. */ -#define CA_MAX_ENDPOINT_IDENTITY_LEN (32) +#define CA_MAX_ENDPOINT_IDENTITY_LEN CA_MAX_IDENTITY_SIZE /** - * option types - the highest option number 63 + * Max identity size. + */ +#define CA_MAX_IDENTITY_SIZE (37) + +/** + * option types - the highest option number 63. */ #define CA_OPTION_IF_MATCH 1 #define CA_OPTION_ETAG 4 @@ -119,7 +143,7 @@ extern "C" #define CA_OPTION_LOCATION_QUERY 20 /** - * Payload information from resource model + * Payload information from resource model. */ typedef uint8_t *CAPayload_t; @@ -129,12 +153,12 @@ typedef uint8_t *CAPayload_t; typedef char *CAURI_t; /** - * Token information for mapping the request and responses by resource model + * Token information for mapping the request and responses by resource model. */ typedef char *CAToken_t; /* - * Socket types and error definitions + * Socket types and error definitions. */ #ifdef HAVE_WINSOCK2_H # define OC_SOCKET_ERROR SOCKET_ERROR @@ -155,12 +179,12 @@ typedef int CASocketFd_t; #define MAX_ADDR_STR_SIZE_CA (256) #else /* - * Max Address could be "coap+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx" - * Which is 64, +1 for null terminator => 65 + * Max Address could be "coaps+tcp://[xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:yyy.yyy.yyy.yyy]:xxxxx" + * Which is 65, +1 for null terminator => 66 * OCDevAddr (defined in OCTypes.h) must be the same * as CAEndpoint_t (defined here) */ -#define MAX_ADDR_STR_SIZE_CA (65) +#define MAX_ADDR_STR_SIZE_CA (66) #endif typedef enum @@ -204,11 +228,21 @@ typedef enum CA_SCOPE_GLOBAL = 0xE, // IPv6 Global scope } CATransportFlags_t; +typedef enum +{ + CA_DEFAULT_BT_FLAGS = 0, + // flags for BLE transport + CA_LE_ADV_DISABLE = 0x1, // disable BLE advertisement. + CA_LE_ADV_ENABLE = 0x2, // enable BLE advertisement. + CA_LE_SERVER_DISABLE = (1 << 4), // disable gatt server. + // flags for EDR transport + CA_EDR_SERVER_DISABLE = (1 << 7) // disable rfcomm server. +} CATransportBTFlags_t; + #define CA_IPFAMILY_MASK (CA_IPV6|CA_IPV4) #define CA_SCOPE_MASK 0xf // mask scope bits above /** - * @enum CANetworkStatus_t * Information about the network status. */ typedef enum @@ -218,7 +252,7 @@ typedef enum } CANetworkStatus_t; /* - * remoteEndpoint identity + * remoteEndpoint identity. */ typedef struct { @@ -227,8 +261,7 @@ typedef struct } CARemoteId_t; /** - * @enum CAMessageType_t - * Message Type for Base source code + * Message Type for Base source code. */ typedef enum { @@ -240,8 +273,7 @@ typedef enum } CAMessageType_t; /** - * @enum CAMethod_t - * Allowed method to be used by resource model + * Allowed method to be used by resource model. */ typedef enum { @@ -252,7 +284,7 @@ typedef enum } CAMethod_t; /** - * block size + * block size. * it depends on defined size in libCoAP. */ typedef enum @@ -267,7 +299,7 @@ typedef enum } CABlockSize_t; /** - * Endpoint information for connectivities + * Endpoint information for connectivities. * Must be identical to OCDevAddr. */ typedef struct @@ -277,6 +309,7 @@ typedef struct uint16_t port; // for IP char addr[MAX_ADDR_STR_SIZE_CA]; // address for all uint32_t ifindex; // usually zero for default interface + char remoteId[CA_MAX_IDENTITY_SIZE]; // device ID of remote device #if defined (ROUTING_GATEWAY) || defined (ROUTING_EP) char routeData[MAX_ADDR_STR_SIZE_CA]; /**< GatewayId:ClientId of destination. **/ @@ -284,17 +317,18 @@ typedef struct } CAEndpoint_t; /** - * Endpoint information for secure messages + * Endpoint information for secure messages. */ typedef struct { CAEndpoint_t endpoint; /**< endpoint */ - CARemoteId_t identity; /**< endpoint identity */ + // TODO change name to deviceId + CARemoteId_t identity; /**< endpoint device uuid */ + CARemoteId_t userId; /**< endpoint user uuid */ } CASecureEndpoint_t; /** - * @enum CAResult_t - * Enums for CA return values + * Enums for CA return values. */ typedef enum { @@ -319,8 +353,7 @@ typedef enum } CAResult_t; /** - * @enum CAResponseResult_t - * Enums for CA Response values + * Enums for CA Response values. */ typedef enum { @@ -342,13 +375,37 @@ typedef enum CA_REQUEST_ENTITY_INCOMPLETE = 408, /**< Request Entity Incomplete */ CA_REQUEST_ENTITY_TOO_LARGE = 413, /**< Request Entity Too Large */ CA_INTERNAL_SERVER_ERROR = 500, /**< Internal Server Error */ - CA_RETRANSMIT_TIMEOUT = 504 /**< Retransmit timeout */ + CA_NOT_IMPLEMENTED = 501, /**< Not Implenented */ + CA_BAD_GATEWAY = 502, /**< Bad Gateway */ + CA_SERVICE_UNAVAILABLE = 503, /**< Server Unavailable */ + CA_RETRANSMIT_TIMEOUT = 504, /**< Retransmit timeout */ + CA_PROXY_NOT_SUPPORTED = 505 /**< Proxy not enabled to service a request */ /* Response status code - END HERE */ } CAResponseResult_t; /** - * @enum CATransportProtocolID_t - * Transport Protocol IDs for additional options + * Data type whether the data is Request Message or Response Message. + * if there is some failure before send data on network. + * Type will be set as error type for error callback. + */ +typedef enum +{ + CA_REQUEST_DATA = 1, + CA_RESPONSE_DATA, + CA_ERROR_DATA, + CA_RESPONSE_FOR_RES, + CA_NETWORK_COMMAND +} CADataType_t; + +typedef enum +{ + CA_DISCONNECTED = 0, + CA_CONNECTED, + CA_REQ_DISCONNECT +} CAConnectEvent_t; + +/** + * Transport Protocol IDs for additional options. */ typedef enum { @@ -357,7 +414,6 @@ typedef enum } CATransportProtocolID_t; /** - * @enum CAAdapterState_t * Adapter State to indicate the network changed notifications. */ typedef enum @@ -384,7 +440,7 @@ typedef enum } CAPayloadFormat_t; /** - * Header options structure to be filled + * Header options structure to be filled. * * This structure is used to hold header information. */ @@ -398,9 +454,9 @@ typedef struct } CAHeaderOption_t; /** - * Base Information received + * Base Information received. * - * This structure is used to hold request & response base information + * This structure is used to hold request & response base information. */ typedef struct { @@ -422,12 +478,14 @@ typedef struct CAPayloadFormat_t acceptFormat; /**< accept format for the response payload */ CAURI_t resourceUri; /**< Resource URI information **/ CARemoteId_t identity; /**< endpoint identity */ + CADataType_t dataType; /**< data type */ + CAConnectEvent_t event; /**< network request message / event type */ } CAInfo_t; /** - * Request Information to be sent + * Request Information to be sent. * - * This structure is used to hold request information + * This structure is used to hold request information. */ typedef struct { @@ -437,9 +495,9 @@ typedef struct } CARequestInfo_t; /** - * Response information received + * Response information received. * - * This structure is used to hold response information + * This structure is used to hold response information. */ typedef struct { @@ -450,9 +508,9 @@ typedef struct /** * Error information from CA - * contains error code and message information + * contains error code and message information. * - * This structure holds error information + * This structure holds error information. */ typedef struct { @@ -462,7 +520,7 @@ typedef struct } CAErrorInfo_t; /** - * Hold global variables for CA layer (also used by RI layer) + * Hold global variables for CA layer. (also used by RI layer) */ typedef struct { @@ -487,7 +545,7 @@ typedef struct } CAHistory_t; /** - * Hold interface index for keeping track of comings and goings + * Hold interface index for keeping track of comings and goings. */ typedef struct { @@ -511,7 +569,9 @@ typedef struct struct tcpports { uint16_t u4; /**< unicast IPv4 socket port */ + uint16_t u4s; /**< unicast IPv6 socket secure port */ uint16_t u6; /**< unicast IPv6 socket port */ + uint16_t u6s; /**< unicast IPv6 socket secure port */ } tcp; #endif } CAPorts_t; @@ -540,8 +600,10 @@ typedef struct #if defined(_WIN32) WSAEVENT shutdownEvent; /**< Event used to signal threads to stop */ #else +#ifndef __TIZENRT__ int shutdownFds[2]; /**< fds used to signal threads to stop */ #endif +#endif int selectTimeout; /**< in seconds */ int maxfd; /**< highest fd (for select) */ bool started; /**< the IP adapter has started */ @@ -574,11 +636,15 @@ typedef struct { void *threadpool; /**< threadpool between Initialize and Start */ CASocket_t ipv4; /**< IPv4 accept socket */ + CASocket_t ipv4s; /**< IPv4 accept socket secure */ CASocket_t ipv6; /**< IPv6 accept socket */ + CASocket_t ipv6s; /**< IPv6 accept socket secure */ void *svrlist; /**< unicast IPv4 TCP server information*/ int selectTimeout; /**< in seconds */ int listenBacklog; /**< backlog counts*/ +#ifndef __TIZENRT__ int shutdownFds[2]; /**< shutdown pipe */ +#endif int connectionFds[2]; /**< connection pipe */ int maxfd; /**< highest fd (for select) */ bool started; /**< the TCP adapter has started */ @@ -587,10 +653,17 @@ typedef struct bool ipv6tcpenabled; /**< IPv6 TCP enabled by OCInit flags */ } tcp; #endif + CATransportBTFlags_t bleFlags; } CAGlobals_t; extern CAGlobals_t caglobals; +typedef enum +{ + CA_LOG_LEVEL_ALL = 1, // all logs. + CA_LOG_LEVEL_INFO, // debug level is disabled +} CAUtilLogLevel_t; + /** * Callback function type for request delivery. * @param[out] object Endpoint object from which the request is received.