Corrected @file tags and restored 'Files' section.
[platform/upstream/iotivity.git] / resource / csdk / connectivity / api / cacommon.h
1 /* ****************************************************************
2  *
3  * Copyright 2014 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file
23  *
24  * This file contains the common data structures between Resource, CA and
25  * adapters.
26  */
27
28 #ifndef __CA_COMMON_H_
29 #define __CA_COMMON_H_
30
31 #include <stdint.h>
32 #include <stdlib.h>
33
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif
38
39 /**
40  @brief IP Address Length
41  */
42 #define CA_IPADDR_SIZE 16
43
44 /**
45  @brief Mac Address Length for BT
46  */
47 #define CA_MACADDR_SIZE 18
48
49 /**
50  @brief Max Header Options data length
51  */
52 #define CA_MAX_HEADER_OPTION_DATA_LENGTH 16
53
54 /**
55  @brief CAPayload_t
56  */
57 typedef char* CAPayload_t;
58
59 /**
60  @brief CAURI_t
61  */
62 typedef char* CAURI_t;
63
64 /**
65  @brief CAToken_t
66  */
67 typedef char* CAToken_t;
68
69 /**
70  @brief CABool_t
71  */
72 typedef enum
73 {
74     CA_FALSE = 0, CA_TRUE
75 } CABool_t;
76
77 /**
78  @brief CAConnectivityType_t
79  */
80 typedef enum
81 {
82     CA_ETHERNET = (1 << 0), CA_WIFI = (1 << 1), CA_EDR = (1 << 2), CA_LE = (1 << 3)
83 } CAConnectivityType_t;
84
85 /**
86  @brief CANetworkStatus_t
87  */
88 typedef enum
89 {
90     CA_INTERFACE_UP, CA_INTERFACE_DOWN
91 } CANetworkStatus_t;
92
93 /**
94  @brief  Address of the local or remote endpoint
95  */
96 typedef union
97 {
98     /**
99      @brief BT Information
100      */
101     struct
102     {
103         /** @brief Bluettoth Mac Address **/
104         char btMacAddress[CA_MACADDR_SIZE];
105     } BT;
106     /**
107      @brief IP Information
108      */
109     struct
110     {
111         /** Ip address of the interface**/
112         char ipAddress[CA_IPADDR_SIZE];
113         /** port information**/
114         uint32_t port;
115     } IP;
116 } CAAddress_t;
117
118 /**
119  @brief CAQualityOfService
120  */
121 typedef enum
122 {
123     CA_LOW_QOS = 0, CA_MEDIUM_QOS, CA_HIGH_QOS, CA_NA_QOS // No Quality is defined, let the stack decide
124 } CAQualityOfService_t;
125
126 /**
127  @brief CAMethod_t
128  */
129 typedef enum
130 {
131     CA_GET = 1, CA_POST, CA_PUT, CA_DELETE
132 } CAMethod_t;
133
134 /**
135  @brief RemoteEndpoint information for connectivities
136  */
137 typedef struct
138 {
139     /** Resource URI information **/
140     CAURI_t resourceUri;
141     /** Remote Endpoint address **/
142     CAAddress_t addressInfo;
143     /** Connectivity of the endpoint**/
144     CAConnectivityType_t connectivityType;
145 } CARemoteEndpoint_t;
146
147 /**
148  @brief Local Connectivity information
149  */
150 typedef struct
151 {
152     /** address of the interface  **/
153     CAAddress_t addressInfo;
154     /** Connectivity type that localconnectivity avaialble **/
155     CAConnectivityType_t type;
156 } CALocalConnectivityt_t;
157
158 /**
159  @brief Enums for CA return values
160  */
161 typedef enum
162 {
163     /* Success status code - START HERE */
164     CA_STATUS_OK = 0,
165     CA_STATUS_INVALID_PARAM,
166     CA_DESTINATION_NOT_REACHABLE,
167     CA_SEND_FAILED,
168     CA_RECEVIE_FAILED,
169     CA_MEMORY_ALLOC_FAILED,
170     CA_REQUEST_TIMEOUT,
171     CA_DESTINATION_DISCONNECTED,
172     CA_STATUS_FAILED,
173     CA_NOT_SUPPORTED
174 /* Error status code - END HERE */
175 } CAResult_t;
176
177 /**
178  @brief Enums for CA Response  values
179  */
180 typedef enum
181 {
182     /* Success status code - START HERE */
183     CA_CREATED = 201,
184     CA_DELETED = 202,
185     CA_VALID = 203,
186     CA_CONTENT = 205,
187     CA_BAD_REQ = 400,
188     CA_BAD_OPT = 402,
189     CA_NOT_FOUND = 404
190 /* Error status code - END HERE */
191 } CAResponseResult_t;
192
193 /**
194  @brief Transport Protocol IDs
195  */
196 typedef enum
197 {
198     CA_INVALID_ID = (1 << 0), CA_COAP_ID = (1 << 1)
199 } CATransportProtocolID_t;
200
201 /**
202  * @brief Header options structure to be filled
203  *
204  * This structure is used to hold header information.
205  */
206 typedef struct
207 {
208     /** The protocol ID this option applies to**/
209     CATransportProtocolID_t protocolID;
210     /** The header option ID which will be added to communication packets**/
211     uint16_t optionID;
212     /** its length   191**/
213     uint16_t optionLength;
214     /** optional data values**/
215     uint8_t optionData[CA_MAX_HEADER_OPTION_DATA_LENGTH];
216 } CAHeaderOption_t;
217
218 /**
219  * @brief Request Information to be sent
220  *
221  * This structure is used to hold request information
222  */
223
224 /**
225  * @brief Base Information received
226  *
227  * This structure is used to hold request & response base information
228  */
229 typedef struct
230 {
231     /**Qos for the request **/
232     CAQualityOfService_t qos;
233     /** Token for CA**/
234     CAToken_t token;
235     /** Header Options for the request **/
236     CAHeaderOption_t * options;
237     /** Number of Header options**/
238     uint8_t numOptions;
239     /** payload of the request **/
240     CAPayload_t payload;
241 } CAInfo_t;
242
243 typedef struct
244 {
245     /** Name of the Method Allowed **/
246     CAMethod_t method;
247     /** Base Information **/
248     CAInfo_t info;
249 } CARequestInfo_t;
250
251 /**
252  * @brief Response Information received
253  *
254  * This structure is used to hold response information
255  */
256 typedef struct
257 {
258     /**Response Result by Resource Model**/
259     CAResponseResult_t result;
260     /**Base Information **/
261     CAInfo_t info;
262 } CAResponseInfo_t;
263
264 #ifdef __cplusplus
265 } /* extern "C" */
266 #endif
267
268 #endif //#ifndef __CA_COMMON_H_