driver.h revision fb79edc9df1f20461e90e478363d207348213d35
1/*
2 * Driver interface definition
3 * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 *
8 * This file defines a driver interface used by both %wpa_supplicant and
9 * hostapd. The first part of the file defines data structures used in various
10 * driver operations. This is followed by the struct wpa_driver_ops that each
11 * driver wrapper will beed to define with callback functions for requesting
12 * driver operations. After this, there are definitions for driver event
13 * reporting with wpa_supplicant_event() and some convenience helper functions
14 * that can be used to report events.
15 */
16
17#ifndef DRIVER_H
18#define DRIVER_H
19
20#define WPA_SUPPLICANT_DRIVER_VERSION 4
21
22#include "common/defs.h"
23#include "utils/list.h"
24
25#define HOSTAPD_CHAN_DISABLED 0x00000001
26#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
27#define HOSTAPD_CHAN_NO_IBSS 0x00000004
28#define HOSTAPD_CHAN_RADAR 0x00000008
29#define HOSTAPD_CHAN_HT40PLUS 0x00000010
30#define HOSTAPD_CHAN_HT40MINUS 0x00000020
31#define HOSTAPD_CHAN_HT40 0x00000040
32#define HOSTAPD_CHAN_SURVEY_LIST_INITIALIZED 0x00000080
33
34#define HOSTAPD_CHAN_DFS_UNKNOWN 0x00000000
35#define HOSTAPD_CHAN_DFS_USABLE 0x00000100
36#define HOSTAPD_CHAN_DFS_UNAVAILABLE 0x00000200
37#define HOSTAPD_CHAN_DFS_AVAILABLE 0x00000300
38#define HOSTAPD_CHAN_DFS_MASK 0x00000300
39
40#define HOSTAPD_CHAN_VHT_10_70 0x00000800
41#define HOSTAPD_CHAN_VHT_30_50 0x00001000
42#define HOSTAPD_CHAN_VHT_50_30 0x00002000
43#define HOSTAPD_CHAN_VHT_70_10 0x00004000
44
45enum reg_change_initiator {
46	REGDOM_SET_BY_CORE,
47	REGDOM_SET_BY_USER,
48	REGDOM_SET_BY_DRIVER,
49	REGDOM_SET_BY_COUNTRY_IE,
50};
51
52/**
53 * struct hostapd_channel_data - Channel information
54 */
55struct hostapd_channel_data {
56	/**
57	 * chan - Channel number (IEEE 802.11)
58	 */
59	short chan;
60
61	/**
62	 * freq - Frequency in MHz
63	 */
64	int freq;
65
66	/**
67	 * flag - Channel flags (HOSTAPD_CHAN_*)
68	 */
69	int flag;
70
71	/**
72	 * max_tx_power - Regulatory transmit power limit in dBm
73	 */
74	u8 max_tx_power;
75
76	/*
77	 * survey_list - Linked list of surveys
78	 */
79	struct dl_list survey_list;
80
81	/**
82	 * min_nf - Minimum observed noise floor, in dBm, based on all
83	 * surveyed channel data
84	 */
85	s8 min_nf;
86
87#ifdef CONFIG_ACS
88	/**
89	 * interference_factor - Computed interference factor on this
90	 * channel (used internally in src/ap/acs.c; driver wrappers do not
91	 * need to set this)
92	 */
93	long double interference_factor;
94#endif /* CONFIG_ACS */
95};
96
97#define HOSTAPD_MODE_FLAG_HT_INFO_KNOWN BIT(0)
98#define HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN BIT(1)
99
100/**
101 * struct hostapd_hw_modes - Supported hardware mode information
102 */
103struct hostapd_hw_modes {
104	/**
105	 * mode - Hardware mode
106	 */
107	enum hostapd_hw_mode mode;
108
109	/**
110	 * num_channels - Number of entries in the channels array
111	 */
112	int num_channels;
113
114	/**
115	 * channels - Array of supported channels
116	 */
117	struct hostapd_channel_data *channels;
118
119	/**
120	 * num_rates - Number of entries in the rates array
121	 */
122	int num_rates;
123
124	/**
125	 * rates - Array of supported rates in 100 kbps units
126	 */
127	int *rates;
128
129	/**
130	 * ht_capab - HT (IEEE 802.11n) capabilities
131	 */
132	u16 ht_capab;
133
134	/**
135	 * mcs_set - MCS (IEEE 802.11n) rate parameters
136	 */
137	u8 mcs_set[16];
138
139	/**
140	 * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
141	 */
142	u8 a_mpdu_params;
143
144	/**
145	 * vht_capab - VHT (IEEE 802.11ac) capabilities
146	 */
147	u32 vht_capab;
148
149	/**
150	 * vht_mcs_set - VHT MCS (IEEE 802.11ac) rate parameters
151	 */
152	u8 vht_mcs_set[8];
153
154	unsigned int flags; /* HOSTAPD_MODE_FLAG_* */
155};
156
157
158#define IEEE80211_MODE_INFRA	0
159#define IEEE80211_MODE_IBSS	1
160#define IEEE80211_MODE_AP	2
161
162#define IEEE80211_CAP_ESS	0x0001
163#define IEEE80211_CAP_IBSS	0x0002
164#define IEEE80211_CAP_PRIVACY	0x0010
165
166/* DMG (60 GHz) IEEE 802.11ad */
167/* type - bits 0..1 */
168#define IEEE80211_CAP_DMG_MASK	0x0003
169#define IEEE80211_CAP_DMG_IBSS	0x0001 /* Tx by: STA */
170#define IEEE80211_CAP_DMG_PBSS	0x0002 /* Tx by: PCP */
171#define IEEE80211_CAP_DMG_AP	0x0003 /* Tx by: AP */
172
173#define WPA_SCAN_QUAL_INVALID		BIT(0)
174#define WPA_SCAN_NOISE_INVALID		BIT(1)
175#define WPA_SCAN_LEVEL_INVALID		BIT(2)
176#define WPA_SCAN_LEVEL_DBM		BIT(3)
177#define WPA_SCAN_AUTHENTICATED		BIT(4)
178#define WPA_SCAN_ASSOCIATED		BIT(5)
179
180/**
181 * struct wpa_scan_res - Scan result for an BSS/IBSS
182 * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
183 * @bssid: BSSID
184 * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
185 * @beacon_int: beacon interval in TUs (host byte order)
186 * @caps: capability information field in host byte order
187 * @qual: signal quality
188 * @noise: noise level
189 * @level: signal level
190 * @tsf: Timestamp
191 * @age: Age of the information in milliseconds (i.e., how many milliseconds
192 * ago the last Beacon or Probe Response frame was received)
193 * @ie_len: length of the following IE field in octets
194 * @beacon_ie_len: length of the following Beacon IE field in octets
195 *
196 * This structure is used as a generic format for scan results from the
197 * driver. Each driver interface implementation is responsible for converting
198 * the driver or OS specific scan results into this format.
199 *
200 * If the driver does not support reporting all IEs, the IE data structure is
201 * constructed of the IEs that are available. This field will also need to
202 * include SSID in IE format. All drivers are encouraged to be extended to
203 * report all IEs to make it easier to support future additions.
204 */
205struct wpa_scan_res {
206	unsigned int flags;
207	u8 bssid[ETH_ALEN];
208	int freq;
209	u16 beacon_int;
210	u16 caps;
211	int qual;
212	int noise;
213	int level;
214	u64 tsf;
215	unsigned int age;
216	size_t ie_len;
217	size_t beacon_ie_len;
218	/*
219	 * Followed by ie_len octets of IEs from Probe Response frame (or if
220	 * the driver does not indicate source of IEs, these may also be from
221	 * Beacon frame). After the first set of IEs, another set of IEs may
222	 * follow (with beacon_ie_len octets of data) if the driver provides
223	 * both IE sets.
224	 */
225};
226
227/**
228 * struct wpa_scan_results - Scan results
229 * @res: Array of pointers to allocated variable length scan result entries
230 * @num: Number of entries in the scan result array
231 * @fetch_time: Time when the results were fetched from the driver
232 */
233struct wpa_scan_results {
234	struct wpa_scan_res **res;
235	size_t num;
236	struct os_reltime fetch_time;
237};
238
239/**
240 * struct wpa_interface_info - Network interface information
241 * @next: Pointer to the next interface or NULL if this is the last one
242 * @ifname: Interface name that can be used with init() or init2()
243 * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
244 *	not available
245 * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
246 *	is not an allocated copy, i.e., get_interfaces() caller will not free
247 *	this)
248 */
249struct wpa_interface_info {
250	struct wpa_interface_info *next;
251	char *ifname;
252	char *desc;
253	const char *drv_name;
254};
255
256#define WPAS_MAX_SCAN_SSIDS 16
257
258/**
259 * struct wpa_driver_scan_params - Scan parameters
260 * Data for struct wpa_driver_ops::scan2().
261 */
262struct wpa_driver_scan_params {
263	/**
264	 * ssids - SSIDs to scan for
265	 */
266	struct wpa_driver_scan_ssid {
267		/**
268		 * ssid - specific SSID to scan for (ProbeReq)
269		 * %NULL or zero-length SSID is used to indicate active scan
270		 * with wildcard SSID.
271		 */
272		const u8 *ssid;
273		/**
274		 * ssid_len: Length of the SSID in octets
275		 */
276		size_t ssid_len;
277	} ssids[WPAS_MAX_SCAN_SSIDS];
278
279	/**
280	 * num_ssids - Number of entries in ssids array
281	 * Zero indicates a request for a passive scan.
282	 */
283	size_t num_ssids;
284
285	/**
286	 * extra_ies - Extra IE(s) to add into Probe Request or %NULL
287	 */
288	const u8 *extra_ies;
289
290	/**
291	 * extra_ies_len - Length of extra_ies in octets
292	 */
293	size_t extra_ies_len;
294
295	/**
296	 * freqs - Array of frequencies to scan or %NULL for all frequencies
297	 *
298	 * The frequency is set in MHz. The array is zero-terminated.
299	 */
300	int *freqs;
301
302	/**
303	 * filter_ssids - Filter for reporting SSIDs
304	 *
305	 * This optional parameter can be used to request the driver wrapper to
306	 * filter scan results to include only the specified SSIDs. %NULL
307	 * indicates that no filtering is to be done. This can be used to
308	 * reduce memory needs for scan results in environments that have large
309	 * number of APs with different SSIDs.
310	 *
311	 * The driver wrapper is allowed to take this allocated buffer into its
312	 * own use by setting the pointer to %NULL. In that case, the driver
313	 * wrapper is responsible for freeing the buffer with os_free() once it
314	 * is not needed anymore.
315	 */
316	struct wpa_driver_scan_filter {
317		u8 ssid[32];
318		size_t ssid_len;
319	} *filter_ssids;
320
321	/**
322	 * num_filter_ssids - Number of entries in filter_ssids array
323	 */
324	size_t num_filter_ssids;
325
326	/**
327	 * filter_rssi - Filter by RSSI
328	 *
329	 * The driver may filter scan results in firmware to reduce host
330	 * wakeups and thereby save power. Specify the RSSI threshold in s32
331	 * dBm.
332	 */
333	s32 filter_rssi;
334
335	/**
336	 * p2p_probe - Used to disable CCK (802.11b) rates for P2P probes
337	 *
338	 * When set, the driver is expected to remove rates 1, 2, 5.5, and 11
339	 * Mbps from the support rates element(s) in the Probe Request frames
340	 * and not to transmit the frames at any of those rates.
341	 */
342	u8 p2p_probe;
343
344	/**
345	 * only_new_results - Request driver to report only new results
346	 *
347	 * This is used to request the driver to report only BSSes that have
348	 * been detected after this scan request has been started, i.e., to
349	 * flush old cached BSS entries.
350	 */
351	int only_new_results;
352
353	/*
354	 * NOTE: Whenever adding new parameters here, please make sure
355	 * wpa_scan_clone_params() and wpa_scan_free_params() get updated with
356	 * matching changes.
357	 */
358};
359
360/**
361 * struct wpa_driver_auth_params - Authentication parameters
362 * Data for struct wpa_driver_ops::authenticate().
363 */
364struct wpa_driver_auth_params {
365	int freq;
366	const u8 *bssid;
367	const u8 *ssid;
368	size_t ssid_len;
369	int auth_alg;
370	const u8 *ie;
371	size_t ie_len;
372	const u8 *wep_key[4];
373	size_t wep_key_len[4];
374	int wep_tx_keyidx;
375	int local_state_change;
376
377	/**
378	 * p2p - Whether this connection is a P2P group
379	 */
380	int p2p;
381
382	const u8 *sae_data;
383	size_t sae_data_len;
384
385};
386
387enum wps_mode {
388	WPS_MODE_NONE /* no WPS provisioning being used */,
389	WPS_MODE_OPEN /* WPS provisioning with AP that is in open mode */,
390	WPS_MODE_PRIVACY /* WPS provisioning with AP that is using protection
391			  */
392};
393
394/**
395 * struct wpa_driver_associate_params - Association parameters
396 * Data for struct wpa_driver_ops::associate().
397 */
398struct wpa_driver_associate_params {
399	/**
400	 * bssid - BSSID of the selected AP
401	 * This can be %NULL, if ap_scan=2 mode is used and the driver is
402	 * responsible for selecting with which BSS to associate. */
403	const u8 *bssid;
404
405	/**
406	 * ssid - The selected SSID
407	 */
408	const u8 *ssid;
409
410	/**
411	 * ssid_len - Length of the SSID (1..32)
412	 */
413	size_t ssid_len;
414
415	/**
416	 * freq - Frequency of the channel the selected AP is using
417	 * Frequency that the selected AP is using (in MHz as
418	 * reported in the scan results)
419	 */
420	int freq;
421
422	/**
423	 * bg_scan_period - Background scan period in seconds, 0 to disable
424	 * background scan, or -1 to indicate no change to default driver
425	 * configuration
426	 */
427	int bg_scan_period;
428
429	/**
430	 * wpa_ie - WPA information element for (Re)Association Request
431	 * WPA information element to be included in (Re)Association
432	 * Request (including information element id and length). Use
433	 * of this WPA IE is optional. If the driver generates the WPA
434	 * IE, it can use pairwise_suite, group_suite, and
435	 * key_mgmt_suite to select proper algorithms. In this case,
436	 * the driver has to notify wpa_supplicant about the used WPA
437	 * IE by generating an event that the interface code will
438	 * convert into EVENT_ASSOCINFO data (see below).
439	 *
440	 * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
441	 * instead. The driver can determine which version is used by
442	 * looking at the first byte of the IE (0xdd for WPA, 0x30 for
443	 * WPA2/RSN).
444	 *
445	 * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
446	 */
447	const u8 *wpa_ie;
448
449	/**
450	 * wpa_ie_len - length of the wpa_ie
451	 */
452	size_t wpa_ie_len;
453
454	/**
455	 * wpa_proto - Bitfield of WPA_PROTO_* values to indicate WPA/WPA2
456	 */
457	unsigned int wpa_proto;
458
459	/**
460	 * pairwise_suite - Selected pairwise cipher suite (WPA_CIPHER_*)
461	 *
462	 * This is usually ignored if @wpa_ie is used.
463	 */
464	unsigned int pairwise_suite;
465
466	/**
467	 * group_suite - Selected group cipher suite (WPA_CIPHER_*)
468	 *
469	 * This is usually ignored if @wpa_ie is used.
470	 */
471	unsigned int group_suite;
472
473	/**
474	 * key_mgmt_suite - Selected key management suite (WPA_KEY_MGMT_*)
475	 *
476	 * This is usually ignored if @wpa_ie is used.
477	 */
478	unsigned int key_mgmt_suite;
479
480	/**
481	 * auth_alg - Allowed authentication algorithms
482	 * Bit field of WPA_AUTH_ALG_*
483	 */
484	int auth_alg;
485
486	/**
487	 * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
488	 */
489	int mode;
490
491	/**
492	 * wep_key - WEP keys for static WEP configuration
493	 */
494	const u8 *wep_key[4];
495
496	/**
497	 * wep_key_len - WEP key length for static WEP configuration
498	 */
499	size_t wep_key_len[4];
500
501	/**
502	 * wep_tx_keyidx - WEP TX key index for static WEP configuration
503	 */
504	int wep_tx_keyidx;
505
506	/**
507	 * mgmt_frame_protection - IEEE 802.11w management frame protection
508	 */
509	enum mfp_options mgmt_frame_protection;
510
511	/**
512	 * ft_ies - IEEE 802.11r / FT information elements
513	 * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
514	 * for fast transition, this parameter is set to include the IEs that
515	 * are to be sent in the next FT Authentication Request message.
516	 * update_ft_ies() handler is called to update the IEs for further
517	 * FT messages in the sequence.
518	 *
519	 * The driver should use these IEs only if the target AP is advertising
520	 * the same mobility domain as the one included in the MDIE here.
521	 *
522	 * In ap_scan=2 mode, the driver can use these IEs when moving to a new
523	 * AP after the initial association. These IEs can only be used if the
524	 * target AP is advertising support for FT and is using the same MDIE
525	 * and SSID as the current AP.
526	 *
527	 * The driver is responsible for reporting the FT IEs received from the
528	 * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
529	 * type. update_ft_ies() handler will then be called with the FT IEs to
530	 * include in the next frame in the authentication sequence.
531	 */
532	const u8 *ft_ies;
533
534	/**
535	 * ft_ies_len - Length of ft_ies in bytes
536	 */
537	size_t ft_ies_len;
538
539	/**
540	 * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
541	 *
542	 * This value is provided to allow the driver interface easier access
543	 * to the current mobility domain. This value is set to %NULL if no
544	 * mobility domain is currently active.
545	 */
546	const u8 *ft_md;
547
548	/**
549	 * passphrase - RSN passphrase for PSK
550	 *
551	 * This value is made available only for WPA/WPA2-Personal (PSK) and
552	 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
553	 * the 8..63 character ASCII passphrase, if available. Please note that
554	 * this can be %NULL if passphrase was not used to generate the PSK. In
555	 * that case, the psk field must be used to fetch the PSK.
556	 */
557	const char *passphrase;
558
559	/**
560	 * psk - RSN PSK (alternative for passphrase for PSK)
561	 *
562	 * This value is made available only for WPA/WPA2-Personal (PSK) and
563	 * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
564	 * the 32-octet (256-bit) PSK, if available. The driver wrapper should
565	 * be prepared to handle %NULL value as an error.
566	 */
567	const u8 *psk;
568
569	/**
570	 * drop_unencrypted - Enable/disable unencrypted frame filtering
571	 *
572	 * Configure the driver to drop all non-EAPOL frames (both receive and
573	 * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
574	 * still be allowed for key negotiation.
575	 */
576	int drop_unencrypted;
577
578	/**
579	 * prev_bssid - Previously used BSSID in this ESS
580	 *
581	 * When not %NULL, this is a request to use reassociation instead of
582	 * association.
583	 */
584	const u8 *prev_bssid;
585
586	/**
587	 * wps - WPS mode
588	 *
589	 * If the driver needs to do special configuration for WPS association,
590	 * this variable provides more information on what type of association
591	 * is being requested. Most drivers should not need ot use this.
592	 */
593	enum wps_mode wps;
594
595	/**
596	 * p2p - Whether this connection is a P2P group
597	 */
598	int p2p;
599
600	/**
601	 * uapsd - UAPSD parameters for the network
602	 * -1 = do not change defaults
603	 * AP mode: 1 = enabled, 0 = disabled
604	 * STA mode: bits 0..3 UAPSD enabled for VO,VI,BK,BE
605	 */
606	int uapsd;
607
608	/**
609	 * fixed_bssid - Whether to force this BSSID in IBSS mode
610	 * 1 = Fix this BSSID and prevent merges.
611	 * 0 = Do not fix BSSID.
612	 */
613	int fixed_bssid;
614
615	/**
616	 * disable_ht - Disable HT (IEEE 802.11n) for this connection
617	 */
618	int disable_ht;
619
620	/**
621	 * HT Capabilities over-rides. Only bits set in the mask will be used,
622	 * and not all values are used by the kernel anyway. Currently, MCS,
623	 * MPDU and MSDU fields are used.
624	 */
625	const u8 *htcaps;       /* struct ieee80211_ht_capabilities * */
626	const u8 *htcaps_mask;  /* struct ieee80211_ht_capabilities * */
627
628#ifdef CONFIG_VHT_OVERRIDES
629	/**
630	 * disable_vht - Disable VHT for this connection
631	 */
632	int disable_vht;
633
634	/**
635	 * VHT capability overrides.
636	 */
637	const struct ieee80211_vht_capabilities *vhtcaps;
638	const struct ieee80211_vht_capabilities *vhtcaps_mask;
639#endif /* CONFIG_VHT_OVERRIDES */
640};
641
642enum hide_ssid {
643	NO_SSID_HIDING,
644	HIDDEN_SSID_ZERO_LEN,
645	HIDDEN_SSID_ZERO_CONTENTS
646};
647
648struct wpa_driver_ap_params {
649	/**
650	 * head - Beacon head from IEEE 802.11 header to IEs before TIM IE
651	 */
652	u8 *head;
653
654	/**
655	 * head_len - Length of the head buffer in octets
656	 */
657	size_t head_len;
658
659	/**
660	 * tail - Beacon tail following TIM IE
661	 */
662	u8 *tail;
663
664	/**
665	 * tail_len - Length of the tail buffer in octets
666	 */
667	size_t tail_len;
668
669	/**
670	 * dtim_period - DTIM period
671	 */
672	int dtim_period;
673
674	/**
675	 * beacon_int - Beacon interval
676	 */
677	int beacon_int;
678
679	/**
680	 * basic_rates: -1 terminated array of basic rates in 100 kbps
681	 *
682	 * This parameter can be used to set a specific basic rate set for the
683	 * BSS. If %NULL, default basic rate set is used.
684	 */
685	int *basic_rates;
686
687	/**
688	 * proberesp - Probe Response template
689	 *
690	 * This is used by drivers that reply to Probe Requests internally in
691	 * AP mode and require the full Probe Response template.
692	 */
693	u8 *proberesp;
694
695	/**
696	 * proberesp_len - Length of the proberesp buffer in octets
697	 */
698	size_t proberesp_len;
699
700	/**
701	 * ssid - The SSID to use in Beacon/Probe Response frames
702	 */
703	const u8 *ssid;
704
705	/**
706	 * ssid_len - Length of the SSID (1..32)
707	 */
708	size_t ssid_len;
709
710	/**
711	 * hide_ssid - Whether to hide the SSID
712	 */
713	enum hide_ssid hide_ssid;
714
715	/**
716	 * pairwise_ciphers - WPA_CIPHER_* bitfield
717	 */
718	unsigned int pairwise_ciphers;
719
720	/**
721	 * group_cipher - WPA_CIPHER_*
722	 */
723	unsigned int group_cipher;
724
725	/**
726	 * key_mgmt_suites - WPA_KEY_MGMT_* bitfield
727	 */
728	unsigned int key_mgmt_suites;
729
730	/**
731	 * auth_algs - WPA_AUTH_ALG_* bitfield
732	 */
733	unsigned int auth_algs;
734
735	/**
736	 * wpa_version - WPA_PROTO_* bitfield
737	 */
738	unsigned int wpa_version;
739
740	/**
741	 * privacy - Whether privacy is used in the BSS
742	 */
743	int privacy;
744
745	/**
746	 * beacon_ies - WPS/P2P IE(s) for Beacon frames
747	 *
748	 * This is used to add IEs like WPS IE and P2P IE by drivers that do
749	 * not use the full Beacon template.
750	 */
751	const struct wpabuf *beacon_ies;
752
753	/**
754	 * proberesp_ies - P2P/WPS IE(s) for Probe Response frames
755	 *
756	 * This is used to add IEs like WPS IE and P2P IE by drivers that
757	 * reply to Probe Request frames internally.
758	 */
759	const struct wpabuf *proberesp_ies;
760
761	/**
762	 * assocresp_ies - WPS IE(s) for (Re)Association Response frames
763	 *
764	 * This is used to add IEs like WPS IE by drivers that reply to
765	 * (Re)Association Request frames internally.
766	 */
767	const struct wpabuf *assocresp_ies;
768
769	/**
770	 * isolate - Whether to isolate frames between associated stations
771	 *
772	 * If this is non-zero, the AP is requested to disable forwarding of
773	 * frames between associated stations.
774	 */
775	int isolate;
776
777	/**
778	 * cts_protect - Whether CTS protection is enabled
779	 */
780	int cts_protect;
781
782	/**
783	 * preamble - Whether short preamble is enabled
784	 */
785	int preamble;
786
787	/**
788	 * short_slot_time - Whether short slot time is enabled
789	 *
790	 * 0 = short slot time disable, 1 = short slot time enabled, -1 = do
791	 * not set (e.g., when 802.11g mode is not in use)
792	 */
793	int short_slot_time;
794
795	/**
796	 * ht_opmode - HT operation mode or -1 if HT not in use
797	 */
798	int ht_opmode;
799
800	/**
801	 * interworking - Whether Interworking is enabled
802	 */
803	int interworking;
804
805	/**
806	 * hessid - Homogeneous ESS identifier or %NULL if not set
807	 */
808	const u8 *hessid;
809
810	/**
811	 * access_network_type - Access Network Type (0..15)
812	 *
813	 * This is used for filtering Probe Request frames when Interworking is
814	 * enabled.
815	 */
816	u8 access_network_type;
817
818	/**
819	 * ap_max_inactivity - Timeout in seconds to detect STA's inactivity
820	 *
821	 * This is used by driver which advertises this capability.
822	 */
823	int ap_max_inactivity;
824
825	/**
826	 * disable_dgaf - Whether group-addressed frames are disabled
827	 */
828	int disable_dgaf;
829};
830
831/**
832 * struct wpa_driver_capa - Driver capability information
833 */
834struct wpa_driver_capa {
835#define WPA_DRIVER_CAPA_KEY_MGMT_WPA		0x00000001
836#define WPA_DRIVER_CAPA_KEY_MGMT_WPA2		0x00000002
837#define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK	0x00000004
838#define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK	0x00000008
839#define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE	0x00000010
840#define WPA_DRIVER_CAPA_KEY_MGMT_FT		0x00000020
841#define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK		0x00000040
842#define WPA_DRIVER_CAPA_KEY_MGMT_WAPI_PSK	0x00000080
843	unsigned int key_mgmt;
844
845#define WPA_DRIVER_CAPA_ENC_WEP40	0x00000001
846#define WPA_DRIVER_CAPA_ENC_WEP104	0x00000002
847#define WPA_DRIVER_CAPA_ENC_TKIP	0x00000004
848#define WPA_DRIVER_CAPA_ENC_CCMP	0x00000008
849#define WPA_DRIVER_CAPA_ENC_WEP128	0x00000010
850#define WPA_DRIVER_CAPA_ENC_GCMP	0x00000020
851#define WPA_DRIVER_CAPA_ENC_GCMP_256	0x00000040
852#define WPA_DRIVER_CAPA_ENC_CCMP_256	0x00000080
853#define WPA_DRIVER_CAPA_ENC_BIP		0x00000100
854#define WPA_DRIVER_CAPA_ENC_BIP_GMAC_128	0x00000200
855#define WPA_DRIVER_CAPA_ENC_BIP_GMAC_256	0x00000400
856#define WPA_DRIVER_CAPA_ENC_BIP_CMAC_256	0x00000800
857	unsigned int enc;
858
859#define WPA_DRIVER_AUTH_OPEN		0x00000001
860#define WPA_DRIVER_AUTH_SHARED		0x00000002
861#define WPA_DRIVER_AUTH_LEAP		0x00000004
862	unsigned int auth;
863
864/* Driver generated WPA/RSN IE */
865#define WPA_DRIVER_FLAGS_DRIVER_IE	0x00000001
866/* Driver needs static WEP key setup after association command */
867#define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
868/* unused: 0x00000004 */
869/* Driver takes care of RSN 4-way handshake internally; PMK is configured with
870 * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
871#define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
872#define WPA_DRIVER_FLAGS_WIRED		0x00000010
873/* Driver provides separate commands for authentication and association (SME in
874 * wpa_supplicant). */
875#define WPA_DRIVER_FLAGS_SME		0x00000020
876/* Driver supports AP mode */
877#define WPA_DRIVER_FLAGS_AP		0x00000040
878/* Driver needs static WEP key setup after association has been completed */
879#define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE	0x00000080
880/* unused: 0x00000100 */
881/* Driver supports concurrent P2P operations */
882#define WPA_DRIVER_FLAGS_P2P_CONCURRENT	0x00000200
883/*
884 * Driver uses the initial interface as a dedicated management interface, i.e.,
885 * it cannot be used for P2P group operations or non-P2P purposes.
886 */
887#define WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE	0x00000400
888/* This interface is P2P capable (P2P GO or P2P Client) */
889#define WPA_DRIVER_FLAGS_P2P_CAPABLE	0x00000800
890/* unused: 0x00001000 */
891/*
892 * Driver uses the initial interface for P2P management interface and non-P2P
893 * purposes (e.g., connect to infra AP), but this interface cannot be used for
894 * P2P group operations.
895 */
896#define WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P		0x00002000
897/*
898 * Driver is known to use sane error codes, i.e., when it indicates that
899 * something (e.g., association) fails, there was indeed a failure and the
900 * operation does not end up getting completed successfully later.
901 */
902#define WPA_DRIVER_FLAGS_SANE_ERROR_CODES		0x00004000
903/* Driver supports off-channel TX */
904#define WPA_DRIVER_FLAGS_OFFCHANNEL_TX			0x00008000
905/* Driver indicates TX status events for EAPOL Data frames */
906#define WPA_DRIVER_FLAGS_EAPOL_TX_STATUS		0x00010000
907/* Driver indicates TX status events for Deauth/Disassoc frames */
908#define WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS		0x00020000
909/* Driver supports roaming (BSS selection) in firmware */
910#define WPA_DRIVER_FLAGS_BSS_SELECTION			0x00040000
911/* Driver supports operating as a TDLS peer */
912#define WPA_DRIVER_FLAGS_TDLS_SUPPORT			0x00080000
913/* Driver requires external TDLS setup/teardown/discovery */
914#define WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP		0x00100000
915/* Driver indicates support for Probe Response offloading in AP mode */
916#define WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD		0x00200000
917/* Driver supports U-APSD in AP mode */
918#define WPA_DRIVER_FLAGS_AP_UAPSD			0x00400000
919/* Driver supports inactivity timer in AP mode */
920#define WPA_DRIVER_FLAGS_INACTIVITY_TIMER		0x00800000
921/* Driver expects user space implementation of MLME in AP mode */
922#define WPA_DRIVER_FLAGS_AP_MLME			0x01000000
923/* Driver supports SAE with user space SME */
924#define WPA_DRIVER_FLAGS_SAE				0x02000000
925/* Driver makes use of OBSS scan mechanism in wpa_supplicant */
926#define WPA_DRIVER_FLAGS_OBSS_SCAN			0x04000000
927/* Driver supports IBSS (Ad-hoc) mode */
928#define WPA_DRIVER_FLAGS_IBSS				0x08000000
929/* Driver supports radar detection */
930#define WPA_DRIVER_FLAGS_RADAR				0x10000000
931/* Driver supports a dedicated interface for P2P Device */
932#define WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE		0x20000000
933/* Driver supports QoS Mapping */
934#define WPA_DRIVER_FLAGS_QOS_MAPPING			0x40000000
935/* Driver supports CSA in AP mode */
936#define WPA_DRIVER_FLAGS_AP_CSA				0x80000000
937	unsigned int flags;
938
939	int max_scan_ssids;
940	int max_sched_scan_ssids;
941	int sched_scan_supported;
942	int max_match_sets;
943
944	/**
945	 * max_remain_on_chan - Maximum remain-on-channel duration in msec
946	 */
947	unsigned int max_remain_on_chan;
948
949	/**
950	 * max_stations - Maximum number of associated stations the driver
951	 * supports in AP mode
952	 */
953	unsigned int max_stations;
954
955	/**
956	 * probe_resp_offloads - Bitmap of supported protocols by the driver
957	 * for Probe Response offloading.
958	 */
959/* Driver Probe Response offloading support for WPS ver. 1 */
960#define WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS		0x00000001
961/* Driver Probe Response offloading support for WPS ver. 2 */
962#define WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2		0x00000002
963/* Driver Probe Response offloading support for P2P */
964#define WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P		0x00000004
965/* Driver Probe Response offloading support for IEEE 802.11u (Interworking) */
966#define WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING	0x00000008
967	unsigned int probe_resp_offloads;
968
969	unsigned int max_acl_mac_addrs;
970
971	/**
972	 * Number of supported concurrent channels
973	 */
974	unsigned int num_multichan_concurrent;
975
976	/**
977	 * extended_capa - extended capabilities in driver/device
978	 *
979	 * Must be allocated and freed by driver and the pointers must be
980	 * valid for the lifetime of the driver, i.e., freed in deinit()
981	 */
982	const u8 *extended_capa, *extended_capa_mask;
983	unsigned int extended_capa_len;
984};
985
986
987struct hostapd_data;
988
989struct hostap_sta_driver_data {
990	unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
991	unsigned long current_tx_rate;
992	unsigned long inactive_msec;
993	unsigned long flags;
994	unsigned long num_ps_buf_frames;
995	unsigned long tx_retry_failed;
996	unsigned long tx_retry_count;
997	int last_rssi;
998	int last_ack_rssi;
999};
1000
1001struct hostapd_sta_add_params {
1002	const u8 *addr;
1003	u16 aid;
1004	u16 capability;
1005	const u8 *supp_rates;
1006	size_t supp_rates_len;
1007	u16 listen_interval;
1008	const struct ieee80211_ht_capabilities *ht_capabilities;
1009	const struct ieee80211_vht_capabilities *vht_capabilities;
1010	u32 flags; /* bitmask of WPA_STA_* flags */
1011	int set; /* Set STA parameters instead of add */
1012	u8 qosinfo;
1013	const u8 *ext_capab;
1014	size_t ext_capab_len;
1015};
1016
1017struct hostapd_freq_params {
1018	int mode;
1019	int freq;
1020	int channel;
1021	/* for HT */
1022	int ht_enabled;
1023	int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
1024				 * secondary channel below primary, 1 = HT40
1025				 * enabled, secondary channel above primary */
1026
1027	/* for VHT */
1028	int vht_enabled;
1029
1030	/* valid for both HT and VHT, center_freq2 is non-zero
1031	 * only for bandwidth 80 and an 80+80 channel */
1032	int center_freq1, center_freq2;
1033	int bandwidth;
1034};
1035
1036struct mac_address {
1037	u8 addr[ETH_ALEN];
1038};
1039
1040struct hostapd_acl_params {
1041	u8 acl_policy;
1042	unsigned int num_mac_acl;
1043	struct mac_address mac_acl[0];
1044};
1045
1046enum wpa_driver_if_type {
1047	/**
1048	 * WPA_IF_STATION - Station mode interface
1049	 */
1050	WPA_IF_STATION,
1051
1052	/**
1053	 * WPA_IF_AP_VLAN - AP mode VLAN interface
1054	 *
1055	 * This interface shares its address and Beacon frame with the main
1056	 * BSS.
1057	 */
1058	WPA_IF_AP_VLAN,
1059
1060	/**
1061	 * WPA_IF_AP_BSS - AP mode BSS interface
1062	 *
1063	 * This interface has its own address and Beacon frame.
1064	 */
1065	WPA_IF_AP_BSS,
1066
1067	/**
1068	 * WPA_IF_P2P_GO - P2P Group Owner
1069	 */
1070	WPA_IF_P2P_GO,
1071
1072	/**
1073	 * WPA_IF_P2P_CLIENT - P2P Client
1074	 */
1075	WPA_IF_P2P_CLIENT,
1076
1077	/**
1078	 * WPA_IF_P2P_GROUP - P2P Group interface (will become either
1079	 * WPA_IF_P2P_GO or WPA_IF_P2P_CLIENT, but the role is not yet known)
1080	 */
1081	WPA_IF_P2P_GROUP,
1082
1083	/**
1084	 * WPA_IF_P2P_DEVICE - P2P Device interface is used to indentify the
1085	 * abstracted P2P Device function in the driver
1086	 */
1087	WPA_IF_P2P_DEVICE
1088};
1089
1090struct wpa_init_params {
1091	void *global_priv;
1092	const u8 *bssid;
1093	const char *ifname;
1094	const u8 *ssid;
1095	size_t ssid_len;
1096	const char *test_socket;
1097	int use_pae_group_addr;
1098	char **bridge;
1099	size_t num_bridge;
1100
1101	u8 *own_addr; /* buffer for writing own MAC address */
1102};
1103
1104
1105struct wpa_bss_params {
1106	/** Interface name (for multi-SSID/VLAN support) */
1107	const char *ifname;
1108	/** Whether IEEE 802.1X or WPA/WPA2 is enabled */
1109	int enabled;
1110
1111	int wpa;
1112	int ieee802_1x;
1113	int wpa_group;
1114	int wpa_pairwise;
1115	int wpa_key_mgmt;
1116	int rsn_preauth;
1117	enum mfp_options ieee80211w;
1118};
1119
1120#define WPA_STA_AUTHORIZED BIT(0)
1121#define WPA_STA_WMM BIT(1)
1122#define WPA_STA_SHORT_PREAMBLE BIT(2)
1123#define WPA_STA_MFP BIT(3)
1124#define WPA_STA_TDLS_PEER BIT(4)
1125
1126enum tdls_oper {
1127	TDLS_DISCOVERY_REQ,
1128	TDLS_SETUP,
1129	TDLS_TEARDOWN,
1130	TDLS_ENABLE_LINK,
1131	TDLS_DISABLE_LINK,
1132	TDLS_ENABLE,
1133	TDLS_DISABLE
1134};
1135
1136enum wnm_oper {
1137	WNM_SLEEP_ENTER_CONFIRM,
1138	WNM_SLEEP_ENTER_FAIL,
1139	WNM_SLEEP_EXIT_CONFIRM,
1140	WNM_SLEEP_EXIT_FAIL,
1141	WNM_SLEEP_TFS_REQ_IE_ADD,   /* STA requests driver to add TFS req IE */
1142	WNM_SLEEP_TFS_REQ_IE_NONE,  /* STA requests empty TFS req IE */
1143	WNM_SLEEP_TFS_REQ_IE_SET,   /* AP requests driver to set TFS req IE for
1144				     * a STA */
1145	WNM_SLEEP_TFS_RESP_IE_ADD,  /* AP requests driver to add TFS resp IE
1146				     * for a STA */
1147	WNM_SLEEP_TFS_RESP_IE_NONE, /* AP requests empty TFS resp IE */
1148	WNM_SLEEP_TFS_RESP_IE_SET,  /* AP requests driver to set TFS resp IE
1149				     * for a STA */
1150	WNM_SLEEP_TFS_IE_DEL        /* AP delete the TFS IE */
1151};
1152
1153/* enum chan_width - Channel width definitions */
1154enum chan_width {
1155	CHAN_WIDTH_20_NOHT,
1156	CHAN_WIDTH_20,
1157	CHAN_WIDTH_40,
1158	CHAN_WIDTH_80,
1159	CHAN_WIDTH_80P80,
1160	CHAN_WIDTH_160,
1161	CHAN_WIDTH_UNKNOWN
1162};
1163
1164/**
1165 * struct wpa_signal_info - Information about channel signal quality
1166 */
1167struct wpa_signal_info {
1168	u32 frequency;
1169	int above_threshold;
1170	int current_signal;
1171	int avg_signal;
1172	int current_noise;
1173	int current_txrate;
1174	enum chan_width chanwidth;
1175	int center_frq1;
1176	int center_frq2;
1177};
1178
1179/**
1180 * struct beacon_data - Beacon data
1181 * @head: Head portion of Beacon frame (before TIM IE)
1182 * @tail: Tail portion of Beacon frame (after TIM IE)
1183 * @beacon_ies: Extra information element(s) to add into Beacon frames or %NULL
1184 * @proberesp_ies: Extra information element(s) to add into Probe Response
1185 *	frames or %NULL
1186 * @assocresp_ies: Extra information element(s) to add into (Re)Association
1187 *	Response frames or %NULL
1188 * @probe_resp: Probe Response frame template
1189 * @head_len: Length of @head
1190 * @tail_len: Length of @tail
1191 * @beacon_ies_len: Length of beacon_ies in octets
1192 * @proberesp_ies_len: Length of proberesp_ies in octets
1193 * @proberesp_ies_len: Length of proberesp_ies in octets
1194 * @probe_resp_len: Length of probe response template (@probe_resp)
1195 */
1196struct beacon_data {
1197	u8 *head, *tail;
1198	u8 *beacon_ies;
1199	u8 *proberesp_ies;
1200	u8 *assocresp_ies;
1201	u8 *probe_resp;
1202
1203	size_t head_len, tail_len;
1204	size_t beacon_ies_len;
1205	size_t proberesp_ies_len;
1206	size_t assocresp_ies_len;
1207	size_t probe_resp_len;
1208};
1209
1210/**
1211 * struct csa_settings - Settings for channel switch command
1212 * @cs_count: Count in Beacon frames (TBTT) to perform the switch
1213 * @block_tx: 1 - block transmission for CSA period
1214 * @freq_params: Next channel frequency parameter
1215 * @beacon_csa: Beacon/probe resp/asooc resp info for CSA period
1216 * @beacon_after: Next beacon/probe resp/asooc resp info
1217 * @counter_offset_beacon: Offset to the count field in beacon's tail
1218 * @counter_offset_presp: Offset to the count field in probe resp.
1219 */
1220struct csa_settings {
1221	u8 cs_count;
1222	u8 block_tx;
1223
1224	struct hostapd_freq_params freq_params;
1225	struct beacon_data beacon_csa;
1226	struct beacon_data beacon_after;
1227
1228	u16 counter_offset_beacon;
1229	u16 counter_offset_presp;
1230};
1231
1232/**
1233 * struct wpa_driver_ops - Driver interface API definition
1234 *
1235 * This structure defines the API that each driver interface needs to implement
1236 * for core wpa_supplicant code. All driver specific functionality is captured
1237 * in this wrapper.
1238 */
1239struct wpa_driver_ops {
1240	/** Name of the driver interface */
1241	const char *name;
1242	/** One line description of the driver interface */
1243	const char *desc;
1244
1245	/**
1246	 * get_bssid - Get the current BSSID
1247	 * @priv: private driver interface data
1248	 * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
1249	 *
1250	 * Returns: 0 on success, -1 on failure
1251	 *
1252	 * Query kernel driver for the current BSSID and copy it to bssid.
1253	 * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
1254	 * associated.
1255	 */
1256	int (*get_bssid)(void *priv, u8 *bssid);
1257
1258	/**
1259	 * get_ssid - Get the current SSID
1260	 * @priv: private driver interface data
1261	 * @ssid: buffer for SSID (at least 32 bytes)
1262	 *
1263	 * Returns: Length of the SSID on success, -1 on failure
1264	 *
1265	 * Query kernel driver for the current SSID and copy it to ssid.
1266	 * Returning zero is recommended if the STA is not associated.
1267	 *
1268	 * Note: SSID is an array of octets, i.e., it is not nul terminated and
1269	 * can, at least in theory, contain control characters (including nul)
1270	 * and as such, should be processed as binary data, not a printable
1271	 * string.
1272	 */
1273	int (*get_ssid)(void *priv, u8 *ssid);
1274
1275	/**
1276	 * set_key - Configure encryption key
1277	 * @ifname: Interface name (for multi-SSID/VLAN support)
1278	 * @priv: private driver interface data
1279	 * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
1280	 *	%WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK,
1281	 *	%WPA_ALG_GCMP, %WPA_ALG_GCMP_256, %WPA_ALG_CCMP_256,
1282	 *	%WPA_ALG_BIP_GMAC_128, %WPA_ALG_BIP_GMAC_256,
1283	 *	%WPA_ALG_BIP_CMAC_256);
1284	 *	%WPA_ALG_NONE clears the key.
1285	 * @addr: Address of the peer STA (BSSID of the current AP when setting
1286	 *	pairwise key in station mode), ff:ff:ff:ff:ff:ff for
1287	 *	broadcast keys, %NULL for default keys that are used both for
1288	 *	broadcast and unicast; when clearing keys, %NULL is used to
1289	 *	indicate that both the broadcast-only and default key of the
1290	 *	specified key index is to be cleared
1291	 * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
1292	 *	IGTK
1293	 * @set_tx: configure this key as the default Tx key (only used when
1294	 *	driver does not support separate unicast/individual key
1295	 * @seq: sequence number/packet number, seq_len octets, the next
1296	 *	packet number to be used for in replay protection; configured
1297	 *	for Rx keys (in most cases, this is only used with broadcast
1298	 *	keys and set to zero for unicast keys); %NULL if not set
1299	 * @seq_len: length of the seq, depends on the algorithm:
1300	 *	TKIP: 6 octets, CCMP/GCMP: 6 octets, IGTK: 6 octets
1301	 * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
1302	 *	8-byte Rx Mic Key
1303	 * @key_len: length of the key buffer in octets (WEP: 5 or 13,
1304	 *	TKIP: 32, CCMP/GCMP: 16, IGTK: 16)
1305	 *
1306	 * Returns: 0 on success, -1 on failure
1307	 *
1308	 * Configure the given key for the kernel driver. If the driver
1309	 * supports separate individual keys (4 default keys + 1 individual),
1310	 * addr can be used to determine whether the key is default or
1311	 * individual. If only 4 keys are supported, the default key with key
1312	 * index 0 is used as the individual key. STA must be configured to use
1313	 * it as the default Tx key (set_tx is set) and accept Rx for all the
1314	 * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
1315	 * broadcast keys, so key index 0 is available for this kind of
1316	 * configuration.
1317	 *
1318	 * Please note that TKIP keys include separate TX and RX MIC keys and
1319	 * some drivers may expect them in different order than wpa_supplicant
1320	 * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
1321	 * will trigger Michael MIC errors. This can be fixed by changing the
1322	 * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
1323	 * in driver_*.c set_key() implementation, see driver_ndis.c for an
1324	 * example on how this can be done.
1325	 */
1326	int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
1327		       const u8 *addr, int key_idx, int set_tx,
1328		       const u8 *seq, size_t seq_len,
1329		       const u8 *key, size_t key_len);
1330
1331	/**
1332	 * init - Initialize driver interface
1333	 * @ctx: context to be used when calling wpa_supplicant functions,
1334	 * e.g., wpa_supplicant_event()
1335	 * @ifname: interface name, e.g., wlan0
1336	 *
1337	 * Returns: Pointer to private data, %NULL on failure
1338	 *
1339	 * Initialize driver interface, including event processing for kernel
1340	 * driver events (e.g., associated, scan results, Michael MIC failure).
1341	 * This function can allocate a private configuration data area for
1342	 * @ctx, file descriptor, interface name, etc. information that may be
1343	 * needed in future driver operations. If this is not used, non-NULL
1344	 * value will need to be returned because %NULL is used to indicate
1345	 * failure. The returned value will be used as 'void *priv' data for
1346	 * all other driver_ops functions.
1347	 *
1348	 * The main event loop (eloop.c) of wpa_supplicant can be used to
1349	 * register callback for read sockets (eloop_register_read_sock()).
1350	 *
1351	 * See below for more information about events and
1352	 * wpa_supplicant_event() function.
1353	 */
1354	void * (*init)(void *ctx, const char *ifname);
1355
1356	/**
1357	 * deinit - Deinitialize driver interface
1358	 * @priv: private driver interface data from init()
1359	 *
1360	 * Shut down driver interface and processing of driver events. Free
1361	 * private data buffer if one was allocated in init() handler.
1362	 */
1363	void (*deinit)(void *priv);
1364
1365	/**
1366	 * set_param - Set driver configuration parameters
1367	 * @priv: private driver interface data from init()
1368	 * @param: driver specific configuration parameters
1369	 *
1370	 * Returns: 0 on success, -1 on failure
1371	 *
1372	 * Optional handler for notifying driver interface about configuration
1373	 * parameters (driver_param).
1374	 */
1375	int (*set_param)(void *priv, const char *param);
1376
1377	/**
1378	 * set_countermeasures - Enable/disable TKIP countermeasures
1379	 * @priv: private driver interface data
1380	 * @enabled: 1 = countermeasures enabled, 0 = disabled
1381	 *
1382	 * Returns: 0 on success, -1 on failure
1383	 *
1384	 * Configure TKIP countermeasures. When these are enabled, the driver
1385	 * should drop all received and queued frames that are using TKIP.
1386	 */
1387	int (*set_countermeasures)(void *priv, int enabled);
1388
1389	/**
1390	 * deauthenticate - Request driver to deauthenticate
1391	 * @priv: private driver interface data
1392	 * @addr: peer address (BSSID of the AP)
1393	 * @reason_code: 16-bit reason code to be sent in the deauthentication
1394	 *	frame
1395	 *
1396	 * Returns: 0 on success, -1 on failure
1397	 */
1398	int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
1399
1400	/**
1401	 * associate - Request driver to associate
1402	 * @priv: private driver interface data
1403	 * @params: association parameters
1404	 *
1405	 * Returns: 0 on success, -1 on failure
1406	 */
1407	int (*associate)(void *priv,
1408			 struct wpa_driver_associate_params *params);
1409
1410	/**
1411	 * add_pmkid - Add PMKSA cache entry to the driver
1412	 * @priv: private driver interface data
1413	 * @bssid: BSSID for the PMKSA cache entry
1414	 * @pmkid: PMKID for the PMKSA cache entry
1415	 *
1416	 * Returns: 0 on success, -1 on failure
1417	 *
1418	 * This function is called when a new PMK is received, as a result of
1419	 * either normal authentication or RSN pre-authentication.
1420	 *
1421	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1422	 * associate(), add_pmkid() can be used to add new PMKSA cache entries
1423	 * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
1424	 * driver_ops function does not need to be implemented. Likewise, if
1425	 * the driver does not support WPA, this function is not needed.
1426	 */
1427	int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
1428
1429	/**
1430	 * remove_pmkid - Remove PMKSA cache entry to the driver
1431	 * @priv: private driver interface data
1432	 * @bssid: BSSID for the PMKSA cache entry
1433	 * @pmkid: PMKID for the PMKSA cache entry
1434	 *
1435	 * Returns: 0 on success, -1 on failure
1436	 *
1437	 * This function is called when the supplicant drops a PMKSA cache
1438	 * entry for any reason.
1439	 *
1440	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1441	 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
1442	 * between the driver and wpa_supplicant. If the driver uses wpa_ie
1443	 * from wpa_supplicant, this driver_ops function does not need to be
1444	 * implemented. Likewise, if the driver does not support WPA, this
1445	 * function is not needed.
1446	 */
1447	int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
1448
1449	/**
1450	 * flush_pmkid - Flush PMKSA cache
1451	 * @priv: private driver interface data
1452	 *
1453	 * Returns: 0 on success, -1 on failure
1454	 *
1455	 * This function is called when the supplicant drops all PMKSA cache
1456	 * entries for any reason.
1457	 *
1458	 * If the driver generates RSN IE, i.e., it does not use wpa_ie in
1459	 * associate(), remove_pmkid() can be used to synchronize PMKSA caches
1460	 * between the driver and wpa_supplicant. If the driver uses wpa_ie
1461	 * from wpa_supplicant, this driver_ops function does not need to be
1462	 * implemented. Likewise, if the driver does not support WPA, this
1463	 * function is not needed.
1464	 */
1465	int (*flush_pmkid)(void *priv);
1466
1467	/**
1468	 * get_capa - Get driver capabilities
1469	 * @priv: private driver interface data
1470	 *
1471	 * Returns: 0 on success, -1 on failure
1472	 *
1473	 * Get driver/firmware/hardware capabilities.
1474	 */
1475	int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
1476
1477	/**
1478	 * poll - Poll driver for association information
1479	 * @priv: private driver interface data
1480	 *
1481	 * This is an option callback that can be used when the driver does not
1482	 * provide event mechanism for association events. This is called when
1483	 * receiving WPA EAPOL-Key messages that require association
1484	 * information. The driver interface is supposed to generate associnfo
1485	 * event before returning from this callback function. In addition, the
1486	 * driver interface should generate an association event after having
1487	 * sent out associnfo.
1488	 */
1489	void (*poll)(void *priv);
1490
1491	/**
1492	 * get_ifname - Get interface name
1493	 * @priv: private driver interface data
1494	 *
1495	 * Returns: Pointer to the interface name. This can differ from the
1496	 * interface name used in init() call. Init() is called first.
1497	 *
1498	 * This optional function can be used to allow the driver interface to
1499	 * replace the interface name with something else, e.g., based on an
1500	 * interface mapping from a more descriptive name.
1501	 */
1502	const char * (*get_ifname)(void *priv);
1503
1504	/**
1505	 * get_mac_addr - Get own MAC address
1506	 * @priv: private driver interface data
1507	 *
1508	 * Returns: Pointer to own MAC address or %NULL on failure
1509	 *
1510	 * This optional function can be used to get the own MAC address of the
1511	 * device from the driver interface code. This is only needed if the
1512	 * l2_packet implementation for the OS does not provide easy access to
1513	 * a MAC address. */
1514	const u8 * (*get_mac_addr)(void *priv);
1515
1516	/**
1517	 * send_eapol - Optional function for sending EAPOL packets
1518	 * @priv: private driver interface data
1519	 * @dest: Destination MAC address
1520	 * @proto: Ethertype
1521	 * @data: EAPOL packet starting with IEEE 802.1X header
1522	 * @data_len: Size of the EAPOL packet
1523	 *
1524	 * Returns: 0 on success, -1 on failure
1525	 *
1526	 * This optional function can be used to override l2_packet operations
1527	 * with driver specific functionality. If this function pointer is set,
1528	 * l2_packet module is not used at all and the driver interface code is
1529	 * responsible for receiving and sending all EAPOL packets. The
1530	 * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
1531	 * event. The driver interface is required to implement get_mac_addr()
1532	 * handler if send_eapol() is used.
1533	 */
1534	int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
1535			  const u8 *data, size_t data_len);
1536
1537	/**
1538	 * set_operstate - Sets device operating state to DORMANT or UP
1539	 * @priv: private driver interface data
1540	 * @state: 0 = dormant, 1 = up
1541	 * Returns: 0 on success, -1 on failure
1542	 *
1543	 * This is an optional function that can be used on operating systems
1544	 * that support a concept of controlling network device state from user
1545	 * space applications. This function, if set, gets called with
1546	 * state = 1 when authentication has been completed and with state = 0
1547	 * when connection is lost.
1548	 */
1549	int (*set_operstate)(void *priv, int state);
1550
1551	/**
1552	 * mlme_setprotection - MLME-SETPROTECTION.request primitive
1553	 * @priv: Private driver interface data
1554	 * @addr: Address of the station for which to set protection (may be
1555	 * %NULL for group keys)
1556	 * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
1557	 * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
1558	 * Returns: 0 on success, -1 on failure
1559	 *
1560	 * This is an optional function that can be used to set the driver to
1561	 * require protection for Tx and/or Rx frames. This uses the layer
1562	 * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
1563	 * (MLME-SETPROTECTION.request). Many drivers do not use explicit
1564	 * set protection operation; instead, they set protection implicitly
1565	 * based on configured keys.
1566	 */
1567	int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
1568				  int key_type);
1569
1570	/**
1571	 * get_hw_feature_data - Get hardware support data (channels and rates)
1572	 * @priv: Private driver interface data
1573	 * @num_modes: Variable for returning the number of returned modes
1574	 * flags: Variable for returning hardware feature flags
1575	 * Returns: Pointer to allocated hardware data on success or %NULL on
1576	 * failure. Caller is responsible for freeing this.
1577	 */
1578	struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
1579							 u16 *num_modes,
1580							 u16 *flags);
1581
1582	/**
1583	 * send_mlme - Send management frame from MLME
1584	 * @priv: Private driver interface data
1585	 * @data: IEEE 802.11 management frame with IEEE 802.11 header
1586	 * @data_len: Size of the management frame
1587	 * @noack: Do not wait for this frame to be acked (disable retries)
1588	 * Returns: 0 on success, -1 on failure
1589	 */
1590	int (*send_mlme)(void *priv, const u8 *data, size_t data_len,
1591			 int noack);
1592
1593	/**
1594	 * update_ft_ies - Update FT (IEEE 802.11r) IEs
1595	 * @priv: Private driver interface data
1596	 * @md: Mobility domain (2 octets) (also included inside ies)
1597	 * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
1598	 * @ies_len: Length of FT IEs in bytes
1599	 * Returns: 0 on success, -1 on failure
1600	 *
1601	 * The supplicant uses this callback to let the driver know that keying
1602	 * material for FT is available and that the driver can use the
1603	 * provided IEs in the next message in FT authentication sequence.
1604	 *
1605	 * This function is only needed for driver that support IEEE 802.11r
1606	 * (Fast BSS Transition).
1607	 */
1608	int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
1609			     size_t ies_len);
1610
1611	/**
1612	 * send_ft_action - Send FT Action frame (IEEE 802.11r)
1613	 * @priv: Private driver interface data
1614	 * @action: Action field value
1615	 * @target_ap: Target AP address
1616	 * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
1617	 * @ies_len: Length of FT IEs in bytes
1618	 * Returns: 0 on success, -1 on failure
1619	 *
1620	 * The supplicant uses this callback to request the driver to transmit
1621	 * an FT Action frame (action category 6) for over-the-DS fast BSS
1622	 * transition.
1623	 */
1624	int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
1625			      const u8 *ies, size_t ies_len);
1626
1627	/**
1628	 * get_scan_results2 - Fetch the latest scan results
1629	 * @priv: private driver interface data
1630	 *
1631	 * Returns: Allocated buffer of scan results (caller is responsible for
1632	 * freeing the data structure) on success, NULL on failure
1633	 */
1634	 struct wpa_scan_results * (*get_scan_results2)(void *priv);
1635
1636	/**
1637	 * set_country - Set country
1638	 * @priv: Private driver interface data
1639	 * @alpha2: country to which to switch to
1640	 * Returns: 0 on success, -1 on failure
1641	 *
1642	 * This function is for drivers which support some form
1643	 * of setting a regulatory domain.
1644	 */
1645	int (*set_country)(void *priv, const char *alpha2);
1646
1647	/**
1648	 * get_country - Get country
1649	 * @priv: Private driver interface data
1650	 * @alpha2: Buffer for returning country code (at least 3 octets)
1651	 * Returns: 0 on success, -1 on failure
1652	 */
1653	int (*get_country)(void *priv, char *alpha2);
1654
1655	/**
1656	 * global_init - Global driver initialization
1657	 * Returns: Pointer to private data (global), %NULL on failure
1658	 *
1659	 * This optional function is called to initialize the driver wrapper
1660	 * for global data, i.e., data that applies to all interfaces. If this
1661	 * function is implemented, global_deinit() will also need to be
1662	 * implemented to free the private data. The driver will also likely
1663	 * use init2() function instead of init() to get the pointer to global
1664	 * data available to per-interface initializer.
1665	 */
1666	void * (*global_init)(void);
1667
1668	/**
1669	 * global_deinit - Global driver deinitialization
1670	 * @priv: private driver global data from global_init()
1671	 *
1672	 * Terminate any global driver related functionality and free the
1673	 * global data structure.
1674	 */
1675	void (*global_deinit)(void *priv);
1676
1677	/**
1678	 * init2 - Initialize driver interface (with global data)
1679	 * @ctx: context to be used when calling wpa_supplicant functions,
1680	 * e.g., wpa_supplicant_event()
1681	 * @ifname: interface name, e.g., wlan0
1682	 * @global_priv: private driver global data from global_init()
1683	 * Returns: Pointer to private data, %NULL on failure
1684	 *
1685	 * This function can be used instead of init() if the driver wrapper
1686	 * uses global data.
1687	 */
1688	void * (*init2)(void *ctx, const char *ifname, void *global_priv);
1689
1690	/**
1691	 * get_interfaces - Get information about available interfaces
1692	 * @global_priv: private driver global data from global_init()
1693	 * Returns: Allocated buffer of interface information (caller is
1694	 * responsible for freeing the data structure) on success, NULL on
1695	 * failure
1696	 */
1697	struct wpa_interface_info * (*get_interfaces)(void *global_priv);
1698
1699	/**
1700	 * scan2 - Request the driver to initiate scan
1701	 * @priv: private driver interface data
1702	 * @params: Scan parameters
1703	 *
1704	 * Returns: 0 on success, -1 on failure
1705	 *
1706	 * Once the scan results are ready, the driver should report scan
1707	 * results event for wpa_supplicant which will eventually request the
1708	 * results with wpa_driver_get_scan_results2().
1709	 */
1710	int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
1711
1712	/**
1713	 * authenticate - Request driver to authenticate
1714	 * @priv: private driver interface data
1715	 * @params: authentication parameters
1716	 * Returns: 0 on success, -1 on failure
1717	 *
1718	 * This is an optional function that can be used with drivers that
1719	 * support separate authentication and association steps, i.e., when
1720	 * wpa_supplicant can act as the SME. If not implemented, associate()
1721	 * function is expected to take care of IEEE 802.11 authentication,
1722	 * too.
1723	 */
1724	int (*authenticate)(void *priv,
1725			    struct wpa_driver_auth_params *params);
1726
1727	/**
1728	 * set_ap - Set Beacon and Probe Response information for AP mode
1729	 * @priv: Private driver interface data
1730	 * @params: Parameters to use in AP mode
1731	 *
1732	 * This function is used to configure Beacon template and/or extra IEs
1733	 * to add for Beacon and Probe Response frames for the driver in
1734	 * AP mode. The driver is responsible for building the full Beacon
1735	 * frame by concatenating the head part with TIM IE generated by the
1736	 * driver/firmware and finishing with the tail part. Depending on the
1737	 * driver architectue, this can be done either by using the full
1738	 * template or the set of additional IEs (e.g., WPS and P2P IE).
1739	 * Similarly, Probe Response processing depends on the driver design.
1740	 * If the driver (or firmware) takes care of replying to Probe Request
1741	 * frames, the extra IEs provided here needs to be added to the Probe
1742	 * Response frames.
1743	 *
1744	 * Returns: 0 on success, -1 on failure
1745	 */
1746	int (*set_ap)(void *priv, struct wpa_driver_ap_params *params);
1747
1748	/**
1749	 * set_acl - Set ACL in AP mode
1750	 * @priv: Private driver interface data
1751	 * @params: Parameters to configure ACL
1752	 * Returns: 0 on success, -1 on failure
1753	 *
1754	 * This is used only for the drivers which support MAC address ACL.
1755	 */
1756	int (*set_acl)(void *priv, struct hostapd_acl_params *params);
1757
1758	/**
1759	 * hapd_init - Initialize driver interface (hostapd only)
1760	 * @hapd: Pointer to hostapd context
1761	 * @params: Configuration for the driver wrapper
1762	 * Returns: Pointer to private data, %NULL on failure
1763	 *
1764	 * This function is used instead of init() or init2() when the driver
1765	 * wrapper is used with hostapd.
1766	 */
1767	void * (*hapd_init)(struct hostapd_data *hapd,
1768			    struct wpa_init_params *params);
1769
1770	/**
1771	 * hapd_deinit - Deinitialize driver interface (hostapd only)
1772	 * @priv: Private driver interface data from hapd_init()
1773	 */
1774	void (*hapd_deinit)(void *priv);
1775
1776	/**
1777	 * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
1778	 * @priv: Private driver interface data
1779	 * @params: BSS parameters
1780	 * Returns: 0 on success, -1 on failure
1781	 *
1782	 * This is an optional function to configure the kernel driver to
1783	 * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
1784	 * can be left undefined (set to %NULL) if IEEE 802.1X support is
1785	 * always enabled and the driver uses set_ap() to set WPA/RSN IE
1786	 * for Beacon frames.
1787	 *
1788	 * DEPRECATED - use set_ap() instead
1789	 */
1790	int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
1791
1792	/**
1793	 * set_privacy - Enable/disable privacy (AP only)
1794	 * @priv: Private driver interface data
1795	 * @enabled: 1 = privacy enabled, 0 = disabled
1796	 * Returns: 0 on success, -1 on failure
1797	 *
1798	 * This is an optional function to configure privacy field in the
1799	 * kernel driver for Beacon frames. This can be left undefined (set to
1800	 * %NULL) if the driver uses the Beacon template from set_ap().
1801	 *
1802	 * DEPRECATED - use set_ap() instead
1803	 */
1804	int (*set_privacy)(void *priv, int enabled);
1805
1806	/**
1807	 * get_seqnum - Fetch the current TSC/packet number (AP only)
1808	 * @ifname: The interface name (main or virtual)
1809	 * @priv: Private driver interface data
1810	 * @addr: MAC address of the station or %NULL for group keys
1811	 * @idx: Key index
1812	 * @seq: Buffer for returning the latest used TSC/packet number
1813	 * Returns: 0 on success, -1 on failure
1814	 *
1815	 * This function is used to fetch the last used TSC/packet number for
1816	 * a TKIP, CCMP, GCMP, or BIP/IGTK key. It is mainly used with group
1817	 * keys, so there is no strict requirement on implementing support for
1818	 * unicast keys (i.e., addr != %NULL).
1819	 */
1820	int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
1821			  int idx, u8 *seq);
1822
1823	/**
1824	 * flush - Flush all association stations (AP only)
1825	 * @priv: Private driver interface data
1826	 * Returns: 0 on success, -1 on failure
1827	 *
1828	 * This function requests the driver to disassociate all associated
1829	 * stations. This function does not need to be implemented if the
1830	 * driver does not process association frames internally.
1831	 */
1832	int (*flush)(void *priv);
1833
1834	/**
1835	 * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
1836	 * @priv: Private driver interface data
1837	 * @elem: Information elements
1838	 * @elem_len: Length of the elem buffer in octets
1839	 * Returns: 0 on success, -1 on failure
1840	 *
1841	 * This is an optional function to add information elements in the
1842	 * kernel driver for Beacon and Probe Response frames. This can be left
1843	 * undefined (set to %NULL) if the driver uses the Beacon template from
1844	 * set_ap().
1845	 *
1846	 * DEPRECATED - use set_ap() instead
1847	 */
1848	int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
1849
1850	/**
1851	 * read_sta_data - Fetch station data
1852	 * @priv: Private driver interface data
1853	 * @data: Buffer for returning station information
1854	 * @addr: MAC address of the station
1855	 * Returns: 0 on success, -1 on failure
1856	 */
1857	int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
1858			     const u8 *addr);
1859
1860	/**
1861	 * hapd_send_eapol - Send an EAPOL packet (AP only)
1862	 * @priv: private driver interface data
1863	 * @addr: Destination MAC address
1864	 * @data: EAPOL packet starting with IEEE 802.1X header
1865	 * @data_len: Length of the EAPOL packet in octets
1866	 * @encrypt: Whether the frame should be encrypted
1867	 * @own_addr: Source MAC address
1868	 * @flags: WPA_STA_* flags for the destination station
1869	 *
1870	 * Returns: 0 on success, -1 on failure
1871	 */
1872	int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
1873			       size_t data_len, int encrypt,
1874			       const u8 *own_addr, u32 flags);
1875
1876	/**
1877	 * sta_deauth - Deauthenticate a station (AP only)
1878	 * @priv: Private driver interface data
1879	 * @own_addr: Source address and BSSID for the Deauthentication frame
1880	 * @addr: MAC address of the station to deauthenticate
1881	 * @reason: Reason code for the Deauthentiation frame
1882	 * Returns: 0 on success, -1 on failure
1883	 *
1884	 * This function requests a specific station to be deauthenticated and
1885	 * a Deauthentication frame to be sent to it.
1886	 */
1887	int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
1888			  int reason);
1889
1890	/**
1891	 * sta_disassoc - Disassociate a station (AP only)
1892	 * @priv: Private driver interface data
1893	 * @own_addr: Source address and BSSID for the Disassociation frame
1894	 * @addr: MAC address of the station to disassociate
1895	 * @reason: Reason code for the Disassociation frame
1896	 * Returns: 0 on success, -1 on failure
1897	 *
1898	 * This function requests a specific station to be disassociated and
1899	 * a Disassociation frame to be sent to it.
1900	 */
1901	int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
1902			    int reason);
1903
1904	/**
1905	 * sta_remove - Remove a station entry (AP only)
1906	 * @priv: Private driver interface data
1907	 * @addr: MAC address of the station to be removed
1908	 * Returns: 0 on success, -1 on failure
1909	 */
1910	int (*sta_remove)(void *priv, const u8 *addr);
1911
1912	/**
1913	 * hapd_get_ssid - Get the current SSID (AP only)
1914	 * @priv: Private driver interface data
1915	 * @buf: Buffer for returning the SSID
1916	 * @len: Maximum length of the buffer
1917	 * Returns: Length of the SSID on success, -1 on failure
1918	 *
1919	 * This function need not be implemented if the driver uses Beacon
1920	 * template from set_ap() and does not reply to Probe Request frames.
1921	 */
1922	int (*hapd_get_ssid)(void *priv, u8 *buf, int len);
1923
1924	/**
1925	 * hapd_set_ssid - Set SSID (AP only)
1926	 * @priv: Private driver interface data
1927	 * @buf: SSID
1928	 * @len: Length of the SSID in octets
1929	 * Returns: 0 on success, -1 on failure
1930	 *
1931	 * DEPRECATED - use set_ap() instead
1932	 */
1933	int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
1934
1935	/**
1936	 * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
1937	 * @priv: Private driver interface data
1938	 * @enabled: 1 = countermeasures enabled, 0 = disabled
1939	 * Returns: 0 on success, -1 on failure
1940	 *
1941	 * This need not be implemented if the driver does not take care of
1942	 * association processing.
1943	 */
1944	int (*hapd_set_countermeasures)(void *priv, int enabled);
1945
1946	/**
1947	 * sta_add - Add a station entry
1948	 * @priv: Private driver interface data
1949	 * @params: Station parameters
1950	 * Returns: 0 on success, -1 on failure
1951	 *
1952	 * This function is used to add a station entry to the driver once the
1953	 * station has completed association. This is only used if the driver
1954	 * does not take care of association processing.
1955	 *
1956	 * With TDLS, this function is also used to add or set (params->set 1)
1957	 * TDLS peer entries.
1958	 */
1959	int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
1960
1961	/**
1962	 * get_inact_sec - Get station inactivity duration (AP only)
1963	 * @priv: Private driver interface data
1964	 * @addr: Station address
1965	 * Returns: Number of seconds station has been inactive, -1 on failure
1966	 */
1967	int (*get_inact_sec)(void *priv, const u8 *addr);
1968
1969	/**
1970	 * sta_clear_stats - Clear station statistics (AP only)
1971	 * @priv: Private driver interface data
1972	 * @addr: Station address
1973	 * Returns: 0 on success, -1 on failure
1974	 */
1975	int (*sta_clear_stats)(void *priv, const u8 *addr);
1976
1977	/**
1978	 * set_freq - Set channel/frequency (AP only)
1979	 * @priv: Private driver interface data
1980	 * @freq: Channel parameters
1981	 * Returns: 0 on success, -1 on failure
1982	 */
1983	int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
1984
1985	/**
1986	 * set_rts - Set RTS threshold
1987	 * @priv: Private driver interface data
1988	 * @rts: RTS threshold in octets
1989	 * Returns: 0 on success, -1 on failure
1990	 */
1991	int (*set_rts)(void *priv, int rts);
1992
1993	/**
1994	 * set_frag - Set fragmentation threshold
1995	 * @priv: Private driver interface data
1996	 * @frag: Fragmentation threshold in octets
1997	 * Returns: 0 on success, -1 on failure
1998	 */
1999	int (*set_frag)(void *priv, int frag);
2000
2001	/**
2002	 * sta_set_flags - Set station flags (AP only)
2003	 * @priv: Private driver interface data
2004	 * @addr: Station address
2005	 * @total_flags: Bitmap of all WPA_STA_* flags currently set
2006	 * @flags_or: Bitmap of WPA_STA_* flags to add
2007	 * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
2008	 * Returns: 0 on success, -1 on failure
2009	 */
2010	int (*sta_set_flags)(void *priv, const u8 *addr,
2011			     int total_flags, int flags_or, int flags_and);
2012
2013	/**
2014	 * set_tx_queue_params - Set TX queue parameters
2015	 * @priv: Private driver interface data
2016	 * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
2017	 * @aifs: AIFS
2018	 * @cw_min: cwMin
2019	 * @cw_max: cwMax
2020	 * @burst_time: Maximum length for bursting in 0.1 msec units
2021	 */
2022	int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
2023				   int cw_max, int burst_time);
2024
2025	/**
2026	 * if_add - Add a virtual interface
2027	 * @priv: Private driver interface data
2028	 * @type: Interface type
2029	 * @ifname: Interface name for the new virtual interface
2030	 * @addr: Local address to use for the interface or %NULL to use the
2031	 *	parent interface address
2032	 * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
2033	 * @drv_priv: Pointer for overwriting the driver context or %NULL if
2034	 *	not allowed (applies only to %WPA_IF_AP_BSS type)
2035	 * @force_ifname: Buffer for returning an interface name that the
2036	 *	driver ended up using if it differs from the requested ifname
2037	 * @if_addr: Buffer for returning the allocated interface address
2038	 *	(this may differ from the requested addr if the driver cannot
2039	 *	change interface address)
2040	 * @bridge: Bridge interface to use or %NULL if no bridge configured
2041	 * @use_existing: Whether to allow existing interface to be used
2042	 * Returns: 0 on success, -1 on failure
2043	 */
2044	int (*if_add)(void *priv, enum wpa_driver_if_type type,
2045		      const char *ifname, const u8 *addr, void *bss_ctx,
2046		      void **drv_priv, char *force_ifname, u8 *if_addr,
2047		      const char *bridge, int use_existing);
2048
2049	/**
2050	 * if_remove - Remove a virtual interface
2051	 * @priv: Private driver interface data
2052	 * @type: Interface type
2053	 * @ifname: Interface name of the virtual interface to be removed
2054	 * Returns: 0 on success, -1 on failure
2055	 */
2056	int (*if_remove)(void *priv, enum wpa_driver_if_type type,
2057			 const char *ifname);
2058
2059	/**
2060	 * set_sta_vlan - Bind a station into a specific interface (AP only)
2061	 * @priv: Private driver interface data
2062	 * @ifname: Interface (main or virtual BSS or VLAN)
2063	 * @addr: MAC address of the associated station
2064	 * @vlan_id: VLAN ID
2065	 * Returns: 0 on success, -1 on failure
2066	 *
2067	 * This function is used to bind a station to a specific virtual
2068	 * interface. It is only used if when virtual interfaces are supported,
2069	 * e.g., to assign stations to different VLAN interfaces based on
2070	 * information from a RADIUS server. This allows separate broadcast
2071	 * domains to be used with a single BSS.
2072	 */
2073	int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
2074			    int vlan_id);
2075
2076	/**
2077	 * commit - Optional commit changes handler (AP only)
2078	 * @priv: driver private data
2079	 * Returns: 0 on success, -1 on failure
2080	 *
2081	 * This optional handler function can be registered if the driver
2082	 * interface implementation needs to commit changes (e.g., by setting
2083	 * network interface up) at the end of initial configuration. If set,
2084	 * this handler will be called after initial setup has been completed.
2085	 */
2086	int (*commit)(void *priv);
2087
2088	/**
2089	 * send_ether - Send an ethernet packet (AP only)
2090	 * @priv: private driver interface data
2091	 * @dst: Destination MAC address
2092	 * @src: Source MAC address
2093	 * @proto: Ethertype
2094	 * @data: EAPOL packet starting with IEEE 802.1X header
2095	 * @data_len: Length of the EAPOL packet in octets
2096	 * Returns: 0 on success, -1 on failure
2097	 */
2098	int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
2099			  const u8 *data, size_t data_len);
2100
2101	/**
2102	 * set_radius_acl_auth - Notification of RADIUS ACL change
2103	 * @priv: Private driver interface data
2104	 * @mac: MAC address of the station
2105	 * @accepted: Whether the station was accepted
2106	 * @session_timeout: Session timeout for the station
2107	 * Returns: 0 on success, -1 on failure
2108	 */
2109	int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
2110				   u32 session_timeout);
2111
2112	/**
2113	 * set_radius_acl_expire - Notification of RADIUS ACL expiration
2114	 * @priv: Private driver interface data
2115	 * @mac: MAC address of the station
2116	 * Returns: 0 on success, -1 on failure
2117	 */
2118	int (*set_radius_acl_expire)(void *priv, const u8 *mac);
2119
2120	/**
2121	 * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
2122	 * @priv: Private driver interface data
2123	 * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
2124	 * @proberesp: WPS IE(s) for Probe Response frames or %NULL to remove
2125	 *	extra IE(s)
2126	 * @assocresp: WPS IE(s) for (Re)Association Response frames or %NULL
2127	 *	to remove extra IE(s)
2128	 * Returns: 0 on success, -1 on failure
2129	 *
2130	 * This is an optional function to add WPS IE in the kernel driver for
2131	 * Beacon and Probe Response frames. This can be left undefined (set
2132	 * to %NULL) if the driver uses the Beacon template from set_ap()
2133	 * and does not process Probe Request frames. If the driver takes care
2134	 * of (Re)Association frame processing, the assocresp buffer includes
2135	 * WPS IE(s) that need to be added to (Re)Association Response frames
2136	 * whenever a (Re)Association Request frame indicated use of WPS.
2137	 *
2138	 * This will also be used to add P2P IE(s) into Beacon/Probe Response
2139	 * frames when operating as a GO. The driver is responsible for adding
2140	 * timing related attributes (e.g., NoA) in addition to the IEs
2141	 * included here by appending them after these buffers. This call is
2142	 * also used to provide Probe Response IEs for P2P Listen state
2143	 * operations for drivers that generate the Probe Response frames
2144	 * internally.
2145	 *
2146	 * DEPRECATED - use set_ap() instead
2147	 */
2148	int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
2149			     const struct wpabuf *proberesp,
2150			     const struct wpabuf *assocresp);
2151
2152	/**
2153	 * set_supp_port - Set IEEE 802.1X Supplicant Port status
2154	 * @priv: Private driver interface data
2155	 * @authorized: Whether the port is authorized
2156	 * Returns: 0 on success, -1 on failure
2157	 */
2158	int (*set_supp_port)(void *priv, int authorized);
2159
2160	/**
2161	 * set_wds_sta - Bind a station into a 4-address WDS (AP only)
2162	 * @priv: Private driver interface data
2163	 * @addr: MAC address of the associated station
2164	 * @aid: Association ID
2165	 * @val: 1 = bind to 4-address WDS; 0 = unbind
2166	 * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
2167	 *	to indicate that bridge is not to be used
2168	 * @ifname_wds: Buffer to return the interface name for the new WDS
2169	 *	station or %NULL to indicate name is not returned.
2170	 * Returns: 0 on success, -1 on failure
2171	 */
2172	int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
2173	                   const char *bridge_ifname, char *ifname_wds);
2174
2175	/**
2176	 * send_action - Transmit an Action frame
2177	 * @priv: Private driver interface data
2178	 * @freq: Frequency (in MHz) of the channel
2179	 * @wait: Time to wait off-channel for a response (in ms), or zero
2180	 * @dst: Destination MAC address (Address 1)
2181	 * @src: Source MAC address (Address 2)
2182	 * @bssid: BSSID (Address 3)
2183	 * @data: Frame body
2184	 * @data_len: data length in octets
2185	 @ @no_cck: Whether CCK rates must not be used to transmit this frame
2186	 * Returns: 0 on success, -1 on failure
2187	 *
2188	 * This command can be used to request the driver to transmit an action
2189	 * frame to the specified destination.
2190	 *
2191	 * If the %WPA_DRIVER_FLAGS_OFFCHANNEL_TX flag is set, the frame will
2192	 * be transmitted on the given channel and the device will wait for a
2193	 * response on that channel for the given wait time.
2194	 *
2195	 * If the flag is not set, the wait time will be ignored. In this case,
2196	 * if a remain-on-channel duration is in progress, the frame must be
2197	 * transmitted on that channel; alternatively the frame may be sent on
2198	 * the current operational channel (if in associated state in station
2199	 * mode or while operating as an AP.)
2200	 */
2201	int (*send_action)(void *priv, unsigned int freq, unsigned int wait,
2202			   const u8 *dst, const u8 *src, const u8 *bssid,
2203			   const u8 *data, size_t data_len, int no_cck);
2204
2205	/**
2206	 * send_action_cancel_wait - Cancel action frame TX wait
2207	 * @priv: Private driver interface data
2208	 *
2209	 * This command cancels the wait time associated with sending an action
2210	 * frame. It is only available when %WPA_DRIVER_FLAGS_OFFCHANNEL_TX is
2211	 * set in the driver flags.
2212	 */
2213	void (*send_action_cancel_wait)(void *priv);
2214
2215	/**
2216	 * remain_on_channel - Remain awake on a channel
2217	 * @priv: Private driver interface data
2218	 * @freq: Frequency (in MHz) of the channel
2219	 * @duration: Duration in milliseconds
2220	 * Returns: 0 on success, -1 on failure
2221	 *
2222	 * This command is used to request the driver to remain awake on the
2223	 * specified channel for the specified duration and report received
2224	 * Action frames with EVENT_RX_MGMT events. Optionally, received
2225	 * Probe Request frames may also be requested to be reported by calling
2226	 * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
2227	 *
2228	 * The driver may not be at the requested channel when this function
2229	 * returns, i.e., the return code is only indicating whether the
2230	 * request was accepted. The caller will need to wait until the
2231	 * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
2232	 * completed the channel change. This may take some time due to other
2233	 * need for the radio and the caller should be prepared to timing out
2234	 * its wait since there are no guarantees on when this request can be
2235	 * executed.
2236	 */
2237	int (*remain_on_channel)(void *priv, unsigned int freq,
2238				 unsigned int duration);
2239
2240	/**
2241	 * cancel_remain_on_channel - Cancel remain-on-channel operation
2242	 * @priv: Private driver interface data
2243	 *
2244	 * This command can be used to cancel a remain-on-channel operation
2245	 * before its originally requested duration has passed. This could be
2246	 * used, e.g., when remain_on_channel() is used to request extra time
2247	 * to receive a response to an Action frame and the response is
2248	 * received when there is still unneeded time remaining on the
2249	 * remain-on-channel operation.
2250	 */
2251	int (*cancel_remain_on_channel)(void *priv);
2252
2253	/**
2254	 * probe_req_report - Request Probe Request frames to be indicated
2255	 * @priv: Private driver interface data
2256	 * @report: Whether to report received Probe Request frames
2257	 * Returns: 0 on success, -1 on failure (or if not supported)
2258	 *
2259	 * This command can be used to request the driver to indicate when
2260	 * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
2261	 * Since this operation may require extra resources, e.g., due to less
2262	 * optimal hardware/firmware RX filtering, many drivers may disable
2263	 * Probe Request reporting at least in station mode. This command is
2264	 * used to notify the driver when the Probe Request frames need to be
2265	 * reported, e.g., during remain-on-channel operations.
2266	 */
2267	int (*probe_req_report)(void *priv, int report);
2268
2269	/**
2270	 * deinit_ap - Deinitialize AP mode
2271	 * @priv: Private driver interface data
2272	 * Returns: 0 on success, -1 on failure (or if not supported)
2273	 *
2274	 * This optional function can be used to disable AP mode related
2275	 * configuration. If the interface was not dynamically added,
2276	 * change the driver mode to station mode to allow normal station
2277	 * operations like scanning to be completed.
2278	 */
2279	int (*deinit_ap)(void *priv);
2280
2281	/**
2282	 * deinit_p2p_cli - Deinitialize P2P client mode
2283	 * @priv: Private driver interface data
2284	 * Returns: 0 on success, -1 on failure (or if not supported)
2285	 *
2286	 * This optional function can be used to disable P2P client mode. If the
2287	 * interface was not dynamically added, change the interface type back
2288	 * to station mode.
2289	 */
2290	int (*deinit_p2p_cli)(void *priv);
2291
2292	/**
2293	 * suspend - Notification on system suspend/hibernate event
2294	 * @priv: Private driver interface data
2295	 */
2296	void (*suspend)(void *priv);
2297
2298	/**
2299	 * resume - Notification on system resume/thaw event
2300	 * @priv: Private driver interface data
2301	 */
2302	void (*resume)(void *priv);
2303
2304	/**
2305	 * signal_monitor - Set signal monitoring parameters
2306	 * @priv: Private driver interface data
2307	 * @threshold: Threshold value for signal change events; 0 = disabled
2308	 * @hysteresis: Minimum change in signal strength before indicating a
2309	 *	new event
2310	 * Returns: 0 on success, -1 on failure (or if not supported)
2311	 *
2312	 * This function can be used to configure monitoring of signal strength
2313	 * with the current AP. Whenever signal strength drops below the
2314	 * %threshold value or increases above it, EVENT_SIGNAL_CHANGE event
2315	 * should be generated assuming the signal strength has changed at
2316	 * least %hysteresis from the previously indicated signal change event.
2317	 */
2318	int (*signal_monitor)(void *priv, int threshold, int hysteresis);
2319
2320	/**
2321	 * send_frame - Send IEEE 802.11 frame (testing use only)
2322	 * @priv: Private driver interface data
2323	 * @data: IEEE 802.11 frame with IEEE 802.11 header
2324	 * @data_len: Size of the frame
2325	 * @encrypt: Whether to encrypt the frame (if keys are set)
2326	 * Returns: 0 on success, -1 on failure
2327	 *
2328	 * This function is only used for debugging purposes and is not
2329	 * required to be implemented for normal operations.
2330	 */
2331	int (*send_frame)(void *priv, const u8 *data, size_t data_len,
2332			  int encrypt);
2333
2334	/**
2335	 * shared_freq - Get operating frequency of shared interface(s)
2336	 * @priv: Private driver interface data
2337	 * Returns: Operating frequency in MHz, 0 if no shared operation in
2338	 * use, or -1 on failure
2339	 *
2340	 * This command can be used to request the current operating frequency
2341	 * of any virtual interface that shares the same radio to provide
2342	 * information for channel selection for other virtual interfaces.
2343	 */
2344	int (*shared_freq)(void *priv);
2345
2346	/**
2347	 * get_noa - Get current Notice of Absence attribute payload
2348	 * @priv: Private driver interface data
2349	 * @buf: Buffer for returning NoA
2350	 * @buf_len: Buffer length in octets
2351	 * Returns: Number of octets used in buf, 0 to indicate no NoA is being
2352	 * advertized, or -1 on failure
2353	 *
2354	 * This function is used to fetch the current Notice of Absence
2355	 * attribute value from GO.
2356	 */
2357	int (*get_noa)(void *priv, u8 *buf, size_t buf_len);
2358
2359	/**
2360	 * set_noa - Set Notice of Absence parameters for GO (testing)
2361	 * @priv: Private driver interface data
2362	 * @count: Count
2363	 * @start: Start time in ms from next TBTT
2364	 * @duration: Duration in ms
2365	 * Returns: 0 on success or -1 on failure
2366	 *
2367	 * This function is used to set Notice of Absence parameters for GO. It
2368	 * is used only for testing. To disable NoA, all parameters are set to
2369	 * 0.
2370	 */
2371	int (*set_noa)(void *priv, u8 count, int start, int duration);
2372
2373	/**
2374	 * set_p2p_powersave - Set P2P power save options
2375	 * @priv: Private driver interface data
2376	 * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change
2377	 * @opp_ps: 0 = disable, 1 = enable, -1 = no change
2378	 * @ctwindow: 0.. = change (msec), -1 = no change
2379	 * Returns: 0 on success or -1 on failure
2380	 */
2381	int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps,
2382				 int ctwindow);
2383
2384	/**
2385	 * ampdu - Enable/disable aggregation
2386	 * @priv: Private driver interface data
2387	 * @ampdu: 1/0 = enable/disable A-MPDU aggregation
2388	 * Returns: 0 on success or -1 on failure
2389	 */
2390	int (*ampdu)(void *priv, int ampdu);
2391
2392	/**
2393	 * get_radio_name - Get physical radio name for the device
2394	 * @priv: Private driver interface data
2395	 * Returns: Radio name or %NULL if not known
2396	 *
2397	 * The returned data must not be modified by the caller. It is assumed
2398	 * that any interface that has the same radio name as another is
2399	 * sharing the same physical radio. This information can be used to
2400	 * share scan results etc. information between the virtual interfaces
2401	 * to speed up various operations.
2402	 */
2403	const char * (*get_radio_name)(void *priv);
2404
2405	/**
2406	 * send_tdls_mgmt - for sending TDLS management packets
2407	 * @priv: private driver interface data
2408	 * @dst: Destination (peer) MAC address
2409	 * @action_code: TDLS action code for the mssage
2410	 * @dialog_token: Dialog Token to use in the message (if needed)
2411	 * @status_code: Status Code or Reason Code to use (if needed)
2412	 * @buf: TDLS IEs to add to the message
2413	 * @len: Length of buf in octets
2414	 * Returns: 0 on success, negative (<0) on failure
2415	 *
2416	 * This optional function can be used to send packet to driver which is
2417	 * responsible for receiving and sending all TDLS packets.
2418	 */
2419	int (*send_tdls_mgmt)(void *priv, const u8 *dst, u8 action_code,
2420			      u8 dialog_token, u16 status_code,
2421			      const u8 *buf, size_t len);
2422
2423	/**
2424	 * tdls_oper - Ask the driver to perform high-level TDLS operations
2425	 * @priv: Private driver interface data
2426	 * @oper: TDLS high-level operation. See %enum tdls_oper
2427	 * @peer: Destination (peer) MAC address
2428	 * Returns: 0 on success, negative (<0) on failure
2429	 *
2430	 * This optional function can be used to send high-level TDLS commands
2431	 * to the driver.
2432	 */
2433	int (*tdls_oper)(void *priv, enum tdls_oper oper, const u8 *peer);
2434
2435	/**
2436	 * wnm_oper - Notify driver of the WNM frame reception
2437	 * @priv: Private driver interface data
2438	 * @oper: WNM operation. See %enum wnm_oper
2439	 * @peer: Destination (peer) MAC address
2440	 * @buf: Buffer for the driver to fill in (for getting IE)
2441	 * @buf_len: Return the len of buf
2442	 * Returns: 0 on success, negative (<0) on failure
2443	 */
2444	int (*wnm_oper)(void *priv, enum wnm_oper oper, const u8 *peer,
2445			u8 *buf, u16 *buf_len);
2446
2447	/**
2448	 * set_qos_map - Set QoS Map
2449	 * @priv: Private driver interface data
2450	 * @qos_map_set: QoS Map
2451	 * @qos_map_set_len: Length of QoS Map
2452	 */
2453	int (*set_qos_map)(void *priv, const u8 *qos_map_set,
2454			   u8 qos_map_set_len);
2455
2456	/**
2457	 * signal_poll - Get current connection information
2458	 * @priv: Private driver interface data
2459	 * @signal_info: Connection info structure
2460         */
2461	int (*signal_poll)(void *priv, struct wpa_signal_info *signal_info);
2462
2463	/**
2464	 * set_authmode - Set authentication algorithm(s) for static WEP
2465	 * @priv: Private driver interface data
2466	 * @authmode: 1=Open System, 2=Shared Key, 3=both
2467	 * Returns: 0 on success, -1 on failure
2468	 *
2469	 * This function can be used to set authentication algorithms for AP
2470	 * mode when static WEP is used. If the driver uses user space MLME/SME
2471	 * implementation, there is no need to implement this function.
2472	 *
2473	 * DEPRECATED - use set_ap() instead
2474	 */
2475	int (*set_authmode)(void *priv, int authmode);
2476
2477#ifdef ANDROID
2478	/**
2479	 * driver_cmd - Execute driver-specific command
2480	 * @priv: Private driver interface data
2481	 * @cmd: Command to execute
2482	 * @buf: Return buffer
2483	 * @buf_len: Buffer length
2484	 * Returns: 0 on success, -1 on failure
2485	 */
2486	int (*driver_cmd)(void *priv, char *cmd, char *buf, size_t buf_len);
2487#endif /* ANDROID */
2488
2489	/**
2490	 * set_rekey_info - Set rekey information
2491	 * @priv: Private driver interface data
2492	 * @kek: Current KEK
2493	 * @kck: Current KCK
2494	 * @replay_ctr: Current EAPOL-Key Replay Counter
2495	 *
2496	 * This optional function can be used to provide information for the
2497	 * driver/firmware to process EAPOL-Key frames in Group Key Handshake
2498	 * while the host (including wpa_supplicant) is sleeping.
2499	 */
2500	void (*set_rekey_info)(void *priv, const u8 *kek, const u8 *kck,
2501			       const u8 *replay_ctr);
2502
2503	/**
2504	 * sta_assoc - Station association indication
2505	 * @priv: Private driver interface data
2506	 * @own_addr: Source address and BSSID for association frame
2507	 * @addr: MAC address of the station to associate
2508	 * @reassoc: flag to indicate re-association
2509	 * @status: association response status code
2510	 * @ie: assoc response ie buffer
2511	 * @len: ie buffer length
2512	 * Returns: 0 on success, -1 on failure
2513	 *
2514	 * This function indicates the driver to send (Re)Association
2515	 * Response frame to the station.
2516	 */
2517	 int (*sta_assoc)(void *priv, const u8 *own_addr, const u8 *addr,
2518			  int reassoc, u16 status, const u8 *ie, size_t len);
2519
2520	/**
2521	 * sta_auth - Station authentication indication
2522	 * @priv: Private driver interface data
2523	 * @own_addr: Source address and BSSID for authentication frame
2524	 * @addr: MAC address of the station to associate
2525	 * @seq: authentication sequence number
2526	 * @status: authentication response status code
2527	 * @ie: authentication frame ie buffer
2528	 * @len: ie buffer length
2529	 *
2530	 * This function indicates the driver to send Authentication frame
2531	 * to the station.
2532	 */
2533	 int (*sta_auth)(void *priv, const u8 *own_addr, const u8 *addr,
2534			 u16 seq, u16 status, const u8 *ie, size_t len);
2535
2536	/**
2537	 * add_tspec - Add traffic stream
2538	 * @priv: Private driver interface data
2539	 * @addr: MAC address of the station to associate
2540	 * @tspec_ie: tspec ie buffer
2541	 * @tspec_ielen: tspec ie length
2542	 * Returns: 0 on success, -1 on failure
2543	 *
2544	 * This function adds the traffic steam for the station
2545	 * and fills the medium_time in tspec_ie.
2546	 */
2547	 int (*add_tspec)(void *priv, const u8 *addr, u8 *tspec_ie,
2548			  size_t tspec_ielen);
2549
2550	/**
2551	 * add_sta_node - Add a station node in the driver
2552	 * @priv: Private driver interface data
2553	 * @addr: MAC address of the station to add
2554	 * @auth_alg: authentication algorithm used by the station
2555	 * Returns: 0 on success, -1 on failure
2556	 *
2557	 * This function adds the station node in the driver, when
2558	 * the station gets added by FT-over-DS.
2559	 */
2560	int (*add_sta_node)(void *priv, const u8 *addr, u16 auth_alg);
2561
2562	/**
2563	 * sched_scan - Request the driver to initiate scheduled scan
2564	 * @priv: Private driver interface data
2565	 * @params: Scan parameters
2566	 * @interval: Interval between scan cycles in milliseconds
2567	 * Returns: 0 on success, -1 on failure
2568	 *
2569	 * This operation should be used for scheduled scan offload to
2570	 * the hardware. Every time scan results are available, the
2571	 * driver should report scan results event for wpa_supplicant
2572	 * which will eventually request the results with
2573	 * wpa_driver_get_scan_results2(). This operation is optional
2574	 * and if not provided or if it returns -1, we fall back to
2575	 * normal host-scheduled scans.
2576	 */
2577	int (*sched_scan)(void *priv, struct wpa_driver_scan_params *params,
2578			  u32 interval);
2579
2580	/**
2581	 * stop_sched_scan - Request the driver to stop a scheduled scan
2582	 * @priv: Private driver interface data
2583	 * Returns: 0 on success, -1 on failure
2584	 *
2585	 * This should cause the scheduled scan to be stopped and
2586	 * results should stop being sent. Must be supported if
2587	 * sched_scan is supported.
2588	 */
2589	int (*stop_sched_scan)(void *priv);
2590
2591	/**
2592	 * poll_client - Probe (null data or such) the given station
2593	 * @priv: Private driver interface data
2594	 * @own_addr: MAC address of sending interface
2595	 * @addr: MAC address of the station to probe
2596	 * @qos: Indicates whether station is QoS station
2597	 *
2598	 * This function is used to verify whether an associated station is
2599	 * still present. This function does not need to be implemented if the
2600	 * driver provides such inactivity polling mechanism.
2601	 */
2602	void (*poll_client)(void *priv, const u8 *own_addr,
2603			    const u8 *addr, int qos);
2604
2605	/**
2606	 * radio_disable - Disable/enable radio
2607	 * @priv: Private driver interface data
2608	 * @disabled: 1=disable 0=enable radio
2609	 * Returns: 0 on success, -1 on failure
2610	 *
2611	 * This optional command is for testing purposes. It can be used to
2612	 * disable the radio on a testbed device to simulate out-of-radio-range
2613	 * conditions.
2614	 */
2615	int (*radio_disable)(void *priv, int disabled);
2616
2617	/**
2618	 * switch_channel - Announce channel switch and migrate the GO to the
2619	 * given frequency
2620	 * @priv: Private driver interface data
2621	 * @settings: Settings for CSA period and new channel
2622	 * Returns: 0 on success, -1 on failure
2623	 *
2624	 * This function is used to move the GO to the legacy STA channel to
2625	 * avoid frequency conflict in single channel concurrency.
2626	 */
2627	int (*switch_channel)(void *priv, struct csa_settings *settings);
2628
2629	/**
2630	 * start_dfs_cac - Listen for radar interference on the channel
2631	 * @priv: Private driver interface data
2632	 * @freq: Channel parameters
2633	 * Returns: 0 on success, -1 on failure
2634	 */
2635	int (*start_dfs_cac)(void *priv, struct hostapd_freq_params *freq);
2636
2637	/**
2638	 * stop_ap - Removes beacon from AP
2639	 * @priv: Private driver interface data
2640	 * Returns: 0 on success, -1 on failure (or if not supported)
2641	 *
2642	 * This optional function can be used to disable AP mode related
2643	 * configuration. Unlike deinit_ap, it does not change to station
2644	 * mode.
2645	 */
2646	int (*stop_ap)(void *priv);
2647
2648	/**
2649	 * get_survey - Retrieve survey data
2650	 * @priv: Private driver interface data
2651	 * @freq: If set, survey data for the specified frequency is only
2652	 *	being requested. If not set, all survey data is requested.
2653	 * Returns: 0 on success, -1 on failure
2654	 *
2655	 * Use this to retrieve:
2656	 *
2657	 * - the observed channel noise floor
2658	 * - the amount of time we have spent on the channel
2659	 * - the amount of time during which we have spent on the channel that
2660	 *   the radio has determined the medium is busy and we cannot
2661	 *   transmit
2662	 * - the amount of time we have spent receiving data
2663	 * - the amount of time we have spent transmitting data
2664	 *
2665	 * This data can be used for spectrum heuristics. One example is
2666	 * Automatic Channel Selection (ACS). The channel survey data is
2667	 * kept on a linked list on the channel data, one entry is added
2668	 * for each survey. The min_nf of the channel is updated for each
2669	 * survey.
2670	 */
2671	int (*get_survey)(void *priv, unsigned int freq);
2672
2673	/**
2674	 * status - Get driver interface status information
2675	 * @priv: Private driver interface data
2676	 * @buf: Buffer for printing tou the status information
2677	 * @buflen: Maximum length of the buffer
2678	 * Returns: Length of written status information or -1 on failure
2679	 */
2680	int (*status)(void *priv, char *buf, size_t buflen);
2681};
2682
2683
2684/**
2685 * enum wpa_event_type - Event type for wpa_supplicant_event() calls
2686 */
2687enum wpa_event_type {
2688	/**
2689	 * EVENT_ASSOC - Association completed
2690	 *
2691	 * This event needs to be delivered when the driver completes IEEE
2692	 * 802.11 association or reassociation successfully.
2693	 * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
2694	 * after this event has been generated. In addition, optional
2695	 * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
2696	 * more information about the association. If the driver interface gets
2697	 * both of these events at the same time, it can also include the
2698	 * assoc_info data in EVENT_ASSOC call.
2699	 */
2700	EVENT_ASSOC,
2701
2702	/**
2703	 * EVENT_DISASSOC - Association lost
2704	 *
2705	 * This event should be called when association is lost either due to
2706	 * receiving deauthenticate or disassociate frame from the AP or when
2707	 * sending either of these frames to the current AP. If the driver
2708	 * supports separate deauthentication event, EVENT_DISASSOC should only
2709	 * be used for disassociation and EVENT_DEAUTH for deauthentication.
2710	 * In AP mode, union wpa_event_data::disassoc_info is required.
2711	 */
2712	EVENT_DISASSOC,
2713
2714	/**
2715	 * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
2716	 *
2717	 * This event must be delivered when a Michael MIC error is detected by
2718	 * the local driver. Additional data for event processing is
2719	 * provided with union wpa_event_data::michael_mic_failure. This
2720	 * information is used to request new encyption key and to initiate
2721	 * TKIP countermeasures if needed.
2722	 */
2723	EVENT_MICHAEL_MIC_FAILURE,
2724
2725	/**
2726	 * EVENT_SCAN_RESULTS - Scan results available
2727	 *
2728	 * This event must be called whenever scan results are available to be
2729	 * fetched with struct wpa_driver_ops::get_scan_results(). This event
2730	 * is expected to be used some time after struct wpa_driver_ops::scan()
2731	 * is called. If the driver provides an unsolicited event when the scan
2732	 * has been completed, this event can be used to trigger
2733	 * EVENT_SCAN_RESULTS call. If such event is not available from the
2734	 * driver, the driver wrapper code is expected to use a registered
2735	 * timeout to generate EVENT_SCAN_RESULTS call after the time that the
2736	 * scan is expected to be completed. Optional information about
2737	 * completed scan can be provided with union wpa_event_data::scan_info.
2738	 */
2739	EVENT_SCAN_RESULTS,
2740
2741	/**
2742	 * EVENT_ASSOCINFO - Report optional extra information for association
2743	 *
2744	 * This event can be used to report extra association information for
2745	 * EVENT_ASSOC processing. This extra information includes IEs from
2746	 * association frames and Beacon/Probe Response frames in union
2747	 * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
2748	 * EVENT_ASSOC. Alternatively, the driver interface can include
2749	 * assoc_info data in the EVENT_ASSOC call if it has all the
2750	 * information available at the same point.
2751	 */
2752	EVENT_ASSOCINFO,
2753
2754	/**
2755	 * EVENT_INTERFACE_STATUS - Report interface status changes
2756	 *
2757	 * This optional event can be used to report changes in interface
2758	 * status (interface added/removed) using union
2759	 * wpa_event_data::interface_status. This can be used to trigger
2760	 * wpa_supplicant to stop and re-start processing for the interface,
2761	 * e.g., when a cardbus card is ejected/inserted.
2762	 */
2763	EVENT_INTERFACE_STATUS,
2764
2765	/**
2766	 * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
2767	 *
2768	 * This event can be used to inform wpa_supplicant about candidates for
2769	 * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
2770	 * for scan request (ap_scan=2 mode), this event is required for
2771	 * pre-authentication. If wpa_supplicant is performing scan request
2772	 * (ap_scan=1), this event is optional since scan results can be used
2773	 * to add pre-authentication candidates. union
2774	 * wpa_event_data::pmkid_candidate is used to report the BSSID of the
2775	 * candidate and priority of the candidate, e.g., based on the signal
2776	 * strength, in order to try to pre-authenticate first with candidates
2777	 * that are most likely targets for re-association.
2778	 *
2779	 * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
2780	 * on the candidate list. In addition, it can be called for the current
2781	 * AP and APs that have existing PMKSA cache entries. wpa_supplicant
2782	 * will automatically skip pre-authentication in cases where a valid
2783	 * PMKSA exists. When more than one candidate exists, this event should
2784	 * be generated once for each candidate.
2785	 *
2786	 * Driver will be notified about successful pre-authentication with
2787	 * struct wpa_driver_ops::add_pmkid() calls.
2788	 */
2789	EVENT_PMKID_CANDIDATE,
2790
2791	/**
2792	 * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
2793	 *
2794	 * This event can be used to inform wpa_supplicant about desire to set
2795	 * up secure direct link connection between two stations as defined in
2796	 * IEEE 802.11e with a new PeerKey mechanism that replaced the original
2797	 * STAKey negotiation. The caller will need to set peer address for the
2798	 * event.
2799	 */
2800	EVENT_STKSTART,
2801
2802	/**
2803	 * EVENT_TDLS - Request TDLS operation
2804	 *
2805	 * This event can be used to request a TDLS operation to be performed.
2806	 */
2807	EVENT_TDLS,
2808
2809	/**
2810	 * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
2811	 *
2812	 * The driver is expected to report the received FT IEs from
2813	 * FT authentication sequence from the AP. The FT IEs are included in
2814	 * the extra information in union wpa_event_data::ft_ies.
2815	 */
2816	EVENT_FT_RESPONSE,
2817
2818	/**
2819	 * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
2820	 *
2821	 * The driver can use this event to inform wpa_supplicant about a STA
2822	 * in an IBSS with which protected frames could be exchanged. This
2823	 * event starts RSN authentication with the other STA to authenticate
2824	 * the STA and set up encryption keys with it.
2825	 */
2826	EVENT_IBSS_RSN_START,
2827
2828	/**
2829	 * EVENT_AUTH - Authentication result
2830	 *
2831	 * This event should be called when authentication attempt has been
2832	 * completed. This is only used if the driver supports separate
2833	 * authentication step (struct wpa_driver_ops::authenticate).
2834	 * Information about authentication result is included in
2835	 * union wpa_event_data::auth.
2836	 */
2837	EVENT_AUTH,
2838
2839	/**
2840	 * EVENT_DEAUTH - Authentication lost
2841	 *
2842	 * This event should be called when authentication is lost either due
2843	 * to receiving deauthenticate frame from the AP or when sending that
2844	 * frame to the current AP.
2845	 * In AP mode, union wpa_event_data::deauth_info is required.
2846	 */
2847	EVENT_DEAUTH,
2848
2849	/**
2850	 * EVENT_ASSOC_REJECT - Association rejected
2851	 *
2852	 * This event should be called when (re)association attempt has been
2853	 * rejected by the AP. Information about the association response is
2854	 * included in union wpa_event_data::assoc_reject.
2855	 */
2856	EVENT_ASSOC_REJECT,
2857
2858	/**
2859	 * EVENT_AUTH_TIMED_OUT - Authentication timed out
2860	 */
2861	EVENT_AUTH_TIMED_OUT,
2862
2863	/**
2864	 * EVENT_ASSOC_TIMED_OUT - Association timed out
2865	 */
2866	EVENT_ASSOC_TIMED_OUT,
2867
2868	/**
2869	 * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
2870	 */
2871	EVENT_FT_RRB_RX,
2872
2873	/**
2874	 * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
2875	 */
2876	EVENT_WPS_BUTTON_PUSHED,
2877
2878	/**
2879	 * EVENT_TX_STATUS - Report TX status
2880	 */
2881	EVENT_TX_STATUS,
2882
2883	/**
2884	 * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
2885	 */
2886	EVENT_RX_FROM_UNKNOWN,
2887
2888	/**
2889	 * EVENT_RX_MGMT - Report RX of a management frame
2890	 */
2891	EVENT_RX_MGMT,
2892
2893	/**
2894	 * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
2895	 *
2896	 * This event is used to indicate when the driver has started the
2897	 * requested remain-on-channel duration. Information about the
2898	 * operation is included in union wpa_event_data::remain_on_channel.
2899	 */
2900	EVENT_REMAIN_ON_CHANNEL,
2901
2902	/**
2903	 * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
2904	 *
2905	 * This event is used to indicate when the driver has completed
2906	 * remain-on-channel duration, i.e., may noot be available on the
2907	 * requested channel anymore. Information about the
2908	 * operation is included in union wpa_event_data::remain_on_channel.
2909	 */
2910	EVENT_CANCEL_REMAIN_ON_CHANNEL,
2911
2912	/**
2913	 * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
2914	 *
2915	 * This event is used only by driver_test.c and userspace MLME.
2916	 */
2917	EVENT_MLME_RX,
2918
2919	/**
2920	 * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
2921	 *
2922	 * This event is used to indicate when a Probe Request frame has been
2923	 * received. Information about the received frame is included in
2924	 * union wpa_event_data::rx_probe_req. The driver is required to report
2925	 * these events only after successfully completed probe_req_report()
2926	 * commands to request the events (i.e., report parameter is non-zero)
2927	 * in station mode. In AP mode, Probe Request frames should always be
2928	 * reported.
2929	 */
2930	EVENT_RX_PROBE_REQ,
2931
2932	/**
2933	 * EVENT_NEW_STA - New wired device noticed
2934	 *
2935	 * This event is used to indicate that a new device has been detected
2936	 * in a network that does not use association-like functionality (i.e.,
2937	 * mainly wired Ethernet). This can be used to start EAPOL
2938	 * authenticator when receiving a frame from a device. The address of
2939	 * the device is included in union wpa_event_data::new_sta.
2940	 */
2941	EVENT_NEW_STA,
2942
2943	/**
2944	 * EVENT_EAPOL_RX - Report received EAPOL frame
2945	 *
2946	 * When in AP mode with hostapd, this event is required to be used to
2947	 * deliver the receive EAPOL frames from the driver. With
2948	 * %wpa_supplicant, this event is used only if the send_eapol() handler
2949	 * is used to override the use of l2_packet for EAPOL frame TX.
2950	 */
2951	EVENT_EAPOL_RX,
2952
2953	/**
2954	 * EVENT_SIGNAL_CHANGE - Indicate change in signal strength
2955	 *
2956	 * This event is used to indicate changes in the signal strength
2957	 * observed in frames received from the current AP if signal strength
2958	 * monitoring has been enabled with signal_monitor().
2959	 */
2960	EVENT_SIGNAL_CHANGE,
2961
2962	/**
2963	 * EVENT_INTERFACE_ENABLED - Notify that interface was enabled
2964	 *
2965	 * This event is used to indicate that the interface was enabled after
2966	 * having been previously disabled, e.g., due to rfkill.
2967	 */
2968	EVENT_INTERFACE_ENABLED,
2969
2970	/**
2971	 * EVENT_INTERFACE_DISABLED - Notify that interface was disabled
2972	 *
2973	 * This event is used to indicate that the interface was disabled,
2974	 * e.g., due to rfkill.
2975	 */
2976	EVENT_INTERFACE_DISABLED,
2977
2978	/**
2979	 * EVENT_CHANNEL_LIST_CHANGED - Channel list changed
2980	 *
2981	 * This event is used to indicate that the channel list has changed,
2982	 * e.g., because of a regulatory domain change triggered by scan
2983	 * results including an AP advertising a country code.
2984	 */
2985	EVENT_CHANNEL_LIST_CHANGED,
2986
2987	/**
2988	 * EVENT_INTERFACE_UNAVAILABLE - Notify that interface is unavailable
2989	 *
2990	 * This event is used to indicate that the driver cannot maintain this
2991	 * interface in its operation mode anymore. The most likely use for
2992	 * this is to indicate that AP mode operation is not available due to
2993	 * operating channel would need to be changed to a DFS channel when
2994	 * the driver does not support radar detection and another virtual
2995	 * interfaces caused the operating channel to change. Other similar
2996	 * resource conflicts could also trigger this for station mode
2997	 * interfaces.
2998	 */
2999	EVENT_INTERFACE_UNAVAILABLE,
3000
3001	/**
3002	 * EVENT_BEST_CHANNEL
3003	 *
3004	 * Driver generates this event whenever it detects a better channel
3005	 * (e.g., based on RSSI or channel use). This information can be used
3006	 * to improve channel selection for a new AP/P2P group.
3007	 */
3008	EVENT_BEST_CHANNEL,
3009
3010	/**
3011	 * EVENT_UNPROT_DEAUTH - Unprotected Deauthentication frame received
3012	 *
3013	 * This event should be called when a Deauthentication frame is dropped
3014	 * due to it not being protected (MFP/IEEE 802.11w).
3015	 * union wpa_event_data::unprot_deauth is required to provide more
3016	 * details of the frame.
3017	 */
3018	EVENT_UNPROT_DEAUTH,
3019
3020	/**
3021	 * EVENT_UNPROT_DISASSOC - Unprotected Disassociation frame received
3022	 *
3023	 * This event should be called when a Disassociation frame is dropped
3024	 * due to it not being protected (MFP/IEEE 802.11w).
3025	 * union wpa_event_data::unprot_disassoc is required to provide more
3026	 * details of the frame.
3027	 */
3028	EVENT_UNPROT_DISASSOC,
3029
3030	/**
3031	 * EVENT_STATION_LOW_ACK
3032	 *
3033	 * Driver generates this event whenever it detected that a particular
3034	 * station was lost. Detection can be through massive transmission
3035	 * failures for example.
3036	 */
3037	EVENT_STATION_LOW_ACK,
3038
3039	/**
3040	 * EVENT_IBSS_PEER_LOST - IBSS peer not reachable anymore
3041	 */
3042	EVENT_IBSS_PEER_LOST,
3043
3044	/**
3045	 * EVENT_DRIVER_GTK_REKEY - Device/driver did GTK rekey
3046	 *
3047	 * This event carries the new replay counter to notify wpa_supplicant
3048	 * of the current EAPOL-Key Replay Counter in case the driver/firmware
3049	 * completed Group Key Handshake while the host (including
3050	 * wpa_supplicant was sleeping).
3051	 */
3052	EVENT_DRIVER_GTK_REKEY,
3053
3054	/**
3055	 * EVENT_SCHED_SCAN_STOPPED - Scheduled scan was stopped
3056	 */
3057	EVENT_SCHED_SCAN_STOPPED,
3058
3059	/**
3060	 * EVENT_DRIVER_CLIENT_POLL_OK - Station responded to poll
3061	 *
3062	 * This event indicates that the station responded to the poll
3063	 * initiated with @poll_client.
3064	 */
3065	EVENT_DRIVER_CLIENT_POLL_OK,
3066
3067	/**
3068	 * EVENT_EAPOL_TX_STATUS - notify of EAPOL TX status
3069	 */
3070	EVENT_EAPOL_TX_STATUS,
3071
3072	/**
3073	 * EVENT_CH_SWITCH - AP or GO decided to switch channels
3074	 *
3075	 * Described in wpa_event_data.ch_switch
3076	 * */
3077	EVENT_CH_SWITCH,
3078
3079	/**
3080	 * EVENT_WNM - Request WNM operation
3081	 *
3082	 * This event can be used to request a WNM operation to be performed.
3083	 */
3084	EVENT_WNM,
3085
3086	/**
3087	 * EVENT_CONNECT_FAILED_REASON - Connection failure reason in AP mode
3088	 *
3089	 * This event indicates that the driver reported a connection failure
3090	 * with the specified client (for example, max client reached, etc.) in
3091	 * AP mode.
3092	 */
3093	EVENT_CONNECT_FAILED_REASON,
3094
3095	/**
3096	 * EVENT_RADAR_DETECTED - Notify of radar detection
3097	 *
3098	 * A radar has been detected on the supplied frequency, hostapd should
3099	 * react accordingly (e.g., change channel).
3100	 */
3101	EVENT_DFS_RADAR_DETECTED,
3102
3103	/**
3104	 * EVENT_CAC_FINISHED - Notify that channel availability check has been completed
3105	 *
3106	 * After a successful CAC, the channel can be marked clear and used.
3107	 */
3108	EVENT_DFS_CAC_FINISHED,
3109
3110	/**
3111	 * EVENT_CAC_ABORTED - Notify that channel availability check has been aborted
3112	 *
3113	 * The CAC was not successful, and the channel remains in the previous
3114	 * state. This may happen due to a radar beeing detected or other
3115	 * external influences.
3116	 */
3117	EVENT_DFS_CAC_ABORTED,
3118
3119	/**
3120	 * EVENT_DFS_CAC_NOP_FINISHED - Notify that non-occupancy period is over
3121	 *
3122	 * The channel which was previously unavailable is now available again.
3123	 */
3124	EVENT_DFS_NOP_FINISHED,
3125
3126	/**
3127	 * EVENT_SURVEY - Received survey data
3128	 *
3129	 * This event gets triggered when a driver query is issued for survey
3130	 * data and the requested data becomes available. The returned data is
3131	 * stored in struct survey_results. The results provide at most one
3132	 * survey entry for each frequency and at minimum will provide one
3133	 * survey entry for one frequency. The survey data can be os_malloc()'d
3134	 * and then os_free()'d, so the event callback must only copy data.
3135	 */
3136	EVENT_SURVEY,
3137
3138	/**
3139	 * EVENT_SCAN_STARTED - Scan started
3140	 *
3141	 * This indicates that driver has started a scan operation either based
3142	 * on a request from wpa_supplicant/hostapd or from another application.
3143	 * EVENT_SCAN_RESULTS is used to indicate when the scan has been
3144	 * completed (either successfully or by getting cancelled).
3145	 */
3146	EVENT_SCAN_STARTED
3147};
3148
3149
3150/**
3151 * struct freq_survey - Channel survey info
3152 *
3153 * @ifidx: Interface index in which this survey was observed
3154 * @freq: Center of frequency of the surveyed channel
3155 * @nf: Channel noise floor in dBm
3156 * @channel_time: Amount of time in ms the radio spent on the channel
3157 * @channel_time_busy: Amount of time in ms the radio detected some signal
3158 *     that indicated to the radio the channel was not clear
3159 * @channel_time_rx: Amount of time the radio spent receiving data
3160 * @channel_time_tx: Amount of time the radio spent transmitting data
3161 * @filled: bitmask indicating which fields have been reported, see
3162 *     SURVEY_HAS_* defines.
3163 * @list: Internal list pointers
3164 */
3165struct freq_survey {
3166	u32 ifidx;
3167	unsigned int freq;
3168	s8 nf;
3169	u64 channel_time;
3170	u64 channel_time_busy;
3171	u64 channel_time_rx;
3172	u64 channel_time_tx;
3173	unsigned int filled;
3174	struct dl_list list;
3175};
3176
3177#define SURVEY_HAS_NF BIT(0)
3178#define SURVEY_HAS_CHAN_TIME BIT(1)
3179#define SURVEY_HAS_CHAN_TIME_BUSY BIT(2)
3180#define SURVEY_HAS_CHAN_TIME_RX BIT(3)
3181#define SURVEY_HAS_CHAN_TIME_TX BIT(4)
3182
3183
3184/**
3185 * union wpa_event_data - Additional data for wpa_supplicant_event() calls
3186 */
3187union wpa_event_data {
3188	/**
3189	 * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
3190	 *
3191	 * This structure is optional for EVENT_ASSOC calls and required for
3192	 * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
3193	 * driver interface does not need to generate separate EVENT_ASSOCINFO
3194	 * calls.
3195	 */
3196	struct assoc_info {
3197		/**
3198		 * reassoc - Flag to indicate association or reassociation
3199		 */
3200		int reassoc;
3201
3202		/**
3203		 * req_ies - (Re)Association Request IEs
3204		 *
3205		 * If the driver generates WPA/RSN IE, this event data must be
3206		 * returned for WPA handshake to have needed information. If
3207		 * wpa_supplicant-generated WPA/RSN IE is used, this
3208		 * information event is optional.
3209		 *
3210		 * This should start with the first IE (fixed fields before IEs
3211		 * are not included).
3212		 */
3213		const u8 *req_ies;
3214
3215		/**
3216		 * req_ies_len - Length of req_ies in bytes
3217		 */
3218		size_t req_ies_len;
3219
3220		/**
3221		 * resp_ies - (Re)Association Response IEs
3222		 *
3223		 * Optional association data from the driver. This data is not
3224		 * required WPA, but may be useful for some protocols and as
3225		 * such, should be reported if this is available to the driver
3226		 * interface.
3227		 *
3228		 * This should start with the first IE (fixed fields before IEs
3229		 * are not included).
3230		 */
3231		const u8 *resp_ies;
3232
3233		/**
3234		 * resp_ies_len - Length of resp_ies in bytes
3235		 */
3236		size_t resp_ies_len;
3237
3238		/**
3239		 * beacon_ies - Beacon or Probe Response IEs
3240		 *
3241		 * Optional Beacon/ProbeResp data: IEs included in Beacon or
3242		 * Probe Response frames from the current AP (i.e., the one
3243		 * that the client just associated with). This information is
3244		 * used to update WPA/RSN IE for the AP. If this field is not
3245		 * set, the results from previous scan will be used. If no
3246		 * data for the new AP is found, scan results will be requested
3247		 * again (without scan request). At this point, the driver is
3248		 * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
3249		 * used).
3250		 *
3251		 * This should start with the first IE (fixed fields before IEs
3252		 * are not included).
3253		 */
3254		const u8 *beacon_ies;
3255
3256		/**
3257		 * beacon_ies_len - Length of beacon_ies */
3258		size_t beacon_ies_len;
3259
3260		/**
3261		 * freq - Frequency of the operational channel in MHz
3262		 */
3263		unsigned int freq;
3264
3265		/**
3266		 * addr - Station address (for AP mode)
3267		 */
3268		const u8 *addr;
3269	} assoc_info;
3270
3271	/**
3272	 * struct disassoc_info - Data for EVENT_DISASSOC events
3273	 */
3274	struct disassoc_info {
3275		/**
3276		 * addr - Station address (for AP mode)
3277		 */
3278		const u8 *addr;
3279
3280		/**
3281		 * reason_code - Reason Code (host byte order) used in
3282		 *	Deauthentication frame
3283		 */
3284		u16 reason_code;
3285
3286		/**
3287		 * ie - Optional IE(s) in Disassociation frame
3288		 */
3289		const u8 *ie;
3290
3291		/**
3292		 * ie_len - Length of ie buffer in octets
3293		 */
3294		size_t ie_len;
3295
3296		/**
3297		 * locally_generated - Whether the frame was locally generated
3298		 */
3299		int locally_generated;
3300	} disassoc_info;
3301
3302	/**
3303	 * struct deauth_info - Data for EVENT_DEAUTH events
3304	 */
3305	struct deauth_info {
3306		/**
3307		 * addr - Station address (for AP mode)
3308		 */
3309		const u8 *addr;
3310
3311		/**
3312		 * reason_code - Reason Code (host byte order) used in
3313		 *	Deauthentication frame
3314		 */
3315		u16 reason_code;
3316
3317		/**
3318		 * ie - Optional IE(s) in Deauthentication frame
3319		 */
3320		const u8 *ie;
3321
3322		/**
3323		 * ie_len - Length of ie buffer in octets
3324		 */
3325		size_t ie_len;
3326
3327		/**
3328		 * locally_generated - Whether the frame was locally generated
3329		 */
3330		int locally_generated;
3331	} deauth_info;
3332
3333	/**
3334	 * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
3335	 */
3336	struct michael_mic_failure {
3337		int unicast;
3338		const u8 *src;
3339	} michael_mic_failure;
3340
3341	/**
3342	 * struct interface_status - Data for EVENT_INTERFACE_STATUS
3343	 */
3344	struct interface_status {
3345		char ifname[100];
3346		enum {
3347			EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
3348		} ievent;
3349	} interface_status;
3350
3351	/**
3352	 * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
3353	 */
3354	struct pmkid_candidate {
3355		/** BSSID of the PMKID candidate */
3356		u8 bssid[ETH_ALEN];
3357		/** Smaller the index, higher the priority */
3358		int index;
3359		/** Whether RSN IE includes pre-authenticate flag */
3360		int preauth;
3361	} pmkid_candidate;
3362
3363	/**
3364	 * struct stkstart - Data for EVENT_STKSTART
3365	 */
3366	struct stkstart {
3367		u8 peer[ETH_ALEN];
3368	} stkstart;
3369
3370	/**
3371	 * struct tdls - Data for EVENT_TDLS
3372	 */
3373	struct tdls {
3374		u8 peer[ETH_ALEN];
3375		enum {
3376			TDLS_REQUEST_SETUP,
3377			TDLS_REQUEST_TEARDOWN
3378		} oper;
3379		u16 reason_code; /* for teardown */
3380	} tdls;
3381
3382	/**
3383	 * struct wnm - Data for EVENT_WNM
3384	 */
3385	struct wnm {
3386		u8 addr[ETH_ALEN];
3387		enum {
3388			WNM_OPER_SLEEP,
3389		} oper;
3390		enum {
3391			WNM_SLEEP_ENTER,
3392			WNM_SLEEP_EXIT
3393		} sleep_action;
3394		int sleep_intval;
3395		u16 reason_code;
3396		u8 *buf;
3397		u16 buf_len;
3398	} wnm;
3399
3400	/**
3401	 * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
3402	 *
3403	 * During FT (IEEE 802.11r) authentication sequence, the driver is
3404	 * expected to use this event to report received FT IEs (MDIE, FTIE,
3405	 * RSN IE, TIE, possible resource request) to the supplicant. The FT
3406	 * IEs for the next message will be delivered through the
3407	 * struct wpa_driver_ops::update_ft_ies() callback.
3408	 */
3409	struct ft_ies {
3410		const u8 *ies;
3411		size_t ies_len;
3412		int ft_action;
3413		u8 target_ap[ETH_ALEN];
3414		/** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
3415		const u8 *ric_ies;
3416		/** Length of ric_ies buffer in octets */
3417		size_t ric_ies_len;
3418	} ft_ies;
3419
3420	/**
3421	 * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
3422	 */
3423	struct ibss_rsn_start {
3424		u8 peer[ETH_ALEN];
3425	} ibss_rsn_start;
3426
3427	/**
3428	 * struct auth_info - Data for EVENT_AUTH events
3429	 */
3430	struct auth_info {
3431		u8 peer[ETH_ALEN];
3432		u8 bssid[ETH_ALEN];
3433		u16 auth_type;
3434		u16 auth_transaction;
3435		u16 status_code;
3436		const u8 *ies;
3437		size_t ies_len;
3438	} auth;
3439
3440	/**
3441	 * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
3442	 */
3443	struct assoc_reject {
3444		/**
3445		 * bssid - BSSID of the AP that rejected association
3446		 */
3447		const u8 *bssid;
3448
3449		/**
3450		 * resp_ies - (Re)Association Response IEs
3451		 *
3452		 * Optional association data from the driver. This data is not
3453		 * required WPA, but may be useful for some protocols and as
3454		 * such, should be reported if this is available to the driver
3455		 * interface.
3456		 *
3457		 * This should start with the first IE (fixed fields before IEs
3458		 * are not included).
3459		 */
3460		const u8 *resp_ies;
3461
3462		/**
3463		 * resp_ies_len - Length of resp_ies in bytes
3464		 */
3465		size_t resp_ies_len;
3466
3467		/**
3468		 * status_code - Status Code from (Re)association Response
3469		 */
3470		u16 status_code;
3471	} assoc_reject;
3472
3473	struct timeout_event {
3474		u8 addr[ETH_ALEN];
3475	} timeout_event;
3476
3477	/**
3478	 * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
3479	 */
3480	struct ft_rrb_rx {
3481		const u8 *src;
3482		const u8 *data;
3483		size_t data_len;
3484	} ft_rrb_rx;
3485
3486	/**
3487	 * struct tx_status - Data for EVENT_TX_STATUS events
3488	 */
3489	struct tx_status {
3490		u16 type;
3491		u16 stype;
3492		const u8 *dst;
3493		const u8 *data;
3494		size_t data_len;
3495		int ack;
3496	} tx_status;
3497
3498	/**
3499	 * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
3500	 */
3501	struct rx_from_unknown {
3502		const u8 *bssid;
3503		const u8 *addr;
3504		int wds;
3505	} rx_from_unknown;
3506
3507	/**
3508	 * struct rx_mgmt - Data for EVENT_RX_MGMT events
3509	 */
3510	struct rx_mgmt {
3511		const u8 *frame;
3512		size_t frame_len;
3513		u32 datarate;
3514
3515		/**
3516		 * freq - Frequency (in MHz) on which the frame was received
3517		 */
3518		int freq;
3519
3520		/**
3521		 * ssi_signal - Signal strength in dBm (or 0 if not available)
3522		 */
3523		int ssi_signal;
3524	} rx_mgmt;
3525
3526	/**
3527	 * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
3528	 *
3529	 * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
3530	 */
3531	struct remain_on_channel {
3532		/**
3533		 * freq - Channel frequency in MHz
3534		 */
3535		unsigned int freq;
3536
3537		/**
3538		 * duration - Duration to remain on the channel in milliseconds
3539		 */
3540		unsigned int duration;
3541	} remain_on_channel;
3542
3543	/**
3544	 * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
3545	 * @aborted: Whether the scan was aborted
3546	 * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
3547	 * @num_freqs: Number of entries in freqs array
3548	 * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
3549	 *	SSID)
3550	 * @num_ssids: Number of entries in ssids array
3551	 */
3552	struct scan_info {
3553		int aborted;
3554		const int *freqs;
3555		size_t num_freqs;
3556		struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
3557		size_t num_ssids;
3558	} scan_info;
3559
3560	/**
3561	 * struct mlme_rx - Data for EVENT_MLME_RX events
3562	 */
3563	struct mlme_rx {
3564		const u8 *buf;
3565		size_t len;
3566		int freq;
3567		int channel;
3568		int ssi;
3569	} mlme_rx;
3570
3571	/**
3572	 * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
3573	 */
3574	struct rx_probe_req {
3575		/**
3576		 * sa - Source address of the received Probe Request frame
3577		 */
3578		const u8 *sa;
3579
3580		/**
3581		 * da - Destination address of the received Probe Request frame
3582		 *	or %NULL if not available
3583		 */
3584		const u8 *da;
3585
3586		/**
3587		 * bssid - BSSID of the received Probe Request frame or %NULL
3588		 *	if not available
3589		 */
3590		const u8 *bssid;
3591
3592		/**
3593		 * ie - IEs from the Probe Request body
3594		 */
3595		const u8 *ie;
3596
3597		/**
3598		 * ie_len - Length of ie buffer in octets
3599		 */
3600		size_t ie_len;
3601
3602		/**
3603		 * signal - signal strength in dBm (or 0 if not available)
3604		 */
3605		int ssi_signal;
3606	} rx_probe_req;
3607
3608	/**
3609	 * struct new_sta - Data for EVENT_NEW_STA events
3610	 */
3611	struct new_sta {
3612		const u8 *addr;
3613	} new_sta;
3614
3615	/**
3616	 * struct eapol_rx - Data for EVENT_EAPOL_RX events
3617	 */
3618	struct eapol_rx {
3619		const u8 *src;
3620		const u8 *data;
3621		size_t data_len;
3622	} eapol_rx;
3623
3624	/**
3625	 * signal_change - Data for EVENT_SIGNAL_CHANGE events
3626	 */
3627	struct wpa_signal_info signal_change;
3628
3629	/**
3630	 * struct best_channel - Data for EVENT_BEST_CHANNEL events
3631	 * @freq_24: Best 2.4 GHz band channel frequency in MHz
3632	 * @freq_5: Best 5 GHz band channel frequency in MHz
3633	 * @freq_overall: Best channel frequency in MHz
3634	 *
3635	 * 0 can be used to indicate no preference in either band.
3636	 */
3637	struct best_channel {
3638		int freq_24;
3639		int freq_5;
3640		int freq_overall;
3641	} best_chan;
3642
3643	struct unprot_deauth {
3644		const u8 *sa;
3645		const u8 *da;
3646		u16 reason_code;
3647	} unprot_deauth;
3648
3649	struct unprot_disassoc {
3650		const u8 *sa;
3651		const u8 *da;
3652		u16 reason_code;
3653	} unprot_disassoc;
3654
3655	/**
3656	 * struct low_ack - Data for EVENT_STATION_LOW_ACK events
3657	 * @addr: station address
3658	 */
3659	struct low_ack {
3660		u8 addr[ETH_ALEN];
3661	} low_ack;
3662
3663	/**
3664	 * struct ibss_peer_lost - Data for EVENT_IBSS_PEER_LOST
3665	 */
3666	struct ibss_peer_lost {
3667		u8 peer[ETH_ALEN];
3668	} ibss_peer_lost;
3669
3670	/**
3671	 * struct driver_gtk_rekey - Data for EVENT_DRIVER_GTK_REKEY
3672	 */
3673	struct driver_gtk_rekey {
3674		const u8 *bssid;
3675		const u8 *replay_ctr;
3676	} driver_gtk_rekey;
3677
3678	/**
3679	 * struct client_poll - Data for EVENT_DRIVER_CLIENT_POLL_OK events
3680	 * @addr: station address
3681	 */
3682	struct client_poll {
3683		u8 addr[ETH_ALEN];
3684	} client_poll;
3685
3686	/**
3687	 * struct eapol_tx_status
3688	 * @dst: Original destination
3689	 * @data: Data starting with IEEE 802.1X header (!)
3690	 * @data_len: Length of data
3691	 * @ack: Indicates ack or lost frame
3692	 *
3693	 * This corresponds to hapd_send_eapol if the frame sent
3694	 * there isn't just reported as EVENT_TX_STATUS.
3695	 */
3696	struct eapol_tx_status {
3697		const u8 *dst;
3698		const u8 *data;
3699		int data_len;
3700		int ack;
3701	} eapol_tx_status;
3702
3703	/**
3704	 * struct ch_switch
3705	 * @freq: Frequency of new channel in MHz
3706	 * @ht_enabled: Whether this is an HT channel
3707	 * @ch_offset: Secondary channel offset
3708	 * @ch_width: Channel width
3709	 * @cf1: Center frequency 1
3710	 * @cf2: Center frequency 2
3711	 */
3712	struct ch_switch {
3713		int freq;
3714		int ht_enabled;
3715		int ch_offset;
3716		enum chan_width ch_width;
3717		int cf1;
3718		int cf2;
3719	} ch_switch;
3720
3721	/**
3722	 * struct connect_failed - Data for EVENT_CONNECT_FAILED_REASON
3723	 * @addr: Remote client address
3724	 * @code: Reason code for connection failure
3725	 */
3726	struct connect_failed_reason {
3727		u8 addr[ETH_ALEN];
3728		enum {
3729			MAX_CLIENT_REACHED,
3730			BLOCKED_CLIENT
3731		} code;
3732	} connect_failed_reason;
3733
3734	/**
3735	 * struct dfs_event - Data for radar detected events
3736	 * @freq: Frequency of the channel in MHz
3737	 */
3738	struct dfs_event {
3739		int freq;
3740		int ht_enabled;
3741		int chan_offset;
3742		enum chan_width chan_width;
3743		int cf1;
3744		int cf2;
3745	} dfs_event;
3746
3747	/**
3748	 * survey_results - Survey result data for EVENT_SURVEY
3749	 * @freq_filter: Requested frequency survey filter, 0 if request
3750	 *	was for all survey data
3751	 * @survey_list: Linked list of survey data
3752	 */
3753	struct survey_results {
3754		unsigned int freq_filter;
3755		struct dl_list survey_list; /* struct freq_survey */
3756	} survey_results;
3757
3758	/**
3759	 * channel_list_changed - Data for EVENT_CHANNEL_LIST_CHANGED
3760	 * @initiator: Initiator of the regulatory change
3761	 */
3762	struct channel_list_changed {
3763		enum reg_change_initiator initiator;
3764	} channel_list_changed;
3765};
3766
3767/**
3768 * wpa_supplicant_event - Report a driver event for wpa_supplicant
3769 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
3770 *	with struct wpa_driver_ops::init()
3771 * @event: event type (defined above)
3772 * @data: possible extra data for the event
3773 *
3774 * Driver wrapper code should call this function whenever an event is received
3775 * from the driver.
3776 */
3777void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
3778			  union wpa_event_data *data);
3779
3780
3781/*
3782 * The following inline functions are provided for convenience to simplify
3783 * event indication for some of the common events.
3784 */
3785
3786static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
3787				   size_t ielen, int reassoc)
3788{
3789	union wpa_event_data event;
3790	os_memset(&event, 0, sizeof(event));
3791	event.assoc_info.reassoc = reassoc;
3792	event.assoc_info.req_ies = ie;
3793	event.assoc_info.req_ies_len = ielen;
3794	event.assoc_info.addr = addr;
3795	wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
3796}
3797
3798static inline void drv_event_disassoc(void *ctx, const u8 *addr)
3799{
3800	union wpa_event_data event;
3801	os_memset(&event, 0, sizeof(event));
3802	event.disassoc_info.addr = addr;
3803	wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
3804}
3805
3806static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
3807				      size_t data_len)
3808{
3809	union wpa_event_data event;
3810	os_memset(&event, 0, sizeof(event));
3811	event.eapol_rx.src = src;
3812	event.eapol_rx.data = data;
3813	event.eapol_rx.data_len = data_len;
3814	wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
3815}
3816
3817/* driver_common.c */
3818void wpa_scan_results_free(struct wpa_scan_results *res);
3819
3820/* Convert wpa_event_type to a string for logging */
3821const char * event_to_string(enum wpa_event_type event);
3822
3823/* NULL terminated array of linked in driver wrappers */
3824extern struct wpa_driver_ops *wpa_drivers[];
3825
3826#endif /* DRIVER_H */
3827