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;
38 * Forward declarations of private structures used within the ctrl_iface
39 * backends. Other parts of wpa_supplicant do not have access to data stored in
42 struct ctrl_iface_priv;
43 struct ctrl_iface_global_priv;
44 struct ctrl_iface_dbus_priv;
47 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
49 struct wpa_interface {
51 * confname - Configuration name (file or profile) name
53 * This can also be %NULL when a configuration file is not used. In
54 * that case, ctrl_interface must be set to allow the interface to be
60 * ctrl_interface - Control interface parameter
62 * If a configuration file is not used, this variable can be used to
63 * set the ctrl_interface parameter that would have otherwise been read
64 * from the configuration file. If both confname and ctrl_interface are
65 * set, ctrl_interface is used to override the value from configuration
68 const char *ctrl_interface;
71 * driver - Driver interface name, or %NULL to use the default driver
76 * driver_param - Driver interface parameters
78 * If a configuration file is not used, this variable can be used to
79 * set the driver_param parameters that would have otherwise been read
80 * from the configuration file. If both confname and driver_param are
81 * set, driver_param is used to override the value from configuration
84 const char *driver_param;
87 * ifname - Interface name
92 * bridge_ifname - Optional bridge interface name
94 * If the driver interface (ifname) is included in a Linux bridge
95 * device, the bridge interface may need to be used for receiving EAPOL
96 * frames. This can be enabled by setting this variable to enable
97 * receiving of EAPOL frames from an additional interface.
99 const char *bridge_ifname;
103 * struct wpa_params - Parameters for wpa_supplicant_init()
107 * daemonize - Run %wpa_supplicant in the background
112 * wait_for_monitor - Wait for a monitor program before starting
114 int wait_for_monitor;
117 * pid_file - Path to a PID (process ID) file
119 * If this and daemonize are set, process ID of the background process
120 * will be written to the specified file.
125 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
130 * wpa_debug_show_keys - Whether keying material is included in debug
132 * This parameter can be used to allow keying material to be included
133 * in debug messages. This is a security risk and this option should
134 * not be enabled in normal configuration. If needed during
135 * development or while troubleshooting, this option can provide more
136 * details for figuring out what is happening.
138 int wpa_debug_show_keys;
141 * wpa_debug_timestamp - Whether to include timestamp in debug messages
143 int wpa_debug_timestamp;
146 * ctrl_interface - Global ctrl_iface path/parameter
148 char *ctrl_interface;
151 * dbus_ctrl_interface - Enable the DBus control interface
153 int dbus_ctrl_interface;
156 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
158 const char *wpa_debug_file_path;
162 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
164 * This structure is initialized by calling wpa_supplicant_init() when starting
168 struct wpa_supplicant *ifaces;
169 struct wpa_params params;
170 struct ctrl_iface_global_priv *ctrl_iface;
171 struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
177 struct wpa_client_mlme {
178 #ifdef CONFIG_CLIENT_MLME
180 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
181 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
182 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
184 u8 prev_bssid[ETH_ALEN];
189 u8 *extra_ie; /* to be added to the end of AssocReq */
191 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
192 size_t extra_probe_ie_len;
193 wpa_key_mgmt key_mgmt;
195 /* The last AssocReq/Resp IEs */
196 u8 *assocreq_ies, *assocresp_ies;
197 size_t assocreq_ies_len, assocresp_ies_len;
199 int auth_tries, assoc_tries;
201 unsigned int ssid_set:1;
202 unsigned int bssid_set:1;
203 unsigned int prev_bssid_set:1;
204 unsigned int authenticated:1;
205 unsigned int associated:1;
206 unsigned int probereq_poll:1;
207 unsigned int use_protection:1;
208 unsigned int create_ibss:1;
209 unsigned int mixed_cell:1;
210 unsigned int wmm_enabled:1;
212 struct os_time last_probe;
214 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
215 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
216 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
217 unsigned int auth_algs; /* bitfield of allowed auth algs */
218 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
219 int auth_transaction;
221 struct os_time ibss_join_req;
222 u8 *probe_resp; /* ProbeResp template for IBSS */
223 size_t probe_resp_len;
226 int wmm_last_param_set;
229 int scan_hw_mode_idx;
230 int scan_channel_idx;
231 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
232 struct os_time last_scan_completed;
233 int scan_oper_channel;
235 int scan_oper_phymode;
237 size_t scan_ssid_len;
240 struct ieee80211_sta_bss *sta_bss_list;
241 #define STA_HASH_SIZE 256
242 #define STA_HASH(sta) (sta[5])
243 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
245 int cts_protect_erp_frames;
247 int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
248 struct wpa_hw_modes *modes;
250 unsigned int hw_modes; /* bitfield of allowed hardware modes;
253 struct wpa_rate_data *curr_rates;
254 int freq; /* The current frequency in MHz */
255 int channel; /* The current IEEE 802.11 channel number */
257 #ifdef CONFIG_IEEE80211R
261 #endif /* CONFIG_IEEE80211R */
263 #else /* CONFIG_CLIENT_MLME */
264 int dummy; /* to keep MSVC happy */
265 #endif /* CONFIG_CLIENT_MLME */
269 * struct wpa_supplicant - Internal data for wpa_supplicant interface
271 * This structure contains the internal data for core wpa_supplicant code. This
272 * should be only used directly from the core code. However, a pointer to this
273 * data is used from other files as an arbitrary context pointer in calls to
276 struct wpa_supplicant {
277 struct wpa_global *global;
278 struct wpa_supplicant *next;
279 struct l2_packet_data *l2;
280 struct l2_packet_data *l2_br;
281 unsigned char own_addr[ETH_ALEN];
283 #ifdef CONFIG_CTRL_IFACE_DBUS
285 #endif /* CONFIG_CTRL_IFACE_DBUS */
286 char bridge_ifname[16];
289 struct wpa_config *conf;
291 os_time_t last_michael_mic_error;
293 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
294 * field contains the targer BSSID. */
295 int reassociate; /* reassociation requested */
296 int disconnected; /* all connections disabled; i.e., do no reassociate
297 * before this has been cleared */
298 struct wpa_ssid *current_ssid;
299 int ap_ies_from_associnfo;
301 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
305 int mgmt_group_cipher;
307 void *drv_priv; /* private data used by driver_ops */
308 void *global_drv_priv;
310 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
311 * NULL = not yet initialized (start
312 * with broadcast SSID)
313 * BROADCAST_SSID_SCAN = broadcast
314 * SSID was used in the previous scan
316 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
318 struct wpa_scan_results *scan_res;
320 struct wpa_driver_ops *driver;
321 int interface_removed; /* whether the network interface has been
324 struct eapol_sm *eapol;
326 struct ctrl_iface_priv *ctrl_iface;
328 wpa_states wpa_state;
331 int reassociated_connection;
333 int eapol_received; /* number of EAPOL packets received after the
334 * previous association event */
336 struct scard_data *scard;
338 unsigned char last_eapol_src[ETH_ALEN];
342 struct wpa_blacklist *blacklist;
344 int scan_req; /* manual scan request; this forces a scan even if there
345 * are no enabled networks in the configuration */
346 int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
347 * results without a new scan request; this is used
348 * to speed up the first association if the driver
349 * has already available scan results. */
350 int scan_runs; /* number of scan runs since WPS was started */
352 struct wpa_client_mlme mlme;
354 int driver_4way_handshake;
356 int pending_mic_error_report;
357 int pending_mic_error_pairwise;
358 int mic_errors_seen; /* Michael MIC errors with the current PTK */
360 struct wps_context *wps;
361 int wps_success; /* WPS success event received */
362 int blacklist_cleared;
364 struct wpabuf *pending_eapol_rx;
365 struct os_time pending_eapol_rx_time;
366 u8 pending_eapol_rx_src[ETH_ALEN];
368 int link_speed; /* current link speed */
369 int rssi; /* current signal level */
371 int scan_interval; /* time between scans when no APs available */
376 /* wpa_supplicant.c */
377 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
379 const char * wpa_supplicant_state_txt(int state);
380 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
381 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
382 struct wpa_scan_res *bss,
383 struct wpa_ssid *ssid,
384 u8 *wpa_ie, size_t *wpa_ie_len);
385 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
386 struct wpa_scan_res *bss,
387 struct wpa_ssid *ssid);
388 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
389 struct wpa_ssid *ssid);
390 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
391 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
392 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
393 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
395 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
396 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
397 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
398 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
400 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
403 void wpa_show_license(void);
405 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
406 struct wpa_interface *iface);
407 int wpa_supplicant_remove_iface(struct wpa_global *global,
408 struct wpa_supplicant *wpa_s);
409 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
411 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
412 int wpa_supplicant_run(struct wpa_global *global);
413 void wpa_supplicant_deinit(struct wpa_global *global);
415 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
416 struct wpa_ssid *ssid);
419 int wpa_supplicant_enabled_networks(struct wpa_config *conf);
420 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
421 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
422 void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s,
426 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
429 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
432 if (wpa_s->driver->init2)
433 return wpa_s->driver->init2(wpa_s, ifname,
434 wpa_s->global_drv_priv);
435 if (wpa_s->driver->init) {
436 return wpa_s->driver->init(wpa_s, ifname);
441 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
443 if (wpa_s->driver->deinit)
444 wpa_s->driver->deinit(wpa_s->drv_priv);
447 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
450 if (wpa_s->driver->set_param)
451 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
455 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
458 if (wpa_s->driver->set_drop_unencrypted) {
459 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
465 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
468 if (wpa_s->driver->set_countermeasures) {
469 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
475 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
478 if (wpa_s->driver->set_auth_alg) {
479 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
485 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
487 if (wpa_s->driver->set_wpa) {
488 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
493 static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
495 if (wpa_s->driver->set_mode) {
496 return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
501 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
502 struct wpa_driver_associate_params *params)
504 if (wpa_s->driver->associate) {
505 return wpa_s->driver->associate(wpa_s->drv_priv, params);
510 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
513 if (wpa_s->driver->scan) {
514 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
519 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
520 struct wpa_scan_result *results,
523 if (wpa_s->driver->get_scan_results) {
524 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
530 static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
531 struct wpa_supplicant *wpa_s)
533 if (wpa_s->driver->get_scan_results2)
534 return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
538 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
540 if (wpa_s->driver->get_bssid) {
541 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
546 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
548 if (wpa_s->driver->get_ssid) {
549 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
554 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
555 const u8 *addr, int key_idx, int set_tx,
556 const u8 *seq, size_t seq_len,
557 const u8 *key, size_t key_len)
559 if (wpa_s->driver->set_key) {
560 wpa_s->keys_cleared = 0;
561 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
562 key_idx, set_tx, seq, seq_len,
568 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
569 const u8 *addr, int reason_code)
571 if (wpa_s->driver->deauthenticate) {
572 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
578 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
579 const u8 *addr, int reason_code)
581 if (wpa_s->driver->disassociate) {
582 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
588 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
589 const u8 *bssid, const u8 *pmkid)
591 if (wpa_s->driver->add_pmkid) {
592 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
597 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
598 const u8 *bssid, const u8 *pmkid)
600 if (wpa_s->driver->remove_pmkid) {
601 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
607 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
609 if (wpa_s->driver->flush_pmkid) {
610 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
615 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
616 struct wpa_driver_capa *capa)
618 if (wpa_s->driver->get_capa) {
619 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
624 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
626 if (wpa_s->driver->poll) {
627 wpa_s->driver->poll(wpa_s->drv_priv);
631 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
633 if (wpa_s->driver->get_ifname) {
634 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
639 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
641 if (wpa_s->driver->get_mac_addr) {
642 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
647 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
648 const u8 *dst, u16 proto,
649 const u8 *data, size_t data_len)
651 if (wpa_s->driver->send_eapol)
652 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
657 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
660 if (wpa_s->driver->set_operstate)
661 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
665 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
666 const u8 *addr, int protect_type,
669 if (wpa_s->driver->mlme_setprotection)
670 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
676 static inline struct wpa_hw_modes *
677 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
680 if (wpa_s->driver->get_hw_feature_data)
681 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
686 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
687 wpa_hw_mode phymode, int chan,
690 if (wpa_s->driver->set_channel)
691 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
696 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
697 const u8 *ssid, size_t ssid_len)
699 if (wpa_s->driver->set_ssid) {
700 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
706 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
709 if (wpa_s->driver->set_bssid) {
710 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
715 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
718 if (wpa_s->driver->set_country)
719 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
723 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
724 const u8 *data, size_t data_len)
726 if (wpa_s->driver->send_mlme)
727 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
732 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
733 const u8 *addr, const u8 *supp_rates,
734 size_t supp_rates_len)
736 if (wpa_s->driver->mlme_add_sta)
737 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
738 supp_rates, supp_rates_len);
742 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
745 if (wpa_s->driver->mlme_remove_sta)
746 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
750 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
752 const u8 *ies, size_t ies_len)
754 if (wpa_s->driver->update_ft_ies)
755 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
760 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
761 u8 action, const u8 *target_ap,
762 const u8 *ies, size_t ies_len)
764 if (wpa_s->driver->send_ft_action)
765 return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
766 target_ap, ies, ies_len);
770 static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
771 const u8 *ies, size_t ies_len)
773 if (wpa_s->driver->set_probe_req_ie)
774 return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
780 static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
781 char *cmd, char *buf, size_t buf_len)
783 if (wpa_s->driver->driver_cmd)
784 return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
788 #endif /* WPA_SUPPLICANT_I_H */