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