8641a2e3c2adabf2d9d573b1109b473efba50d02
[framework/connectivity/libnet-client.git] / include / profile / network-pm-wlan.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __NETWORK_PM_WLAN_H__
19 #define __NETWORK_PM_WLAN_H__
20
21
22 #ifdef __cplusplus
23 extern "C"
24 {
25 #endif /* __cplusplus */
26
27 /**  \file network-pm-wlan.h
28      \brief This file contains constants, enums, tructs, and function prototypes that are used by Wlan related sources internally. This File defines the WLAN exported Data Structures.
29
30 */
31
32 /**
33  * \addtogroup  profile_managing
34  * \{
35 */
36
37 /*
38 ==================================================================================================
39                                          INCLUDE FILES
40 ==================================================================================================
41 */
42
43 #include "network-pm-config.h"
44
45 /*
46 ==================================================================================================
47                                            CONSTANTS
48 ==================================================================================================
49 */
50
51 /** Length of essid */
52 #define NET_WLAN_ESSID_LEN      128
53
54
55 /** 
56  * Length of WPS PIN code 
57  * WPS PIN code should be 4 or 8 digits
58  */
59 #define NET_WLAN_MAX_WPSPIN_LEN         8       
60
61 /**
62  * Passphrase length should be between 8..63,
63  * If we plan to use encrypted key(hex value generated by wpa_passphrase),
64  * then we have to set this value to some higher number
65  *
66  */
67 #define NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN 65
68
69 /**
70  * Length of WEP Key
71  * Max of 10 Hex digits allowed in case of 64 bit encryption
72  * Max of 26 Hex digits allowed in case of 128 bit encryption
73  */
74 #define NETPM_WLAN_MAX_WEP_KEY_LEN        26
75
76
77 /**
78  * These lengths depends on authentication server being used,
79  * In case of freeradius server Max allowed length for username/password is 255
80  * Let us restrict this value to some optimal value say 50.
81  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
82  */
83 #define NETPM_WLAN_USERNAME_LEN               50
84 /**
85  * These lengths depends on authentication server being used,
86  * In case of freeradius server Max allowed length for username/password is 255
87  * Let us restrict this value to some optimal value say 50.
88  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
89  */
90 #define NETPM_WLAN_PASSWORD_LEN               50
91
92 /**
93  * length of CA Cert file name
94  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
95  */
96 #define NETPM_WLAN_CA_CERT_FILENAME_LEN       50
97 /**
98  * length of Client Cert file name
99  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
100  */
101 #define NETPM_WLAN_CLIENT_CERT_FILENAME_LEN   50
102 /**
103  * length of private key file name
104  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
105  */
106 #define NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN   50
107 /**
108  * length of Private key password
109  * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
110  */
111 #define NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN     50
112
113 /*==================================================================================================
114                                              ENUMS
115 ==================================================================================================*/
116
117 /**
118  * @enum wlan_security_mode_type_t
119  * Below security modes are used in infrastructure and ad-hoc mode
120  * For now all EAP security mechanisms are provided only in infrastructure mode
121  */
122 typedef enum
123 {
124         /** Security disabled */
125         WLAN_SEC_MODE_NONE = 0x01,
126         /** WEP */
127         WLAN_SEC_MODE_WEP,
128         /** EAP */
129         WLAN_SEC_MODE_IEEE8021X,
130         /** WPA-PSK */
131         WLAN_SEC_MODE_WPA_PSK,
132         /** WPA2-PSK */
133         WLAN_SEC_MODE_WPA2_PSK,
134 } wlan_security_mode_type_t;
135
136 /**
137  * @enum wlan_encryption_mode_type_t
138  * Below encryption modes are used in infrastructure and ad-hoc mode
139  */
140 typedef enum
141 {
142         /** Encryption disabled */
143         WLAN_ENC_MODE_NONE = 0x01,
144         /** WEP */
145         WLAN_ENC_MODE_WEP,
146         /** TKIP */
147         WLAN_ENC_MODE_TKIP,
148         /** AES */
149         WLAN_ENC_MODE_AES,
150         /** TKIP and AES are both supported */
151         WLAN_ENC_MODE_TKIP_AES_MIXED,
152 } wlan_encryption_mode_type_t;
153
154 /**
155  * @enum wlan_connection_mode_type_t
156  * WLAN Operation Mode
157  * @see net_pm_wlan_profile_info_t
158  */
159 typedef enum
160 {
161         /** auto connection mode */
162         NETPM_WLAN_CONNMODE_AUTO = 0x01,
163         /** Connection mode Adhoc  */
164         NETPM_WLAN_CONNMODE_ADHOC,
165         /** Infra connection mode */
166         NETPM_WLAN_CONNMODE_INFRA,
167 } wlan_connection_mode_type_t;
168
169
170 /**
171  * @enum wlan_eap_type_t
172  * EAP type
173  * @see wlan_eap_info_t
174  */
175  typedef enum
176 {
177         /** EAP PEAP type */
178         WLAN_SEC_EAP_TYPE_PEAP = 0x01,
179         /** EAP TLS type */
180         WLAN_SEC_EAP_TYPE_TLS,
181         /** EAP TTLS type */
182         WLAN_SEC_EAP_TYPE_TTLS,
183         /** EAP SIM type */
184         WLAN_SEC_EAP_TYPE_SIM,
185         /** EAP AKA type */
186         WLAN_SEC_EAP_TYPE_AKA,
187 } wlan_eap_type_t;
188
189 /**
190  * @enum wlan_eap_auth_type_t
191  * EAP phase2 authentication type
192  * @see wlan_eap_info_t
193  */
194 typedef enum
195 {
196         /** EAP phase2 authentication none */
197         WLAN_SEC_EAP_AUTH_NONE = 0x01,
198         /** EAP phase2 authentication PAP */
199         WLAN_SEC_EAP_AUTH_PAP,
200         /** EAP phase2 authentication MSCHAP */
201         WLAN_SEC_EAP_AUTH_MSCHAP,
202         /** EAP phase2 authentication MSCHAPv2 */
203         WLAN_SEC_EAP_AUTH_MSCHAPV2,
204         /** EAP phase2 authentication GTC */
205         WLAN_SEC_EAP_AUTH_GTC,
206         /** EAP phase2 authentication MD5 */
207         WLAN_SEC_EAP_AUTH_MD5,
208 } wlan_eap_auth_type_t;
209
210 /*
211 ==================================================================================================
212                                             MACROS
213 ==================================================================================================
214 */
215
216
217 /*==================================================================================================
218                                  STRUCTURES AND OTHER TYPEDEFS
219 ==================================================================================================*/
220
221 /**
222  * Below structure is used to export essid
223  */
224 typedef struct
225 {
226         /** ESSID */
227         char essid[NET_WLAN_ESSID_LEN+1];
228 } net_essid_t;
229
230
231 /**
232  * Below structure is used by WPA-PSK or WPA2-PSK
233  * @remark To see the maximum length of PSK passphrase key.
234  * @see wlan_auth_info_t
235  */
236 typedef struct
237 {
238         /** key value for WPA-PSK or WPA2-PSK */
239         char pskKey[NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
240 } wlan_psk_info_t;
241
242
243 /**
244  * Below structure is used by WEP
245  * @remark To see the maximum length of WEP key.
246  * @see wlan_auth_info_t
247  */
248 typedef struct
249 {
250         /** key value for WEP */
251         char wepKey[NETPM_WLAN_MAX_WEP_KEY_LEN + 1];
252 } wlan_wep_info_t;
253
254
255 /**
256  * Below structure is used by EAP
257  * @see wlan_auth_info_t
258  */
259 typedef struct
260 {
261         /** User name */
262         char username[NETPM_WLAN_USERNAME_LEN+1];
263         /** Password */
264         char password[NETPM_WLAN_PASSWORD_LEN+1];
265
266         /**
267          * Following fields are mandatory for EAP-TLS,
268          * Optional for EAP-TTLS and EAP-PEAP
269          */
270         /**
271          * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
272          */
273         char ca_cert_filename[NETPM_WLAN_CA_CERT_FILENAME_LEN+1]; /* Used to authenticate server */
274         /** client certificate file name */
275         char client_cert_filename[NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1];
276         /** private key file name */
277         char private_key_filename[NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1];
278         /** private key password */
279         char private_key_passwd[NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1];
280
281         /** eap type */
282         wlan_eap_type_t eap_type;
283         /** eap phase2 authentication type */
284         wlan_eap_auth_type_t eap_auth;
285 } wlan_eap_info_t;
286
287
288 /**
289  * At any point of time only one security mechanism is supported
290  * @see wlan_security_info_t
291  */
292 typedef union
293 {
294         /** Wep Authentication */
295         wlan_wep_info_t wep;
296         /** psk Authentication */
297         wlan_psk_info_t psk;
298         /** eap Authentication */
299         wlan_eap_info_t eap;
300 } wlan_auth_info_t;
301
302
303 /**
304  * This is main security information structure
305  * @see net_pm_wlan_profile_info_t
306  */
307 typedef struct
308 {
309         /** security mode type */
310         wlan_security_mode_type_t sec_mode;
311         /** encryption mode type */
312         wlan_encryption_mode_type_t enc_mode;
313         /** authentication information */
314         wlan_auth_info_t authentication;
315         /** If WPS is supported, then this property will be set to TRUE */
316         char wps_support;
317 } wlan_security_info_t;
318
319
320 /**
321  * AP Profile information
322  */
323 typedef struct
324 {
325         /** ESSID */
326         char essid[NET_WLAN_ESSID_LEN+1];
327         /** Basic service set identification */
328         char bssid[NET_MAX_MAC_ADDR_LEN+1];
329         /**  Strength : between 0 and 100 */
330         unsigned char Strength;
331         /** Frequency band(MHz) */
332         unsigned int frequency;
333         /** Maximum speed of the line(bps) */
334         unsigned int max_rate;
335         /** If a passphrase has been set already or if no
336                 passphrase is needed, then this property will
337                 be set to FALSE. */
338         char PassphraseRequired;
339         /** Infrastucture / ad-hoc / auto mode */
340         wlan_connection_mode_type_t wlan_mode;
341         /** Security mode and authentication info */
342         wlan_security_info_t security_info;
343
344         /** network information */
345         net_dev_info_t net_info;
346 } net_wifi_profile_info_t;
347
348 /**
349  * \}
350  */
351
352 #ifdef __cplusplus
353 }
354 #endif /* __cplusplus */
355
356 #endif /* __NETPM_WLAN_H__ */
357
358