]>
Commit | Line | Data |
---|---|---|
6fc6879b JM |
1 | /* |
2 | * wpa_supplicant - Internal definitions | |
3 | * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * Alternatively, this software may be distributed under the terms of BSD | |
10 | * license. | |
11 | * | |
12 | * See README and COPYING for more details. | |
13 | */ | |
14 | ||
15 | #ifndef WPA_SUPPLICANT_I_H | |
16 | #define WPA_SUPPLICANT_I_H | |
17 | ||
2d5b792d | 18 | #include "common/defs.h" |
6fc6879b | 19 | |
7e5ba1b9 JM |
20 | extern const char *wpa_supplicant_version; |
21 | extern const char *wpa_supplicant_license; | |
22 | #ifndef CONFIG_NO_STDOUT_DEBUG | |
23 | extern const char *wpa_supplicant_full_license1; | |
24 | extern const char *wpa_supplicant_full_license2; | |
25 | extern const char *wpa_supplicant_full_license3; | |
26 | extern const char *wpa_supplicant_full_license4; | |
27 | extern const char *wpa_supplicant_full_license5; | |
28 | #endif /* CONFIG_NO_STDOUT_DEBUG */ | |
29 | ||
6fc6879b | 30 | struct wpa_scan_result; |
2d5b792d | 31 | struct wpa_scan_res; |
6fc6879b JM |
32 | struct wpa_sm; |
33 | struct wpa_supplicant; | |
11ef8d35 | 34 | struct ibss_rsn; |
6fc6879b JM |
35 | |
36 | /* | |
37 | * Forward declarations of private structures used within the ctrl_iface | |
38 | * backends. Other parts of wpa_supplicant do not have access to data stored in | |
39 | * these structures. | |
40 | */ | |
41 | struct ctrl_iface_priv; | |
42 | struct ctrl_iface_global_priv; | |
43 | struct ctrl_iface_dbus_priv; | |
44 | ||
45 | /** | |
46 | * struct wpa_interface - Parameters for wpa_supplicant_add_iface() | |
47 | */ | |
48 | struct wpa_interface { | |
49 | /** | |
50 | * confname - Configuration name (file or profile) name | |
51 | * | |
52 | * This can also be %NULL when a configuration file is not used. In | |
53 | * that case, ctrl_interface must be set to allow the interface to be | |
54 | * configured. | |
55 | */ | |
56 | const char *confname; | |
57 | ||
58 | /** | |
59 | * ctrl_interface - Control interface parameter | |
60 | * | |
61 | * If a configuration file is not used, this variable can be used to | |
62 | * set the ctrl_interface parameter that would have otherwise been read | |
63 | * from the configuration file. If both confname and ctrl_interface are | |
64 | * set, ctrl_interface is used to override the value from configuration | |
65 | * file. | |
66 | */ | |
67 | const char *ctrl_interface; | |
68 | ||
69 | /** | |
70 | * driver - Driver interface name, or %NULL to use the default driver | |
71 | */ | |
72 | const char *driver; | |
73 | ||
74 | /** | |
75 | * driver_param - Driver interface parameters | |
76 | * | |
77 | * If a configuration file is not used, this variable can be used to | |
78 | * set the driver_param parameters that would have otherwise been read | |
79 | * from the configuration file. If both confname and driver_param are | |
80 | * set, driver_param is used to override the value from configuration | |
81 | * file. | |
82 | */ | |
83 | const char *driver_param; | |
84 | ||
85 | /** | |
86 | * ifname - Interface name | |
87 | */ | |
88 | const char *ifname; | |
89 | ||
90 | /** | |
91 | * bridge_ifname - Optional bridge interface name | |
92 | * | |
93 | * If the driver interface (ifname) is included in a Linux bridge | |
94 | * device, the bridge interface may need to be used for receiving EAPOL | |
95 | * frames. This can be enabled by setting this variable to enable | |
96 | * receiving of EAPOL frames from an additional interface. | |
97 | */ | |
98 | const char *bridge_ifname; | |
99 | }; | |
100 | ||
101 | /** | |
102 | * struct wpa_params - Parameters for wpa_supplicant_init() | |
103 | */ | |
104 | struct wpa_params { | |
105 | /** | |
106 | * daemonize - Run %wpa_supplicant in the background | |
107 | */ | |
108 | int daemonize; | |
109 | ||
110 | /** | |
111 | * wait_for_monitor - Wait for a monitor program before starting | |
112 | */ | |
113 | int wait_for_monitor; | |
114 | ||
115 | /** | |
116 | * pid_file - Path to a PID (process ID) file | |
117 | * | |
118 | * If this and daemonize are set, process ID of the background process | |
119 | * will be written to the specified file. | |
120 | */ | |
121 | char *pid_file; | |
122 | ||
123 | /** | |
124 | * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO) | |
125 | */ | |
126 | int wpa_debug_level; | |
127 | ||
128 | /** | |
129 | * wpa_debug_show_keys - Whether keying material is included in debug | |
130 | * | |
131 | * This parameter can be used to allow keying material to be included | |
132 | * in debug messages. This is a security risk and this option should | |
133 | * not be enabled in normal configuration. If needed during | |
134 | * development or while troubleshooting, this option can provide more | |
135 | * details for figuring out what is happening. | |
136 | */ | |
137 | int wpa_debug_show_keys; | |
138 | ||
139 | /** | |
140 | * wpa_debug_timestamp - Whether to include timestamp in debug messages | |
141 | */ | |
142 | int wpa_debug_timestamp; | |
143 | ||
144 | /** | |
145 | * ctrl_interface - Global ctrl_iface path/parameter | |
146 | */ | |
147 | char *ctrl_interface; | |
148 | ||
149 | /** | |
150 | * dbus_ctrl_interface - Enable the DBus control interface | |
151 | */ | |
152 | int dbus_ctrl_interface; | |
153 | ||
154 | /** | |
155 | * wpa_debug_file_path - Path of debug file or %NULL to use stdout | |
156 | */ | |
157 | const char *wpa_debug_file_path; | |
daa70d49 SL |
158 | |
159 | /** | |
160 | * wpa_debug_syslog - Enable log output through syslog | |
161 | */ | |
162 | int wpa_debug_syslog; | |
d27df100 JM |
163 | |
164 | /** | |
165 | * override_driver - Optional driver parameter override | |
166 | * | |
167 | * This parameter can be used to override the driver parameter in | |
168 | * dynamic interface addition to force a specific driver wrapper to be | |
169 | * used instead. | |
170 | */ | |
171 | char *override_driver; | |
172 | ||
173 | /** | |
174 | * override_ctrl_interface - Optional ctrl_interface override | |
175 | * | |
176 | * This parameter can be used to override the ctrl_interface parameter | |
177 | * in dynamic interface addition to force a control interface to be | |
178 | * created. | |
179 | */ | |
180 | char *override_ctrl_interface; | |
6fc6879b JM |
181 | }; |
182 | ||
183 | /** | |
184 | * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces | |
185 | * | |
186 | * This structure is initialized by calling wpa_supplicant_init() when starting | |
187 | * %wpa_supplicant. | |
188 | */ | |
189 | struct wpa_global { | |
190 | struct wpa_supplicant *ifaces; | |
191 | struct wpa_params params; | |
192 | struct ctrl_iface_global_priv *ctrl_iface; | |
8fc2fb56 | 193 | /* old DBus API data */ |
6fc6879b | 194 | struct ctrl_iface_dbus_priv *dbus_ctrl_iface; |
8fc2fb56 WS |
195 | /* new DBus API data */ |
196 | struct ctrl_iface_dbus_new_priv *dbus_new_ctrl_iface; | |
ac305589 JM |
197 | void **drv_priv; |
198 | size_t drv_count; | |
6fc6879b JM |
199 | }; |
200 | ||
201 | ||
202 | struct wpa_client_mlme { | |
203 | #ifdef CONFIG_CLIENT_MLME | |
204 | enum { | |
205 | IEEE80211_DISABLED, IEEE80211_AUTHENTICATE, | |
206 | IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED, | |
207 | IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED | |
208 | } state; | |
209 | u8 prev_bssid[ETH_ALEN]; | |
210 | u8 ssid[32]; | |
211 | size_t ssid_len; | |
212 | u16 aid; | |
213 | u16 ap_capab, capab; | |
214 | u8 *extra_ie; /* to be added to the end of AssocReq */ | |
215 | size_t extra_ie_len; | |
216 | u8 *extra_probe_ie; /* to be added to the end of ProbeReq */ | |
217 | size_t extra_probe_ie_len; | |
218 | wpa_key_mgmt key_mgmt; | |
219 | ||
220 | /* The last AssocReq/Resp IEs */ | |
221 | u8 *assocreq_ies, *assocresp_ies; | |
222 | size_t assocreq_ies_len, assocresp_ies_len; | |
223 | ||
224 | int auth_tries, assoc_tries; | |
225 | ||
226 | unsigned int ssid_set:1; | |
227 | unsigned int bssid_set:1; | |
228 | unsigned int prev_bssid_set:1; | |
229 | unsigned int authenticated:1; | |
230 | unsigned int associated:1; | |
231 | unsigned int probereq_poll:1; | |
232 | unsigned int use_protection:1; | |
233 | unsigned int create_ibss:1; | |
234 | unsigned int mixed_cell:1; | |
235 | unsigned int wmm_enabled:1; | |
236 | ||
237 | struct os_time last_probe; | |
238 | ||
239 | #define IEEE80211_AUTH_ALG_OPEN BIT(0) | |
240 | #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) | |
241 | #define IEEE80211_AUTH_ALG_LEAP BIT(2) | |
242 | unsigned int auth_algs; /* bitfield of allowed auth algs */ | |
243 | int auth_alg; /* currently used IEEE 802.11 authentication algorithm */ | |
244 | int auth_transaction; | |
245 | ||
246 | struct os_time ibss_join_req; | |
247 | u8 *probe_resp; /* ProbeResp template for IBSS */ | |
248 | size_t probe_resp_len; | |
249 | u32 supp_rates_bits; | |
250 | ||
251 | int wmm_last_param_set; | |
252 | ||
253 | int sta_scanning; | |
254 | int scan_hw_mode_idx; | |
255 | int scan_channel_idx; | |
256 | enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state; | |
257 | struct os_time last_scan_completed; | |
258 | int scan_oper_channel; | |
259 | int scan_oper_freq; | |
260 | int scan_oper_phymode; | |
261 | u8 scan_ssid[32]; | |
262 | size_t scan_ssid_len; | |
263 | int scan_skip_11b; | |
264 | ||
265 | struct ieee80211_sta_bss *sta_bss_list; | |
266 | #define STA_HASH_SIZE 256 | |
267 | #define STA_HASH(sta) (sta[5]) | |
268 | struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE]; | |
269 | ||
270 | int cts_protect_erp_frames; | |
271 | ||
6caf9ca6 JM |
272 | hostapd_hw_mode phymode; /* current mode */ |
273 | struct hostapd_hw_modes *modes; | |
6fc6879b JM |
274 | size_t num_modes; |
275 | unsigned int hw_modes; /* bitfield of allowed hardware modes; | |
6caf9ca6 | 276 | * (1 << HOSTAPD_MODE_*) */ |
6fc6879b | 277 | int num_curr_rates; |
6caf9ca6 | 278 | struct hostapd_rate_data *curr_rates; |
6fc6879b JM |
279 | int freq; /* The current frequency in MHz */ |
280 | int channel; /* The current IEEE 802.11 channel number */ | |
281 | ||
282 | #ifdef CONFIG_IEEE80211R | |
283 | u8 current_md[6]; | |
284 | u8 *ft_ies; | |
285 | size_t ft_ies_len; | |
286 | #endif /* CONFIG_IEEE80211R */ | |
287 | ||
288 | #else /* CONFIG_CLIENT_MLME */ | |
289 | int dummy; /* to keep MSVC happy */ | |
290 | #endif /* CONFIG_CLIENT_MLME */ | |
291 | }; | |
292 | ||
293 | /** | |
294 | * struct wpa_supplicant - Internal data for wpa_supplicant interface | |
295 | * | |
296 | * This structure contains the internal data for core wpa_supplicant code. This | |
297 | * should be only used directly from the core code. However, a pointer to this | |
298 | * data is used from other files as an arbitrary context pointer in calls to | |
299 | * core functions. | |
300 | */ | |
301 | struct wpa_supplicant { | |
302 | struct wpa_global *global; | |
303 | struct wpa_supplicant *next; | |
304 | struct l2_packet_data *l2; | |
305 | struct l2_packet_data *l2_br; | |
306 | unsigned char own_addr[ETH_ALEN]; | |
307 | char ifname[100]; | |
308 | #ifdef CONFIG_CTRL_IFACE_DBUS | |
309 | char *dbus_path; | |
310 | #endif /* CONFIG_CTRL_IFACE_DBUS */ | |
8fc2fb56 WS |
311 | #ifdef CONFIG_CTRL_IFACE_DBUS_NEW |
312 | char *dbus_new_path; | |
313 | #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ | |
6fc6879b JM |
314 | char bridge_ifname[16]; |
315 | ||
316 | char *confname; | |
317 | struct wpa_config *conf; | |
318 | int countermeasures; | |
319 | os_time_t last_michael_mic_error; | |
320 | u8 bssid[ETH_ALEN]; | |
321 | u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this | |
322 | * field contains the targer BSSID. */ | |
323 | int reassociate; /* reassociation requested */ | |
324 | int disconnected; /* all connections disabled; i.e., do no reassociate | |
325 | * before this has been cleared */ | |
326 | struct wpa_ssid *current_ssid; | |
327 | int ap_ies_from_associnfo; | |
328 | ||
329 | /* Selected configuration (based on Beacon/ProbeResp WPA IE) */ | |
330 | int pairwise_cipher; | |
331 | int group_cipher; | |
332 | int key_mgmt; | |
333 | int mgmt_group_cipher; | |
334 | ||
335 | void *drv_priv; /* private data used by driver_ops */ | |
8a5ab9f5 | 336 | void *global_drv_priv; |
6fc6879b JM |
337 | |
338 | struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID; | |
339 | * NULL = not yet initialized (start | |
ba2a573c JM |
340 | * with wildcard SSID) |
341 | * WILDCARD_SSID_SCAN = wildcard | |
6fc6879b JM |
342 | * SSID was used in the previous scan |
343 | */ | |
ba2a573c | 344 | #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1) |
6fc6879b JM |
345 | |
346 | struct wpa_scan_results *scan_res; | |
347 | ||
348 | struct wpa_driver_ops *driver; | |
349 | int interface_removed; /* whether the network interface has been | |
350 | * removed */ | |
351 | struct wpa_sm *wpa; | |
352 | struct eapol_sm *eapol; | |
353 | ||
354 | struct ctrl_iface_priv *ctrl_iface; | |
355 | ||
356 | wpa_states wpa_state; | |
cb8564b1 | 357 | int scanning; |
6fc6879b JM |
358 | int new_connection; |
359 | int reassociated_connection; | |
360 | ||
361 | int eapol_received; /* number of EAPOL packets received after the | |
362 | * previous association event */ | |
363 | ||
364 | struct scard_data *scard; | |
365 | ||
366 | unsigned char last_eapol_src[ETH_ALEN]; | |
367 | ||
368 | int keys_cleared; | |
369 | ||
370 | struct wpa_blacklist *blacklist; | |
371 | ||
372 | int scan_req; /* manual scan request; this forces a scan even if there | |
373 | * are no enabled networks in the configuration */ | |
374 | int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan | |
375 | * results without a new scan request; this is used | |
376 | * to speed up the first association if the driver | |
377 | * has already available scan results. */ | |
a6099152 | 378 | int scan_runs; /* number of scan runs since WPS was started */ |
6fc6879b JM |
379 | |
380 | struct wpa_client_mlme mlme; | |
c2a04078 | 381 | unsigned int drv_flags; |
80bc75f1 | 382 | int max_scan_ssids; |
46690a3b JM |
383 | |
384 | int pending_mic_error_report; | |
385 | int pending_mic_error_pairwise; | |
386 | int mic_errors_seen; /* Michael MIC errors with the current PTK */ | |
116654ce JM |
387 | |
388 | struct wps_context *wps; | |
a6099152 | 389 | int wps_success; /* WPS success event received */ |
e9bcfebf | 390 | struct wps_er *wps_er; |
a6099152 | 391 | int blacklist_cleared; |
11ef8d35 | 392 | |
1ff73338 JM |
393 | struct wpabuf *pending_eapol_rx; |
394 | struct os_time pending_eapol_rx_time; | |
395 | u8 pending_eapol_rx_src[ETH_ALEN]; | |
396 | ||
11ef8d35 | 397 | struct ibss_rsn *ibss_rsn; |
c2a04078 JM |
398 | |
399 | #ifdef CONFIG_SME | |
400 | struct { | |
401 | u8 ssid[32]; | |
402 | size_t ssid_len; | |
403 | int freq; | |
404 | u8 assoc_req_ie[80]; | |
405 | size_t assoc_req_ie_len; | |
406 | int mfp; | |
407 | int ft_used; | |
408 | u8 mobility_domain[2]; | |
409 | u8 *ft_ies; | |
410 | size_t ft_ies_len; | |
62fa124c JM |
411 | u8 prev_bssid[ETH_ALEN]; |
412 | int prev_bssid_set; | |
c2a04078 JM |
413 | } sme; |
414 | #endif /* CONFIG_SME */ | |
2d5b792d JM |
415 | |
416 | #ifdef CONFIG_AP | |
417 | struct hostapd_iface *ap_iface; | |
418 | #endif /* CONFIG_AP */ | |
60b94c98 JM |
419 | |
420 | struct wpa_ssid *bgscan_ssid; | |
421 | const struct bgscan_ops *bgscan; | |
422 | void *bgscan_priv; | |
6fc6879b JM |
423 | }; |
424 | ||
425 | ||
426 | /* wpa_supplicant.c */ | |
0194fedb JB |
427 | int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); |
428 | ||
6fc6879b JM |
429 | int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s); |
430 | ||
431 | const char * wpa_supplicant_state_txt(int state); | |
432 | int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s); | |
433 | int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, | |
434 | struct wpa_scan_res *bss, | |
435 | struct wpa_ssid *ssid, | |
436 | u8 *wpa_ie, size_t *wpa_ie_len); | |
437 | void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, | |
438 | struct wpa_scan_res *bss, | |
439 | struct wpa_ssid *ssid); | |
440 | void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s, | |
441 | struct wpa_ssid *ssid); | |
442 | void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s); | |
443 | int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s); | |
444 | void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr); | |
445 | void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, | |
446 | int sec, int usec); | |
447 | void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state); | |
448 | struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s); | |
449 | void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s); | |
450 | void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s, | |
451 | int reason_code); | |
452 | void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s, | |
453 | int reason_code); | |
454 | ||
86b89452 WS |
455 | void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s, |
456 | struct wpa_ssid *ssid); | |
457 | void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s, | |
458 | struct wpa_ssid *ssid); | |
459 | void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s, | |
460 | struct wpa_ssid *ssid); | |
461 | int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s, | |
462 | int ap_scan); | |
463 | int wpa_supplicant_set_debug_params(struct wpa_global *global, | |
464 | int debug_level, int debug_timestamp, | |
465 | int debug_show_keys); | |
466 | ||
6fc6879b JM |
467 | void wpa_show_license(void); |
468 | ||
469 | struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, | |
470 | struct wpa_interface *iface); | |
471 | int wpa_supplicant_remove_iface(struct wpa_global *global, | |
472 | struct wpa_supplicant *wpa_s); | |
473 | struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global, | |
474 | const char *ifname); | |
475 | struct wpa_global * wpa_supplicant_init(struct wpa_params *params); | |
476 | int wpa_supplicant_run(struct wpa_global *global); | |
477 | void wpa_supplicant_deinit(struct wpa_global *global); | |
478 | ||
479 | int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, | |
480 | struct wpa_ssid *ssid); | |
481 | ||
482 | /* scan.c */ | |
4f34d51a | 483 | int wpa_supplicant_enabled_networks(struct wpa_config *conf); |
6fc6879b JM |
484 | void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec); |
485 | void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s); | |
cb8564b1 DW |
486 | void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s, |
487 | int scanning); | |
60b94c98 JM |
488 | struct wpa_driver_scan_params; |
489 | int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s, | |
490 | struct wpa_driver_scan_params *params); | |
6fc6879b JM |
491 | |
492 | /* events.c */ | |
493 | void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s); | |
494 | ||
6fc6879b | 495 | #endif /* WPA_SUPPLICANT_I_H */ |