2 * wpa_supplicant - Internal definitions
3 * Copyright (c) 2003-2006, 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
20 struct wpa_blacklist {
21 struct wpa_blacklist *next;
27 struct wpa_scan_result;
29 struct wpa_supplicant;
32 * Forward declarations of private structures used within the ctrl_iface
33 * backends. Other parts of wpa_supplicant do not have access to data stored in
36 struct ctrl_iface_priv;
37 struct ctrl_iface_global_priv;
38 struct ctrl_iface_dbus_priv;
41 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
43 struct wpa_interface {
45 * confname - Configuration name (file or profile) name
47 * This can also be %NULL when a configuration file is not used. In
48 * that case, ctrl_interface must be set to allow the interface to be
54 * ctrl_interface - Control interface parameter
56 * If a configuration file is not used, this variable can be used to
57 * set the ctrl_interface parameter that would have otherwise been read
58 * from the configuration file. If both confname and ctrl_interface are
59 * set, ctrl_interface is used to override the value from configuration
62 const char *ctrl_interface;
65 * driver - Driver interface name, or %NULL to use the default driver
70 * driver_param - Driver interface parameters
72 * If a configuration file is not used, this variable can be used to
73 * set the driver_param parameters that would have otherwise been read
74 * from the configuration file. If both confname and driver_param are
75 * set, driver_param is used to override the value from configuration
78 const char *driver_param;
81 * ifname - Interface name
86 * bridge_ifname - Optional bridge interface name
88 * If the driver interface (ifname) is included in a Linux bridge
89 * device, the bridge interface may need to be used for receiving EAPOL
90 * frames. This can be enabled by setting this variable to enable
91 * receiving of EAPOL frames from an additional interface.
93 const char *bridge_ifname;
97 * struct wpa_params - Parameters for wpa_supplicant_init()
101 * daemonize - Run %wpa_supplicant in the background
106 * wait_for_interface - Wait for the network interface to appear
108 * If set, %wpa_supplicant will wait until all the configured network
109 * interfaces are available before starting processing. Please note
110 * that in many cases, a better alternative would be to start
111 * %wpa_supplicant without network interfaces and add the interfaces
112 * dynamically whenever they become available.
114 int wait_for_interface;
117 * wait_for_monitor - Wait for a monitor program before starting
119 int wait_for_monitor;
122 * pid_file - Path to a PID (process ID) file
124 * If this and daemonize are set, process ID of the background process
125 * will be written to the specified file.
130 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
135 * wpa_debug_show_keys - Whether keying material is included in debug
137 * This parameter can be used to allow keying material to be included
138 * in debug messages. This is a security risk and this option should
139 * not be enabled in normal configuration. If needed during
140 * development or while troubleshooting, this option can provide more
141 * details for figuring out what is happening.
143 int wpa_debug_show_keys;
146 * wpa_debug_timestamp - Whether to include timestamp in debug messages
148 int wpa_debug_timestamp;
151 * ctrl_interface - Global ctrl_iface path/parameter
153 char *ctrl_interface;
156 * dbus_ctrl_interface - Enable the DBus control interface
158 int dbus_ctrl_interface;
161 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
163 const char *wpa_debug_file_path;
166 * wpa_debug_syslog - Enable log output through syslog
168 const char *wpa_debug_syslog;
172 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
174 * This structure is initialized by calling wpa_supplicant_init() when starting
178 struct wpa_supplicant *ifaces;
179 struct wpa_params params;
180 struct ctrl_iface_global_priv *ctrl_iface;
181 struct ctrl_iface_dbus_priv *dbus_ctrl_iface;
185 struct wpa_client_mlme {
186 #ifdef CONFIG_CLIENT_MLME
188 IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
189 IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
190 IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
192 u8 prev_bssid[ETH_ALEN];
197 u8 *extra_ie; /* to be added to the end of AssocReq */
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 */
262 #else /* CONFIG_CLIENT_MLME */
263 int dummy; /* to keep MSVC happy */
264 #endif /* CONFIG_CLIENT_MLME */
268 * struct wpa_supplicant - Internal data for wpa_supplicant interface
270 * This structure contains the internal data for core wpa_supplicant code. This
271 * should be only used directly from the core code. However, a pointer to this
272 * data is used from other files as an arbitrary context pointer in calls to
275 struct wpa_supplicant {
276 struct wpa_global *global;
277 struct wpa_supplicant *next;
278 struct l2_packet_data *l2;
279 struct l2_packet_data *l2_br;
280 unsigned char own_addr[ETH_ALEN];
282 #ifdef CONFIG_CTRL_IFACE_DBUS
284 #endif /* CONFIG_CTRL_IFACE_DBUS */
285 char bridge_ifname[16];
288 struct wpa_config *conf;
290 os_time_t last_michael_mic_error;
292 u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
293 * field contains the targer BSSID. */
294 int reassociate; /* reassociation requested */
295 int disconnected; /* all connections disabled; i.e., do no reassociate
296 * before this has been cleared */
297 struct wpa_ssid *current_ssid;
299 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
303 int mgmt_group_cipher;
305 void *drv_priv; /* private data used by driver_ops */
307 struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
308 * NULL = not yet initialized (start
309 * with broadcast SSID)
310 * BROADCAST_SSID_SCAN = broadcast
311 * SSID was used in the previous scan
313 #define BROADCAST_SSID_SCAN ((struct wpa_ssid *) 1)
315 struct wpa_scan_result *scan_results;
316 int num_scan_results;
318 struct wpa_driver_ops *driver;
319 int interface_removed; /* whether the network interface has been
322 struct eapol_sm *eapol;
324 struct ctrl_iface_priv *ctrl_iface;
326 wpa_states wpa_state;
328 int reassociated_connection;
330 int eapol_received; /* number of EAPOL packets received after the
331 * previous association event */
333 struct scard_data *scard;
335 unsigned char last_eapol_src[ETH_ALEN];
339 struct wpa_blacklist *blacklist;
341 int scan_req; /* manual scan request; this forces a scan even if there
342 * are no enabled networks in the configuration */
343 int scan_res_tried; /* whether ap_scan=1 mode has tried to fetch scan
344 * results without a new scan request; this is used
345 * to speed up the first association if the driver
346 * has already available scan results. */
348 struct wpa_client_mlme mlme;
353 /* wpa_supplicant.c */
354 void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s);
356 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
358 const char * wpa_supplicant_state_txt(int state);
359 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s,
360 int wait_for_interface);
361 struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s,
363 int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid);
364 void wpa_blacklist_clear(struct wpa_supplicant *wpa_s);
365 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
366 struct wpa_scan_result *bss,
367 struct wpa_ssid *ssid,
368 u8 *wpa_ie, size_t *wpa_ie_len);
369 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
370 struct wpa_scan_result *bss,
371 struct wpa_ssid *ssid);
372 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
373 struct wpa_ssid *ssid);
374 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
375 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s);
376 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
377 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
379 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state);
380 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
381 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
382 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
384 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
386 void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec);
388 void wpa_show_license(void);
390 struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
391 struct wpa_interface *iface);
392 int wpa_supplicant_remove_iface(struct wpa_global *global,
393 struct wpa_supplicant *wpa_s);
394 struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
396 struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
397 int wpa_supplicant_run(struct wpa_global *global);
398 void wpa_supplicant_deinit(struct wpa_global *global);
400 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
401 struct wpa_ssid *ssid);
404 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
407 static inline void * wpa_drv_init(struct wpa_supplicant *wpa_s,
410 if (wpa_s->driver->init) {
411 return wpa_s->driver->init(wpa_s, ifname);
416 static inline void wpa_drv_deinit(struct wpa_supplicant *wpa_s)
418 if (wpa_s->driver->deinit)
419 wpa_s->driver->deinit(wpa_s->drv_priv);
422 static inline int wpa_drv_set_param(struct wpa_supplicant *wpa_s,
425 if (wpa_s->driver->set_param)
426 return wpa_s->driver->set_param(wpa_s->drv_priv, param);
430 static inline int wpa_drv_set_drop_unencrypted(struct wpa_supplicant *wpa_s,
433 if (wpa_s->driver->set_drop_unencrypted) {
434 return wpa_s->driver->set_drop_unencrypted(wpa_s->drv_priv,
440 static inline int wpa_drv_set_countermeasures(struct wpa_supplicant *wpa_s,
443 if (wpa_s->driver->set_countermeasures) {
444 return wpa_s->driver->set_countermeasures(wpa_s->drv_priv,
450 static inline int wpa_drv_set_auth_alg(struct wpa_supplicant *wpa_s,
453 if (wpa_s->driver->set_auth_alg) {
454 return wpa_s->driver->set_auth_alg(wpa_s->drv_priv,
460 static inline int wpa_drv_set_wpa(struct wpa_supplicant *wpa_s, int enabled)
462 if (wpa_s->driver->set_wpa) {
463 return wpa_s->driver->set_wpa(wpa_s->drv_priv, enabled);
468 static inline int wpa_drv_associate(struct wpa_supplicant *wpa_s,
469 struct wpa_driver_associate_params *params)
471 if (wpa_s->driver->associate) {
472 return wpa_s->driver->associate(wpa_s->drv_priv, params);
477 static inline int wpa_drv_scan(struct wpa_supplicant *wpa_s, const u8 *ssid,
480 if (wpa_s->driver->scan) {
481 return wpa_s->driver->scan(wpa_s->drv_priv, ssid, ssid_len);
486 static inline int wpa_drv_get_scan_results(struct wpa_supplicant *wpa_s,
487 struct wpa_scan_result *results,
490 if (wpa_s->driver->get_scan_results) {
491 return wpa_s->driver->get_scan_results(wpa_s->drv_priv,
497 static inline int wpa_drv_get_bssid(struct wpa_supplicant *wpa_s, u8 *bssid)
499 if (wpa_s->driver->get_bssid) {
500 return wpa_s->driver->get_bssid(wpa_s->drv_priv, bssid);
505 static inline int wpa_drv_get_ssid(struct wpa_supplicant *wpa_s, u8 *ssid)
507 if (wpa_s->driver->get_ssid) {
508 return wpa_s->driver->get_ssid(wpa_s->drv_priv, ssid);
513 static inline int wpa_drv_set_key(struct wpa_supplicant *wpa_s, wpa_alg alg,
514 const u8 *addr, int key_idx, int set_tx,
515 const u8 *seq, size_t seq_len,
516 const u8 *key, size_t key_len)
518 if (wpa_s->driver->set_key) {
519 wpa_s->keys_cleared = 0;
520 return wpa_s->driver->set_key(wpa_s->drv_priv, alg, addr,
521 key_idx, set_tx, seq, seq_len,
527 static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,
528 const u8 *addr, int reason_code)
530 if (wpa_s->driver->deauthenticate) {
531 return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,
537 static inline int wpa_drv_disassociate(struct wpa_supplicant *wpa_s,
538 const u8 *addr, int reason_code)
540 if (wpa_s->driver->disassociate) {
541 return wpa_s->driver->disassociate(wpa_s->drv_priv, addr,
547 static inline int wpa_drv_add_pmkid(struct wpa_supplicant *wpa_s,
548 const u8 *bssid, const u8 *pmkid)
550 if (wpa_s->driver->add_pmkid) {
551 return wpa_s->driver->add_pmkid(wpa_s->drv_priv, bssid, pmkid);
556 static inline int wpa_drv_remove_pmkid(struct wpa_supplicant *wpa_s,
557 const u8 *bssid, const u8 *pmkid)
559 if (wpa_s->driver->remove_pmkid) {
560 return wpa_s->driver->remove_pmkid(wpa_s->drv_priv, bssid,
566 static inline int wpa_drv_flush_pmkid(struct wpa_supplicant *wpa_s)
568 if (wpa_s->driver->flush_pmkid) {
569 return wpa_s->driver->flush_pmkid(wpa_s->drv_priv);
574 static inline int wpa_drv_get_capa(struct wpa_supplicant *wpa_s,
575 struct wpa_driver_capa *capa)
577 if (wpa_s->driver->get_capa) {
578 return wpa_s->driver->get_capa(wpa_s->drv_priv, capa);
583 static inline void wpa_drv_poll(struct wpa_supplicant *wpa_s)
585 if (wpa_s->driver->poll) {
586 wpa_s->driver->poll(wpa_s->drv_priv);
590 static inline const char * wpa_drv_get_ifname(struct wpa_supplicant *wpa_s)
592 if (wpa_s->driver->get_ifname) {
593 return wpa_s->driver->get_ifname(wpa_s->drv_priv);
598 static inline const u8 * wpa_drv_get_mac_addr(struct wpa_supplicant *wpa_s)
600 if (wpa_s->driver->get_mac_addr) {
601 return wpa_s->driver->get_mac_addr(wpa_s->drv_priv);
606 static inline int wpa_drv_send_eapol(struct wpa_supplicant *wpa_s,
607 const u8 *dst, u16 proto,
608 const u8 *data, size_t data_len)
610 if (wpa_s->driver->send_eapol)
611 return wpa_s->driver->send_eapol(wpa_s->drv_priv, dst, proto,
616 static inline int wpa_drv_set_operstate(struct wpa_supplicant *wpa_s,
619 if (wpa_s->driver->set_operstate)
620 return wpa_s->driver->set_operstate(wpa_s->drv_priv, state);
624 static inline int wpa_drv_mlme_setprotection(struct wpa_supplicant *wpa_s,
625 const u8 *addr, int protect_type,
628 if (wpa_s->driver->mlme_setprotection)
629 return wpa_s->driver->mlme_setprotection(wpa_s->drv_priv, addr,
635 static inline struct wpa_hw_modes *
636 wpa_drv_get_hw_feature_data(struct wpa_supplicant *wpa_s, u16 *num_modes,
639 if (wpa_s->driver->get_hw_feature_data)
640 return wpa_s->driver->get_hw_feature_data(wpa_s->drv_priv,
645 static inline int wpa_drv_set_channel(struct wpa_supplicant *wpa_s,
646 wpa_hw_mode phymode, int chan,
649 if (wpa_s->driver->set_channel)
650 return wpa_s->driver->set_channel(wpa_s->drv_priv, phymode,
655 static inline int wpa_drv_set_ssid(struct wpa_supplicant *wpa_s,
656 const u8 *ssid, size_t ssid_len)
658 if (wpa_s->driver->set_ssid) {
659 return wpa_s->driver->set_ssid(wpa_s->drv_priv, ssid,
665 static inline int wpa_drv_set_bssid(struct wpa_supplicant *wpa_s,
668 if (wpa_s->driver->set_bssid) {
669 return wpa_s->driver->set_bssid(wpa_s->drv_priv, bssid);
674 static inline int wpa_drv_send_mlme(struct wpa_supplicant *wpa_s,
675 const u8 *data, size_t data_len)
677 if (wpa_s->driver->send_mlme)
678 return wpa_s->driver->send_mlme(wpa_s->drv_priv,
683 static inline int wpa_drv_mlme_add_sta(struct wpa_supplicant *wpa_s,
684 const u8 *addr, const u8 *supp_rates,
685 size_t supp_rates_len)
687 if (wpa_s->driver->mlme_add_sta)
688 return wpa_s->driver->mlme_add_sta(wpa_s->drv_priv, addr,
689 supp_rates, supp_rates_len);
693 static inline int wpa_drv_mlme_remove_sta(struct wpa_supplicant *wpa_s,
696 if (wpa_s->driver->mlme_remove_sta)
697 return wpa_s->driver->mlme_remove_sta(wpa_s->drv_priv, addr);
701 #endif /* WPA_SUPPLICANT_I_H */