Apply device policy for wifi and wifi profile
[platform/core/connectivity/libnet-client.git] / include / wifi / network-wifi-intf.h
1 /*
2  * Network Client Library
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 __NETWORK_WIFI_INTF_H__
21 #define __NETWORK_WIFI_INTF_H__
22
23 #include <glib.h>
24
25 #include "network-cm-intf.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * @file network-wifi-intf.h
33  * @brief This file defines the Wi-Fi specific interface with the application/Connection Manager.
34 */
35
36 /**
37  * \addtogroup  wifi_specific
38  * \{
39 */
40
41 /*****************************************************************************
42  *      Macros and Typedefs
43  *****************************************************************************/
44
45
46 /*****************************************************************************
47  *      Global Enums
48  *****************************************************************************/
49
50 /**
51 * @enum net_wifi_state_t
52 * This enum indicates wifi state
53 */
54 typedef enum {
55         WIFI_UNKNOWN            = 0x00, /** Unknown state */
56         WIFI_OFF                        = 0x01, /** Wi-Fi is Off */
57         WIFI_ON                         = 0x02, /** Wi-Fi is On(idle/failure) */
58         WIFI_ASSOCIATION        = 0x03, /** Trying association */
59         WIFI_CONFIGURATION      = 0x04, /** Trying configuration */
60         WIFI_CONNECTED          = 0x05, /** Wi-Fi is connected */
61         WIFI_DISCONNECTING      = 0x06, /** Trying to disconnect */
62 } net_wifi_state_t;
63
64 /**
65 *@enum net_wifi_background_scan_mode_t
66 * This enum indicates background scanning mode.
67 */
68 typedef enum {
69         /** scan cycle : 4, 8, 16, ...128s */
70         WIFI_BGSCAN_MODE_EXPONENTIAL = 0x00,
71         /** scan cycle : 10s */
72         WIFI_BGSCAN_MODE_PERIODIC,
73 } net_wifi_background_scan_mode_t;
74
75 /**
76 *@enum net_wifi_wps_type_t
77 * This enum indicates WPS type.
78 */
79 typedef enum
80 {
81         /** WPS type is PBC */
82         WIFI_WPS_PBC = 0x00,
83         /** WPS type is PIN */
84         WIFI_WPS_PIN
85 } net_wifi_wps_type_t;
86
87 /*****************************************************************************
88  *      Global Structures
89  *****************************************************************************/
90 /**
91  * This is the structure to connect with WPS network.
92  */
93 typedef struct {
94         /** PBC / PIN */
95         net_wifi_wps_type_t type;
96
97         /** Optional. This pin is needed when the user input PIN code */
98         char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
99 } net_wifi_wps_info_t;
100
101 /**
102  * This is the profile structure to connect hidden WiFi network.
103  */
104 typedef struct {
105         /** Basic feature */
106         char essid[NET_WLAN_ESSID_LEN + 1];
107
108         /** Infrastructure / ad-hoc / auto mode */
109         wlan_connection_mode_type_t wlan_mode;
110
111         /** Security mode and authentication info */
112         wlan_security_info_t security_info;
113
114         /** Hidden network */
115         gboolean is_hidden;
116 } net_wifi_connection_info_t;
117
118 struct ssid_scan_bss_info_t {
119         char ssid[NET_WLAN_ESSID_LEN + 1];
120         wlan_security_mode_type_t security;
121         char wps;
122 };
123
124 struct wps_scan_bss_info_t {
125         unsigned char ssid[NET_WLAN_ESSID_LEN + 1];
126         char bssid[NET_WLAN_BSSID_LEN + 1];
127         int rssi;
128         int mode;
129 };
130
131 /*****************************************************************************
132  *      Typedefs
133  *****************************************************************************/
134
135
136 /*****************************************************************************
137  *      Global Functions
138  *****************************************************************************/
139
140
141 /*****************************************************************************
142  *      ConnMan Wi-Fi Client Interface Synchronous API Declaration
143  *****************************************************************************/
144
145 /**
146  * @fn   int net_get_wifi_state(net_wifi_state_t *current_state)
147  *
148  * This function requests current state of wifi.
149  *
150  * \par Sync (or) Async:
151  * These is a Synchronous API.
152  *
153  * @param[in]    none
154  * @param[out]   current_state  Current wifi state
155  * @param[out]   profile_name   Profile name of current Wi-Fi state\n
156  *                              (valid for WIFI_ASSOCIATION, WIFI_CONFIGURATION,\n
157  *                               WIFI_CONNECTED, WIFI_DISCONNECTING state only)
158  * @return       NET_ERR_NONE on success, negative values for errors
159  */
160
161 int net_get_wifi_state(net_wifi_state_t *current_state);
162
163 /**
164  * @fn   int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
165  *
166  * This function sends set background scan mode request to ConnMan daemon,
167  * with background scan mode - default/periodic/exponential
168  * Background scan trigger is restarted if the same mode is set again.
169  *
170  * \par Sync (or) Async:
171  * These is a Synchronous API.
172  *
173  * @param[in]    scan_mode  default/periodic/exponential
174  * @param[out]   none
175  *
176  * @return       NET_ERR_NONE on success, negative values for errors
177  */
178
179 int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode);
180
181 /**
182  * @fn   int net_specific_scan_wifi(const char *ssid)
183  *
184  * This function sends specific scan request to NetConfig daemon,
185  * with ssid - any AP name
186  *
187  * \par Sync (or) Async:
188  * This is Asynchronous API.
189  *
190  * @param[in]    ssid  Wi-Fi AP name
191  * @param[out]   none
192  *
193  * @return       NET_ERR_NONE on success, negative values for errors
194  */
195
196 int net_specific_scan_wifi(const char *ssid);
197
198 /**
199  * @fn   int net_get_wps_pin(void)
200  *
201  * This function get wps pin
202  *
203  * \par Sync (or) Async:
204  * This is an Synchronous API.
205  *
206  * @param[out]   wps pin
207  *
208  * @return       NET_ERR_NONE on success, negative values for errors
209  */
210 int net_get_wps_pin(char **wps_pin);
211
212 /**
213  * @fn   int net_wps_scan_wifi(void)
214  *
215  * This function sends scan request to NetConfig daemon,
216  *
217  * \par Sync (or) Async:
218  * This is Asynchronous API.
219  *
220  * @param[out]   none
221  *
222  * @return       NET_ERR_NONE on success, negative values for errors
223  */
224
225 int net_wps_scan_wifi(void);
226
227 /**
228  * @fn   int net_wifi_get_passpoint(int *enable)
229  *
230  * This function requests current passpoint on/off state to NetConfig daemon,
231  *
232  * \par Sync (or) Sync:
233  * This is Synchronous API.
234  *
235  * @param[in]   none
236  * @param[out]  enabled passpoint on(1)/off(0)
237  *
238  * @return      NET_ERR_NONE on success, negative values for errors
239  */
240
241 int net_wifi_get_passpoint(int *enable);
242
243 /**
244  * @fn   int net_wifi_set_passpoint(int enable)
245  *
246  * This function sends passpoint on/off request to NetConfig daemon,
247  *
248  * \par Sync (or) Async:
249  * This is Asynchronous API.
250  *
251  * @param[in]    enable passpoint on(1)/off(0)
252  * @param[out]   none
253  *
254  * @return       NET_ERR_NONE on success, negative values for errors
255  */
256
257 int net_wifi_set_passpoint(int enable);
258
259 #if defined TIZEN_TV
260 /**
261 * @fn   int net_wifi_cancel_wps(void)
262 *
263 * This function  stops ongoing WPS Provisioning / disconnects
264 *       connected access point.
265 *
266 * \par Sync (or) Async:
267 * This is an Sync API.
268 *
269 * @param[in]    none
270 * @param[out]   none
271 *
272 * @return          NET_ERR_NONE on success, negative values for errors
273 */
274
275 int net_wifi_cancel_wps(void);
276
277 #endif
278 /*****************************************************************************
279  *      ConnMan Wi-Fi Client Interface Asynchronous Function Declaration
280  *****************************************************************************/
281
282 /**
283  * @fn   int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info)
284  *
285  * This function requests Wi-Fi open connection. This should be used only for opening
286  * connection with hidden ap
287  *
288  * \par Sync (or) Async:
289  * This is an Asynchronous API.
290  *
291  * @param[in]    wifi_info  Pointer to connection information structure
292  * @param[out]   none
293  *
294  * \par Async Response Message:
295  *        NET_EVENT_OPEN_RSP: Connection Establishment response will be sent asynchronously to the App in the callback function registered.\n
296  *        refer to net_event_cb_t()
297  *
298  * @return       NET_ERR_NONE on success, negative values for errors
299  */
300
301 int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info);
302
303 /**
304  * @fn   int net_scan_wifi(void)
305  *
306  * This function sends scan request to ConnMan daemon.\n
307  * You can receive scan completion response(NET_EVENT_WIFI_SCAN_RSP) via the callback function registered,\n
308  * and then get scan result by using net_get_profile_list().
309  *
310  *\par Sync (or) Async:
311  * This is an Asynchronous API.
312  *
313  * @param[in]    none
314  * @param[out]   none
315  *
316  * \par Async Response Message:
317  *        NET_EVENT_WIFI_SCAN_RSP: Scan completion response will be sent asynchronously to the App in the callback function registered.\n
318  *        refer to net_event_cb_t()
319  *
320  * @return       NET_ERR_NONE on success, negative values for errors
321  */
322
323 int net_scan_wifi(void);
324
325 /**
326  * @fn   int net_wifi_power_on(gboolean wifi_picker_test)
327  *
328  * This function requests wifi power on.
329  *
330  * \par Sync (or) Async:
331  * This is an Asynchronous API.
332  *
333  * @param[in]    wifi_picker_test  whether wifi list popup(picker) display or not
334  * @param[out]   none
335  *
336  * \par Async Response Message:
337  *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power on response will be sent asynchronously to the App in the callback function registered.\n
338  *        refer to net_event_cb_t()
339  *
340  * @return       NET_ERR_NONE on success, negative values for errors
341  */
342
343 int net_wifi_power_on(gboolean wifi_picker_test);
344
345 /**
346  * @fn   int net_wifi_power_off(void)
347  *
348  * This function requests wifi power off.
349  *
350  * \par Sync (or) Async:
351  * This is an Asynchronous API.
352  *
353  * @param[in]    none
354  * @param[out]   none
355  *
356  * \par Async Response Message:
357  *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power off response will be sent asynchronously to the App in the callback function registered.\n
358  *        refer to net_event_cb_t()
359  *
360  * @return       NET_ERR_NONE on success, negative values for errors
361  */
362
363 int net_wifi_power_off(void);
364
365 /**
366  * @fn   int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
367  *
368  * This function sends enroll wps request to ConnMan daemon,
369  * with profile name and wps information.
370  *
371  * \par Sync (or) Async:
372  * This is an Asynchronous API.
373  *
374  * @param[in]    profile_name  Profile Name to be connected
375  * @param[in]    wps_info      wps type and pin code for WPS PIN(optional)
376  * @param[out]   none
377  *
378  * \par Async Response Message:
379  *        NET_EVENT_WIFI_WPS_RSP : enroll wps response will be sent asynchronously to the App in the callback function registered.\n
380  *        refer to net_event_cb_t()
381  *
382  * @return       NET_ERR_NONE on success, negative values for errors
383  */
384
385 int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info);
386
387 /**
388  * @fn   int net_check_get_privilege()
389  *
390  * This function checks get privilege (dummy function).
391  *
392  * \par Sync (or) Async:
393  * This is an Synchronous API.
394  *
395  * @param[out]   none
396  *
397  *
398  * @return       NET_ERR_NONE on success, negative values for errors
399  */
400
401 int net_check_get_privilege(void);
402
403 /**
404  * @fn   int net_check_profile_privilege()
405  *
406  * This function checks get privilege (dummy function).
407  *
408  * \par Sync (or) Async:
409  * This is an Synchronous API.
410  *
411  * @param[out]   none
412  *
413  *
414  * @return       NET_ERR_NONE on success, negative values for errors
415  */
416
417 int net_check_profile_privilege(void);
418
419 #if defined TIZEN_TV
420 /**
421  * @fn   int net_wifi_enroll_wps_without_ssid()
422  *
423  * This function sends enroll wps request to NetConfig daemon,
424  * with wps information.
425  *
426  * \par Sync (or) Async:
427  * This is an Asynchronous API.
428  *
429  * @param[in]    wps_info      wps type
430  * @param[out]   none
431  *
432  * \par Async Response Message:
433  *        NET_EVENT_WIFI_WPS_RSP : enroll wps response will be sent asynchronously to the App in the callback function registered.\n
434  *        refer to net_event_cb_t()
435  *
436  * @return       NET_ERR_NONE on success, negative values for errors
437  */
438 int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_t *wps_info);
439
440 #endif
441
442 int net_wifi_tdls_disconnect(const char* peer_mac_addr);
443 int net_wifi_tdls_connected_peer(char** peer_mac_addr);
444
445 int net_get_device_policy_wifi(void);
446 int net_get_device_policy_wifi_profile(void);
447
448 /**
449  * \}
450  */
451
452 #ifdef __cplusplus
453 }
454 #endif
455
456 #endif /** __NETWORK_WIFI_INTF_H__ */