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_
38 @brief IP address Length
40 #define CA_IPADDR_SIZE 16
43 @brief Mac address length for BT port
45 #define CA_MACADDR_SIZE 18
48 @brief Max header options data length
50 #define CA_MAX_HEADER_OPTION_DATA_LENGTH 16
55 #define CA_MAX_URI_LENGTH 128
58 @brief option types - the highest option number 63
60 #define CA_OPTION_IF_MATCH 1
61 #define CA_OPTION_ETAG 4
62 #define CA_OPTION_IF_NONE_MATCH 5
63 #define CA_OPTION_LOCATION_PATH 8
64 #define CA_OPTION_URI_PATH 11
65 #define CA_OPTION_CONTENT_FORMAT 12
66 #define CA_OPTION_CONTENT_TYPE COAP_OPTION_CONTENT_FORMAT
67 #define CA_OPTION_MAXAGE 14
68 #define CA_OPTION_URI_QUERY 15
69 #define CA_OPTION_ACCEPT 17
70 #define CA_OPTION_LOCATION_QUERY 20
71 #define CA_OPTION_OBSERVE 6
74 @brief Max length of ID
76 #define DTLS_PSK_ID_LEN 16
79 @brief Max length of PSK
81 #define DTLS_PSK_PSK_LEN 16
86 #define DtlsPskCredsBlobVer_1 1
89 @brief current version
91 #define DtlsPskCredsBlobVer_CurrentVersion DtlsPskCredsBlobVer_1
95 @brief Payload information from resource model
97 typedef char *CAPayload_t;
100 @brief URI for the OIC base.CA considers relative URI as the URI.
102 typedef char *CAURI_t;
105 @brief Token information for mapping the request and responses by resource model
107 typedef char *CAToken_t;
110 @brief Boolean value used for specifying the success or failure
120 @brief Different connectivities that are handled in Connectivity Abstraction
124 CA_ETHERNET = (1 << 0),
128 } CAConnectivityType_t;
131 @brief Information about the network status.CA_INTERFACE_UP means connectivity is available
140 @brief Address of the local or remote endpoint
145 @brief BT Mac Information
149 /** @brief BT mac address **/
150 char btMacAddress[CA_MACADDR_SIZE];
154 @brief LE MAC Information
158 /** @brief BLE mac address **/
159 char leMacAddress[CA_MACADDR_SIZE];
163 @brief IP Information for wifi and ethernet ports
167 /** Ip address of the interface**/
168 char ipAddress[CA_IPADDR_SIZE];
169 /** port information**/
175 @brief Message Type for Base source code
179 CA_MSG_CONFIRM = 0, /* confirmable message (requires ACK/RST) */
180 CA_MSG_NONCONFIRM, /* non-confirmable message (one-shot message) */
181 CA_MSG_ACKNOWLEDGE, /* used to acknowledge confirmable messages */
182 CA_MSG_RESET /* indicates error in received messages */
186 @brief Allowed method to be used by resource model
197 @brief Remote endpoint information for connectivities
201 /** Resource URI information **/
203 /** Remote Endpoint address **/
204 CAAddress_t addressInfo;
205 /** Connectivity of the endpoint**/
206 CAConnectivityType_t connectivityType;
207 /** Secure connection**/
209 } CARemoteEndpoint_t;
213 @brief Group endpoint information for connectivities
217 /** Resource URI information **/
219 /** Connectivity of the endpoint**/
220 CAConnectivityType_t connectivityType;
224 @brief Local Connectivity information
228 /** address of the interface **/
229 CAAddress_t addressInfo;
230 /** Connectivity type that localconnectivity avaialble **/
231 CAConnectivityType_t type;
232 /** Secure connection**/
234 } CALocalConnectivity_t;
237 @brief Enums for CA return values
241 /* Success status code - START HERE */
243 CA_STATUS_INVALID_PARAM,
244 CA_ADAPTER_NOT_ENABLED,
245 CA_SERVER_STARTED_ALREADY,
246 CA_SERVER_NOT_STARTED,
247 CA_DESTINATION_NOT_REACHABLE,
248 CA_SOCKET_OPERATION_FAILED,
251 CA_MEMORY_ALLOC_FAILED,
253 CA_DESTINATION_DISCONNECTED,
256 /* Result code - END HERE */
260 @brief Enums for CA Response values
264 /* Success status code - START HERE */
271 /* Response status code - END HERE */
272 } CAResponseResult_t;
275 @brief Transport Protocol IDs for additional options
279 CA_INVALID_ID = (1 << 0),
280 CA_COAP_ID = (1 << 1)
281 } CATransportProtocolID_t;
284 * @brief Header options structure to be filled
286 * This structure is used to hold header information.
290 /** The protocol ID this option applies to**/
291 CATransportProtocolID_t protocolID;
292 /** The header option ID which will be added to communication packets**/
295 uint16_t optionLength;
296 /** optional data values**/
297 uint8_t optionData[CA_MAX_HEADER_OPTION_DATA_LENGTH];
301 * @brief Base Information received
303 * This structure is used to hold request & response base information
307 /**Qos for the request **/
308 CAMessageType_t type;
310 * if message id is zero, it will generated by CA inside.
311 * otherwise, you can use it.**/
315 /** Header Options for the request **/
316 CAHeaderOption_t *options;
317 /** Number of Header options**/
319 /** payload of the request **/
324 * @brief Request Information to be sent
326 * This structure is used to hold request information
330 /** Name of the Method Allowed **/
332 /** Information of the request. **/
337 * @brief Response information received
339 * This structure is used to hold response information
343 /**Result for response by resource model**/
344 CAResponseResult_t result;
345 /**Information of the response.**/
350 * Credentials for a device. Includes identity and the associated PSK.
354 unsigned char clientIdentity[DTLS_PSK_ID_LEN];
355 unsigned char rsClientPsk[DTLS_PSK_PSK_LEN];
359 * Binary blob containing device identity and the credentials for all devices
360 * trusted by this device.
364 uint16_t blobVer; /**< version of the blob */
365 uint16_t reserved; /**< reserved for future use */
366 unsigned char rsIdentity[DTLS_PSK_ID_LEN]; /**< identity of self */
367 uint32_t num; /**< number of credentials in this blob */
368 CADtlsPskCreds_t *creds; /**< list of credentials. Size of this
369 array is determined by 'num' variable. */
370 } CADtlsPskCredsBlob_t;
376 #endif //#ifndef __CA_COMMON_H_