1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * @brief This file contains the common data structures between Resource , CA and adapters
26 #ifndef __CA_COMMON_H_
27 #define __CA_COMMON_H_
40 * @brief IP address Length
42 #define CA_IPADDR_SIZE 16
45 * @brief Mac address length for BT port
47 #define CA_MACADDR_SIZE 18
50 * @brief Max header options data length
52 #define CA_MAX_HEADER_OPTION_DATA_LENGTH 16
55 * @brief Max URI length
57 #define CA_MAX_URI_LENGTH 2048
60 * @brief option types - the highest option number 63
62 #define CA_OPTION_IF_MATCH 1
63 #define CA_OPTION_ETAG 4
64 #define CA_OPTION_IF_NONE_MATCH 5
65 #define CA_OPTION_LOCATION_PATH 8
66 #define CA_OPTION_URI_PATH 11
67 #define CA_OPTION_CONTENT_FORMAT 12
68 #define CA_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
69 #define CA_OPTION_MAXAGE 14
70 #define CA_OPTION_URI_QUERY 15
71 #define CA_OPTION_ACCEPT 17
72 #define CA_OPTION_LOCATION_QUERY 20
73 #define CA_OPTION_OBSERVE 6
76 * @brief Payload information from resource model
78 typedef char *CAPayload_t;
81 * @brief URI for the OIC base.CA considers relative URI as the URI.
83 typedef char *CAURI_t;
86 * @brief Token information for mapping the request and responses by resource model
88 typedef char *CAToken_t;
92 * @brief Boolean value used for specifying the success or failure
96 CA_FALSE = 0, /**< False */
101 * @enum CAConnectivityType_t
102 * @brief Different connectivities that are handled in Connectivity Abstraction
106 CA_ETHERNET = (1 << 0), /**< Ethernet Connection */
107 CA_WIFI = (1 << 1), /**< WIFI Connection */
108 CA_EDR = (1 << 2), /**< EDR Connection */
109 CA_LE = (1 << 3) /**< LE Connection */
110 } CAConnectivityType_t;
113 * @enum CANetworkStatus_t
114 * @brief Information about the network status.
118 CA_INTERFACE_UP, /**< Connection is Available */
119 CA_INTERFACE_DOWN /**< Connection is not available */
123 * @brief Address of the local or remote endpoint
128 * @brief BT Mac Information
132 char btMacAddress[CA_MACADDR_SIZE]; /**< BT mac address **/
136 * @brief LE MAC Information
140 char leMacAddress[CA_MACADDR_SIZE]; /**< BLE mac address **/
144 * @brief IP Information for wifi and ethernet ports
148 char ipAddress[CA_IPADDR_SIZE]; /**< Ip address of the interface**/
149 uint32_t port; /**< port information**/
154 * @enum CAMessageType_t
155 * @brief Message Type for Base source code
159 CA_MSG_CONFIRM = 0, /**< confirmable message (requires ACK/RST) */
160 CA_MSG_NONCONFIRM, /**< non-confirmable message (one-shot message) */
161 CA_MSG_ACKNOWLEDGE, /**< used to acknowledge confirmable messages */
162 CA_MSG_RESET /**< indicates error in received messages */
167 * @brief Allowed method to be used by resource model
171 CA_GET = 1, /**< GET Method */
172 CA_POST, /**< POST Method */
173 CA_PUT, /**< PUT Method */
174 CA_DELETE /**< DELETE Method */
178 * @brief Remote endpoint information for connectivities
183 CAURI_t resourceUri; /**< Resource URI information **/
184 CAAddress_t addressInfo; /**< Remote Endpoint address **/
185 CAConnectivityType_t connectivityType; /**< Connectivity of the endpoint**/
186 CABool_t isSecured; /**< Secure connection**/
187 } CARemoteEndpoint_t;
191 * @brief Group endpoint information for connectivities
195 CAURI_t resourceUri; /**< Resource URI information **/
196 CAConnectivityType_t connectivityType; /**< Connectivity of the endpoint**/
200 @brief Local Connectivity information
204 CAAddress_t addressInfo; /**< Address of the interface **/
205 CAConnectivityType_t type; /**< Connectivity type that localconnectivity avaialble **/
206 CABool_t isSecured; /**< Secure connection**/
207 } CALocalConnectivity_t;
211 * @brief Enums for CA return values
215 /* Success status code - START HERE */
216 CA_STATUS_OK = 0, /**< Success */
217 CA_STATUS_INVALID_PARAM, /**< Invalid Parameter */
218 CA_ADAPTER_NOT_ENABLED, /**< Adapter is not enabled */
219 CA_SERVER_STARTED_ALREADY, /**< Server is started already */
220 CA_SERVER_NOT_STARTED, /**< Server is not started*/
221 CA_DESTINATION_NOT_REACHABLE, /**< Destination is not reachable */
222 CA_SOCKET_OPERATION_FAILED, /**< Socket operation failed */
223 CA_SEND_FAILED, /**< Send request failed */
224 CA_RECEVIE_FAILED, /**< Receive failed */
225 CA_MEMORY_ALLOC_FAILED, /**< Memory allocation failed */
226 CA_REQUEST_TIMEOUT, /**< Request is Timeout */
227 CA_DESTINATION_DISCONNECTED, /**< Destination is disconnected */
228 CA_STATUS_FAILED, /**< Failure */
229 CA_NOT_SUPPORTED /**< Not supported */
230 /* Result code - END HERE */
234 * @enum CAResponseResult_t
235 * @brief Enums for CA Response values
239 /* Success status code - START HERE */
240 CA_SUCCESS = 200, /**< Success */
241 CA_CREATED = 201, /**< Created */
242 CA_DELETED = 202, /**< Deleted */
243 CA_BAD_REQ = 400, /**< Bad Request */
244 CA_BAD_OPT = 402, /**< Bad Option */
245 CA_NOT_FOUND = 404, /**< Not found */
246 CA_RETRANSMIT_TIMEOUT = 500 /**< Retransmit timeout */
247 /* Response status code - END HERE */
248 } CAResponseResult_t;
251 * @enum CATransportProtocolID_t
252 * @brief Transport Protocol IDs for additional options
256 CA_INVALID_ID = (1 << 0), /**< Invalid ID */
257 CA_COAP_ID = (1 << 1) /**< COAP ID */
258 } CATransportProtocolID_t;
261 * @enum CAAdapterState_t
262 * @brief Adapter State to indicate the network changed notifications.
266 CA_ADAPTER_ENABLED, /**< Adapter is Enabled */
267 CA_ADAPTER_DISABLED /**< Adapter is Disabled */
271 * @brief Header options structure to be filled
273 * This structure is used to hold header information.
277 CATransportProtocolID_t protocolID; /**< Protocol ID of the Option */
278 uint16_t optionID; /**< The header option ID which will be
279 added to communication packets */
280 uint16_t optionLength; /**< Option Length **/
281 uint8_t optionData[CA_MAX_HEADER_OPTION_DATA_LENGTH]; /**< Optional data values**/
285 * @brief Base Information received
287 * This structure is used to hold request & response base information
292 CAMessageType_t type; /**< Qos for the request */
293 uint16_t messageId; /**< Message id.
294 * if message id is zero, it will generated by CA inside.
295 * otherwise, you can use it */
296 CAToken_t token; /**< Token for CA */
297 CAHeaderOption_t *options; /** Header Options for the request */
298 uint8_t numOptions; /**< Number of Header options */
299 CAPayload_t payload; /**< payload of the request */
303 * @brief Request Information to be sent
305 * This structure is used to hold request information
309 CAMethod_t method; /**< Name of the Method Allowed */
310 CAInfo_t info; /**< Information of the request. */
314 * @brief Response information received
316 * This structure is used to hold response information
320 CAResponseResult_t result; /**< Result for response by resource model */
321 CAInfo_t info; /**< Information of the response */
328 #endif //#ifndef __CA_COMMON_H_