3 * WPA supplicant library with GLib integration
5 * Copyright (C) 2010 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)
53 #define G_SUPPLICANT_KEYMGMT_NONE (1 << 0)
54 #define G_SUPPLICANT_KEYMGMT_IEEE8021X (1 << 1)
55 #define G_SUPPLICANT_KEYMGMT_WPA_NONE (1 << 2)
56 #define G_SUPPLICANT_KEYMGMT_WPA_PSK (1 << 3)
57 #define G_SUPPLICANT_KEYMGMT_WPA_PSK_256 (1 << 4)
58 #define G_SUPPLICANT_KEYMGMT_WPA_FT_PSK (1 << 5)
59 #define G_SUPPLICANT_KEYMGMT_WPA_FT_EAP (1 << 6)
60 #define G_SUPPLICANT_KEYMGMT_WPA_EAP (1 << 7)
61 #define G_SUPPLICANT_KEYMGMT_WPA_EAP_256 (1 << 8)
62 #define G_SUPPLICANT_KEYMGMT_WPS (1 << 9)
64 #define G_SUPPLICANT_PROTO_WPA (1 << 0)
65 #define G_SUPPLICANT_PROTO_RSN (1 << 1)
67 #define G_SUPPLICANT_GROUP_WEP40 (1 << 0)
68 #define G_SUPPLICANT_GROUP_WEP104 (1 << 1)
69 #define G_SUPPLICANT_GROUP_TKIP (1 << 2)
70 #define G_SUPPLICANT_GROUP_CCMP (1 << 3)
72 #define G_SUPPLICANT_PAIRWISE_NONE (1 << 0)
73 #define G_SUPPLICANT_PAIRWISE_TKIP (1 << 1)
74 #define G_SUPPLICANT_PAIRWISE_CCMP (1 << 2)
76 #define G_SUPPLICANT_MAX_FAST_SCAN 4
79 G_SUPPLICANT_MODE_UNKNOWN,
80 G_SUPPLICANT_MODE_INFRA,
81 G_SUPPLICANT_MODE_IBSS,
82 G_SUPPLICANT_MODE_MASTER,
86 G_SUPPLICANT_SECURITY_UNKNOWN,
87 G_SUPPLICANT_SECURITY_NONE,
88 G_SUPPLICANT_SECURITY_WEP,
89 G_SUPPLICANT_SECURITY_PSK,
90 G_SUPPLICANT_SECURITY_IEEE8021X,
91 } GSupplicantSecurity;
94 G_SUPPLICANT_STATE_UNKNOWN,
95 G_SUPPLICANT_STATE_DISCONNECTED,
96 G_SUPPLICANT_STATE_INACTIVE,
97 G_SUPPLICANT_STATE_SCANNING,
98 G_SUPPLICANT_STATE_AUTHENTICATING,
99 G_SUPPLICANT_STATE_ASSOCIATING,
100 G_SUPPLICANT_STATE_ASSOCIATED,
101 G_SUPPLICANT_STATE_4WAY_HANDSHAKE,
102 G_SUPPLICANT_STATE_GROUP_HANDSHAKE,
103 G_SUPPLICANT_STATE_COMPLETED,
107 G_SUPPLICANT_WPS_STATE_UNKNOWN,
108 G_SUPPLICANT_WPS_STATE_SUCCESS,
109 G_SUPPLICANT_WPS_STATE_FAIL,
110 } GSupplicantWpsState;
112 struct _GSupplicantSSID {
114 unsigned int ssid_len;
115 unsigned int scan_ssid;
116 GSupplicantMode mode;
117 GSupplicantSecurity security;
118 unsigned int protocol;
119 unsigned int pairwise_cipher;
120 unsigned int group_cipher;
123 const char *passphrase;
124 const char *identity;
125 const char *ca_cert_path;
126 const char *client_cert_path;
127 const char *private_key_path;
128 const char *private_key_passphrase;
129 const char *phase2_auth;
134 typedef struct _GSupplicantSSID GSupplicantSSID;
136 struct _GSupplicantScanParams {
138 unsigned char ssid[32];
140 } ssids[G_SUPPLICANT_MAX_FAST_SCAN];
144 uint16_t freqs[G_SUPPLICANT_MAX_FAST_SCAN];
147 typedef struct _GSupplicantScanParams GSupplicantScanParams;
150 typedef void (*GSupplicantCountryCallback) (void *user_data);
152 int g_supplicant_set_country(const char *alpha2,
153 GSupplicantCountryCallback callback,
154 const void *user_data);
157 struct _GSupplicantInterface;
159 typedef struct _GSupplicantInterface GSupplicantInterface;
161 typedef void (*GSupplicantInterfaceCallback) (int result,
162 GSupplicantInterface *interface,
165 int g_supplicant_interface_create(const char *ifname, const char *driver,
167 GSupplicantInterfaceCallback callback,
169 int g_supplicant_interface_remove(GSupplicantInterface *interface,
170 GSupplicantInterfaceCallback callback,
172 int g_supplicant_interface_scan(GSupplicantInterface *interface,
173 GSupplicantScanParams *scan_data,
174 GSupplicantInterfaceCallback callback,
177 int g_supplicant_interface_connect(GSupplicantInterface *interface,
178 GSupplicantSSID *ssid,
179 GSupplicantInterfaceCallback callback,
182 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
183 GSupplicantInterfaceCallback callback,
186 int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
187 unsigned int ap_scan);
189 void g_supplicant_interface_set_data(GSupplicantInterface *interface,
191 void *g_supplicant_interface_get_data(GSupplicantInterface *interface);
192 const char *g_supplicant_interface_get_ifname(GSupplicantInterface *interface);
193 const char *g_supplicant_interface_get_driver(GSupplicantInterface *interface);
194 GSupplicantState g_supplicant_interface_get_state(GSupplicantInterface *interface);
195 const char *g_supplicant_interface_get_wps_key(GSupplicantInterface *interface);
196 const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
197 unsigned int *ssid_len);
198 GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
199 unsigned int g_supplicant_interface_get_mode(GSupplicantInterface *interface);
200 dbus_bool_t g_supplicant_interface_get_ready(GSupplicantInterface *interface);
201 unsigned int g_supplicant_interface_get_max_scan_ssids(
202 GSupplicantInterface *interface);
204 int g_supplicant_interface_enable_selected_network(GSupplicantInterface *interface,
208 struct _GSupplicantNetwork;
210 typedef struct _GSupplicantNetwork GSupplicantNetwork;
212 GSupplicantInterface *g_supplicant_network_get_interface(GSupplicantNetwork *network);
213 const char *g_supplicant_network_get_name(GSupplicantNetwork *network);
214 const char *g_supplicant_network_get_identifier(GSupplicantNetwork *network);
215 const char *g_supplicant_network_get_path(GSupplicantNetwork *network);
216 const void *g_supplicant_network_get_ssid(GSupplicantNetwork *network,
217 unsigned int *ssid_len);
218 const char *g_supplicant_network_get_mode(GSupplicantNetwork *network);
219 const char *g_supplicant_network_get_security(GSupplicantNetwork *network);
220 dbus_int16_t g_supplicant_network_get_signal(GSupplicantNetwork *network);
221 dbus_uint16_t g_supplicant_network_get_frequency(GSupplicantNetwork *network);
222 dbus_bool_t g_supplicant_network_get_wps(GSupplicantNetwork *network);
224 struct _GSupplicantCallbacks {
225 void (*system_ready) (void);
226 void (*system_killed) (void);
227 void (*interface_added) (GSupplicantInterface *interface);
228 void (*interface_state) (GSupplicantInterface *interface);
229 void (*interface_removed) (GSupplicantInterface *interface);
230 void (*scan_started) (GSupplicantInterface *interface);
231 void (*scan_finished) (GSupplicantInterface *interface);
232 void (*network_added) (GSupplicantNetwork *network);
233 void (*network_removed) (GSupplicantNetwork *network);
234 void (*network_changed) (GSupplicantNetwork *network,
235 const char *property);
236 void (*debug) (const char *str);
239 typedef struct _GSupplicantCallbacks GSupplicantCallbacks;
241 int g_supplicant_register(const GSupplicantCallbacks *callbacks);
242 void g_supplicant_unregister(const GSupplicantCallbacks *callbacks);
248 #endif /* __G_SUPPLICANT_H */