Remove DPM codes
[apps/native/ug-wifi-efl.git] / sources / libraries / WlanManager / include / wlan_manager.h
1 /*
2  * Wi-Fi
3  *
4  * Copyright 2012 Samsung Electronics Co., Ltd
5  *
6  * Licensed under the Flora License, Version 1.1 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.tizenopensource.org/license
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __WIFI_WLAN_MANAGER_H__
21 #define __WIFI_WLAN_MANAGER_H__
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27
28 #include <glib.h>
29 #include <wifi-manager.h>
30 #include <wifi-manager-extension.h>
31
32 typedef enum {
33         WLAN_MANAGER_ERR_NONE = 0x00,
34         WLAN_MANAGER_ERR_UNKNOWN,
35         WLAN_MANAGER_ERR_INVALID_PARAM,
36         WLAN_MANAGER_ERR_ALREADY_REGISTERED,
37         WLAN_MANAGER_ERR_CONNECT_PASSWORD_NEEDED,
38         WLAN_MANAGER_ERR_CONNECT_EAP_SEC_TYPE,
39         WLAN_MANAGER_ERR_WIFI_TETHERING_OCCUPIED,
40         WLAN_MANAGER_ERR_WIFI_AP_TETHERING_OCCUPIED,
41         WLAN_MANAGER_ERR_NOSERVICE,
42         WLAN_MANAGER_ERR_IN_PROGRESS,
43         WLAN_MANAGER_ERR_OPERATION_FAILED,
44 } WLAN_MANAGER_ERR_TYPE;
45
46 typedef enum {
47         SIGNAL_STRENGTH_TYPE_EXCELLENT,
48         SIGNAL_STRENGTH_TYPE_GOOD,
49         SIGNAL_STRENGTH_TYPE_WEAK,
50         SIGNAL_STRENGTH_TYPE_VERY_WEAK,
51         SIGNAL_STRENGTH_TYPE_NULL
52 } STRENGTH_TYPES;
53
54 /*
55  * JOIN TYPE, SECURITY TYPE and EAP_TYPE
56  *
57  * Determine it`s security type
58  * It should be merged into one enumerations
59 */
60 typedef enum {
61         SECURITY_TYPE_NONE = 0x01,
62         SECURITY_TYPE_WEP,
63         SECURITY_TYPE_WPA_PSK,
64         SECURITY_TYPE_WPA2_PSK,
65
66         SECURITY_TYPE_WPA_EAP,
67         SECURITY_TYPE_WPA2_EAP,
68
69         SECURITY_TYPE_MAX,
70         SECURITY_TYPE_NULL
71 } SECURITY_TYPES;
72
73 typedef enum {
74         WLAN_MANAGER_EAP_TYPE_NONE, /* only use it`s WPA number */
75         WLAN_MANAGER_EAP_TYPE_TLS,
76         WLAN_MANAGER_EAP_TYPE_TTLS_PAP,         /** PAP is tunneled protocol */
77         WLAN_MANAGER_EAP_TYPE_TTLS_CHAP,             /** CHAP is tunneled protocol */
78         WLAN_MANAGER_EAP_TYPE_TTLS_MSCHAP,           /** MSCHAP is tunneled protocol */
79         WLAN_MANAGER_EAP_TYPE_TTLS_MSCHAPV2,         /** MSCHAPV2 is tunneled protocol */
80
81         /** Define EAP-TTLS and tunneled EAP sub types here */
82         WLAN_MANAGER_EAP_TYPE_TTLS_EAP_GTC,     /** EAP_GTC is tunneled protocol */
83         WLAN_MANAGER_EAP_TYPE_TTLS_EAP_MD5,          /** EAP_MD5 is tunneled protocol */
84         WLAN_MANAGER_EAP_TYPE_TTLS_EAP_MSCHAPV2,     /** EAP_MSCHAPV2 is tunneled protocol */
85
86         /** Define EAP-PEAP version 0 */
87         WLAN_MANAGER_EAP_TYPE_PEAP0_MSCHAPV2,   /** MSCHAPV2 is tunneled protocol, PEAP version is 0 */
88         WLAN_MANAGER_EAP_TYPE_PEAP0_MD5,             /** MD5 is tunneled protocol, PEAP version is 0 */
89         WLAN_MANAGER_EAP_TYPE_PEAP0_GTC,             /** GTC is tunneled protocol, PEAP version is 0 */
90
91         /** Define EAP-PEAP version 1 */
92         WLAN_MANAGER_EAP_TYPE_PEAP1_MSCHAPV2,   /** MSCHAPV2 is tunneled protocol, PEAP version is 1 */
93         WLAN_MANAGER_EAP_TYPE_PEAP1_MD5,             /** MD5 is tunneled protocol, PEAP version is 1 */
94         WLAN_MANAGER_EAP_TYPE_PEAP1_GTC,             /** GTC is tunneled protocol, PEAP version is 1 */
95         WLAN_MANAGER_EAP_TYPE_MAX,
96         WLAN_MANAGER_EAP_TYPE_ERROR
97 } WLAN_MANAGER_EAP_TYPES;
98
99 /*
100  * RESPONSES
101  */
102 typedef enum {
103         WLAN_MANAGER_RESPONSE_TYPE_NONE                                                         = 0x00,
104         WLAN_MANAGER_RESPONSE_TYPE_CONNECTING                                           = 0x01,
105         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_OK                                        = 0x02,
106         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_IN_PROGRESS          = 0x03,
107         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_ABORTED                      = 0x04,
108         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_ALREADY_EXIST        = 0x05,
109         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_TIMEOUT                      = 0x06,
110         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_UNKNOWN                      = 0x07,
111         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_FAIL_UNKNOWN_METHOD       = 0x08,
112         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_CONNECT_FAILED            = 0x09,
113         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_INVALID_KEY                       = 0x0A,
114         WLAN_MANAGER_RESPONSE_TYPE_DISCONNECTION_OK                                     = 0x0B,
115         WLAN_MANAGER_RESPONSE_TYPE_POWER_ON_OK                                          = 0x0C,
116         WLAN_MANAGER_RESPONSE_TYPE_POWER_ON_NOT_SUPPORTED                       = 0x0D,
117         WLAN_MANAGER_RESPONSE_TYPE_POWER_ON_RESTRICTED                          = 0x0E,
118         WLAN_MANAGER_RESPONSE_TYPE_POWER_OFF_OK                                         = 0x0F,
119         WLAN_MANAGER_RESPONSE_TYPE_SCAN_OK                                                      = 0x10,
120         WLAN_MANAGER_RESPONSE_TYPE_WPS_ENROLL_OK                                        = 0x11,
121         WLAN_MANAGER_RESPONSE_TYPE_WPS_ENROLL_FAIL                                      = 0x12,
122         WLAN_MANAGER_RESPONSE_TYPE_CANCEL_WPS_ENROLL_OK                         = 0x13,
123         WLAN_MANAGER_RESPONSE_TYPE_CANCEL_WPS_ENROLL_FAIL                       = 0x14,
124         WLAN_MANAGER_RESPONSE_TYPE_CONNECTION_IND                                       = 0x15,
125         WLAN_MANAGER_RESPONSE_TYPE_DISCONNECTION_IND                            = 0x16,
126         WLAN_MANAGER_RESPONSE_TYPE_SCAN_RESULT_IND                                      = 0x17,
127         WLAN_MANAGER_RESPONSE_TYPE_MAC_ID_IND                                           = 0x18,
128         WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_OK                                     = 0x19,
129         WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_FAIL                           = 0x1A,
130         WLAN_MANAGER_RESPONSE_TYPE_SPECIFIC_SCAN_IND                            = 0x1B,
131         WLAN_MANAGER_RESPONSE_TYPE_UPDATE_WIFI_RSSI                                     = 0x1C,
132         WLAN_MANAGER_RESPONSE_TYPE_CONFIGURATION                                        = 0x1D,
133         WLAN_MANAGER_RESPONSE_TYPE_DHCP_FAILED                                          = 0x1E,
134         WLAN_MANAGER_RESPONSE_TYPE_MAX                                                          = 0x1F,
135 } WLAN_MANAGER_RESPONSE_TYPES;
136
137 typedef enum {
138         WIFI_MANAGER_CONNECTION_ERROR_NONE                              = 0x00,
139         WIFI_MANAGER_CONNECTION_ERROR_OUT_OF_RANGE              = 0x01,
140         WIFI_MANAGER_CONNECTION_ERROR_PIN_MISSING               = 0x02,
141         WIFI_MANAGER_CONNECTION_ERROR_DHCP_FAILED               = 0x03,
142         WIFI_MANAGER_CONNECTION_ERROR_CONNECT_FAILED    = 0x04,
143         WIFI_MANAGER_CONNECTION_ERROR_LOGIN_FAILED              = 0x05,
144         WIFI_MANAGER_CONNECTION_ERROR_AUTH_FAILED               = 0x06,
145         WIFI_MANAGER_CONNECTION_ERROR_INVALID_KEY               = 0x07,
146         WIFI_MANAGER_CONNECTION_ERROR_UNKNOWN                   = 0x08,
147 } wifi_connection_error_e;
148
149 typedef enum {
150         WLAN_MANAGER_AUTOSCAN_MODE_PERIODIC = WIFI_MANAGER_AUTOSCAN_MODE_PERIODIC,
151         WLAN_MANAGER_AUTOSCAN_MODE_EXPONENTIAL = WIFI_MANAGER_AUTOSCAN_MODE_EXPONENTIAL,
152 } wlan_manager_autoscan_mode_e;
153
154 #define WLAN_PROXY_LEN_MAX 64
155
156 typedef struct _wifi_device_info_t {
157 //      wifi_manager_h wifi;
158         wifi_manager_ap_h ap;
159         char *ssid;
160         char *ap_status_txt;
161         char *ap_image_path;
162         int ipconfigtype;
163         int rssi;
164         wifi_manager_security_type_e security_mode;
165         bool wps_mode;
166         bool is_hidden;
167 } wifi_device_info_t;
168
169 typedef struct {
170         const char *password;
171         char *category;
172         char *subcategory;
173         char *username;
174         char *userpassword;
175         char *ca_cert_filename;
176         char *client_cert_filename;
177         char *private_key;
178         char *private_key_password;
179         int wlan_eap_type;
180 } wlan_manager_password_data;
181
182 /* it should be implement. */
183 typedef enum {
184         WLAN_MANAGER_ERROR                      = 0x01,
185         WLAN_MANAGER_OFF                        = 0x02,
186         WLAN_MANAGER_UNCONNECTED        = 0x03,
187         WLAN_MANAGER_CONNECTED          = 0x04,
188         WLAN_MANAGER_CONNECTING         = 0x05,
189         WLAN_MANAGER_MAX                        = 0x06,
190 } WLAN_MANAGER_STATES;
191
192 typedef void (*wlan_manager_ui_refresh_func_t)(void);
193
194 typedef struct {
195         WLAN_MANAGER_RESPONSE_TYPES event_type;
196         wifi_manager_ap_h ap;
197         wifi_manager_rssi_level_e rssi_level;
198         GSList *bss_info_list;
199 } wlan_mgr_event_info_t;
200
201 typedef void (*wlan_event_handler)(wlan_mgr_event_info_t *event_info, void *user_data);
202
203 /** It should be hide to others */
204 typedef struct wlan_manager_object {
205         wlan_event_handler message_func;
206         wlan_manager_ui_refresh_func_t refresh_func;
207         gboolean b_scan_blocked;
208         gboolean b_ui_refresh;
209         wifi_manager_h wifi;
210 } wlan_manager_object;
211
212 /////////////////////////////////////////////////////////////////
213
214 /////////////////////////////////////////////////////////////////
215 // FUNCTIONS
216 /////////////////////////////////////////////////////////////////
217
218 wlan_manager_object *wlan_manager_get_singleton(void);
219 void *wlan_manager_create(void);
220 int wlan_manager_update_ap(wifi_manager_ap_h ap);
221 int wlan_manager_is_activated(bool *activated);
222 int wlan_manager_destroy(void);
223 int wlan_manager_start(void);
224 int wlan_manager_get_connection_state(wifi_manager_connection_state_e *state);
225 int wlan_manager_foreach_found_ap(wifi_manager_found_ap_cb callback, int *profiles_list_size);
226 wifi_manager_ap_h wlan_manager_get_ap_with_state(int ap_state);
227 int wlan_manager_get_connected_ap(wifi_manager_ap_h *ap);
228 int wlan_manager_state_get(void);
229 void wlan_manager_set_message_callback(wlan_event_handler func);
230 void wlan_manager_set_refresh_callback(wlan_manager_ui_refresh_func_t func);
231
232 void wlan_manager_enable_scan_result_update(void);
233 void wlan_manager_disable_scan_result_update(void);
234
235 // request
236 void wlan_manager_ap_hidden_create(char *ssid, wifi_manager_ap_h *hidden_ap);
237 int wlan_manager_ap_create(const char *essid, wifi_manager_ap_h *ap);
238 int wlan_manager_connect(wifi_manager_ap_h ap);
239 int wlan_manager_connect_with_password(wifi_manager_ap_h ap, const char *pass_phrase);
240 int wlan_manager_wps_connect(wifi_manager_ap_h ap);
241 int wlan_manager_wps_pin_connect(wifi_manager_ap_h ap, const char *pin);
242 int wlan_manager_power_on(void);
243 int wlan_manager_power_off(void);
244 void wlan_validate_alt_connection(void);
245 int wlan_manager_emulator_power_on(void);
246 int wlan_manager_emulator_power_off(void);
247 int wlan_manager_disconnect(wifi_manager_ap_h);
248 int wlan_manager_scan(void);
249 int wlan_manager_forget(wifi_manager_ap_h ap);
250 int wlan_manager_scan_with_ssid(const char *ssid, void *data);
251 gboolean wlan_manager_is_same_network(wifi_manager_ap_h ap1, wifi_manager_ap_h ap2);
252 STRENGTH_TYPES wlan_manager_get_signal_strength(int rssi);
253 int wlan_manager_set_autoscan_mode(wlan_manager_autoscan_mode_e mode);
254
255 //// profile refresh /////////////////////////////////////////////
256 void wlan_manager_scanned_profile_refresh(void);
257
258 typedef struct {
259         int event_id;
260         guint timer_id;
261 } wifi_emul_timer_s;
262
263 typedef enum {
264         WIFI_EMUL_EVENT_TIMER_ACTIVATE = 0x00,
265         WIFI_EMUL_EVENT_TIMER_DEACTIVATE,
266         WIFI_EMUL_EVENT_TIMER_SCAN,
267         WIFI_EMUL_EVENT_TIMER_MAX,
268 } wifi_emul_event_timer_e;
269
270 void wifi_emulator_create_event_timer(int evt_id, int itv, void *evt_cb, void *usr_data);
271 void wifi_emulator_remove_event_timer(int evt_id);
272 void wifi_emulator_remove_all_event_timer(void);
273
274 #ifdef __cplusplus
275 }
276 #endif
277
278 #endif /* __WIFI_REQUEST_HANDLER_H__ */