3 * WPA supplicant library with GLib integration
5 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef __G_SUPPLICANT_H
22 #define __G_SUPPLICANT_H
28 #define G_SUPPLICANT_EAP_METHOD_MD5 (1 << 0)
29 #define G_SUPPLICANT_EAP_METHOD_TLS (1 << 1)
30 #define G_SUPPLICANT_EAP_METHOD_MSCHAPV2 (1 << 2)
31 #define G_SUPPLICANT_EAP_METHOD_PEAP (1 << 3)
32 #define G_SUPPLICANT_EAP_METHOD_TTLS (1 << 4)
33 #define G_SUPPLICANT_EAP_METHOD_GTC (1 << 5)
34 #define G_SUPPLICANT_EAP_METHOD_OTP (1 << 6)
35 #define G_SUPPLICANT_EAP_METHOD_LEAP (1 << 7)
36 #define G_SUPPLICANT_EAP_METHOD_WSC (1 << 8)
38 #define G_SUPPLICANT_CAPABILITY_AUTHALG_OPEN (1 << 0)
39 #define G_SUPPLICANT_CAPABILITY_AUTHALG_SHARED (1 << 1)
40 #define G_SUPPLICANT_CAPABILITY_AUTHALG_LEAP (1 << 2)
42 #define G_SUPPLICANT_CAPABILITY_PROTO_WPA (1 << 0)
43 #define G_SUPPLICANT_CAPABILITY_PROTO_RSN (1 << 1)
45 #define G_SUPPLICANT_CAPABILITY_SCAN_ACTIVE (1 << 0)
46 #define G_SUPPLICANT_CAPABILITY_SCAN_PASSIVE (1 << 1)
47 #define G_SUPPLICANT_CAPABILITY_SCAN_SSID (1 << 2)
49 #define G_SUPPLICANT_CAPABILITY_MODE_INFRA (1 << 0)
50 #define G_SUPPLICANT_CAPABILITY_MODE_IBSS (1 << 1)
51 #define G_SUPPLICANT_CAPABILITY_MODE_AP (1 << 2)
52 #define G_SUPPLICANT_CAPABILITY_MODE_P2P (1 << 3)
53 #if defined TIZEN_EXT_WIFI_MESH
54 #define G_SUPPLICANT_CAPABILITY_MODE_MESH (1 << 4)
57 #define G_SUPPLICANT_KEYMGMT_NONE (1 << 0)
58 #define G_SUPPLICANT_KEYMGMT_IEEE8021X (1 << 1)
59 #define G_SUPPLICANT_KEYMGMT_WPA_NONE (1 << 2)
60 #define G_SUPPLICANT_KEYMGMT_WPA_PSK (1 << 3)
61 #define G_SUPPLICANT_KEYMGMT_WPA_PSK_256 (1 << 4)
63 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 5)
64 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 6)
66 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 5)
67 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 6)
69 #define G_SUPPLICANT_KEYMGMT_WPA_EAP (1 << 7)
70 #define G_SUPPLICANT_KEYMGMT_WPA_EAP_256 (1 << 8)
71 #define G_SUPPLICANT_KEYMGMT_WPS (1 << 9)
72 #if defined TIZEN_EXT_WIFI_MESH
73 #define G_SUPPLICANT_KEYMGMT_SAE (1 << 10)
76 #define G_SUPPLICANT_PROTO_WPA (1 << 0)
77 #define G_SUPPLICANT_PROTO_RSN (1 << 1)
79 #define G_SUPPLICANT_GROUP_WEP40 (1 << 0)
80 #define G_SUPPLICANT_GROUP_WEP104 (1 << 1)
81 #define G_SUPPLICANT_GROUP_TKIP (1 << 2)
82 #define G_SUPPLICANT_GROUP_CCMP (1 << 3)
84 #define G_SUPPLICANT_PAIRWISE_NONE (1 << 0)
85 #define G_SUPPLICANT_PAIRWISE_TKIP (1 << 1)
86 #define G_SUPPLICANT_PAIRWISE_CCMP (1 << 2)
88 #define G_SUPPLICANT_WPS_CONFIGURED (1 << 0)
89 #define G_SUPPLICANT_WPS_PBC (1 << 1)
90 #define G_SUPPLICANT_WPS_PIN (1 << 2)
91 #define G_SUPPLICANT_WPS_REGISTRAR (1 << 3)
93 #define G_SUPPLICANT_WPS_CONFIG_PBC 0x0080
95 #define G_SUPPLICANT_GROUP_ROLE_CLIENT (1 << 0)
96 #define G_SUPPLICANT_GROUP_ROLE_GO (1 << 1)
99 G_SUPPLICANT_MODE_UNKNOWN,
100 G_SUPPLICANT_MODE_INFRA,
101 G_SUPPLICANT_MODE_IBSS,
102 G_SUPPLICANT_MODE_MASTER,
103 #if defined TIZEN_EXT_WIFI_MESH
104 G_SUPPLICANT_MODE_MESH,
108 #if defined TIZEN_EXT_WIFI_MESH
110 G_SUPPLICANT_IEEE80211W_UNKNOWN,
111 G_SUPPLICANT_IEEE80211W_OPTIONAL,
112 G_SUPPLICANT_IEEE80211W_REQUIRED,
117 G_SUPPLICANT_SECURITY_UNKNOWN,
118 G_SUPPLICANT_SECURITY_NONE,
119 G_SUPPLICANT_SECURITY_WEP,
120 G_SUPPLICANT_SECURITY_PSK,
121 G_SUPPLICANT_SECURITY_IEEE8021X,
122 #if defined TIZEN_EXT
123 G_SUPPLICANT_SECURITY_FT_PSK,
124 G_SUPPLICANT_SECURITY_FT_IEEE8021X,
126 #if defined TIZEN_EXT_WIFI_MESH
127 G_SUPPLICANT_SECURITY_SAE,
129 } GSupplicantSecurity;
131 #if defined TIZEN_EXT
133 G_SUPPLICANT_EAP_KEYMGMT_NONE,
134 G_SUPPLICANT_EAP_KEYMGMT_FT,
135 G_SUPPLICANT_EAP_KEYMGMT_CCKM,
136 G_SUPPLICANT_EAP_KEYMGMT_OKC,
137 } GSupplicantEapKeymgmt;
140 G_SUPPLICANT_MODE_IEEE80211_UNKNOWN,
141 G_SUPPLICANT_MODE_IEEE80211B,
142 G_SUPPLICANT_MODE_IEEE80211BG,
143 G_SUPPLICANT_MODE_IEEE80211BGN,
144 G_SUPPLICANT_MODE_IEEE80211A,
145 G_SUPPLICANT_MODE_IEEE80211AN,
146 G_SUPPLICANT_MODE_IEEE80211ANAC,
147 } GSupplicantPhy_mode;
151 G_SUPPLICANT_STATE_UNKNOWN,
152 G_SUPPLICANT_STATE_DISABLED,
153 G_SUPPLICANT_STATE_DISCONNECTED,
154 G_SUPPLICANT_STATE_INACTIVE,
155 G_SUPPLICANT_STATE_SCANNING,
156 G_SUPPLICANT_STATE_AUTHENTICATING,
157 G_SUPPLICANT_STATE_ASSOCIATING,
158 G_SUPPLICANT_STATE_ASSOCIATED,
159 G_SUPPLICANT_STATE_4WAY_HANDSHAKE,
160 G_SUPPLICANT_STATE_GROUP_HANDSHAKE,
161 G_SUPPLICANT_STATE_COMPLETED,
165 G_SUPPLICANT_WPS_STATE_UNKNOWN,
166 G_SUPPLICANT_WPS_STATE_SUCCESS,
167 G_SUPPLICANT_WPS_STATE_FAIL,
168 } GSupplicantWpsState;
171 G_SUPPLICANT_PEER_SERVICES_CHANGED,
172 G_SUPPLICANT_PEER_GROUP_CHANGED,
173 G_SUPPLICANT_PEER_GROUP_STARTED,
174 G_SUPPLICANT_PEER_GROUP_FINISHED,
175 G_SUPPLICANT_PEER_GROUP_JOINED,
176 G_SUPPLICANT_PEER_GROUP_DISCONNECTED,
177 G_SUPPLICANT_PEER_GROUP_FAILED,
178 } GSupplicantPeerState;
180 enum GSupplicantAPHiddenSSID {
181 G_SUPPLICANT_AP_NO_SSID_HIDING,
182 G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_LEN,
183 G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_CONTENTS,
186 struct _GSupplicantSSID {
187 #if defined TIZEN_EXT
192 unsigned int ssid_len;
193 unsigned int scan_ssid;
194 GSupplicantMode mode;
195 GSupplicantSecurity security;
196 unsigned int protocol;
197 unsigned int pairwise_cipher;
198 unsigned int group_cipher;
201 const char *passphrase;
202 const char *identity;
203 const char *anonymous_identity;
204 const char *ca_cert_path;
205 const char *subject_match;
206 const char *altsubject_match;
207 const char *domain_suffix_match;
208 const char *domain_match;
209 const char *client_cert_path;
210 const char *private_key_path;
211 const char *private_key_passphrase;
212 const char *phase2_auth;
216 int ignore_broadcast_ssid;
217 #if defined TIZEN_EXT
218 unsigned char *bssid;
219 unsigned int bssid_for_connect_len;
220 unsigned char bssid_for_connect[6];
221 GSupplicantEapKeymgmt eap_keymgmt;
223 const char *pac_file;
225 #if defined TIZEN_EXT_WIFI_MESH
230 typedef struct _GSupplicantSSID GSupplicantSSID;
233 * Max number of SSIDs that can be scanned.
234 * In wpa_s 0.7x the limit is 4.
235 * In wps_s 0.8 or later it is 16.
236 * The value is only used if wpa_supplicant does not return any max limit
237 * for number of scannable SSIDs.
239 #define WPAS_MAX_SCAN_SSIDS 4
242 unsigned char ssid[32];
246 struct _GSupplicantScanParams {
255 typedef struct _GSupplicantScanParams GSupplicantScanParams;
257 struct _GSupplicantPeerParams {
263 typedef struct _GSupplicantPeerParams GSupplicantPeerParams;
265 struct _GSupplicantP2PServiceParams {
268 unsigned char *query;
270 unsigned char *response;
272 unsigned char *wfd_ies;
276 typedef struct _GSupplicantP2PServiceParams GSupplicantP2PServiceParams;
279 typedef void (*GSupplicantCountryCallback) (int result,
283 int g_supplicant_set_country(const char *alpha2,
284 GSupplicantCountryCallback callback,
285 const void *user_data);
288 struct _GSupplicantInterface;
289 struct _GSupplicantPeer;
291 typedef struct _GSupplicantInterface GSupplicantInterface;
292 typedef struct _GSupplicantPeer GSupplicantPeer;
293 #if defined TIZEN_EXT_WIFI_MESH
294 typedef struct _GSupplicantMeshPeer GSupplicantMeshPeer;
297 typedef void (*GSupplicantInterfaceCallback) (int result,
298 GSupplicantInterface *interface,
301 #if defined TIZEN_EXT
302 typedef void (*GSupplicantMaxSpeedCallback) (int result,
303 int maxspeed, void *user_data);
306 void g_supplicant_interface_cancel(GSupplicantInterface *interface);
308 int g_supplicant_interface_create(const char *ifname, const char *driver,
310 GSupplicantInterfaceCallback callback,
312 int g_supplicant_interface_remove(GSupplicantInterface *interface,
313 GSupplicantInterfaceCallback callback,
315 int g_supplicant_interface_scan(GSupplicantInterface *interface,
316 GSupplicantScanParams *scan_data,
317 GSupplicantInterfaceCallback callback,
320 #if defined TIZEN_EXT
321 int g_supplicant_interface_signalpoll(GSupplicantInterface *interface,
322 GSupplicantMaxSpeedCallback callback,
326 int g_supplicant_interface_p2p_find(GSupplicantInterface *interface,
327 GSupplicantInterfaceCallback callback,
330 int g_supplicant_interface_p2p_stop_find(GSupplicantInterface *interface);
332 int g_supplicant_interface_p2p_connect(GSupplicantInterface *interface,
333 GSupplicantPeerParams *peer_params,
334 GSupplicantInterfaceCallback callback,
337 int g_supplicant_interface_p2p_disconnect(GSupplicantInterface *interface,
338 GSupplicantPeerParams *peer_params);
340 int g_supplicant_interface_p2p_listen(GSupplicantInterface *interface,
341 int period, int interval);
343 int g_supplicant_interface_p2p_add_service(GSupplicantInterface *interface,
344 GSupplicantInterfaceCallback callback,
345 GSupplicantP2PServiceParams *p2p_service_params,
348 int g_supplicant_interface_p2p_del_service(GSupplicantInterface *interface,
349 GSupplicantP2PServiceParams *p2p_service_params);
351 int g_supplicant_set_widi_ies(GSupplicantP2PServiceParams *p2p_service_params,
352 GSupplicantInterfaceCallback callback,
355 int g_supplicant_interface_connect(GSupplicantInterface *interface,
356 GSupplicantSSID *ssid,
357 GSupplicantInterfaceCallback callback,
360 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
361 GSupplicantInterfaceCallback callback,
364 int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
365 unsigned int ap_scan);
367 void g_supplicant_interface_set_data(GSupplicantInterface *interface,
369 void *g_supplicant_interface_get_data(GSupplicantInterface *interface);
370 const char *g_supplicant_interface_get_ifname(GSupplicantInterface *interface);
371 #if defined TIZEN_EXT
372 bool g_supplicant_interface_get_is_5_0_ghz_supported(GSupplicantInterface *interface);
374 const char *g_supplicant_interface_get_driver(GSupplicantInterface *interface);
375 GSupplicantState g_supplicant_interface_get_state(GSupplicantInterface *interface);
376 const char *g_supplicant_interface_get_wps_key(GSupplicantInterface *interface);
377 const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
378 unsigned int *ssid_len);
379 GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
380 unsigned int g_supplicant_interface_get_mode(GSupplicantInterface *interface);
381 dbus_bool_t g_supplicant_interface_get_ready(GSupplicantInterface *interface);
382 unsigned int g_supplicant_interface_get_max_scan_ssids(
383 GSupplicantInterface *interface);
385 int g_supplicant_interface_enable_selected_network(GSupplicantInterface *interface,
387 int g_supplicant_interface_set_country(GSupplicantInterface *interface,
388 GSupplicantCountryCallback callback,
391 bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface);
392 int g_supplicant_interface_set_p2p_device_config(GSupplicantInterface *interface,
393 const char *device_name,
394 const char *primary_dev_type);
395 GSupplicantPeer *g_supplicant_interface_peer_lookup(GSupplicantInterface *interface,
396 const char *identifier);
397 bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface);
399 #if defined TIZEN_EXT_WIFI_MESH
400 bool g_supplicant_interface_has_mesh(GSupplicantInterface *interface);
401 int g_supplicant_mesh_interface_create(const char *ifname, const char *driver,
402 const char *bridge, const char *parent_ifname,
403 GSupplicantInterfaceCallback callback, void *user_data);
404 const void *g_supplicant_interface_get_mesh_group_ssid(
405 GSupplicantInterface *interface,
406 unsigned int *ssid_len);
407 int g_supplicant_mesh_get_disconnect_reason(GSupplicantInterface *interface);
408 const char *g_supplicant_mesh_peer_get_address(GSupplicantMeshPeer *mesh_peer);
409 int g_supplicant_mesh_peer_get_disconnect_reason(
410 GSupplicantMeshPeer *mesh_peer);
411 int g_supplicant_interface_abort_scan(GSupplicantInterface *interface,
412 GSupplicantInterfaceCallback callback, void *user_data);
413 int g_supplicant_interface_mesh_peer_change_status(
414 GSupplicantInterface *interface,
415 GSupplicantInterfaceCallback callback, const char *peer_address,
416 const char *method, void *user_data);
419 /* Network and Peer API */
420 struct _GSupplicantNetwork;
421 struct _GSupplicantGroup;
423 typedef struct _GSupplicantNetwork GSupplicantNetwork;
424 typedef struct _GSupplicantGroup GSupplicantGroup;
426 GSupplicantInterface *g_supplicant_network_get_interface(GSupplicantNetwork *network);
427 const char *g_supplicant_network_get_name(GSupplicantNetwork *network);
428 const char *g_supplicant_network_get_identifier(GSupplicantNetwork *network);
429 const char *g_supplicant_network_get_path(GSupplicantNetwork *network);
430 const void *g_supplicant_network_get_ssid(GSupplicantNetwork *network,
431 unsigned int *ssid_len);
432 const char *g_supplicant_network_get_mode(GSupplicantNetwork *network);
433 const char *g_supplicant_network_get_security(GSupplicantNetwork *network);
434 dbus_int16_t g_supplicant_network_get_signal(GSupplicantNetwork *network);
435 dbus_uint16_t g_supplicant_network_get_frequency(GSupplicantNetwork *network);
436 dbus_bool_t g_supplicant_network_get_wps(GSupplicantNetwork *network);
437 dbus_bool_t g_supplicant_network_is_wps_active(GSupplicantNetwork *network);
438 dbus_bool_t g_supplicant_network_is_wps_pbc(GSupplicantNetwork *network);
439 dbus_bool_t g_supplicant_network_is_wps_advertizing(GSupplicantNetwork *network);
441 GSupplicantInterface *g_supplicant_peer_get_interface(GSupplicantPeer *peer);
442 const char *g_supplicant_peer_get_path(GSupplicantPeer *peer);
443 const char *g_supplicant_peer_get_identifier(GSupplicantPeer *peer);
444 const void *g_supplicant_peer_get_device_address(GSupplicantPeer *peer);
445 const void *g_supplicant_peer_get_iface_address(GSupplicantPeer *peer);
446 const char *g_supplicant_peer_get_name(GSupplicantPeer *peer);
447 const unsigned char *g_supplicant_peer_get_widi_ies(GSupplicantPeer *peer,
449 bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
450 bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
451 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
452 GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer *peer);
453 bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
454 bool g_supplicant_peer_has_requested_connection(GSupplicantPeer *peer);
456 #if defined TIZEN_EXT
458 * Description: Network client requires additional wifi specific info
460 const unsigned char *g_supplicant_network_get_bssid(
461 GSupplicantNetwork *network);
462 unsigned int g_supplicant_network_get_maxrate(GSupplicantNetwork *network);
463 const char *g_supplicant_network_get_enc_mode(GSupplicantNetwork *network);
464 bool g_supplicant_network_get_rsn_mode(GSupplicantNetwork *network);
465 bool g_supplicant_network_is_hs20AP(GSupplicantNetwork *network);
466 const char *g_supplicant_network_get_eap(GSupplicantNetwork *network);
467 const char *g_supplicant_network_get_identity(GSupplicantNetwork *network);
468 const char *g_supplicant_network_get_phase2(GSupplicantNetwork *network);
469 unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network);
470 void *g_supplicant_network_get_wifi_vsie(GSupplicantNetwork *network);
471 const unsigned char *g_supplicant_network_get_countrycode(GSupplicantNetwork
473 void *g_supplicant_network_get_bssid_list(GSupplicantNetwork *network);
474 GSupplicantPhy_mode g_supplicant_network_get_phy_mode(GSupplicantNetwork *network);
477 struct _GSupplicantCallbacks {
478 void (*system_ready) (void);
479 void (*system_killed) (void);
480 void (*interface_added) (GSupplicantInterface *interface);
481 void (*interface_state) (GSupplicantInterface *interface);
482 void (*interface_removed) (GSupplicantInterface *interface);
483 void (*p2p_support) (GSupplicantInterface *interface);
484 void (*scan_started) (GSupplicantInterface *interface);
485 void (*scan_finished) (GSupplicantInterface *interface);
486 void (*ap_create_fail) (GSupplicantInterface *interface);
487 void (*network_added) (GSupplicantNetwork *network);
488 void (*network_removed) (GSupplicantNetwork *network);
489 #if defined TIZEN_EXT
490 void (*network_merged) (GSupplicantNetwork *network);
492 void (*network_changed) (GSupplicantNetwork *network,
493 const char *property);
494 void (*network_associated) (GSupplicantNetwork *network);
495 #if defined TIZEN_EXT
496 void (*system_power_off) (void);
497 void (*assoc_failed) (void *user_data);
499 void (*add_station) (const char *mac);
500 void (*remove_station) (const char *mac);
501 void (*peer_found) (GSupplicantPeer *peer);
502 void (*peer_lost) (GSupplicantPeer *peer);
503 void (*peer_changed) (GSupplicantPeer *peer,
504 GSupplicantPeerState state);
505 void (*peer_request) (GSupplicantPeer *peer);
506 void (*debug) (const char *str);
507 void (*disconnect_reasoncode)(GSupplicantInterface *interface,
509 void (*assoc_status_code)(GSupplicantInterface *interface,
511 #if defined TIZEN_EXT_WIFI_MESH
512 void (*mesh_support) (GSupplicantInterface *interface);
513 void (*mesh_group_started) (GSupplicantInterface *interface);
514 void (*mesh_group_removed) (GSupplicantInterface *interface);
515 void (*mesh_peer_connected) (GSupplicantMeshPeer *mesh_peer);
516 void (*mesh_peer_disconnected) (GSupplicantMeshPeer *mesh_peer);
520 typedef struct _GSupplicantCallbacks GSupplicantCallbacks;
522 int g_supplicant_register(const GSupplicantCallbacks *callbacks);
523 void g_supplicant_unregister(const GSupplicantCallbacks *callbacks);
526 void g_supplicant_free_scan_params(GSupplicantScanParams *scan_params)
528 g_slist_free_full(scan_params->ssids, g_free);
529 g_free(scan_params->freqs);
537 #endif /* __G_SUPPLICANT_H */