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)
54 #define G_SUPPLICANT_KEYMGMT_NONE (1 << 0)
55 #define G_SUPPLICANT_KEYMGMT_IEEE8021X (1 << 1)
56 #define G_SUPPLICANT_KEYMGMT_WPA_NONE (1 << 2)
57 #define G_SUPPLICANT_KEYMGMT_WPA_PSK (1 << 3)
58 #define G_SUPPLICANT_KEYMGMT_WPA_PSK_256 (1 << 4)
60 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 5)
61 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 6)
63 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 5)
64 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 6)
66 #define G_SUPPLICANT_KEYMGMT_WPA_EAP (1 << 7)
67 #define G_SUPPLICANT_KEYMGMT_WPA_EAP_256 (1 << 8)
68 #define G_SUPPLICANT_KEYMGMT_WPS (1 << 9)
70 #define G_SUPPLICANT_PROTO_WPA (1 << 0)
71 #define G_SUPPLICANT_PROTO_RSN (1 << 1)
73 #define G_SUPPLICANT_GROUP_WEP40 (1 << 0)
74 #define G_SUPPLICANT_GROUP_WEP104 (1 << 1)
75 #define G_SUPPLICANT_GROUP_TKIP (1 << 2)
76 #define G_SUPPLICANT_GROUP_CCMP (1 << 3)
78 #define G_SUPPLICANT_PAIRWISE_NONE (1 << 0)
79 #define G_SUPPLICANT_PAIRWISE_TKIP (1 << 1)
80 #define G_SUPPLICANT_PAIRWISE_CCMP (1 << 2)
82 #define G_SUPPLICANT_WPS_CONFIGURED (1 << 0)
83 #define G_SUPPLICANT_WPS_PBC (1 << 1)
84 #define G_SUPPLICANT_WPS_PIN (1 << 2)
85 #define G_SUPPLICANT_WPS_REGISTRAR (1 << 3)
87 #define G_SUPPLICANT_WPS_CONFIG_PBC 0x0080
89 #define G_SUPPLICANT_GROUP_ROLE_CLIENT (1 << 0)
90 #define G_SUPPLICANT_GROUP_ROLE_GO (1 << 1)
93 G_SUPPLICANT_MODE_UNKNOWN,
94 G_SUPPLICANT_MODE_INFRA,
95 G_SUPPLICANT_MODE_IBSS,
96 G_SUPPLICANT_MODE_MASTER,
100 G_SUPPLICANT_SECURITY_UNKNOWN,
101 G_SUPPLICANT_SECURITY_NONE,
102 G_SUPPLICANT_SECURITY_WEP,
103 G_SUPPLICANT_SECURITY_PSK,
104 G_SUPPLICANT_SECURITY_IEEE8021X,
105 #if defined TIZEN_EXT
106 G_SUPPLICANT_SECURITY_FT_PSK,
107 G_SUPPLICANT_SECURITY_FT_IEEE8021X,
109 } GSupplicantSecurity;
112 G_SUPPLICANT_STATE_UNKNOWN,
113 G_SUPPLICANT_STATE_DISABLED,
114 G_SUPPLICANT_STATE_DISCONNECTED,
115 G_SUPPLICANT_STATE_INACTIVE,
116 G_SUPPLICANT_STATE_SCANNING,
117 G_SUPPLICANT_STATE_AUTHENTICATING,
118 G_SUPPLICANT_STATE_ASSOCIATING,
119 G_SUPPLICANT_STATE_ASSOCIATED,
120 G_SUPPLICANT_STATE_4WAY_HANDSHAKE,
121 G_SUPPLICANT_STATE_GROUP_HANDSHAKE,
122 G_SUPPLICANT_STATE_COMPLETED,
126 G_SUPPLICANT_WPS_STATE_UNKNOWN,
127 G_SUPPLICANT_WPS_STATE_SUCCESS,
128 G_SUPPLICANT_WPS_STATE_FAIL,
129 } GSupplicantWpsState;
132 G_SUPPLICANT_PEER_SERVICES_CHANGED,
133 G_SUPPLICANT_PEER_GROUP_CHANGED,
134 G_SUPPLICANT_PEER_GROUP_STARTED,
135 G_SUPPLICANT_PEER_GROUP_FINISHED,
136 G_SUPPLICANT_PEER_GROUP_JOINED,
137 G_SUPPLICANT_PEER_GROUP_DISCONNECTED,
138 G_SUPPLICANT_PEER_GROUP_FAILED,
139 } GSupplicantPeerState;
141 enum GSupplicantAPHiddenSSID {
142 G_SUPPLICANT_AP_NO_SSID_HIDING,
143 G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_LEN,
144 G_SUPPLICANT_AP_HIDDEN_SSID_ZERO_CONTENTS,
147 struct _GSupplicantSSID {
149 unsigned int ssid_len;
150 unsigned int scan_ssid;
151 GSupplicantMode mode;
152 GSupplicantSecurity security;
153 unsigned int protocol;
154 unsigned int pairwise_cipher;
155 unsigned int group_cipher;
158 const char *passphrase;
159 const char *identity;
160 const char *ca_cert_path;
161 const char *client_cert_path;
162 const char *private_key_path;
163 const char *private_key_passphrase;
164 const char *phase2_auth;
168 int ignore_broadcast_ssid;
169 #if defined TIZEN_EXT
170 unsigned char *bssid;
174 typedef struct _GSupplicantSSID GSupplicantSSID;
177 * Max number of SSIDs that can be scanned.
178 * In wpa_s 0.7x the limit is 4.
179 * In wps_s 0.8 or later it is 16.
180 * The value is only used if wpa_supplicant does not return any max limit
181 * for number of scannable SSIDs.
183 #define WPAS_MAX_SCAN_SSIDS 4
186 unsigned char ssid[32];
190 struct _GSupplicantScanParams {
199 typedef struct _GSupplicantScanParams GSupplicantScanParams;
201 struct _GSupplicantPeerParams {
207 typedef struct _GSupplicantPeerParams GSupplicantPeerParams;
209 struct _GSupplicantP2PServiceParams {
212 unsigned char *query;
214 unsigned char *response;
216 unsigned char *wfd_ies;
220 typedef struct _GSupplicantP2PServiceParams GSupplicantP2PServiceParams;
223 typedef void (*GSupplicantCountryCallback) (int result,
227 int g_supplicant_set_country(const char *alpha2,
228 GSupplicantCountryCallback callback,
229 const void *user_data);
232 struct _GSupplicantInterface;
233 struct _GSupplicantPeer;
235 typedef struct _GSupplicantInterface GSupplicantInterface;
236 typedef struct _GSupplicantPeer GSupplicantPeer;
238 typedef void (*GSupplicantInterfaceCallback) (int result,
239 GSupplicantInterface *interface,
242 void g_supplicant_interface_cancel(GSupplicantInterface *interface);
244 int g_supplicant_interface_create(const char *ifname, const char *driver,
246 GSupplicantInterfaceCallback callback,
248 int g_supplicant_interface_remove(GSupplicantInterface *interface,
249 GSupplicantInterfaceCallback callback,
251 int g_supplicant_interface_scan(GSupplicantInterface *interface,
252 GSupplicantScanParams *scan_data,
253 GSupplicantInterfaceCallback callback,
256 int g_supplicant_interface_p2p_find(GSupplicantInterface *interface,
257 GSupplicantInterfaceCallback callback,
260 int g_supplicant_interface_p2p_stop_find(GSupplicantInterface *interface);
262 int g_supplicant_interface_p2p_connect(GSupplicantInterface *interface,
263 GSupplicantPeerParams *peer_params,
264 GSupplicantInterfaceCallback callback,
267 int g_supplicant_interface_p2p_disconnect(GSupplicantInterface *interface,
268 GSupplicantPeerParams *peer_params);
270 int g_supplicant_interface_p2p_listen(GSupplicantInterface *interface,
271 int period, int interval);
273 int g_supplicant_interface_p2p_add_service(GSupplicantInterface *interface,
274 GSupplicantInterfaceCallback callback,
275 GSupplicantP2PServiceParams *p2p_service_params,
278 int g_supplicant_interface_p2p_del_service(GSupplicantInterface *interface,
279 GSupplicantP2PServiceParams *p2p_service_params);
281 int g_supplicant_set_widi_ies(GSupplicantP2PServiceParams *p2p_service_params,
282 GSupplicantInterfaceCallback callback,
285 int g_supplicant_interface_connect(GSupplicantInterface *interface,
286 GSupplicantSSID *ssid,
287 GSupplicantInterfaceCallback callback,
290 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
291 GSupplicantInterfaceCallback callback,
294 #if defined TIZEN_EXT
295 int g_supplicant_interface_remove_network(GSupplicantInterface *interface);
297 int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
298 unsigned int ap_scan);
300 void g_supplicant_interface_set_data(GSupplicantInterface *interface,
302 void *g_supplicant_interface_get_data(GSupplicantInterface *interface);
303 const char *g_supplicant_interface_get_ifname(GSupplicantInterface *interface);
304 const char *g_supplicant_interface_get_driver(GSupplicantInterface *interface);
305 GSupplicantState g_supplicant_interface_get_state(GSupplicantInterface *interface);
306 const char *g_supplicant_interface_get_wps_key(GSupplicantInterface *interface);
307 const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
308 unsigned int *ssid_len);
309 GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
310 unsigned int g_supplicant_interface_get_mode(GSupplicantInterface *interface);
311 dbus_bool_t g_supplicant_interface_get_ready(GSupplicantInterface *interface);
312 unsigned int g_supplicant_interface_get_max_scan_ssids(
313 GSupplicantInterface *interface);
315 int g_supplicant_interface_enable_selected_network(GSupplicantInterface *interface,
317 int g_supplicant_interface_set_country(GSupplicantInterface *interface,
318 GSupplicantCountryCallback callback,
321 bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface);
322 int g_supplicant_interface_set_p2p_device_config(GSupplicantInterface *interface,
323 const char *device_name,
324 const char *primary_dev_type);
325 GSupplicantPeer *g_supplicant_interface_peer_lookup(GSupplicantInterface *interface,
326 const char *identifier);
327 bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface);
329 /* Network and Peer API */
330 struct _GSupplicantNetwork;
331 struct _GSupplicantGroup;
333 typedef struct _GSupplicantNetwork GSupplicantNetwork;
334 typedef struct _GSupplicantGroup GSupplicantGroup;
336 GSupplicantInterface *g_supplicant_network_get_interface(GSupplicantNetwork *network);
337 const char *g_supplicant_network_get_name(GSupplicantNetwork *network);
338 const char *g_supplicant_network_get_identifier(GSupplicantNetwork *network);
339 const char *g_supplicant_network_get_path(GSupplicantNetwork *network);
340 const void *g_supplicant_network_get_ssid(GSupplicantNetwork *network,
341 unsigned int *ssid_len);
342 const char *g_supplicant_network_get_mode(GSupplicantNetwork *network);
343 const char *g_supplicant_network_get_security(GSupplicantNetwork *network);
344 dbus_int16_t g_supplicant_network_get_signal(GSupplicantNetwork *network);
345 dbus_uint16_t g_supplicant_network_get_frequency(GSupplicantNetwork *network);
346 dbus_bool_t g_supplicant_network_get_wps(GSupplicantNetwork *network);
347 dbus_bool_t g_supplicant_network_is_wps_active(GSupplicantNetwork *network);
348 dbus_bool_t g_supplicant_network_is_wps_pbc(GSupplicantNetwork *network);
349 dbus_bool_t g_supplicant_network_is_wps_advertizing(GSupplicantNetwork *network);
351 GSupplicantInterface *g_supplicant_peer_get_interface(GSupplicantPeer *peer);
352 const char *g_supplicant_peer_get_path(GSupplicantPeer *peer);
353 const char *g_supplicant_peer_get_identifier(GSupplicantPeer *peer);
354 const void *g_supplicant_peer_get_device_address(GSupplicantPeer *peer);
355 const void *g_supplicant_peer_get_iface_address(GSupplicantPeer *peer);
356 const char *g_supplicant_peer_get_name(GSupplicantPeer *peer);
357 const unsigned char *g_supplicant_peer_get_widi_ies(GSupplicantPeer *peer,
359 bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
360 bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
361 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
362 GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer *peer);
363 bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
364 bool g_supplicant_peer_has_requested_connection(GSupplicantPeer *peer);
366 #if defined TIZEN_EXT
368 * Description: Network client requires additional wifi specific info
370 const unsigned char *g_supplicant_network_get_bssid(
371 GSupplicantNetwork *network);
372 unsigned int g_supplicant_network_get_maxrate(GSupplicantNetwork *network);
373 const char *g_supplicant_network_get_enc_mode(GSupplicantNetwork *network);
374 bool g_supplicant_network_get_rsn_mode(GSupplicantNetwork *network);
375 unsigned int g_supplicant_network_is_hs20AP(GSupplicantNetwork *network);
376 const char *g_supplicant_network_get_eap(GSupplicantNetwork *network);
377 const char *g_supplicant_network_get_identity(GSupplicantNetwork *network);
378 const char *g_supplicant_network_get_phase2(GSupplicantNetwork *network);
379 unsigned int g_supplicant_network_get_keymgmt(GSupplicantNetwork *network);
382 struct _GSupplicantCallbacks {
383 void (*system_ready) (void);
384 void (*system_killed) (void);
385 void (*interface_added) (GSupplicantInterface *interface);
386 void (*interface_state) (GSupplicantInterface *interface);
387 void (*interface_removed) (GSupplicantInterface *interface);
388 void (*p2p_support) (GSupplicantInterface *interface);
389 void (*scan_started) (GSupplicantInterface *interface);
390 void (*scan_finished) (GSupplicantInterface *interface);
391 void (*network_added) (GSupplicantNetwork *network);
392 void (*network_removed) (GSupplicantNetwork *network);
393 #if defined TIZEN_EXT
394 void (*network_merged) (GSupplicantNetwork *network);
396 void (*network_changed) (GSupplicantNetwork *network,
397 const char *property);
398 #if defined TIZEN_EXT
399 void (*system_power_off) (void);
401 void (*add_station) (const char *mac);
402 void (*remove_station) (const char *mac);
403 void (*peer_found) (GSupplicantPeer *peer);
404 void (*peer_lost) (GSupplicantPeer *peer);
405 void (*peer_changed) (GSupplicantPeer *peer,
406 GSupplicantPeerState state);
407 void (*peer_request) (GSupplicantPeer *peer);
408 void (*debug) (const char *str);
409 void (*disconnect_reasoncode)(GSupplicantInterface *interface,
413 typedef struct _GSupplicantCallbacks GSupplicantCallbacks;
415 int g_supplicant_register(const GSupplicantCallbacks *callbacks);
416 void g_supplicant_unregister(const GSupplicantCallbacks *callbacks);
419 void g_supplicant_free_scan_params(GSupplicantScanParams *scan_params)
421 g_slist_free_full(scan_params->ssids, g_free);
422 g_free(scan_params->freqs);
430 #endif /* __G_SUPPLICANT_H */