wpa_supplicant_i.h revision 8d520ff1dc2da35cdca849e982051b86468016d8
1/*
2 * wpa_supplicant - Internal definitions
3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
4 *
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.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#ifndef WPA_SUPPLICANT_I_H
16#define WPA_SUPPLICANT_I_H
17
18#include "utils/list.h"
19#include "common/defs.h"
20
21extern const char *wpa_supplicant_version;
22extern const char *wpa_supplicant_license;
23#ifndef CONFIG_NO_STDOUT_DEBUG
24extern const char *wpa_supplicant_full_license1;
25extern const char *wpa_supplicant_full_license2;
26extern const char *wpa_supplicant_full_license3;
27extern const char *wpa_supplicant_full_license4;
28extern const char *wpa_supplicant_full_license5;
29#endif /* CONFIG_NO_STDOUT_DEBUG */
30
31struct wpa_sm;
32struct wpa_supplicant;
33struct ibss_rsn;
34struct scan_info;
35struct wpa_bss;
36struct wpa_scan_results;
37struct hostapd_hw_modes;
38
39/*
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
42 * these structures.
43 */
44struct ctrl_iface_priv;
45struct ctrl_iface_global_priv;
46struct wpas_dbus_priv;
47
48/**
49 * struct wpa_interface - Parameters for wpa_supplicant_add_iface()
50 */
51struct wpa_interface {
52	/**
53	 * confname - Configuration name (file or profile) name
54	 *
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
57	 * configured.
58	 */
59	const char *confname;
60
61	/**
62	 * ctrl_interface - Control interface parameter
63	 *
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
68	 * file.
69	 */
70	const char *ctrl_interface;
71
72	/**
73	 * driver - Driver interface name, or %NULL to use the default driver
74	 */
75	const char *driver;
76
77	/**
78	 * driver_param - Driver interface parameters
79	 *
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
84	 * file.
85	 */
86	const char *driver_param;
87
88	/**
89	 * ifname - Interface name
90	 */
91	const char *ifname;
92
93	/**
94	 * bridge_ifname - Optional bridge interface name
95	 *
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.
100	 */
101	const char *bridge_ifname;
102};
103
104/**
105 * struct wpa_params - Parameters for wpa_supplicant_init()
106 */
107struct wpa_params {
108	/**
109	 * daemonize - Run %wpa_supplicant in the background
110	 */
111	int daemonize;
112
113	/**
114	 * wait_for_monitor - Wait for a monitor program before starting
115	 */
116	int wait_for_monitor;
117
118	/**
119	 * pid_file - Path to a PID (process ID) file
120	 *
121	 * If this and daemonize are set, process ID of the background process
122	 * will be written to the specified file.
123	 */
124	char *pid_file;
125
126	/**
127	 * wpa_debug_level - Debugging verbosity level (e.g., MSG_INFO)
128	 */
129	int wpa_debug_level;
130
131	/**
132	 * wpa_debug_show_keys - Whether keying material is included in debug
133	 *
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.
139	 */
140	int wpa_debug_show_keys;
141
142	/**
143	 * wpa_debug_timestamp - Whether to include timestamp in debug messages
144	 */
145	int wpa_debug_timestamp;
146
147	/**
148	 * ctrl_interface - Global ctrl_iface path/parameter
149	 */
150	char *ctrl_interface;
151
152	/**
153	 * dbus_ctrl_interface - Enable the DBus control interface
154	 */
155	int dbus_ctrl_interface;
156
157	/**
158	 * wpa_debug_file_path - Path of debug file or %NULL to use stdout
159	 */
160	const char *wpa_debug_file_path;
161
162	/**
163	 * wpa_debug_syslog - Enable log output through syslog
164	 */
165	int wpa_debug_syslog;
166
167	/**
168	 * override_driver - Optional driver parameter override
169	 *
170	 * This parameter can be used to override the driver parameter in
171	 * dynamic interface addition to force a specific driver wrapper to be
172	 * used instead.
173	 */
174	char *override_driver;
175
176	/**
177	 * override_ctrl_interface - Optional ctrl_interface override
178	 *
179	 * This parameter can be used to override the ctrl_interface parameter
180	 * in dynamic interface addition to force a control interface to be
181	 * created.
182	 */
183	char *override_ctrl_interface;
184};
185
186struct p2p_srv_bonjour {
187	struct dl_list list;
188	struct wpabuf *query;
189	struct wpabuf *resp;
190};
191
192struct p2p_srv_upnp {
193	struct dl_list list;
194	u8 version;
195	char *service;
196};
197
198/**
199 * struct wpa_global - Internal, global data for all %wpa_supplicant interfaces
200 *
201 * This structure is initialized by calling wpa_supplicant_init() when starting
202 * %wpa_supplicant.
203 */
204struct wpa_global {
205	struct wpa_supplicant *ifaces;
206	struct wpa_params params;
207	struct ctrl_iface_global_priv *ctrl_iface;
208	struct wpas_dbus_priv *dbus;
209	void **drv_priv;
210	size_t drv_count;
211	struct os_time suspend_time;
212	struct p2p_data *p2p;
213	struct wpa_supplicant *p2p_group_formation;
214	u8 p2p_dev_addr[ETH_ALEN];
215	struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
216	struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
217	int p2p_disabled;
218	int cross_connection;
219};
220
221
222struct wpa_client_mlme {
223#ifdef CONFIG_CLIENT_MLME
224	enum {
225		IEEE80211_DISABLED, IEEE80211_AUTHENTICATE,
226		IEEE80211_ASSOCIATE, IEEE80211_ASSOCIATED,
227		IEEE80211_IBSS_SEARCH, IEEE80211_IBSS_JOINED
228	} state;
229	u8 prev_bssid[ETH_ALEN];
230	u8 ssid[32];
231	size_t ssid_len;
232	u16 aid;
233	u16 ap_capab, capab;
234	u8 *extra_ie; /* to be added to the end of AssocReq */
235	size_t extra_ie_len;
236	u8 *extra_probe_ie; /* to be added to the end of ProbeReq */
237	size_t extra_probe_ie_len;
238	enum wpa_key_mgmt key_mgmt;
239
240	/* The last AssocReq/Resp IEs */
241	u8 *assocreq_ies, *assocresp_ies;
242	size_t assocreq_ies_len, assocresp_ies_len;
243
244	int auth_tries, assoc_tries;
245
246	unsigned int ssid_set:1;
247	unsigned int bssid_set:1;
248	unsigned int prev_bssid_set:1;
249	unsigned int authenticated:1;
250	unsigned int associated:1;
251	unsigned int probereq_poll:1;
252	unsigned int use_protection:1;
253	unsigned int create_ibss:1;
254	unsigned int mixed_cell:1;
255	unsigned int wmm_enabled:1;
256
257	struct os_time last_probe;
258
259	unsigned int auth_algs; /* bitfield of allowed auth algs
260				 * (WPA_AUTH_ALG_*) */
261	int auth_alg; /* currently used IEEE 802.11 authentication algorithm */
262	int auth_transaction;
263
264	struct os_time ibss_join_req;
265	u8 *probe_resp; /* ProbeResp template for IBSS */
266	size_t probe_resp_len;
267	u32 supp_rates_bits;
268
269	int wmm_last_param_set;
270
271	int sta_scanning;
272	int scan_hw_mode_idx;
273	int scan_channel_idx;
274	enum { SCAN_SET_CHANNEL, SCAN_SEND_PROBE } scan_state;
275	struct os_time last_scan_completed;
276	int scan_oper_channel;
277	int scan_oper_freq;
278	int scan_oper_phymode;
279	u8 scan_ssid[32];
280	size_t scan_ssid_len;
281	int scan_skip_11b;
282	int *scan_freqs;
283
284	struct ieee80211_sta_bss *sta_bss_list;
285#define STA_HASH_SIZE 256
286#define STA_HASH(sta) (sta[5])
287	struct ieee80211_sta_bss *sta_bss_hash[STA_HASH_SIZE];
288
289	int cts_protect_erp_frames;
290
291	enum hostapd_hw_mode phymode; /* current mode */
292	struct hostapd_hw_modes *modes;
293	size_t num_modes;
294	unsigned int hw_modes; /* bitfield of allowed hardware modes;
295				* (1 << HOSTAPD_MODE_*) */
296	int num_curr_rates;
297	int *curr_rates;
298	int freq; /* The current frequency in MHz */
299	int channel; /* The current IEEE 802.11 channel number */
300
301#ifdef CONFIG_IEEE80211R
302	u8 current_md[6];
303	u8 *ft_ies;
304	size_t ft_ies_len;
305#endif /* CONFIG_IEEE80211R */
306
307	void (*public_action_cb)(void *ctx, const u8 *buf, size_t len,
308				 int freq);
309	void *public_action_cb_ctx;
310
311#else /* CONFIG_CLIENT_MLME */
312	int dummy; /* to keep MSVC happy */
313#endif /* CONFIG_CLIENT_MLME */
314};
315
316/**
317 * struct wpa_supplicant - Internal data for wpa_supplicant interface
318 *
319 * This structure contains the internal data for core wpa_supplicant code. This
320 * should be only used directly from the core code. However, a pointer to this
321 * data is used from other files as an arbitrary context pointer in calls to
322 * core functions.
323 */
324struct wpa_supplicant {
325	struct wpa_global *global;
326	struct wpa_supplicant *parent;
327	struct wpa_supplicant *next;
328	struct l2_packet_data *l2;
329	struct l2_packet_data *l2_br;
330	unsigned char own_addr[ETH_ALEN];
331	char ifname[100];
332#ifdef CONFIG_CTRL_IFACE_DBUS
333	char *dbus_path;
334#endif /* CONFIG_CTRL_IFACE_DBUS */
335#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
336	char *dbus_new_path;
337#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
338	char bridge_ifname[16];
339
340	char *confname;
341	struct wpa_config *conf;
342	int countermeasures;
343	os_time_t last_michael_mic_error;
344	u8 bssid[ETH_ALEN];
345	u8 pending_bssid[ETH_ALEN]; /* If wpa_state == WPA_ASSOCIATING, this
346				     * field contains the targer BSSID. */
347	int reassociate; /* reassociation requested */
348	int disconnected; /* all connections disabled; i.e., do no reassociate
349			   * before this has been cleared */
350	struct wpa_ssid *current_ssid;
351	struct wpa_bss *current_bss;
352	int ap_ies_from_associnfo;
353	unsigned int assoc_freq;
354
355	/* Selected configuration (based on Beacon/ProbeResp WPA IE) */
356	int pairwise_cipher;
357	int group_cipher;
358	int key_mgmt;
359	int mgmt_group_cipher;
360
361	void *drv_priv; /* private data used by driver_ops */
362	void *global_drv_priv;
363
364	struct wpa_ssid *prev_scan_ssid; /* previously scanned SSID;
365					  * NULL = not yet initialized (start
366					  * with wildcard SSID)
367					  * WILDCARD_SSID_SCAN = wildcard
368					  * SSID was used in the previous scan
369					  */
370#define WILDCARD_SSID_SCAN ((struct wpa_ssid *) 1)
371
372	void (*scan_res_handler)(struct wpa_supplicant *wpa_s,
373				 struct wpa_scan_results *scan_res);
374	struct dl_list bss; /* struct wpa_bss::list */
375	struct dl_list bss_id; /* struct wpa_bss::list_id */
376	size_t num_bss;
377	unsigned int bss_update_idx;
378	unsigned int bss_next_id;
379
380	struct wpa_driver_ops *driver;
381	int interface_removed; /* whether the network interface has been
382				* removed */
383	struct wpa_sm *wpa;
384	struct eapol_sm *eapol;
385
386	struct ctrl_iface_priv *ctrl_iface;
387
388	enum wpa_states wpa_state;
389	int scanning;
390	int new_connection;
391	int reassociated_connection;
392
393	int eapol_received; /* number of EAPOL packets received after the
394			     * previous association event */
395
396	struct scard_data *scard;
397
398	unsigned char last_eapol_src[ETH_ALEN];
399
400	int keys_cleared;
401
402	struct wpa_blacklist *blacklist;
403
404	int scan_req; /* manual scan request; this forces a scan even if there
405		       * are no enabled networks in the configuration */
406	int scan_runs; /* number of scan runs since WPS was started */
407	int *next_scan_freqs;
408	int scan_interval; /* time in sec between scans to find suitable AP */
409
410	struct wpa_client_mlme mlme;
411	unsigned int drv_flags;
412	int max_scan_ssids;
413	unsigned int max_remain_on_chan;
414	unsigned int max_stations;
415
416	int pending_mic_error_report;
417	int pending_mic_error_pairwise;
418	int mic_errors_seen; /* Michael MIC errors with the current PTK */
419
420	struct wps_context *wps;
421	int wps_success; /* WPS success event received */
422	struct wps_er *wps_er;
423	int blacklist_cleared;
424
425	struct wpabuf *pending_eapol_rx;
426	struct os_time pending_eapol_rx_time;
427	u8 pending_eapol_rx_src[ETH_ALEN];
428
429	struct ibss_rsn *ibss_rsn;
430
431	int set_sta_uapsd;
432	int sta_uapsd;
433	int set_ap_uapsd;
434	int ap_uapsd;
435
436#ifdef CONFIG_SME
437	struct {
438		u8 ssid[32];
439		size_t ssid_len;
440		int freq;
441		u8 assoc_req_ie[200];
442		size_t assoc_req_ie_len;
443		int mfp;
444		int ft_used;
445		u8 mobility_domain[2];
446		u8 *ft_ies;
447		size_t ft_ies_len;
448		u8 prev_bssid[ETH_ALEN];
449		int prev_bssid_set;
450		int auth_alg;
451
452		int sa_query_count; /* number of pending SA Query requests;
453				     * 0 = no SA Query in progress */
454		int sa_query_timed_out;
455		u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
456					* sa_query_count octets of pending
457					* SA Query transaction identifiers */
458		struct os_time sa_query_start;
459	} sme;
460#endif /* CONFIG_SME */
461
462#ifdef CONFIG_AP
463	struct hostapd_iface *ap_iface;
464	void (*ap_configured_cb)(void *ctx, void *data);
465	void *ap_configured_cb_ctx;
466	void *ap_configured_cb_data;
467#endif /* CONFIG_AP */
468
469#ifdef CONFIG_P2P
470	struct p2p_go_neg_results *go_params;
471	int create_p2p_iface;
472	u8 pending_interface_addr[ETH_ALEN];
473	char pending_interface_name[100];
474	int pending_interface_type;
475	int p2p_group_idx;
476	unsigned int off_channel_freq;
477	struct wpabuf *pending_action_tx;
478	u8 pending_action_src[ETH_ALEN];
479	u8 pending_action_dst[ETH_ALEN];
480	u8 pending_action_bssid[ETH_ALEN];
481	unsigned int pending_action_freq;
482	int pending_action_without_roc;
483	unsigned int pending_listen_freq;
484	unsigned int pending_listen_duration;
485	enum {
486		NOT_P2P_GROUP_INTERFACE,
487		P2P_GROUP_INTERFACE_PENDING,
488		P2P_GROUP_INTERFACE_GO,
489		P2P_GROUP_INTERFACE_CLIENT
490	} p2p_group_interface;
491	struct p2p_group *p2p_group;
492	int p2p_long_listen; /* remaining time in long Listen state in ms */
493	char p2p_pin[10];
494	int p2p_wps_method;
495	u8 p2p_auth_invite[ETH_ALEN];
496	int p2p_sd_over_ctrl_iface;
497	int p2p_in_provisioning;
498	int pending_invite_ssid_id;
499	int show_group_started;
500	u8 go_dev_addr[ETH_ALEN];
501	int pending_pd_before_join;
502	u8 pending_join_iface_addr[ETH_ALEN];
503	u8 pending_join_dev_addr[ETH_ALEN];
504	int pending_join_wps_method;
505	int p2p_join_scan_count;
506	unsigned int roc_waiting_drv_freq;
507	int action_tx_wait_time;
508	int force_long_sd;
509
510	/*
511	 * Whether cross connection is disallowed by the AP to which this
512	 * interface is associated (only valid if there is an association).
513	 */
514	int cross_connect_disallowed;
515
516	/*
517	 * Whether this P2P group is configured to use cross connection (only
518	 * valid if this is P2P GO interface). The actual cross connect packet
519	 * forwarding may not be configured depending on the uplink status.
520	 */
521	int cross_connect_enabled;
522
523	/* Whether cross connection forwarding is in use at the moment. */
524	int cross_connect_in_use;
525
526	/*
527	 * Uplink interface name for cross connection
528	 */
529	char cross_connect_uplink[100];
530
531	enum {
532		P2P_GROUP_REMOVAL_UNKNOWN,
533		P2P_GROUP_REMOVAL_REQUESTED,
534		P2P_GROUP_REMOVAL_IDLE_TIMEOUT,
535		P2P_GROUP_REMOVAL_UNAVAILABLE
536	} removal_reason;
537#endif /* CONFIG_P2P */
538
539	struct wpa_ssid *bgscan_ssid;
540	const struct bgscan_ops *bgscan;
541	void *bgscan_priv;
542
543	int connect_without_scan;
544
545	int after_wps;
546	unsigned int wps_freq;
547	int wps_fragment_size;
548	int auto_reconnect_disabled;
549
550	 /* Channel preferences for AP/P2P GO use */
551	int best_24_freq;
552	int best_5_freq;
553	int best_overall_freq;
554};
555
556
557/* wpa_supplicant.c */
558int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid);
559
560int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s);
561
562const char * wpa_supplicant_state_txt(enum wpa_states state);
563int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s);
564int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
565			      struct wpa_bss *bss, struct wpa_ssid *ssid,
566			      u8 *wpa_ie, size_t *wpa_ie_len);
567void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
568			      struct wpa_bss *bss,
569			      struct wpa_ssid *ssid);
570void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
571				       struct wpa_ssid *ssid);
572void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s);
573void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr);
574void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
575				     int sec, int usec);
576void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
577			      enum wpa_states state);
578struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s);
579const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s);
580void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s);
581void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
582				   int reason_code);
583void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
584				 int reason_code);
585
586void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
587				   struct wpa_ssid *ssid);
588void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
589				    struct wpa_ssid *ssid);
590void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
591				   struct wpa_ssid *ssid);
592int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s,
593			       int ap_scan);
594int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
595					  unsigned int expire_age);
596int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
597					    unsigned int expire_count);
598int wpa_supplicant_set_debug_params(struct wpa_global *global,
599				    int debug_level, int debug_timestamp,
600				    int debug_show_keys);
601
602void wpa_show_license(void);
603
604struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
605						 struct wpa_interface *iface);
606int wpa_supplicant_remove_iface(struct wpa_global *global,
607				struct wpa_supplicant *wpa_s);
608struct wpa_supplicant * wpa_supplicant_get_iface(struct wpa_global *global,
609						 const char *ifname);
610struct wpa_global * wpa_supplicant_init(struct wpa_params *params);
611int wpa_supplicant_run(struct wpa_global *global);
612void wpa_supplicant_deinit(struct wpa_global *global);
613
614int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
615			      struct wpa_ssid *ssid);
616void wpa_supplicant_terminate_proc(struct wpa_global *global);
617void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr,
618			     const u8 *buf, size_t len);
619enum wpa_key_mgmt key_mgmt2driver(int key_mgmt);
620enum wpa_cipher cipher_suite2driver(int cipher);
621void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s);
622void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s);
623void ieee80211_sta_free_hw_features(struct hostapd_hw_modes *hw_features,
624				    size_t num_hw_features);
625void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid);
626
627/* events.c */
628void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s);
629void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
630			    struct wpa_bss *selected,
631			    struct wpa_ssid *ssid);
632
633/* eap_register.c */
634int eap_register_methods(void);
635
636#endif /* WPA_SUPPLICANT_I_H */
637