f31e3d5d5cbf2a645246560c8e98be89d3cb9de2
[platform/upstream/iotivity.git] / service / easy-setup / inc / escommon.h
1 //******************************************************************
2 //
3 // Copyright 2015 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 #ifndef ES_COMMON_H_
22 #define ES_COMMON_H_
23
24 #include "ocstack.h"
25 #include "octypes.h"
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 // Defines
33 #define OIC_STRING_MAX_VALUE    64
34 #define MAX_WEBLINKLEN          3
35 #define NUM_WIFIMODE            5
36
37 /**
38  * Attributes used to form a proper easysetup conforming JSON message.
39  */
40 #define OC_RSRVD_ES_PROVSTATUS             "ps"
41 #define OC_RSRVD_ES_LAST_ERRORCODE         "lec"
42 #define OC_RSRVD_ES_LINKS                  "links"
43 #define OC_RSRVD_ES_SUPPORTEDWIFIMODE      "swmt"
44 #define OC_RSRVD_ES_SUPPORTEDWIFIFREQ      "swf"
45 #define OC_RSRVD_ES_SSID                   "tnn"
46 #define OC_RSRVD_ES_CRED                   "cd"
47 #define OC_RSRVD_ES_AUTHTYPE               "wat"
48 #define OC_RSRVD_ES_ENCTYPE                "wet"
49 #define OC_RSRVD_ES_AUTHCODE               "ac"
50 #define OC_RSRVD_ES_AUTHPROVIDER           "apn"
51 #define OC_RSRVD_ES_CISERVER               "cis"
52 #define OC_RSRVD_ES_SERVERID               "sid"
53 #define OC_RSRVD_ES_DEVNAME                "dn"
54 #define OC_RSRVD_ES_LANGUAGE               "lang"
55 #define OC_RSRVD_ES_COUNTRY                "ctry"
56 #define OC_RSRVD_ES_MODELNUMBER            "mnmo"
57 #define OC_RSRVD_ES_LOCATION               "loc"
58 #define OC_RSRVD_ES_HREF                   "href"
59
60 /**
61  * Easysetup defined resoruce types and uris.
62  */
63 #define OC_RSRVD_ES_RES_TYPE_PROV         "oic.wk.prov"
64 #define OC_RSRVD_ES_URI_PROV              "/ProvisioningResURI"
65 #define OC_RSRVD_ES_RES_TYPE_WIFI         "oic.wk.wifi"
66 #define OC_RSRVD_ES_URI_WIFI              "/WiFiProvisioningResURI"
67 #define OC_RSRVD_ES_RES_TYPE_CLOUDSERVER  "oic.wk.cloudserver"
68 #define OC_RSRVD_ES_URI_CLOUDSERVER       "/CloudServerProvisioningResURI"
69 #define OC_RSRVD_ES_RES_TYPE_DEVCONF      "oic.wk.devconf"
70 #define OC_RSRVD_ES_URI_DEVCONF           "/DevConfProvisioningResURI"
71
72
73 /**
74  * @brief  Supported WIFI frequency like 2.4G and 5G
75  */
76 typedef enum
77 {
78     WIFI_24G = 0,       /**< 2.4G **/
79     WIFI_5G,            /**< 5G **/
80     WIFI_BOTH,          /**< 2.4G and 5G **/
81     WIFI_FREQ_NONE      /**< EOF **/
82 } WIFI_FREQ;
83
84 /**
85  * @brief  Supported WIFI mode like 802.11g and 802.11n
86  */
87 typedef enum
88 {
89     WIFI_11A = 0,       /**< 802.11a **/
90     WIFI_11B,           /**< 802.11b **/
91     WIFI_11G,           /**< 802.11g **/
92     WIFI_11N,           /**< 802.11n **/
93     WIFI_11AC,          /**< 802.11ac **/
94     WiFi_EOF = 999
95 } WIFI_MODE;
96
97
98 /**
99  * @brief  WIFI Authentication tlype of the Enroller
100  */
101 typedef enum
102 {
103     NONE_AUTH = 0,      /**< NO authentication **/
104     WEP,                /**< WEP **/
105     WPA_PSK,            /**< WPA-PSK **/
106     WPA2_PSK            /**< WPA2-PSK **/
107 } WIFI_AUTHTYPE;
108
109 /**
110  * @brief  WIFI encryption type of the Enroller
111  */
112 typedef enum
113 {
114     NONE_ENC = 0,       /**< NO encryption **/
115     WEP_64,             /**< WEP-64 **/
116     WEP_128,            /**< WEP-128**/
117     TKIP,               /**< TKIP **/
118     AES,                /**< AES **/
119     TKIP_AES            /**< TKIP-AES **/
120 } WIFI_ENCTYPE;
121
122 /**
123  * @brief A result of Easy Setup
124  */
125 typedef enum
126 {
127     /**
128      * Provisioning succeeds.
129      */
130     ES_OK = 0,
131
132     /**
133      * Successfully found Enrollee in a given network. This will be given in Cloud provisioning step.
134      */
135     ES_FOUND_ENROLLEE = 1,
136
137     /**
138      * Not found Enrollee in a give network. This will be given in Cloud provisioning step.
139      */
140     ES_NOT_FOUND_ENROLLEE = 11,
141
142     /**
143      * Security opertion is not supported because it is built as unsecured mode.
144      */
145     ES_SEC_OPERATION_IS_NOT_SUPPORTED = 20,
146
147     /**
148      * A previous request is denied due to its unauthority. It means, Mediator is not unauthroized
149      * to Enrollee for some reaons.
150      */
151     ES_UNAUTHORIZED_REQ = 21,
152
153     /**
154      * Security provisioning fails. The reasons would be: a packet loss for unowned/owned device
155      * discovery request or ownership transfer request, or a denial to ownership transfer by Enrollee
156      * for some reason.
157      */
158     ES_SEC_PROVISION_FAILS = 22,
159
160     /**
161      * Provisioning fails for some reason.
162      */
163     ES_ERROR = 255,
164 } ESResult;
165
166 /**
167  * @brief Indicate which resource is created in Enrollee
168  */
169 typedef enum
170 {
171     ES_WIFI_RESOURCE = 0x01,
172     ES_CLOUD_RESOURCE = 0x02,
173     ES_DEVCONF_RESOURCE = 0x04
174 } ESResourceMask;
175
176 /**
177  * @brief Indicate enrollee and provisioning status. Provisioning status is shown in "provisioning
178  *        status" property in provisioning resource.
179  */
180 typedef enum
181 {
182     /**
183      * Default state of the device
184      */
185     ES_STATE_INIT = 0,
186
187     /**
188     * Status indicating being cnnecting to target network
189     */
190     ES_STATE_CONNECTING_TO_ENROLLER,
191
192     /**
193     * Status indicating successful conection to target network
194     */
195     ES_STATE_CONNECTED_TO_ENROLLER,
196
197     /**
198     * Status indicating failure connection to target network
199     */
200     ES_STATE_CONNECTED_FAIL_TO_ENROLLER,
201
202     /**
203     * Status indicating successful registration to cloud
204     */
205     ES_STATE_REGISTERED_TO_CLOUD,
206
207     /**
208     * Status indicating failure registeration to cloud
209     */
210     ES_STATE_REGISTRRED_FAIL_TO_CLOUD
211 } ESEnrolleeState, ProvStatus;
212
213 /**
214  * @brief Indicate last error code to describe a reason of error during easy setup.
215  */
216 typedef enum
217 {
218     /**
219      * Init Error Code
220      */
221     ES_ERRCODE_NO_ERROR = 0,
222
223     /**
224     * Error Code that given WiFi's SSID is not found
225     */
226     ES_ERRCODE_SSID_NOT_FOUND,
227
228     /**
229     * Error Code that given WiFi's Password is wrong
230     */
231     ES_ERRCODE_PW_WRONG,
232
233     /**
234     * Error Code that IP address is not allocated
235     */
236     ES_ERRCODE_IP_NOT_ALLOCATED,
237
238     /**
239     * Error Code that there is no Internet connection
240     */
241     ES_ERRCODE_NO_INTERNETCONNECTION,
242
243     /**
244     * Error Code that Timeout occured
245     */
246     ES_ERRCODE_TIMEOUT,
247
248     /**
249     * Error Code that Unknown error occured
250     */
251     ES_ERRCODE_UNKNOWN
252 } ESErrorCode;
253
254 #ifdef __cplusplus
255 }
256 #endif
257
258 #endif //ES_COMMON_H_