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