2 * wpa_supplicant - Internal definitions
3 * Copyright (c) 2003-2010, 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 "utils/list.h"
19 #include "common/defs.h"
21 extern const char *wpa_supplicant_version
;
22 extern const char *wpa_supplicant_license
;
23 #ifndef CONFIG_NO_STDOUT_DEBUG
24 extern const char *wpa_supplicant_full_license1
;
25 extern const char *wpa_supplicant_full_license2
;
26 extern const char *wpa_supplicant_full_license3
;
27 extern const char *wpa_supplicant_full_license4
;
28 extern const char *wpa_supplicant_full_license5
;
29 #endif /* CONFIG_NO_STDOUT_DEBUG */
32 struct wpa_supplicant
;
36 struct wpa_scan_results
;
37 struct hostapd_hw_modes
;
40 * Forward declarations of private structures used within the ctrl_iface
41 * backends. Other parts of wpa_supplicant do not have access to data stored in
44 struct ctrl_iface_priv
;
45 struct ctrl_iface_global_priv
;
46 struct wpas_dbus_priv
;
49 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
51 struct wpa_interface
{
53 * confname - Configuration name (file or profile) name
55 * This can also be %NULL when a configuration file is not used. In
56 * that case, ctrl_interface must be set to allow the interface to be
62 * ctrl_interface - Control interface parameter
64 * If a configuration file is not used, this variable can be used to
65 * set the ctrl_interface parameter that would have otherwise been read
66 * from the configuration file. If both confname and ctrl_interface are
67 * set, ctrl_interface is used to override the value from configuration
70 const char *ctrl_interface
;
73 * driver - Driver interface name, or %NULL to use the default driver
78 * driver_param - Driver interface parameters
80 * If a configuration file is not used, this variable can be used to
81 * set the driver_param parameters that would have otherwise been read
82 * from the configuration file. If both confname and driver_param are
83 * set, driver_param is used to override the value from configuration
86 const char *driver_param
;
89 * ifname - Interface name
94 * bridge_ifname - Optional bridge interface name
96 * If the driver interface (ifname) is included in a Linux bridge
97 * device, the bridge interface may need to be used for receiving EAPOL
98 * frames. This can be enabled by setting this variable to enable
99 * receiving of EAPOL frames from an additional interface.
101 const char *bridge_ifname
;
105 * struct wpa_params - Parameters for wpa_supplicant_init()
109 * daemonize - Run %wpa_supplicant in the background
114 * wait_for_monitor - Wait for a monitor program before starting
116 int wait_for_monitor
;
119 * pid_file - Path to a PID (process ID) file
121 * If this and daemonize are set, process ID of the background process
122 * will be written to the specified file.
127 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
132 * wpa_debug_show_keys - Whether keying material is included in debug
134 * This parameter can be used to allow keying material to be included
135 * in debug messages. This is a security risk and this option should
136 * not be enabled in normal configuration. If needed during
137 * development or while troubleshooting, this option can provide more
138 * details for figuring out what is happening.
140 int wpa_debug_show_keys
;
143 * wpa_debug_timestamp - Whether to include timestamp in debug messages
145 int wpa_debug_timestamp
;
148 * ctrl_interface - Global ctrl_iface path/parameter
150 char *ctrl_interface
;
153 * dbus_ctrl_interface - Enable the DBus control interface
155 int dbus_ctrl_interface
;
158 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
160 const char *wpa_debug_file_path
;
163 * wpa_debug_syslog - Enable log output through syslog
165 int wpa_debug_syslog
;
168 * override_driver - Optional driver parameter override
170 * This parameter can be used to override the driver parameter in
171 * dynamic interface addition to force a specific driver wrapper to be
174 char *override_driver
;
177 * override_ctrl_interface - Optional ctrl_interface override
179 * This parameter can be used to override the ctrl_interface parameter
180 * in dynamic interface addition to force a control interface to be
183 char *override_ctrl_interface
;
186 * entropy_file - Optional entropy file
188 * This parameter can be used to configure wpa_supplicant to maintain
189 * its internal entropy store over restarts.
194 struct p2p_srv_bonjour
{
196 struct wpabuf
*query
;
200 struct p2p_srv_upnp
{
207 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
209 * This structure is initialized by calling wpa_supplicant_init() when starting
213 struct wpa_supplicant
*ifaces
;
214 struct wpa_params params
;
215 struct ctrl_iface_global_priv
*ctrl_iface
;
216 struct wpas_dbus_priv
*dbus
;
219 struct os_time suspend_time
;
220 struct p2p_data
*p2p
;
221 struct wpa_supplicant
*p2p_group_formation
;
222 u8 p2p_dev_addr
[ETH_ALEN
];
223 struct dl_list p2p_srv_bonjour
; /* struct p2p_srv_bonjour */
224 struct dl_list p2p_srv_upnp
; /* struct p2p_srv_upnp */
226 int cross_connection
;
230 struct wpa_client_mlme
{
231 #ifdef CONFIG_CLIENT_MLME
233 IEEE80211_DISABLED
, IEEE80211_AUTHENTICATE
,
234 IEEE80211_ASSOCIATE
, IEEE80211_ASSOCIATED
,
235 IEEE80211_IBSS_SEARCH
, IEEE80211_IBSS_JOINED
237 u8 prev_bssid
[ETH_ALEN
];
242 u8
*extra_ie
; /* to be added to the end of AssocReq */
244 u8
*extra_probe_ie
; /* to be added to the end of ProbeReq */
245 size_t extra_probe_ie_len
;
246 enum wpa_key_mgmt key_mgmt
;
248 /* The last AssocReq/Resp IEs */
249 u8
*assocreq_ies
, *assocresp_ies
;
250 size_t assocreq_ies_len
, assocresp_ies_len
;
252 int auth_tries
, assoc_tries
;
254 unsigned int ssid_set
:1;
255 unsigned int bssid_set
:1;
256 unsigned int prev_bssid_set
:1;
257 unsigned int authenticated
:1;
258 unsigned int associated
:1;
259 unsigned int probereq_poll
:1;
260 unsigned int use_protection
:1;
261 unsigned int create_ibss
:1;
262 unsigned int mixed_cell
:1;
263 unsigned int wmm_enabled
:1;
265 struct os_time last_probe
;
267 unsigned int auth_algs
; /* bitfield of allowed auth algs
268 * (WPA_AUTH_ALG_*) */
269 int auth_alg
; /* currently used IEEE 802.11 authentication algorithm */
270 int auth_transaction
;
272 struct os_time ibss_join_req
;
273 u8
*probe_resp
; /* ProbeResp template for IBSS */
274 size_t probe_resp_len
;
277 int wmm_last_param_set
;
280 int scan_hw_mode_idx
;
281 int scan_channel_idx
;
282 enum { SCAN_SET_CHANNEL
, SCAN_SEND_PROBE
} scan_state
;
283 struct os_time last_scan_completed
;
284 int scan_oper_channel
;
286 int scan_oper_phymode
;
288 size_t scan_ssid_len
;
292 struct ieee80211_sta_bss
*sta_bss_list
;
293 #define STA_HASH_SIZE 256
294 #define STA_HASH(sta) (sta[5])
295 struct ieee80211_sta_bss
*sta_bss_hash
[STA_HASH_SIZE
];
297 int cts_protect_erp_frames
;
299 enum hostapd_hw_mode phymode
; /* current mode */
300 struct hostapd_hw_modes
*modes
;
302 unsigned int hw_modes
; /* bitfield of allowed hardware modes;
303 * (1 << HOSTAPD_MODE_*) */
306 int freq
; /* The current frequency in MHz */
307 int channel
; /* The current IEEE 802.11 channel number */
309 #ifdef CONFIG_IEEE80211R
313 #endif /* CONFIG_IEEE80211R */
315 void (*public_action_cb
)(void *ctx
, const u8
*buf
, size_t len
,
317 void *public_action_cb_ctx
;
319 #else /* CONFIG_CLIENT_MLME */
320 int dummy
; /* to keep MSVC happy */
321 #endif /* CONFIG_CLIENT_MLME */
325 * struct wpa_supplicant - Internal data for wpa_supplicant interface
327 * This structure contains the internal data for core wpa_supplicant code. This
328 * should be only used directly from the core code. However, a pointer to this
329 * data is used from other files as an arbitrary context pointer in calls to
332 struct wpa_supplicant
{
333 struct wpa_global
*global
;
334 struct wpa_supplicant
*parent
;
335 struct wpa_supplicant
*next
;
336 struct l2_packet_data
*l2
;
337 struct l2_packet_data
*l2_br
;
338 unsigned char own_addr
[ETH_ALEN
];
340 #ifdef CONFIG_CTRL_IFACE_DBUS
342 #endif /* CONFIG_CTRL_IFACE_DBUS */
343 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
345 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
346 char bridge_ifname
[16];
349 struct wpa_config
*conf
;
351 os_time_t last_michael_mic_error
;
353 u8 pending_bssid
[ETH_ALEN
]; /* If wpa_state == WPA_ASSOCIATING, this
354 * field contains the targer BSSID. */
355 int reassociate
; /* reassociation requested */
356 int disconnected
; /* all connections disabled; i.e., do no reassociate
357 * before this has been cleared */
358 struct wpa_ssid
*current_ssid
;
359 struct wpa_bss
*current_bss
;
360 int ap_ies_from_associnfo
;
361 unsigned int assoc_freq
;
363 /* Selected configuration (based on Beacon/ProbeResp WPA IE) */
367 int mgmt_group_cipher
;
369 void *drv_priv
; /* private data used by driver_ops */
370 void *global_drv_priv
;
372 struct wpa_ssid
*prev_scan_ssid
; /* previously scanned SSID;
373 * NULL = not yet initialized (start
374 * with wildcard SSID)
375 * WILDCARD_SSID_SCAN = wildcard
376 * SSID was used in the previous scan
378 #define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
380 void (*scan_res_handler
)(struct wpa_supplicant
*wpa_s
,
381 struct wpa_scan_results
*scan_res
);
382 struct dl_list bss
; /* struct wpa_bss::list */
383 struct dl_list bss_id
; /* struct wpa_bss::list_id */
385 unsigned int bss_update_idx
;
386 unsigned int bss_next_id
;
388 struct wpa_driver_ops
*driver
;
389 int interface_removed
; /* whether the network interface has been
392 struct eapol_sm
*eapol
;
394 struct ctrl_iface_priv
*ctrl_iface
;
396 enum wpa_states wpa_state
;
399 int reassociated_connection
;
401 int eapol_received
; /* number of EAPOL packets received after the
402 * previous association event */
404 struct scard_data
*scard
;
406 unsigned char last_eapol_src
[ETH_ALEN
];
410 struct wpa_blacklist
*blacklist
;
412 int scan_req
; /* manual scan request; this forces a scan even if there
413 * are no enabled networks in the configuration */
414 int scan_runs
; /* number of scan runs since WPS was started */
415 int *next_scan_freqs
;
416 int scan_interval
; /* time in sec between scans to find suitable AP */
418 struct wpa_client_mlme mlme
;
419 unsigned int drv_flags
;
421 unsigned int max_remain_on_chan
;
422 unsigned int max_stations
;
424 int pending_mic_error_report
;
425 int pending_mic_error_pairwise
;
426 int mic_errors_seen
; /* Michael MIC errors with the current PTK */
428 struct wps_context
*wps
;
429 int wps_success
; /* WPS success event received */
430 struct wps_er
*wps_er
;
431 int blacklist_cleared
;
433 struct wpabuf
*pending_eapol_rx
;
434 struct os_time pending_eapol_rx_time
;
435 u8 pending_eapol_rx_src
[ETH_ALEN
];
437 struct ibss_rsn
*ibss_rsn
;
449 u8 assoc_req_ie
[200];
450 size_t assoc_req_ie_len
;
453 u8 mobility_domain
[2];
456 u8 prev_bssid
[ETH_ALEN
];
460 int sa_query_count
; /* number of pending SA Query requests;
461 * 0 = no SA Query in progress */
462 int sa_query_timed_out
;
463 u8
*sa_query_trans_id
; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
464 * sa_query_count octets of pending
465 * SA Query transaction identifiers */
466 struct os_time sa_query_start
;
468 #endif /* CONFIG_SME */
471 struct hostapd_iface
*ap_iface
;
472 void (*ap_configured_cb
)(void *ctx
, void *data
);
473 void *ap_configured_cb_ctx
;
474 void *ap_configured_cb_data
;
475 #endif /* CONFIG_AP */
478 struct p2p_go_neg_results
*go_params
;
479 int create_p2p_iface
;
480 u8 pending_interface_addr
[ETH_ALEN
];
481 char pending_interface_name
[100];
482 int pending_interface_type
;
484 unsigned int off_channel_freq
;
485 struct wpabuf
*pending_action_tx
;
486 u8 pending_action_src
[ETH_ALEN
];
487 u8 pending_action_dst
[ETH_ALEN
];
488 u8 pending_action_bssid
[ETH_ALEN
];
489 unsigned int pending_action_freq
;
490 int pending_action_without_roc
;
491 unsigned int pending_listen_freq
;
492 unsigned int pending_listen_duration
;
494 NOT_P2P_GROUP_INTERFACE
,
495 P2P_GROUP_INTERFACE_PENDING
,
496 P2P_GROUP_INTERFACE_GO
,
497 P2P_GROUP_INTERFACE_CLIENT
498 } p2p_group_interface
;
499 struct p2p_group
*p2p_group
;
500 int p2p_long_listen
; /* remaining time in long Listen state in ms */
503 u8 p2p_auth_invite
[ETH_ALEN
];
504 int p2p_sd_over_ctrl_iface
;
505 int p2p_in_provisioning
;
506 int pending_invite_ssid_id
;
507 int show_group_started
;
508 u8 go_dev_addr
[ETH_ALEN
];
509 int pending_pd_before_join
;
510 u8 pending_join_iface_addr
[ETH_ALEN
];
511 u8 pending_join_dev_addr
[ETH_ALEN
];
512 int pending_join_wps_method
;
513 int p2p_join_scan_count
;
514 unsigned int roc_waiting_drv_freq
;
515 int action_tx_wait_time
;
519 * Whether cross connection is disallowed by the AP to which this
520 * interface is associated (only valid if there is an association).
522 int cross_connect_disallowed
;
525 * Whether this P2P group is configured to use cross connection (only
526 * valid if this is P2P GO interface). The actual cross connect packet
527 * forwarding may not be configured depending on the uplink status.
529 int cross_connect_enabled
;
531 /* Whether cross connection forwarding is in use at the moment. */
532 int cross_connect_in_use
;
535 * Uplink interface name for cross connection
537 char cross_connect_uplink
[100];
540 P2P_GROUP_REMOVAL_UNKNOWN
,
541 P2P_GROUP_REMOVAL_REQUESTED
,
542 P2P_GROUP_REMOVAL_IDLE_TIMEOUT
,
543 P2P_GROUP_REMOVAL_UNAVAILABLE
545 #endif /* CONFIG_P2P */
547 struct wpa_ssid
*bgscan_ssid
;
548 const struct bgscan_ops
*bgscan
;
551 int connect_without_scan
;
554 unsigned int wps_freq
;
555 int wps_fragment_size
;
556 int auto_reconnect_disabled
;
558 /* Channel preferences for AP/P2P GO use */
561 int best_overall_freq
;
565 /* wpa_supplicant.c */
566 int wpa_set_wep_keys(struct wpa_supplicant
*wpa_s
, struct wpa_ssid
*ssid
);
568 int wpa_supplicant_reload_configuration(struct wpa_supplicant
*wpa_s
);
570 const char * wpa_supplicant_state_txt(enum wpa_states state
);
571 int wpa_supplicant_driver_init(struct wpa_supplicant
*wpa_s
);
572 int wpa_supplicant_set_suites(struct wpa_supplicant
*wpa_s
,
573 struct wpa_bss
*bss
, struct wpa_ssid
*ssid
,
574 u8
*wpa_ie
, size_t *wpa_ie_len
);
575 void wpa_supplicant_associate(struct wpa_supplicant
*wpa_s
,
577 struct wpa_ssid
*ssid
);
578 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant
*wpa_s
,
579 struct wpa_ssid
*ssid
);
580 void wpa_supplicant_initiate_eapol(struct wpa_supplicant
*wpa_s
);
581 void wpa_clear_keys(struct wpa_supplicant
*wpa_s
, const u8
*addr
);
582 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant
*wpa_s
,
584 void wpa_supplicant_set_state(struct wpa_supplicant
*wpa_s
,
585 enum wpa_states state
);
586 struct wpa_ssid
* wpa_supplicant_get_ssid(struct wpa_supplicant
*wpa_s
);
587 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant
*wpa_s
);
588 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant
*wpa_s
);
589 void wpa_supplicant_deauthenticate(struct wpa_supplicant
*wpa_s
,
591 void wpa_supplicant_disassociate(struct wpa_supplicant
*wpa_s
,
594 void wpa_supplicant_enable_network(struct wpa_supplicant
*wpa_s
,
595 struct wpa_ssid
*ssid
);
596 void wpa_supplicant_disable_network(struct wpa_supplicant
*wpa_s
,
597 struct wpa_ssid
*ssid
);
598 void wpa_supplicant_select_network(struct wpa_supplicant
*wpa_s
,
599 struct wpa_ssid
*ssid
);
600 int wpa_supplicant_set_ap_scan(struct wpa_supplicant
*wpa_s
,
602 int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant
*wpa_s
,
603 unsigned int expire_age
);
604 int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant
*wpa_s
,
605 unsigned int expire_count
);
606 int wpa_supplicant_set_debug_params(struct wpa_global
*global
,
607 int debug_level
, int debug_timestamp
,
608 int debug_show_keys
);
610 void wpa_show_license(void);
612 struct wpa_supplicant
* wpa_supplicant_add_iface(struct wpa_global
*global
,
613 struct wpa_interface
*iface
);
614 int wpa_supplicant_remove_iface(struct wpa_global
*global
,
615 struct wpa_supplicant
*wpa_s
);
616 struct wpa_supplicant
* wpa_supplicant_get_iface(struct wpa_global
*global
,
618 struct wpa_global
* wpa_supplicant_init(struct wpa_params
*params
);
619 int wpa_supplicant_run(struct wpa_global
*global
);
620 void wpa_supplicant_deinit(struct wpa_global
*global
);
622 int wpa_supplicant_scard_init(struct wpa_supplicant
*wpa_s
,
623 struct wpa_ssid
*ssid
);
624 void wpa_supplicant_terminate_proc(struct wpa_global
*global
);
625 void wpa_supplicant_rx_eapol(void *ctx
, const u8
*src_addr
,
626 const u8
*buf
, size_t len
);
627 enum wpa_key_mgmt
key_mgmt2driver(int key_mgmt
);
628 enum wpa_cipher
cipher_suite2driver(int cipher
);
629 void wpa_supplicant_update_config(struct wpa_supplicant
*wpa_s
);
630 void wpa_supplicant_clear_status(struct wpa_supplicant
*wpa_s
);
631 void ieee80211_sta_free_hw_features(struct hostapd_hw_modes
*hw_features
,
632 size_t num_hw_features
);
633 void wpas_connection_failed(struct wpa_supplicant
*wpa_s
, const u8
*bssid
);
636 void wpa_supplicant_mark_disassoc(struct wpa_supplicant
*wpa_s
);
637 void wpa_supplicant_connect(struct wpa_supplicant
*wpa_s
,
638 struct wpa_bss
*selected
,
639 struct wpa_ssid
*ssid
);
642 int eap_register_methods(void);
644 #endif /* WPA_SUPPLICANT_I_H */