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 Payload information from resource model
76 typedef char *CAPayload_t;
79 @brief URI for the OIC base.CA considers relative URI as the URI.
81 typedef char *CAURI_t;
84 @brief Token information for mapping the request and responses by resource model
86 typedef char *CAToken_t;
89 @brief Boolean value used for specifying the success or failure
99 @brief Different connectivities that are handled in Connectivity Abstraction
103 CA_ETHERNET = (1 << 0),
107 } CAConnectivityType_t;
110 @brief Information about the network status.CA_INTERFACE_UP means connectivity is available
119 @brief Address of the local or remote endpoint
124 @brief BT Mac Information
128 /** @brief BT mac address **/
129 char btMacAddress[CA_MACADDR_SIZE];
133 @brief LE MAC Information
137 /** @brief BLE mac address **/
138 char leMacAddress[CA_MACADDR_SIZE];
142 @brief IP Information for wifi and ethernet ports
146 /** Ip address of the interface**/
147 char ipAddress[CA_IPADDR_SIZE];
148 /** port information**/
154 @brief Message Type for Base source code
158 CA_MSG_CONFIRM = 0, /* confirmable message (requires ACK/RST) */
159 CA_MSG_NONCONFIRM, /* non-confirmable message (one-shot message) */
160 CA_MSG_ACKNOWLEDGE, /* used to acknowledge confirmable messages */
161 CA_MSG_RESET /* indicates error in received messages */
165 @brief Allowed method to be used by resource model
176 @brief Remote endpoint information for connectivities
180 /** Resource URI information **/
182 /** Remote Endpoint address **/
183 CAAddress_t addressInfo;
184 /** Connectivity of the endpoint**/
185 CAConnectivityType_t connectivityType;
186 /** Secure connection**/
188 } CARemoteEndpoint_t;
192 @brief Group endpoint information for connectivities
196 /** Resource URI information **/
198 /** Connectivity of the endpoint**/
199 CAConnectivityType_t connectivityType;
203 @brief Local Connectivity information
207 /** address of the interface **/
208 CAAddress_t addressInfo;
209 /** Connectivity type that localconnectivity avaialble **/
210 CAConnectivityType_t type;
211 /** Secure connection**/
213 } CALocalConnectivity_t;
216 @brief Enums for CA return values
220 /* Success status code - START HERE */
222 CA_STATUS_INVALID_PARAM,
223 CA_ADAPTER_NOT_ENABLED,
224 CA_SERVER_STARTED_ALREADY,
225 CA_SERVER_NOT_STARTED,
226 CA_DESTINATION_NOT_REACHABLE,
227 CA_SOCKET_OPERATION_FAILED,
230 CA_MEMORY_ALLOC_FAILED,
232 CA_DESTINATION_DISCONNECTED,
235 /* Result code - END HERE */
239 @brief Enums for CA Response values
243 /* Success status code - START HERE */
250 CA_RETRANSMIT_TIMEOUT = 500
251 /* Response status code - END HERE */
252 } CAResponseResult_t;
255 @brief Transport Protocol IDs for additional options
259 CA_INVALID_ID = (1 << 0),
260 CA_COAP_ID = (1 << 1)
261 } CATransportProtocolID_t;
264 * @brief Header options structure to be filled
266 * This structure is used to hold header information.
270 /** The protocol ID this option applies to**/
271 CATransportProtocolID_t protocolID;
272 /** The header option ID which will be added to communication packets**/
275 uint16_t optionLength;
276 /** optional data values**/
277 uint8_t optionData[CA_MAX_HEADER_OPTION_DATA_LENGTH];
281 * @brief Base Information received
283 * This structure is used to hold request & response base information
287 /**Qos for the request **/
288 CAMessageType_t type;
290 * if message id is zero, it will generated by CA inside.
291 * otherwise, you can use it.**/
295 /** Header Options for the request **/
296 CAHeaderOption_t *options;
297 /** Number of Header options**/
299 /** payload of the request **/
304 * @brief Request Information to be sent
306 * This structure is used to hold request information
310 /** Name of the Method Allowed **/
312 /** Information of the request. **/
317 * @brief Response information received
319 * This structure is used to hold response information
323 /**Result for response by resource model**/
324 CAResponseResult_t result;
325 /**Information of the response.**/
333 #endif //#ifndef __CA_COMMON_H_