2 * wpa_supplicant - Internal definitions
3 * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #ifndef WPA_SUPPLICANT_I_H
16 #define WPA_SUPPLICANT_I_H
18 #include "drivers/driver.h"
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 */
30 extern struct wpa_driver_ops *wpa_supplicant_drivers[];
33 struct wpa_scan_result;
35 struct wpa_supplicant;
39 * Forward declarations of private structures used within the ctrl_iface
40 * backends. Other parts of wpa_supplicant do not have access to data stored in
43 struct ctrl_iface_priv;
44 struct ctrl_iface_global_priv;
45 struct ctrl_iface_dbus_priv;
48 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
50 struct wpa_interface {
52 * confname - Configuration name (file or profile) name
54 * This can also be %NULL when a configuration file is not used. In
55 * that case, ctrl_interface must be set to allow the interface to be
61 * ctrl_interface - Control interface parameter
63 * If a configuration file is not used, this variable can be used to
64 * set the ctrl_interface parameter that would have otherwise been read
65 * from the configuration file. If both confname and ctrl_interface are
66 * set, ctrl_interface is used to override the value from configuration
69 const char *ctrl_interface;
72 * driver - Driver interface name, or %NULL to use the default driver
77 * driver_param - Driver interface parameters
79 * If a configuration file is not used, this variable can be used to
80 * set the driver_param parameters that would have otherwise been read
81 * from the configuration file. If both confname and driver_param are
82 * set, driver_param is used to override the value from configuration
85 const char *driver_param;
88 * ifname - Interface name
93 * bridge_ifname - Optional bridge interface name
95 * If the driver interface (ifname) is included in a Linux bridge
96 * device, the bridge interface may need to be used for receiving EAPOL
97 * frames. This can be enabled by setting this variable to enable
98 * receiving of EAPOL frames from an additional interface.
100 const char *bridge_ifname;
104 * struct wpa_params - Parameters for wpa_supplicant_init()
108 * daemonize - Run %wpa_supplicant in the background
113 * wait_for_monitor - Wait for a monitor program before starting
115 int wait_for_monitor;
118 * pid_file - Path to a PID (process ID) file
120 * If this and daemonize are set, process ID of the background process
121 * will be written to the specified file.
126 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
131 * wpa_debug_show_keys - Whether keying material is included in debug
133 * This parameter can be used to allow keying material to be included
134 * in debug messages. This is a security risk and this option should
135 * not be enabled in normal configuration. If needed during
136 * development or while troubleshooting, this option can provide more
137 * details for figuring out what is happening.
139 int wpa_debug_show_keys;
142 * wpa_debug_timestamp - Whether to include timestamp in debug messages
144 int wpa_debug_timestamp;
147 * ctrl_interface - Global ctrl_iface path/parameter
149 char *ctrl_interface;
152 * dbus_ctrl_interface - Enable the DBus control interface
154 int dbus_ctrl_interface;
157 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
159 const char *wpa_debug_file_path;
162 * wpa_debug_syslog - Enable log output through syslog
164 int wpa_debug_syslog;
168 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
170 * This structure is initialized by calling wpa_supplicant_init() when starting
174 struct wpa_supplicant *ifaces;
175 struct wpa_params params;
176 struct ctrl_iface_global_priv *ctrl_iface;
177 struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
183 struct wpa_client_mlme {
184 #ifdef CONFIG_CLIENT_MLME
186 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
187 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
188 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
190 u8 prev_bssid[ETH_ALEN];
195 u8 *extra_ie; /* to be added to the end of AssocReq */
197 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
198 size_t extra_probe_ie_len;
199 wpa_key_mgmt key_mgmt;
201 /* The last AssocReq/Resp IEs */
202 u8 *assocreq_ies, *assocresp_ies;
203 size_t assocreq_ies_len, assocresp_ies_len;
205 int auth_tries, assoc_tries;
207 unsigned int ssid_set:1;
208 unsigned int bssid_set:1;
209 unsigned int prev_bssid_set:1;
210 unsigned int authenticated:1;
211 unsigned int associated:1;
212 unsigned int probereq_poll:1;
213 unsigned int use_protection:1;
214 unsigned int create_ibss:1;
215 unsigned int mixed_cell:1;
216 unsigned int wmm_enabled:1;
218 struct os_time last_probe;
220 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
221 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
222 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
223 unsigned int auth_algs; /* bitfield of allowed auth algs */
224 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
225 int auth_transaction;
227 struct os_time ibss_join_req;
228 u8 *probe_resp; /* ProbeResp template for IBSS */
229 size_t probe_resp_len;
232 int wmm_last_param_set;
235 int scan_hw_mode_idx;
236 int scan_channel_idx;
237 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
238 struct os_time last_scan_completed;
239 int scan_oper_channel;
241 int scan_oper_phymode;
243 size_t scan_ssid_len;
246 struct ieee80211_sta_bss *sta_bss_list;
247 #define STA_HASH_SIZE 256
248 #define STA_HASH(sta) (sta[5])
249 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
251 int cts_protect_erp_frames;
253 int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
254 struct wpa_hw_modes *modes;
256 unsigned int hw_modes; /* bitfield of allowed hardware modes;
259 struct wpa_rate_data *curr_rates;
260 int freq; /* The current frequency in MHz */
261 int channel; /* The current IEEE 802.11 channel number */
263 #ifdef CONFIG_IEEE80211R
267 #endif /* CONFIG_IEEE80211R */
269 #else /* CONFIG_CLIENT_MLME */
270 int dummy; /* to keep MSVC happy */
271 #endif /* CONFIG_CLIENT_MLME */
275 * struct wpa_supplicant - Internal data for wpa_supplicant interface
277 * This structure contains the internal data for core wpa_supplicant code. This
278 * should be only used directly from the core code. However, a pointer to this
279 * data is used from other files as an arbitrary context pointer in calls to
282 struct wpa_supplicant {
283 struct wpa_global *global;
284 struct wpa_supplicant *next;
285 struct l2_packet_data *l2;
286 struct l2_packet_data *l2_br;
287 unsigned char own_addr[ETH_ALEN];
289 #ifdef CONFIG_CTRL_IFACE_DBUS
291 #endif /* CONFIG_CTRL_IFACE_DBUS */
292 char bridge_ifname[16];
295 struct wpa_config *conf;
297 os_time_t last_michael_mic_error;
299 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
300 * field contains the targer BSSID. */
301 int reassociate; /* reassociation requested */
302 int disconnected; /* all connections disabled; i.e., do no reassociate
303 * before this has been cleared */
304 struct wpa_ssid *current_ssid;
305 int ap_ies_from_associnfo;
307 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
311 int mgmt_group_cipher;
313 void *drv_priv; /* private data used by driver_ops */
316 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
317 * NULL = not yet initialized (start
318 * with wildcard SSID)
319 * WILDCARD_SSID_SCAN = wildcard
320 * SSID was used in the previous scan
322 #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
324 struct wpa_scan_results *scan_res;
326 struct wpa_driver_ops *driver;
327 int interface_removed; /* whether the network interface has been
330 struct eapol_sm *eapol;
332 struct ctrl_iface_priv *ctrl_iface;
334 wpa_states wpa_state;
336 int reassociated_connection;
338 int eapol_received; /* number of EAPOL packets received after the
339 * previous association event */
341 struct scard_data *scard;
343 unsigned char last_eapol_src[ETH_ALEN];
347 struct wpa_blacklist *blacklist;
349 int scan_req; /* manual scan request; this forces a scan even if there
350 * are no enabled networks in the configuration */
351 int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
352 * results without a new scan request; this is used
353 * to speed up the first association if the driver
354 * has already available scan results. */
355 int scan_runs; /* number of scan runs since WPS was started */
357 struct wpa_client_mlme mlme;
359 int driver_4way_handshake;
362 int pending_mic_error_report;
363 int pending_mic_error_pairwise;
364 int mic_errors_seen; /* Michael MIC errors with the current PTK */
366 struct wps_context *wps;
367 int wps_success; /* WPS success event received */
368 int blacklist_cleared;
370 struct ibss_rsn *ibss_rsn;
374 /* wpa_supplicant.c */
375 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
377 const char * wpa_supplicant_state_txt(int state);
378 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
379 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
380 struct wpa_scan_res *bss,
381 struct wpa_ssid *ssid,
382 u8 *wpa_ie, size_t *wpa_ie_len);
383 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
384 struct wpa_scan_res *bss,
385 struct wpa_ssid *ssid);
386 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
387 struct wpa_ssid *ssid);
388 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
389 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
390 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
391 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
393 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
394 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
395 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
396 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
398 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
401 void wpa_show_license(void);
403 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
404 struct wpa_interface *iface);
405 int wpa_supplicant_remove_iface(struct wpa_global *global,
406 struct wpa_supplicant *wpa_s);
407 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
409 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
410 int wpa_supplicant_run(struct wpa_global *global);
411 void wpa_supplicant_deinit(struct wpa_global *global);
413 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
414 struct wpa_ssid *ssid);
417 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
418 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
421 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
424 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
427 if (wpa_s->driver->init2)
428 return wpa_s->driver->init2(wpa_s, ifname, wpa_s->global);
429 if (wpa_s->driver->init) {
430 return wpa_s->driver->init(wpa_s, ifname);
435 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
437 if (wpa_s->driver->deinit)
438 wpa_s->driver->deinit(wpa_s->drv_priv);
441 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
444 if (wpa_s->driver->set_param)
445 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
449 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
452 if (wpa_s->driver->set_drop_unencrypted) {
453 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
459 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
462 if (wpa_s->driver->set_countermeasures) {
463 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
469 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
472 if (wpa_s->driver->set_auth_alg) {
473 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
479 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
481 if (wpa_s->driver->set_wpa) {
482 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
487 static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
489 if (wpa_s->driver->set_mode) {
490 return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
495 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
496 struct wpa_driver_associate_params *params)
498 if (wpa_s->driver->associate) {
499 return wpa_s->driver->associate(wpa_s->drv_priv, params);
504 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s,
505 struct wpa_driver_scan_params *params)
507 if (wpa_s->driver->scan2)
508 return wpa_s->driver->scan2(wpa_s->drv_priv, params);
509 if (wpa_s->driver->scan)
510 return wpa_s->driver->scan(wpa_s->drv_priv,
511 params->ssids[0].ssid,
512 params->ssids[0].ssid_len);
516 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
517 struct wpa_scan_result *results,
520 if (wpa_s->driver->get_scan_results) {
521 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
527 static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
528 struct wpa_supplicant *wpa_s)
530 if (wpa_s->driver->get_scan_results2)
531 return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
535 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
537 if (wpa_s->driver->get_bssid) {
538 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
543 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
545 if (wpa_s->driver->get_ssid) {
546 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
551 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
552 const u8 *addr, int key_idx, int set_tx,
553 const u8 *seq, size_t seq_len,
554 const u8 *key, size_t key_len)
556 if (wpa_s->driver->set_key) {
557 wpa_s->keys_cleared = 0;
558 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
559 key_idx, set_tx, seq, seq_len,
565 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
566 const u8 *addr, int reason_code)
568 if (wpa_s->driver->deauthenticate) {
569 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
575 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
576 const u8 *addr, int reason_code)
578 if (wpa_s->driver->disassociate) {
579 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
585 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
586 const u8 *bssid, const u8 *pmkid)
588 if (wpa_s->driver->add_pmkid) {
589 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
594 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
595 const u8 *bssid, const u8 *pmkid)
597 if (wpa_s->driver->remove_pmkid) {
598 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
604 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
606 if (wpa_s->driver->flush_pmkid) {
607 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
612 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
613 struct wpa_driver_capa *capa)
615 if (wpa_s->driver->get_capa) {
616 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
621 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
623 if (wpa_s->driver->poll) {
624 wpa_s->driver->poll(wpa_s->drv_priv);
628 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
630 if (wpa_s->driver->get_ifname) {
631 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
636 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
638 if (wpa_s->driver->get_mac_addr) {
639 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
644 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
645 const u8 *dst, u16 proto,
646 const u8 *data, size_t data_len)
648 if (wpa_s->driver->send_eapol)
649 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
654 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
657 if (wpa_s->driver->set_operstate)
658 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
662 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
663 const u8 *addr, int protect_type,
666 if (wpa_s->driver->mlme_setprotection)
667 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
673 static inline struct wpa_hw_modes *
674 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
677 if (wpa_s->driver->get_hw_feature_data)
678 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
683 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
684 wpa_hw_mode phymode, int chan,
687 if (wpa_s->driver->set_channel)
688 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
693 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
694 const u8 *ssid, size_t ssid_len)
696 if (wpa_s->driver->set_ssid) {
697 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
703 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
706 if (wpa_s->driver->set_bssid) {
707 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
712 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
715 if (wpa_s->driver->set_country)
716 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
720 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
721 const u8 *data, size_t data_len)
723 if (wpa_s->driver->send_mlme)
724 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
729 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
730 const u8 *addr, const u8 *supp_rates,
731 size_t supp_rates_len)
733 if (wpa_s->driver->mlme_add_sta)
734 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
735 supp_rates, supp_rates_len);
739 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
742 if (wpa_s->driver->mlme_remove_sta)
743 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
747 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
749 const u8 *ies, size_t ies_len)
751 if (wpa_s->driver->update_ft_ies)
752 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
757 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
758 u8 action, const u8 *target_ap,
759 const u8 *ies, size_t ies_len)
761 if (wpa_s->driver->send_ft_action)
762 return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
763 target_ap, ies, ies_len);
767 static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
768 const u8 *ies, size_t ies_len)
770 if (wpa_s->driver->set_probe_req_ie)
771 return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
776 #endif /* WPA_SUPPLICANT_I_H */