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
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 token length
57 #define CA_MAX_TOKEN_LEN (8)
60 * @brief Max URI length
63 #define CA_MAX_URI_LENGTH 128 /* maximum size of URI for embedded platforms*/
65 #define CA_MAX_URI_LENGTH 512 /* maximum size of URI for other platforms*/
69 * @brief Max PDU length supported
72 #define COAP_MAX_PDU_SIZE 320 /* maximum size of a CoAP PDU for embedded platforms*/
74 #define COAP_MAX_PDU_SIZE 1400 /* maximum size of a CoAP PDU for big platforms*/
78 * @brief option types - the highest option number 63
80 #define CA_OPTION_IF_MATCH 1
81 #define CA_OPTION_ETAG 4
82 #define CA_OPTION_IF_NONE_MATCH 5
83 #define CA_OPTION_OBSERVE 6
84 #define CA_OPTION_LOCATION_PATH 8
85 #define CA_OPTION_URI_PATH 11
86 #define CA_OPTION_CONTENT_FORMAT 12
87 #define CA_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
88 #define CA_OPTION_MAXAGE 14
89 #define CA_OPTION_URI_QUERY 15
90 #define CA_OPTION_ACCEPT 17
91 #define CA_OPTION_LOCATION_QUERY 20
94 * @brief Payload information from resource model
96 typedef char *CAPayload_t;
99 * @brief URI for the OIC base.CA considers relative URI as the URI.
101 typedef char *CAURI_t;
104 * @brief Token information for mapping the request and responses by resource model
106 typedef char *CAToken_t;
109 * @enum CATransportType_t
110 * @brief Different connectivities that are handled in Connectivity Abstraction
114 CA_IPV4 = (1 << 0), /**< IPV4 Transport Type */
115 CA_IPV6 = (1 << 1), /**< IPV6 Transport Type */
116 CA_EDR = (1 << 2), /**< EDR Transport Type */
117 CA_LE = (1 << 3) /**< LE Transport Type */
121 * @enum CANetworkStatus_t
122 * @brief Information about the network status.
126 CA_INTERFACE_DOWN, /**< Connection is not available */
127 CA_INTERFACE_UP /**< Connection is Available */
131 * @brief Address of the local or remote endpoint
136 * @brief BT Mac Information
140 char btMacAddress[CA_MACADDR_SIZE]; /**< BT mac address **/
144 * @brief LE MAC Information
148 char leMacAddress[CA_MACADDR_SIZE]; /**< BLE mac address **/
152 * @brief IP Information
156 char ipAddress[CA_IPADDR_SIZE]; /**< Ip address of the interface**/
157 uint16_t port; /**< port information**/
162 * @enum CAMessageType_t
163 * @brief Message Type for Base source code
167 CA_MSG_CONFIRM = 0, /**< confirmable message (requires ACK/RST) */
168 CA_MSG_NONCONFIRM, /**< non-confirmable message (one-shot message) */
169 CA_MSG_ACKNOWLEDGE, /**< used to acknowledge confirmable messages */
170 CA_MSG_RESET /**< used to indicates not-interested or error (lack of context)in
176 * @brief Allowed method to be used by resource model
180 CA_GET = 1, /**< GET Method */
181 CA_POST, /**< POST Method */
182 CA_PUT, /**< PUT Method */
183 CA_DELETE /**< DELETE Method */
187 * @brief Remote endpoint information for connectivities
192 CAURI_t resourceUri; /**< Resource URI information **/
193 CAAddress_t addressInfo; /**< Remote Endpoint address **/
194 CATransportType_t transportType; /**< Transport Type of the endpoint**/
195 bool isSecured; /**< Secure connection**/
196 } CARemoteEndpoint_t;
200 * @brief Group endpoint information for connectivities
204 CAURI_t resourceUri; /**< Resource URI information **/
205 CATransportType_t transportType; /**< Transport type of the endpoint**/
209 @brief Local Connectivity information
213 CAAddress_t addressInfo; /**< Address of the interface **/
214 CATransportType_t type; /**< Transport type of local device **/
215 bool isSecured; /**< Secure connection**/
216 } CALocalConnectivity_t;
220 * @brief Enums for CA return values
224 // Result code - START HERE
225 CA_STATUS_OK = 0, /**< Success */
226 CA_STATUS_INVALID_PARAM, /**< Invalid Parameter */
227 CA_ADAPTER_NOT_ENABLED, /**< Adapter is not enabled */
228 CA_SERVER_STARTED_ALREADY, /**< Server is started already */
229 CA_SERVER_NOT_STARTED, /**< Server is not started*/
230 CA_DESTINATION_NOT_REACHABLE, /**< Destination is not reachable */
231 CA_SOCKET_OPERATION_FAILED, /**< Socket operation failed */
232 CA_SEND_FAILED, /**< Send request failed */
233 CA_RECEIVE_FAILED, /**< Receive failed */
234 CA_MEMORY_ALLOC_FAILED, /**< Memory allocation failed */
235 CA_REQUEST_TIMEOUT, /**< Request is Timeout */
236 CA_DESTINATION_DISCONNECTED, /**< Destination is disconnected */
237 CA_NOT_SUPPORTED, /**< Not supported */
238 CA_STATUS_FAILED =255 /**< Failure */
239 /* Result code - END HERE */
243 * @enum CAResponseResult_t
244 * @brief Enums for CA Response values
248 /* Response status code - START HERE */
249 CA_EMPTY = 0, /**< Empty */
250 CA_SUCCESS = 200, /**< Success */
251 CA_CREATED = 201, /**< Created */
252 CA_DELETED = 202, /**< Deleted */
253 CA_BAD_REQ = 400, /**< Bad Request */
254 CA_BAD_OPT = 402, /**< Bad Option */
255 CA_NOT_FOUND = 404, /**< Not found */
256 CA_INTERNAL_SERVER_ERROR = 500, /**< Internal Server Error */
257 CA_RETRANSMIT_TIMEOUT = 504 /**< Retransmit timeout */
258 /* Response status code - END HERE */
259 } CAResponseResult_t;
262 * @enum CATransportProtocolID_t
263 * @brief Transport Protocol IDs for additional options
267 CA_INVALID_ID = (1 << 0), /**< Invalid ID */
268 CA_COAP_ID = (1 << 1) /**< COAP ID */
269 } CATransportProtocolID_t;
272 * @enum CAAdapterState_t
273 * @brief Adapter State to indicate the network changed notifications.
277 CA_ADAPTER_DISABLED, /**< Adapter is Disabled */
278 CA_ADAPTER_ENABLED /**< Adapter is Enabled */
282 * @brief Header options structure to be filled
284 * This structure is used to hold header information.
288 CATransportProtocolID_t protocolID; /**< Protocol ID of the Option */
289 uint16_t optionID; /**< The header option ID which will be
290 added to communication packets */
291 uint16_t optionLength; /**< Option Length **/
292 uint8_t optionData[CA_MAX_HEADER_OPTION_DATA_LENGTH]; /**< Optional data values**/
296 * @brief Base Information received
298 * This structure is used to hold request & response base information
303 CAMessageType_t type; /**< Qos for the request */
304 uint16_t messageId; /**< Message id.
305 * if message id is zero, it will generated by CA inside.
306 * otherwise, you can use it */
307 CAToken_t token; /**< Token for CA */
308 uint8_t tokenLength; /**< token length*/
309 CAHeaderOption_t *options; /** Header Options for the request */
310 uint8_t numOptions; /**< Number of Header options */
311 CAPayload_t payload; /**< payload of the request */
315 * @brief Request Information to be sent
317 * This structure is used to hold request information
321 CAMethod_t method; /**< Name of the Method Allowed */
322 CAInfo_t info; /**< Information of the request. */
326 * @brief Response information received
328 * This structure is used to hold response information
332 CAResponseResult_t result; /**< Result for response by resource model */
333 CAInfo_t info; /**< Information of the response */
340 #endif /* CA_COMMON_H_ */