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 struct wpa_scan_result;
22 struct wpa_supplicant;
25 * Forward declarations of private structures used within the ctrl_iface
26 * backends. Other parts of wpa_supplicant do not have access to data stored in
29 struct ctrl_iface_priv;
30 struct ctrl_iface_global_priv;
31 struct ctrl_iface_dbus_priv;
34 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
36 struct wpa_interface {
38 * confname - Configuration name (file or profile) name
40 * This can also be %NULL when a configuration file is not used. In
41 * that case, ctrl_interface must be set to allow the interface to be
47 * ctrl_interface - Control interface parameter
49 * If a configuration file is not used, this variable can be used to
50 * set the ctrl_interface parameter that would have otherwise been read
51 * from the configuration file. If both confname and ctrl_interface are
52 * set, ctrl_interface is used to override the value from configuration
55 const char *ctrl_interface;
58 * driver - Driver interface name, or %NULL to use the default driver
63 * driver_param - Driver interface parameters
65 * If a configuration file is not used, this variable can be used to
66 * set the driver_param parameters that would have otherwise been read
67 * from the configuration file. If both confname and driver_param are
68 * set, driver_param is used to override the value from configuration
71 const char *driver_param;
74 * ifname - Interface name
79 * bridge_ifname - Optional bridge interface name
81 * If the driver interface (ifname) is included in a Linux bridge
82 * device, the bridge interface may need to be used for receiving EAPOL
83 * frames. This can be enabled by setting this variable to enable
84 * receiving of EAPOL frames from an additional interface.
86 const char *bridge_ifname;
90 * struct wpa_params - Parameters for wpa_supplicant_init()
94 * daemonize - Run %wpa_supplicant in the background
99 * wait_for_monitor - Wait for a monitor program before starting
101 int wait_for_monitor;
104 * pid_file - Path to a PID (process ID) file
106 * If this and daemonize are set, process ID of the background process
107 * will be written to the specified file.
112 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
117 * wpa_debug_show_keys - Whether keying material is included in debug
119 * This parameter can be used to allow keying material to be included
120 * in debug messages. This is a security risk and this option should
121 * not be enabled in normal configuration. If needed during
122 * development or while troubleshooting, this option can provide more
123 * details for figuring out what is happening.
125 int wpa_debug_show_keys;
128 * wpa_debug_timestamp - Whether to include timestamp in debug messages
130 int wpa_debug_timestamp;
133 * ctrl_interface - Global ctrl_iface path/parameter
135 char *ctrl_interface;
138 * dbus_ctrl_interface - Enable the DBus control interface
140 int dbus_ctrl_interface;
143 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
145 const char *wpa_debug_file_path;
149 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
151 * This structure is initialized by calling wpa_supplicant_init() when starting
155 struct wpa_supplicant *ifaces;
156 struct wpa_params params;
157 struct ctrl_iface_global_priv *ctrl_iface;
158 struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
162 struct wpa_client_mlme {
163 #ifdef CONFIG_CLIENT_MLME
165 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
166 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
167 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
169 u8 prev_bssid[ETH_ALEN];
174 u8 *extra_ie; /* to be added to the end of AssocReq */
176 u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
177 size_t extra_probe_ie_len;
178 wpa_key_mgmt key_mgmt;
180 /* The last AssocReq/Resp IEs */
181 u8 *assocreq_ies, *assocresp_ies;
182 size_t assocreq_ies_len, assocresp_ies_len;
184 int auth_tries, assoc_tries;
186 unsigned int ssid_set:1;
187 unsigned int bssid_set:1;
188 unsigned int prev_bssid_set:1;
189 unsigned int authenticated:1;
190 unsigned int associated:1;
191 unsigned int probereq_poll:1;
192 unsigned int use_protection:1;
193 unsigned int create_ibss:1;
194 unsigned int mixed_cell:1;
195 unsigned int wmm_enabled:1;
197 struct os_time last_probe;
199 #define IEEE80211_AUTH_ALG_OPEN BIT(0)
200 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1)
201 #define IEEE80211_AUTH_ALG_LEAP BIT(2)
202 unsigned int auth_algs; /* bitfield of allowed auth algs */
203 int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
204 int auth_transaction;
206 struct os_time ibss_join_req;
207 u8 *probe_resp; /* ProbeResp template for IBSS */
208 size_t probe_resp_len;
211 int wmm_last_param_set;
214 int scan_hw_mode_idx;
215 int scan_channel_idx;
216 enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
217 struct os_time last_scan_completed;
218 int scan_oper_channel;
220 int scan_oper_phymode;
222 size_t scan_ssid_len;
225 struct ieee80211_sta_bss *sta_bss_list;
226 #define STA_HASH_SIZE 256
227 #define STA_HASH(sta) (sta[5])
228 struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
230 int cts_protect_erp_frames;
232 int phymode; /* current mode; WPA_MODE_IEEE80211A, .. */
233 struct wpa_hw_modes *modes;
235 unsigned int hw_modes; /* bitfield of allowed hardware modes;
238 struct wpa_rate_data *curr_rates;
239 int freq; /* The current frequency in MHz */
240 int channel; /* The current IEEE 802.11 channel number */
242 #ifdef CONFIG_IEEE80211R
246 #endif /* CONFIG_IEEE80211R */
248 #else /* CONFIG_CLIENT_MLME */
249 int dummy; /* to keep MSVC happy */
250 #endif /* CONFIG_CLIENT_MLME */
254 * struct wpa_supplicant - Internal data for wpa_supplicant interface
256 * This structure contains the internal data for core wpa_supplicant code. This
257 * should be only used directly from the core code. However, a pointer to this
258 * data is used from other files as an arbitrary context pointer in calls to
261 struct wpa_supplicant {
262 struct wpa_global *global;
263 struct wpa_supplicant *next;
264 struct l2_packet_data *l2;
265 struct l2_packet_data *l2_br;
266 unsigned char own_addr[ETH_ALEN];
268 #ifdef CONFIG_CTRL_IFACE_DBUS
270 #endif /* CONFIG_CTRL_IFACE_DBUS */
271 char bridge_ifname[16];
274 struct wpa_config *conf;
276 os_time_t last_michael_mic_error;
278 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
279 * field contains the targer BSSID. */
280 int reassociate; /* reassociation requested */
281 int disconnected; /* all connections disabled; i.e., do no reassociate
282 * before this has been cleared */
283 struct wpa_ssid *current_ssid;
284 int ap_ies_from_associnfo;
286 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
290 int mgmt_group_cipher;
292 void *drv_priv; /* private data used by driver_ops */
294 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
295 * NULL = not yet initialized (start
296 * with broadcast SSID)
297 * BROADCAST_SSID_SCAN = broadcast
298 * SSID was used in the previous scan
300 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
302 struct wpa_scan_results *scan_res;
304 struct wpa_driver_ops *driver;
305 int interface_removed; /* whether the network interface has been
308 struct eapol_sm *eapol;
310 struct ctrl_iface_priv *ctrl_iface;
312 wpa_states wpa_state;
314 int reassociated_connection;
316 int eapol_received; /* number of EAPOL packets received after the
317 * previous association event */
319 struct scard_data *scard;
321 unsigned char last_eapol_src[ETH_ALEN];
325 struct wpa_blacklist *blacklist;
327 int scan_req; /* manual scan request; this forces a scan even if there
328 * are no enabled networks in the configuration */
329 int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
330 * results without a new scan request; this is used
331 * to speed up the first association if the driver
332 * has already available scan results. */
334 struct wpa_client_mlme mlme;
336 int driver_4way_handshake;
338 int pending_mic_error_report;
339 int pending_mic_error_pairwise;
340 int mic_errors_seen; /* Michael MIC errors with the current PTK */
342 struct wps_context *wps;
346 /* wpa_supplicant.c */
347 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
349 const char * wpa_supplicant_state_txt(int state);
350 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
351 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
352 struct wpa_scan_res *bss,
353 struct wpa_ssid *ssid,
354 u8 *wpa_ie, size_t *wpa_ie_len);
355 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
356 struct wpa_scan_res *bss,
357 struct wpa_ssid *ssid);
358 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
359 struct wpa_ssid *ssid);
360 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
361 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
362 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
363 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
365 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
366 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
367 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
368 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
370 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
373 void wpa_show_license(void);
375 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
376 struct wpa_interface *iface);
377 int wpa_supplicant_remove_iface(struct wpa_global *global,
378 struct wpa_supplicant *wpa_s);
379 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
381 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
382 int wpa_supplicant_run(struct wpa_global *global);
383 void wpa_supplicant_deinit(struct wpa_global *global);
385 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
386 struct wpa_ssid *ssid);
389 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
390 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
393 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
396 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
399 if (wpa_s->driver->init) {
400 return wpa_s->driver->init(wpa_s, ifname);
405 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
407 if (wpa_s->driver->deinit)
408 wpa_s->driver->deinit(wpa_s->drv_priv);
411 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
414 if (wpa_s->driver->set_param)
415 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
419 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
422 if (wpa_s->driver->set_drop_unencrypted) {
423 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
429 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
432 if (wpa_s->driver->set_countermeasures) {
433 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
439 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
442 if (wpa_s->driver->set_auth_alg) {
443 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
449 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
451 if (wpa_s->driver->set_wpa) {
452 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
457 static inline int wpa_drv_set_mode(struct wpa_supplicant *wpa_s, int mode)
459 if (wpa_s->driver->set_mode) {
460 return wpa_s->driver->set_mode(wpa_s->drv_priv, mode);
465 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
466 struct wpa_driver_associate_params *params)
468 if (wpa_s->driver->associate) {
469 return wpa_s->driver->associate(wpa_s->drv_priv, params);
474 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
477 if (wpa_s->driver->scan) {
478 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
483 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
484 struct wpa_scan_result *results,
487 if (wpa_s->driver->get_scan_results) {
488 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
494 static inline struct wpa_scan_results * wpa_drv_get_scan_results2(
495 struct wpa_supplicant *wpa_s)
497 if (wpa_s->driver->get_scan_results2)
498 return wpa_s->driver->get_scan_results2(wpa_s->drv_priv);
502 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
504 if (wpa_s->driver->get_bssid) {
505 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
510 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
512 if (wpa_s->driver->get_ssid) {
513 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
518 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
519 const u8 *addr, int key_idx, int set_tx,
520 const u8 *seq, size_t seq_len,
521 const u8 *key, size_t key_len)
523 if (wpa_s->driver->set_key) {
524 wpa_s->keys_cleared = 0;
525 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
526 key_idx, set_tx, seq, seq_len,
532 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
533 const u8 *addr, int reason_code)
535 if (wpa_s->driver->deauthenticate) {
536 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
542 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
543 const u8 *addr, int reason_code)
545 if (wpa_s->driver->disassociate) {
546 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
552 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
553 const u8 *bssid, const u8 *pmkid)
555 if (wpa_s->driver->add_pmkid) {
556 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
561 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
562 const u8 *bssid, const u8 *pmkid)
564 if (wpa_s->driver->remove_pmkid) {
565 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
571 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
573 if (wpa_s->driver->flush_pmkid) {
574 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
579 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
580 struct wpa_driver_capa *capa)
582 if (wpa_s->driver->get_capa) {
583 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
588 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
590 if (wpa_s->driver->poll) {
591 wpa_s->driver->poll(wpa_s->drv_priv);
595 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
597 if (wpa_s->driver->get_ifname) {
598 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
603 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
605 if (wpa_s->driver->get_mac_addr) {
606 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
611 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
612 const u8 *dst, u16 proto,
613 const u8 *data, size_t data_len)
615 if (wpa_s->driver->send_eapol)
616 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
621 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
624 if (wpa_s->driver->set_operstate)
625 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
629 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
630 const u8 *addr, int protect_type,
633 if (wpa_s->driver->mlme_setprotection)
634 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
640 static inline struct wpa_hw_modes *
641 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
644 if (wpa_s->driver->get_hw_feature_data)
645 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
650 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
651 wpa_hw_mode phymode, int chan,
654 if (wpa_s->driver->set_channel)
655 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
660 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
661 const u8 *ssid, size_t ssid_len)
663 if (wpa_s->driver->set_ssid) {
664 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
670 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
673 if (wpa_s->driver->set_bssid) {
674 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
679 static inline int wpa_drv_set_country(struct wpa_supplicant *wpa_s,
682 if (wpa_s->driver->set_country)
683 return wpa_s->driver->set_country(wpa_s->drv_priv, alpha2);
687 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
688 const u8 *data, size_t data_len)
690 if (wpa_s->driver->send_mlme)
691 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
696 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
697 const u8 *addr, const u8 *supp_rates,
698 size_t supp_rates_len)
700 if (wpa_s->driver->mlme_add_sta)
701 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
702 supp_rates, supp_rates_len);
706 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
709 if (wpa_s->driver->mlme_remove_sta)
710 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
714 static inline int wpa_drv_update_ft_ies(struct wpa_supplicant *wpa_s,
716 const u8 *ies, size_t ies_len)
718 if (wpa_s->driver->update_ft_ies)
719 return wpa_s->driver->update_ft_ies(wpa_s->drv_priv, md,
724 static inline int wpa_drv_send_ft_action(struct wpa_supplicant *wpa_s,
725 u8 action, const u8 *target_ap,
726 const u8 *ies, size_t ies_len)
728 if (wpa_s->driver->send_ft_action)
729 return wpa_s->driver->send_ft_action(wpa_s->drv_priv, action,
730 target_ap, ies, ies_len);
734 static inline int wpa_drv_set_probe_req_ie(struct wpa_supplicant *wpa_s,
735 const u8 *ies, size_t ies_len)
737 if (wpa_s->driver->set_probe_req_ie)
738 return wpa_s->driver->set_probe_req_ie(wpa_s->drv_priv, ies,
743 #endif /* WPA_SUPPLICANT_I_H */