Add HT40 flags into driver channel list
[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 /**
64  * struct hostapd_hw_modes - Supported hardware mode information
65  */
66 struct hostapd_hw_modes {
67         /**
68          * mode - Hardware mode
69          */
70         enum hostapd_hw_mode mode;
71
72         /**
73          * num_channels - Number of entries in the channels array
74          */
75         int num_channels;
76
77         /**
78          * channels - Array of supported channels
79          */
80         struct hostapd_channel_data *channels;
81
82         /**
83          * num_rates - Number of entries in the rates array
84          */
85         int num_rates;
86
87         /**
88          * rates - Array of supported rates in 100 kbps units
89          */
90         int *rates;
91
92         /**
93          * ht_capab - HT (IEEE 802.11n) capabilities
94          */
95         u16 ht_capab;
96
97         /**
98          * mcs_set - MCS (IEEE 802.11n) rate parameters
99          */
100         u8 mcs_set[16];
101
102         /**
103          * a_mpdu_params - A-MPDU (IEEE 802.11n) parameters
104          */
105         u8 a_mpdu_params;
106 };
107
108
109 #define IEEE80211_MODE_INFRA    0
110 #define IEEE80211_MODE_IBSS     1
111 #define IEEE80211_MODE_AP       2
112
113 #define IEEE80211_CAP_ESS       0x0001
114 #define IEEE80211_CAP_IBSS      0x0002
115 #define IEEE80211_CAP_PRIVACY   0x0010
116
117 #define WPA_SCAN_QUAL_INVALID           BIT(0)
118 #define WPA_SCAN_NOISE_INVALID          BIT(1)
119 #define WPA_SCAN_LEVEL_INVALID          BIT(2)
120 #define WPA_SCAN_LEVEL_DBM              BIT(3)
121 #define WPA_SCAN_AUTHENTICATED          BIT(4)
122 #define WPA_SCAN_ASSOCIATED             BIT(5)
123
124 /**
125  * struct wpa_scan_res - Scan result for an BSS/IBSS
126  * @flags: information flags about the BSS/IBSS (WPA_SCAN_*)
127  * @bssid: BSSID
128  * @freq: frequency of the channel in MHz (e.g., 2412 = channel 1)
129  * @beacon_int: beacon interval in TUs (host byte order)
130  * @caps: capability information field in host byte order
131  * @qual: signal quality
132  * @noise: noise level
133  * @level: signal level
134  * @tsf: Timestamp
135  * @age: Age of the information in milliseconds (i.e., how many milliseconds
136  * ago the last Beacon or Probe Response frame was received)
137  * @ie_len: length of the following IE field in octets
138  * @beacon_ie_len: length of the following Beacon IE field in octets
139  *
140  * This structure is used as a generic format for scan results from the
141  * driver. Each driver interface implementation is responsible for converting
142  * the driver or OS specific scan results into this format.
143  *
144  * If the driver does not support reporting all IEs, the IE data structure is
145  * constructed of the IEs that are available. This field will also need to
146  * include SSID in IE format. All drivers are encouraged to be extended to
147  * report all IEs to make it easier to support future additions.
148  */
149 struct wpa_scan_res {
150         unsigned int flags;
151         u8 bssid[ETH_ALEN];
152         int freq;
153         u16 beacon_int;
154         u16 caps;
155         int qual;
156         int noise;
157         int level;
158         u64 tsf;
159         unsigned int age;
160         size_t ie_len;
161         size_t beacon_ie_len;
162         /*
163          * Followed by ie_len octets of IEs from Probe Response frame (or if
164          * the driver does not indicate source of IEs, these may also be from
165          * Beacon frame). After the first set of IEs, another set of IEs may
166          * follow (with beacon_ie_len octets of data) if the driver provides
167          * both IE sets.
168          */
169 };
170
171 /**
172  * struct wpa_scan_results - Scan results
173  * @res: Array of pointers to allocated variable length scan result entries
174  * @num: Number of entries in the scan result array
175  */
176 struct wpa_scan_results {
177         struct wpa_scan_res **res;
178         size_t num;
179 };
180
181 /**
182  * struct wpa_interface_info - Network interface information
183  * @next: Pointer to the next interface or NULL if this is the last one
184  * @ifname: Interface name that can be used with init() or init2()
185  * @desc: Human readable adapter description (e.g., vendor/model) or NULL if
186  *      not available
187  * @drv_name: struct wpa_driver_ops::name (note: unlike other strings, this one
188  *      is not an allocated copy, i.e., get_interfaces() caller will not free
189  *      this)
190  */
191 struct wpa_interface_info {
192         struct wpa_interface_info *next;
193         char *ifname;
194         char *desc;
195         const char *drv_name;
196 };
197
198 #define WPAS_MAX_SCAN_SSIDS 4
199
200 /**
201  * struct wpa_driver_scan_params - Scan parameters
202  * Data for struct wpa_driver_ops::scan2().
203  */
204 struct wpa_driver_scan_params {
205         /**
206          * ssids - SSIDs to scan for
207          */
208         struct wpa_driver_scan_ssid {
209                 /**
210                  * ssid - specific SSID to scan for (ProbeReq)
211                  * %NULL or zero-length SSID is used to indicate active scan
212                  * with wildcard SSID.
213                  */
214                 const u8 *ssid;
215                 /**
216                  * ssid_len: Length of the SSID in octets
217                  */
218                 size_t ssid_len;
219         } ssids[WPAS_MAX_SCAN_SSIDS];
220
221         /**
222          * num_ssids - Number of entries in ssids array
223          * Zero indicates a request for a passive scan.
224          */
225         size_t num_ssids;
226
227         /**
228          * extra_ies - Extra IE(s) to add into Probe Request or %NULL
229          */
230         const u8 *extra_ies;
231
232         /**
233          * extra_ies_len - Length of extra_ies in octets
234          */
235         size_t extra_ies_len;
236
237         /**
238          * freqs - Array of frequencies to scan or %NULL for all frequencies
239          *
240          * The frequency is set in MHz. The array is zero-terminated.
241          */
242         int *freqs;
243
244         /**
245          * filter_ssids - Filter for reporting SSIDs
246          *
247          * This optional parameter can be used to request the driver wrapper to
248          * filter scan results to include only the specified SSIDs. %NULL
249          * indicates that no filtering is to be done. This can be used to
250          * reduce memory needs for scan results in environments that have large
251          * number of APs with different SSIDs.
252          *
253          * The driver wrapper is allowed to take this allocated buffer into its
254          * own use by setting the pointer to %NULL. In that case, the driver
255          * wrapper is responsible for freeing the buffer with os_free() once it
256          * is not needed anymore.
257          */
258         struct wpa_driver_scan_filter {
259                 u8 ssid[32];
260                 size_t ssid_len;
261         } *filter_ssids;
262
263         /**
264          * num_filter_ssids - Number of entries in filter_ssids array
265          */
266         size_t num_filter_ssids;
267 };
268
269 /**
270  * struct wpa_driver_auth_params - Authentication parameters
271  * Data for struct wpa_driver_ops::authenticate().
272  */
273 struct wpa_driver_auth_params {
274         int freq;
275         const u8 *bssid;
276         const u8 *ssid;
277         size_t ssid_len;
278         int auth_alg;
279         const u8 *ie;
280         size_t ie_len;
281         const u8 *wep_key[4];
282         size_t wep_key_len[4];
283         int wep_tx_keyidx;
284         int local_state_change;
285 };
286
287 enum wps_mode {
288         WPS_MODE_NONE /* no WPS provisioning being used */,
289         WPS_MODE_OPEN /* WPS provisioning with AP that is in open mode */,
290         WPS_MODE_PRIVACY /* WPS provisioning with AP that is using protection
291                           */
292 };
293
294 /**
295  * struct wpa_driver_associate_params - Association parameters
296  * Data for struct wpa_driver_ops::associate().
297  */
298 struct wpa_driver_associate_params {
299         /**
300          * bssid - BSSID of the selected AP
301          * This can be %NULL, if ap_scan=2 mode is used and the driver is
302          * responsible for selecting with which BSS to associate. */
303         const u8 *bssid;
304
305         /**
306          * ssid - The selected SSID
307          */
308         const u8 *ssid;
309
310         /**
311          * ssid_len - Length of the SSID (1..32)
312          */
313         size_t ssid_len;
314
315         /**
316          * freq - Frequency of the channel the selected AP is using
317          * Frequency that the selected AP is using (in MHz as
318          * reported in the scan results)
319          */
320         int freq;
321
322         /**
323          * wpa_ie - WPA information element for (Re)Association Request
324          * WPA information element to be included in (Re)Association
325          * Request (including information element id and length). Use
326          * of this WPA IE is optional. If the driver generates the WPA
327          * IE, it can use pairwise_suite, group_suite, and
328          * key_mgmt_suite to select proper algorithms. In this case,
329          * the driver has to notify wpa_supplicant about the used WPA
330          * IE by generating an event that the interface code will
331          * convert into EVENT_ASSOCINFO data (see below).
332          *
333          * When using WPA2/IEEE 802.11i, wpa_ie is used for RSN IE
334          * instead. The driver can determine which version is used by
335          * looking at the first byte of the IE (0xdd for WPA, 0x30 for
336          * WPA2/RSN).
337          *
338          * When using WPS, wpa_ie is used for WPS IE instead of WPA/RSN IE.
339          */
340         const u8 *wpa_ie;
341
342         /**
343          * wpa_ie_len - length of the wpa_ie
344          */
345         size_t wpa_ie_len;
346
347         /**
348          * pairwise_suite - Selected pairwise cipher suite
349          *
350          * This is usually ignored if @wpa_ie is used.
351          */
352         enum wpa_cipher pairwise_suite;
353
354         /**
355          * group_suite - Selected group cipher suite
356          *
357          * This is usually ignored if @wpa_ie is used.
358          */
359         enum wpa_cipher group_suite;
360
361         /**
362          * key_mgmt_suite - Selected key management suite
363          *
364          * This is usually ignored if @wpa_ie is used.
365          */
366         enum wpa_key_mgmt key_mgmt_suite;
367
368         /**
369          * auth_alg - Allowed authentication algorithms
370          * Bit field of WPA_AUTH_ALG_*
371          */
372         int auth_alg;
373
374         /**
375          * mode - Operation mode (infra/ibss) IEEE80211_MODE_*
376          */
377         int mode;
378
379         /**
380          * wep_key - WEP keys for static WEP configuration
381          */
382         const u8 *wep_key[4];
383
384         /**
385          * wep_key_len - WEP key length for static WEP configuration
386          */
387         size_t wep_key_len[4];
388
389         /**
390          * wep_tx_keyidx - WEP TX key index for static WEP configuration
391          */
392         int wep_tx_keyidx;
393
394         /**
395          * mgmt_frame_protection - IEEE 802.11w management frame protection
396          */
397         enum mfp_options mgmt_frame_protection;
398
399         /**
400          * ft_ies - IEEE 802.11r / FT information elements
401          * If the supplicant is using IEEE 802.11r (FT) and has the needed keys
402          * for fast transition, this parameter is set to include the IEs that
403          * are to be sent in the next FT Authentication Request message.
404          * update_ft_ies() handler is called to update the IEs for further
405          * FT messages in the sequence.
406          *
407          * The driver should use these IEs only if the target AP is advertising
408          * the same mobility domain as the one included in the MDIE here.
409          *
410          * In ap_scan=2 mode, the driver can use these IEs when moving to a new
411          * AP after the initial association. These IEs can only be used if the
412          * target AP is advertising support for FT and is using the same MDIE
413          * and SSID as the current AP.
414          *
415          * The driver is responsible for reporting the FT IEs received from the
416          * AP's response using wpa_supplicant_event() with EVENT_FT_RESPONSE
417          * type. update_ft_ies() handler will then be called with the FT IEs to
418          * include in the next frame in the authentication sequence.
419          */
420         const u8 *ft_ies;
421
422         /**
423          * ft_ies_len - Length of ft_ies in bytes
424          */
425         size_t ft_ies_len;
426
427         /**
428          * ft_md - FT Mobility domain (6 octets) (also included inside ft_ies)
429          *
430          * This value is provided to allow the driver interface easier access
431          * to the current mobility domain. This value is set to %NULL if no
432          * mobility domain is currently active.
433          */
434         const u8 *ft_md;
435
436         /**
437          * passphrase - RSN passphrase for PSK
438          *
439          * This value is made available only for WPA/WPA2-Personal (PSK) and
440          * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
441          * the 8..63 character ASCII passphrase, if available. Please note that
442          * this can be %NULL if passphrase was not used to generate the PSK. In
443          * that case, the psk field must be used to fetch the PSK.
444          */
445         const char *passphrase;
446
447         /**
448          * psk - RSN PSK (alternative for passphrase for PSK)
449          *
450          * This value is made available only for WPA/WPA2-Personal (PSK) and
451          * only for drivers that set WPA_DRIVER_FLAGS_4WAY_HANDSHAKE. This is
452          * the 32-octet (256-bit) PSK, if available. The driver wrapper should
453          * be prepared to handle %NULL value as an error.
454          */
455         const u8 *psk;
456
457         /**
458          * drop_unencrypted - Enable/disable unencrypted frame filtering
459          *
460          * Configure the driver to drop all non-EAPOL frames (both receive and
461          * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must
462          * still be allowed for key negotiation.
463          */
464         int drop_unencrypted;
465
466         /**
467          * prev_bssid - Previously used BSSID in this ESS
468          *
469          * When not %NULL, this is a request to use reassociation instead of
470          * association.
471          */
472         const u8 *prev_bssid;
473
474         /**
475          * wps - WPS mode
476          *
477          * If the driver needs to do special configuration for WPS association,
478          * this variable provides more information on what type of association
479          * is being requested. Most drivers should not need ot use this.
480          */
481         enum wps_mode wps;
482
483         /**
484          * p2p - Whether this connection is a P2P group
485          */
486         int p2p;
487
488         /**
489          * uapsd - UAPSD parameters for the network
490          * -1 = do not change defaults
491          * AP mode: 1 = enabled, 0 = disabled
492          * STA mode: bits 0..3 UAPSD enabled for VO,VI,BK,BE
493          */
494         int uapsd;
495 };
496
497 /**
498  * struct wpa_driver_capa - Driver capability information
499  */
500 struct wpa_driver_capa {
501 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA            0x00000001
502 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2           0x00000002
503 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK        0x00000004
504 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK       0x00000008
505 #define WPA_DRIVER_CAPA_KEY_MGMT_WPA_NONE       0x00000010
506 #define WPA_DRIVER_CAPA_KEY_MGMT_FT             0x00000020
507 #define WPA_DRIVER_CAPA_KEY_MGMT_FT_PSK         0x00000040
508         unsigned int key_mgmt;
509
510 #define WPA_DRIVER_CAPA_ENC_WEP40       0x00000001
511 #define WPA_DRIVER_CAPA_ENC_WEP104      0x00000002
512 #define WPA_DRIVER_CAPA_ENC_TKIP        0x00000004
513 #define WPA_DRIVER_CAPA_ENC_CCMP        0x00000008
514         unsigned int enc;
515
516 #define WPA_DRIVER_AUTH_OPEN            0x00000001
517 #define WPA_DRIVER_AUTH_SHARED          0x00000002
518 #define WPA_DRIVER_AUTH_LEAP            0x00000004
519         unsigned int auth;
520
521 /* Driver generated WPA/RSN IE */
522 #define WPA_DRIVER_FLAGS_DRIVER_IE      0x00000001
523 /* Driver needs static WEP key setup after association command */
524 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC 0x00000002
525 #define WPA_DRIVER_FLAGS_USER_SPACE_MLME 0x00000004
526 /* Driver takes care of RSN 4-way handshake internally; PMK is configured with
527  * struct wpa_driver_ops::set_key using alg = WPA_ALG_PMK */
528 #define WPA_DRIVER_FLAGS_4WAY_HANDSHAKE 0x00000008
529 #define WPA_DRIVER_FLAGS_WIRED          0x00000010
530 /* Driver provides separate commands for authentication and association (SME in
531  * wpa_supplicant). */
532 #define WPA_DRIVER_FLAGS_SME            0x00000020
533 /* Driver supports AP mode */
534 #define WPA_DRIVER_FLAGS_AP             0x00000040
535 /* Driver needs static WEP key setup after association has been completed */
536 #define WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE      0x00000080
537 /* Driver takes care of P2P management operations */
538 #define WPA_DRIVER_FLAGS_P2P_MGMT       0x00000100
539 /* Driver supports concurrent P2P operations */
540 #define WPA_DRIVER_FLAGS_P2P_CONCURRENT 0x00000200
541 /*
542  * Driver uses the initial interface as a dedicated management interface, i.e.,
543  * it cannot be used for P2P group operations.
544  */
545 #define WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE        0x00000400
546 /* This interface is P2P capable (P2P Device, GO, or P2P Client */
547 #define WPA_DRIVER_FLAGS_P2P_CAPABLE    0x00000800
548 /* Driver supports concurrent operations on multiple channels */
549 #define WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT       0x00001000
550         unsigned int flags;
551
552         int max_scan_ssids;
553
554         /**
555          * max_remain_on_chan - Maximum remain-on-channel duration in msec
556          */
557         unsigned int max_remain_on_chan;
558
559         /**
560          * max_stations - Maximum number of associated stations the driver
561          * supports in AP mode
562          */
563         unsigned int max_stations;
564 };
565
566
567 struct hostapd_data;
568
569 struct hostap_sta_driver_data {
570         unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
571         unsigned long current_tx_rate;
572         unsigned long inactive_msec;
573         unsigned long flags;
574         unsigned long num_ps_buf_frames;
575         unsigned long tx_retry_failed;
576         unsigned long tx_retry_count;
577         int last_rssi;
578         int last_ack_rssi;
579 };
580
581 struct hostapd_sta_add_params {
582         const u8 *addr;
583         u16 aid;
584         u16 capability;
585         const u8 *supp_rates;
586         size_t supp_rates_len;
587         u16 listen_interval;
588         const struct ieee80211_ht_capabilities *ht_capabilities;
589 };
590
591 struct hostapd_freq_params {
592         int mode;
593         int freq;
594         int channel;
595         int ht_enabled;
596         int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
597                                  * secondary channel below primary, 1 = HT40
598                                  * enabled, secondary channel above primary */
599 };
600
601 enum wpa_driver_if_type {
602         /**
603          * WPA_IF_STATION - Station mode interface
604          */
605         WPA_IF_STATION,
606
607         /**
608          * WPA_IF_AP_VLAN - AP mode VLAN interface
609          *
610          * This interface shares its address and Beacon frame with the main
611          * BSS.
612          */
613         WPA_IF_AP_VLAN,
614
615         /**
616          * WPA_IF_AP_BSS - AP mode BSS interface
617          *
618          * This interface has its own address and Beacon frame.
619          */
620         WPA_IF_AP_BSS,
621
622         /**
623          * WPA_IF_P2P_GO - P2P Group Owner
624          */
625         WPA_IF_P2P_GO,
626
627         /**
628          * WPA_IF_P2P_CLIENT - P2P Client
629          */
630         WPA_IF_P2P_CLIENT,
631
632         /**
633          * WPA_IF_P2P_GROUP - P2P Group interface (will become either
634          * WPA_IF_P2P_GO or WPA_IF_P2P_CLIENT, but the role is not yet known)
635          */
636         WPA_IF_P2P_GROUP
637 };
638
639 struct wpa_init_params {
640         const u8 *bssid;
641         const char *ifname;
642         const u8 *ssid;
643         size_t ssid_len;
644         const char *test_socket;
645         int use_pae_group_addr;
646         char **bridge;
647         size_t num_bridge;
648
649         u8 *own_addr; /* buffer for writing own MAC address */
650 };
651
652
653 struct wpa_bss_params {
654         /** Interface name (for multi-SSID/VLAN support) */
655         const char *ifname;
656         /** Whether IEEE 802.1X or WPA/WPA2 is enabled */
657         int enabled;
658
659         int wpa;
660         int ieee802_1x;
661         int wpa_group;
662         int wpa_pairwise;
663         int wpa_key_mgmt;
664         int rsn_preauth;
665 };
666
667 #define WPA_STA_AUTHORIZED BIT(0)
668 #define WPA_STA_WMM BIT(1)
669 #define WPA_STA_SHORT_PREAMBLE BIT(2)
670 #define WPA_STA_MFP BIT(3)
671
672 /**
673  * struct wpa_driver_ops - Driver interface API definition
674  *
675  * This structure defines the API that each driver interface needs to implement
676  * for core wpa_supplicant code. All driver specific functionality is captured
677  * in this wrapper.
678  */
679 struct wpa_driver_ops {
680         /** Name of the driver interface */
681         const char *name;
682         /** One line description of the driver interface */
683         const char *desc;
684
685         /**
686          * get_bssid - Get the current BSSID
687          * @priv: private driver interface data
688          * @bssid: buffer for BSSID (ETH_ALEN = 6 bytes)
689          *
690          * Returns: 0 on success, -1 on failure
691          *
692          * Query kernel driver for the current BSSID and copy it to bssid.
693          * Setting bssid to 00:00:00:00:00:00 is recommended if the STA is not
694          * associated.
695          */
696         int (*get_bssid)(void *priv, u8 *bssid);
697
698         /**
699          * get_ssid - Get the current SSID
700          * @priv: private driver interface data
701          * @ssid: buffer for SSID (at least 32 bytes)
702          *
703          * Returns: Length of the SSID on success, -1 on failure
704          *
705          * Query kernel driver for the current SSID and copy it to ssid.
706          * Returning zero is recommended if the STA is not associated.
707          *
708          * Note: SSID is an array of octets, i.e., it is not nul terminated and
709          * can, at least in theory, contain control characters (including nul)
710          * and as such, should be processed as binary data, not a printable
711          * string.
712          */
713         int (*get_ssid)(void *priv, u8 *ssid);
714
715         /**
716          * set_key - Configure encryption key
717          * @ifname: Interface name (for multi-SSID/VLAN support)
718          * @priv: private driver interface data
719          * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP,
720          *      %WPA_ALG_TKIP, %WPA_ALG_CCMP, %WPA_ALG_IGTK, %WPA_ALG_PMK);
721          *      %WPA_ALG_NONE clears the key.
722          * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for
723          *      broadcast/default keys
724          * @key_idx: key index (0..3), usually 0 for unicast keys; 0..4095 for
725          *      IGTK
726          * @set_tx: configure this key as the default Tx key (only used when
727          *      driver does not support separate unicast/individual key
728          * @seq: sequence number/packet number, seq_len octets, the next
729          *      packet number to be used for in replay protection; configured
730          *      for Rx keys (in most cases, this is only used with broadcast
731          *      keys and set to zero for unicast keys)
732          * @seq_len: length of the seq, depends on the algorithm:
733          *      TKIP: 6 octets, CCMP: 6 octets, IGTK: 6 octets
734          * @key: key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key,
735          *      8-byte Rx Mic Key
736          * @key_len: length of the key buffer in octets (WEP: 5 or 13,
737          *      TKIP: 32, CCMP: 16, IGTK: 16)
738          *
739          * Returns: 0 on success, -1 on failure
740          *
741          * Configure the given key for the kernel driver. If the driver
742          * supports separate individual keys (4 default keys + 1 individual),
743          * addr can be used to determine whether the key is default or
744          * individual. If only 4 keys are supported, the default key with key
745          * index 0 is used as the individual key. STA must be configured to use
746          * it as the default Tx key (set_tx is set) and accept Rx for all the
747          * key indexes. In most cases, WPA uses only key indexes 1 and 2 for
748          * broadcast keys, so key index 0 is available for this kind of
749          * configuration.
750          *
751          * Please note that TKIP keys include separate TX and RX MIC keys and
752          * some drivers may expect them in different order than wpa_supplicant
753          * is using. If the TX/RX keys are swapped, all TKIP encrypted packets
754          * will tricker Michael MIC errors. This can be fixed by changing the
755          * order of MIC keys by swapping te bytes 16..23 and 24..31 of the key
756          * in driver_*.c set_key() implementation, see driver_ndis.c for an
757          * example on how this can be done.
758          */
759         int (*set_key)(const char *ifname, void *priv, enum wpa_alg alg,
760                        const u8 *addr, int key_idx, int set_tx,
761                        const u8 *seq, size_t seq_len,
762                        const u8 *key, size_t key_len);
763
764         /**
765          * init - Initialize driver interface
766          * @ctx: context to be used when calling wpa_supplicant functions,
767          * e.g., wpa_supplicant_event()
768          * @ifname: interface name, e.g., wlan0
769          *
770          * Returns: Pointer to private data, %NULL on failure
771          *
772          * Initialize driver interface, including event processing for kernel
773          * driver events (e.g., associated, scan results, Michael MIC failure).
774          * This function can allocate a private configuration data area for
775          * @ctx, file descriptor, interface name, etc. information that may be
776          * needed in future driver operations. If this is not used, non-NULL
777          * value will need to be returned because %NULL is used to indicate
778          * failure. The returned value will be used as 'void *priv' data for
779          * all other driver_ops functions.
780          *
781          * The main event loop (eloop.c) of wpa_supplicant can be used to
782          * register callback for read sockets (eloop_register_read_sock()).
783          *
784          * See below for more information about events and
785          * wpa_supplicant_event() function.
786          */
787         void * (*init)(void *ctx, const char *ifname);
788
789         /**
790          * deinit - Deinitialize driver interface
791          * @priv: private driver interface data from init()
792          *
793          * Shut down driver interface and processing of driver events. Free
794          * private data buffer if one was allocated in init() handler.
795          */
796         void (*deinit)(void *priv);
797
798         /**
799          * set_param - Set driver configuration parameters
800          * @priv: private driver interface data from init()
801          * @param: driver specific configuration parameters
802          *
803          * Returns: 0 on success, -1 on failure
804          *
805          * Optional handler for notifying driver interface about configuration
806          * parameters (driver_param).
807          */
808         int (*set_param)(void *priv, const char *param);
809
810         /**
811          * set_countermeasures - Enable/disable TKIP countermeasures
812          * @priv: private driver interface data
813          * @enabled: 1 = countermeasures enabled, 0 = disabled
814          *
815          * Returns: 0 on success, -1 on failure
816          *
817          * Configure TKIP countermeasures. When these are enabled, the driver
818          * should drop all received and queued frames that are using TKIP.
819          */
820         int (*set_countermeasures)(void *priv, int enabled);
821
822         /**
823          * deauthenticate - Request driver to deauthenticate
824          * @priv: private driver interface data
825          * @addr: peer address (BSSID of the AP)
826          * @reason_code: 16-bit reason code to be sent in the deauthentication
827          *      frame
828          *
829          * Returns: 0 on success, -1 on failure
830          */
831         int (*deauthenticate)(void *priv, const u8 *addr, int reason_code);
832
833         /**
834          * disassociate - Request driver to disassociate
835          * @priv: private driver interface data
836          * @addr: peer address (BSSID of the AP)
837          * @reason_code: 16-bit reason code to be sent in the disassociation
838          *      frame
839          *
840          * Returns: 0 on success, -1 on failure
841          */
842         int (*disassociate)(void *priv, const u8 *addr, int reason_code);
843
844         /**
845          * associate - Request driver to associate
846          * @priv: private driver interface data
847          * @params: association parameters
848          *
849          * Returns: 0 on success, -1 on failure
850          */
851         int (*associate)(void *priv,
852                          struct wpa_driver_associate_params *params);
853
854         /**
855          * add_pmkid - Add PMKSA cache entry to the driver
856          * @priv: private driver interface data
857          * @bssid: BSSID for the PMKSA cache entry
858          * @pmkid: PMKID for the PMKSA cache entry
859          *
860          * Returns: 0 on success, -1 on failure
861          *
862          * This function is called when a new PMK is received, as a result of
863          * either normal authentication or RSN pre-authentication.
864          *
865          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
866          * associate(), add_pmkid() can be used to add new PMKSA cache entries
867          * in the driver. If the driver uses wpa_ie from wpa_supplicant, this
868          * driver_ops function does not need to be implemented. Likewise, if
869          * the driver does not support WPA, this function is not needed.
870          */
871         int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
872
873         /**
874          * remove_pmkid - Remove PMKSA cache entry to the driver
875          * @priv: private driver interface data
876          * @bssid: BSSID for the PMKSA cache entry
877          * @pmkid: PMKID for the PMKSA cache entry
878          *
879          * Returns: 0 on success, -1 on failure
880          *
881          * This function is called when the supplicant drops a PMKSA cache
882          * entry for any reason.
883          *
884          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
885          * associate(), remove_pmkid() can be used to synchronize PMKSA caches
886          * between the driver and wpa_supplicant. If the driver uses wpa_ie
887          * from wpa_supplicant, this driver_ops function does not need to be
888          * implemented. Likewise, if the driver does not support WPA, this
889          * function is not needed.
890          */
891         int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid);
892
893         /**
894          * flush_pmkid - Flush PMKSA cache
895          * @priv: private driver interface data
896          *
897          * Returns: 0 on success, -1 on failure
898          *
899          * This function is called when the supplicant drops all PMKSA cache
900          * entries for any reason.
901          *
902          * If the driver generates RSN IE, i.e., it does not use wpa_ie in
903          * associate(), remove_pmkid() can be used to synchronize PMKSA caches
904          * between the driver and wpa_supplicant. If the driver uses wpa_ie
905          * from wpa_supplicant, this driver_ops function does not need to be
906          * implemented. Likewise, if the driver does not support WPA, this
907          * function is not needed.
908          */
909         int (*flush_pmkid)(void *priv);
910
911         /**
912          * get_capa - Get driver capabilities
913          * @priv: private driver interface data
914          *
915          * Returns: 0 on success, -1 on failure
916          *
917          * Get driver/firmware/hardware capabilities.
918          */
919         int (*get_capa)(void *priv, struct wpa_driver_capa *capa);
920
921         /**
922          * poll - Poll driver for association information
923          * @priv: private driver interface data
924          *
925          * This is an option callback that can be used when the driver does not
926          * provide event mechanism for association events. This is called when
927          * receiving WPA EAPOL-Key messages that require association
928          * information. The driver interface is supposed to generate associnfo
929          * event before returning from this callback function. In addition, the
930          * driver interface should generate an association event after having
931          * sent out associnfo.
932          */
933         void (*poll)(void *priv);
934
935         /**
936          * get_ifname - Get interface name
937          * @priv: private driver interface data
938          *
939          * Returns: Pointer to the interface name. This can differ from the
940          * interface name used in init() call. Init() is called first.
941          *
942          * This optional function can be used to allow the driver interface to
943          * replace the interface name with something else, e.g., based on an
944          * interface mapping from a more descriptive name.
945          */
946         const char * (*get_ifname)(void *priv);
947
948         /**
949          * get_mac_addr - Get own MAC address
950          * @priv: private driver interface data
951          *
952          * Returns: Pointer to own MAC address or %NULL on failure
953          *
954          * This optional function can be used to get the own MAC address of the
955          * device from the driver interface code. This is only needed if the
956          * l2_packet implementation for the OS does not provide easy access to
957          * a MAC address. */
958         const u8 * (*get_mac_addr)(void *priv);
959
960         /**
961          * send_eapol - Optional function for sending EAPOL packets
962          * @priv: private driver interface data
963          * @dest: Destination MAC address
964          * @proto: Ethertype
965          * @data: EAPOL packet starting with IEEE 802.1X header
966          * @data_len: Size of the EAPOL packet
967          *
968          * Returns: 0 on success, -1 on failure
969          *
970          * This optional function can be used to override l2_packet operations
971          * with driver specific functionality. If this function pointer is set,
972          * l2_packet module is not used at all and the driver interface code is
973          * responsible for receiving and sending all EAPOL packets. The
974          * received EAPOL packets are sent to core code with EVENT_EAPOL_RX
975          * event. The driver interface is required to implement get_mac_addr()
976          * handler if send_eapol() is used.
977          */
978         int (*send_eapol)(void *priv, const u8 *dest, u16 proto,
979                           const u8 *data, size_t data_len);
980
981         /**
982          * set_operstate - Sets device operating state to DORMANT or UP
983          * @priv: private driver interface data
984          * @state: 0 = dormant, 1 = up
985          * Returns: 0 on success, -1 on failure
986          *
987          * This is an optional function that can be used on operating systems
988          * that support a concept of controlling network device state from user
989          * space applications. This function, if set, gets called with
990          * state = 1 when authentication has been completed and with state = 0
991          * when connection is lost.
992          */
993         int (*set_operstate)(void *priv, int state);
994
995         /**
996          * mlme_setprotection - MLME-SETPROTECTION.request primitive
997          * @priv: Private driver interface data
998          * @addr: Address of the station for which to set protection (may be
999          * %NULL for group keys)
1000          * @protect_type: MLME_SETPROTECTION_PROTECT_TYPE_*
1001          * @key_type: MLME_SETPROTECTION_KEY_TYPE_*
1002          * Returns: 0 on success, -1 on failure
1003          *
1004          * This is an optional function that can be used to set the driver to
1005          * require protection for Tx and/or Rx frames. This uses the layer
1006          * interface defined in IEEE 802.11i-2004 clause 10.3.22.1
1007          * (MLME-SETPROTECTION.request). Many drivers do not use explicit
1008          * set protection operation; instead, they set protection implicitly
1009          * based on configured keys.
1010          */
1011         int (*mlme_setprotection)(void *priv, const u8 *addr, int protect_type,
1012                                   int key_type);
1013
1014         /**
1015          * get_hw_feature_data - Get hardware support data (channels and rates)
1016          * @priv: Private driver interface data
1017          * @num_modes: Variable for returning the number of returned modes
1018          * flags: Variable for returning hardware feature flags
1019          * Returns: Pointer to allocated hardware data on success or %NULL on
1020          * failure. Caller is responsible for freeing this.
1021          *
1022          * This function is only needed for drivers that export MLME
1023          * (management frame processing) to %wpa_supplicant or hostapd.
1024          */
1025         struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
1026                                                          u16 *num_modes,
1027                                                          u16 *flags);
1028
1029         /**
1030          * set_channel - Set channel
1031          * @priv: Private driver interface data
1032          * @phymode: HOSTAPD_MODE_IEEE80211B, ..
1033          * @chan: IEEE 802.11 channel number
1034          * @freq: Frequency of the channel in MHz
1035          * Returns: 0 on success, -1 on failure
1036          *
1037          * This function is only needed for drivers that export MLME
1038          * (management frame processing) to wpa_supplicant.
1039          */
1040         int (*set_channel)(void *priv, enum hostapd_hw_mode phymode, int chan,
1041                            int freq);
1042
1043         /**
1044          * set_ssid - Set SSID
1045          * @priv: Private driver interface data
1046          * @ssid: SSID
1047          * @ssid_len: SSID length
1048          * Returns: 0 on success, -1 on failure
1049          *
1050          * This function is only needed for drivers that export MLME
1051          * (management frame processing) to wpa_supplicant.
1052          */
1053         int (*set_ssid)(void *priv, const u8 *ssid, size_t ssid_len);
1054
1055         /**
1056          * set_bssid - Set BSSID
1057          * @priv: Private driver interface data
1058          * @bssid: BSSID
1059          * Returns: 0 on success, -1 on failure
1060          *
1061          * This function is only needed for drivers that export MLME
1062          * (management frame processing) to wpa_supplicant.
1063          */
1064         int (*set_bssid)(void *priv, const u8 *bssid);
1065
1066         /**
1067          * send_mlme - Send management frame from MLME
1068          * @priv: Private driver interface data
1069          * @data: IEEE 802.11 management frame with IEEE 802.11 header
1070          * @data_len: Size of the management frame
1071          * Returns: 0 on success, -1 on failure
1072          *
1073          * This function is only needed for drivers that export MLME
1074          * (management frame processing) to wpa_supplicant.
1075          */
1076         int (*send_mlme)(void *priv, const u8 *data, size_t data_len);
1077
1078         /**
1079          * mlme_add_sta - Add a STA entry into the driver/netstack
1080          * @priv: Private driver interface data
1081          * @addr: MAC address of the STA (e.g., BSSID of the AP)
1082          * @supp_rates: Supported rate set (from (Re)AssocResp); in IEEE 802.11
1083          * format (one octet per rate, 1 = 0.5 Mbps)
1084          * @supp_rates_len: Number of entries in supp_rates
1085          * Returns: 0 on success, -1 on failure
1086          *
1087          * This function is only needed for drivers that export MLME
1088          * (management frame processing) to wpa_supplicant. When the MLME code
1089          * completes association with an AP, this function is called to
1090          * configure the driver/netstack with a STA entry for data frame
1091          * processing (TX rate control, encryption/decryption).
1092          */
1093         int (*mlme_add_sta)(void *priv, const u8 *addr, const u8 *supp_rates,
1094                             size_t supp_rates_len);
1095
1096         /**
1097          * mlme_remove_sta - Remove a STA entry from the driver/netstack
1098          * @priv: Private driver interface data
1099          * @addr: MAC address of the STA (e.g., BSSID of the AP)
1100          * Returns: 0 on success, -1 on failure
1101          *
1102          * This function is only needed for drivers that export MLME
1103          * (management frame processing) to wpa_supplicant.
1104          */
1105         int (*mlme_remove_sta)(void *priv, const u8 *addr);
1106
1107         /**
1108          * update_ft_ies - Update FT (IEEE 802.11r) IEs
1109          * @priv: Private driver interface data
1110          * @md: Mobility domain (2 octets) (also included inside ies)
1111          * @ies: FT IEs (MDIE, FTIE, ...) or %NULL to remove IEs
1112          * @ies_len: Length of FT IEs in bytes
1113          * Returns: 0 on success, -1 on failure
1114          *
1115          * The supplicant uses this callback to let the driver know that keying
1116          * material for FT is available and that the driver can use the
1117          * provided IEs in the next message in FT authentication sequence.
1118          *
1119          * This function is only needed for driver that support IEEE 802.11r
1120          * (Fast BSS Transition).
1121          */
1122         int (*update_ft_ies)(void *priv, const u8 *md, const u8 *ies,
1123                              size_t ies_len);
1124
1125         /**
1126          * send_ft_action - Send FT Action frame (IEEE 802.11r)
1127          * @priv: Private driver interface data
1128          * @action: Action field value
1129          * @target_ap: Target AP address
1130          * @ies: FT IEs (MDIE, FTIE, ...) (FT Request action frame body)
1131          * @ies_len: Length of FT IEs in bytes
1132          * Returns: 0 on success, -1 on failure
1133          *
1134          * The supplicant uses this callback to request the driver to transmit
1135          * an FT Action frame (action category 6) for over-the-DS fast BSS
1136          * transition.
1137          */
1138         int (*send_ft_action)(void *priv, u8 action, const u8 *target_ap,
1139                               const u8 *ies, size_t ies_len);
1140
1141         /**
1142          * get_scan_results2 - Fetch the latest scan results
1143          * @priv: private driver interface data
1144          *
1145          * Returns: Allocated buffer of scan results (caller is responsible for
1146          * freeing the data structure) on success, NULL on failure
1147          */
1148          struct wpa_scan_results * (*get_scan_results2)(void *priv);
1149
1150         /**
1151          * set_country - Set country
1152          * @priv: Private driver interface data
1153          * @alpha2: country to which to switch to
1154          * Returns: 0 on success, -1 on failure
1155          *
1156          * This function is for drivers which support some form
1157          * of setting a regulatory domain.
1158          */
1159         int (*set_country)(void *priv, const char *alpha2);
1160
1161         /**
1162          * global_init - Global driver initialization
1163          * Returns: Pointer to private data (global), %NULL on failure
1164          *
1165          * This optional function is called to initialize the driver wrapper
1166          * for global data, i.e., data that applies to all interfaces. If this
1167          * function is implemented, global_deinit() will also need to be
1168          * implemented to free the private data. The driver will also likely
1169          * use init2() function instead of init() to get the pointer to global
1170          * data available to per-interface initializer.
1171          */
1172         void * (*global_init)(void);
1173
1174         /**
1175          * global_deinit - Global driver deinitialization
1176          * @priv: private driver global data from global_init()
1177          *
1178          * Terminate any global driver related functionality and free the
1179          * global data structure.
1180          */
1181         void (*global_deinit)(void *priv);
1182
1183         /**
1184          * init2 - Initialize driver interface (with global data)
1185          * @ctx: context to be used when calling wpa_supplicant functions,
1186          * e.g., wpa_supplicant_event()
1187          * @ifname: interface name, e.g., wlan0
1188          * @global_priv: private driver global data from global_init()
1189          * Returns: Pointer to private data, %NULL on failure
1190          *
1191          * This function can be used instead of init() if the driver wrapper
1192          * uses global data.
1193          */
1194         void * (*init2)(void *ctx, const char *ifname, void *global_priv);
1195
1196         /**
1197          * get_interfaces - Get information about available interfaces
1198          * @global_priv: private driver global data from global_init()
1199          * Returns: Allocated buffer of interface information (caller is
1200          * responsible for freeing the data structure) on success, NULL on
1201          * failure
1202          */
1203         struct wpa_interface_info * (*get_interfaces)(void *global_priv);
1204
1205         /**
1206          * scan2 - Request the driver to initiate scan
1207          * @priv: private driver interface data
1208          * @params: Scan parameters
1209          *
1210          * Returns: 0 on success, -1 on failure
1211          *
1212          * Once the scan results are ready, the driver should report scan
1213          * results event for wpa_supplicant which will eventually request the
1214          * results with wpa_driver_get_scan_results2().
1215          */
1216         int (*scan2)(void *priv, struct wpa_driver_scan_params *params);
1217
1218         /**
1219          * authenticate - Request driver to authenticate
1220          * @priv: private driver interface data
1221          * @params: authentication parameters
1222          * Returns: 0 on success, -1 on failure
1223          *
1224          * This is an optional function that can be used with drivers that
1225          * support separate authentication and association steps, i.e., when
1226          * wpa_supplicant can act as the SME. If not implemented, associate()
1227          * function is expected to take care of IEEE 802.11 authentication,
1228          * too.
1229          */
1230         int (*authenticate)(void *priv,
1231                             struct wpa_driver_auth_params *params);
1232
1233         /**
1234          * set_beacon - Set Beacon frame template
1235          * @priv: Private driver interface data
1236          * @head: Beacon head from IEEE 802.11 header to IEs before TIM IE
1237          * @head_len: Length of the head buffer in octets
1238          * @tail: Beacon tail following TIM IE
1239          * @tail_len: Length of the tail buffer in octets
1240          * @dtim_period: DTIM period
1241          * @beacon_int: Beacon interval
1242          * Returns: 0 on success, -1 on failure
1243          *
1244          * This function is used to configure Beacon template for the driver in
1245          * AP mode. The driver is responsible for building the full Beacon
1246          * frame by concatenating the head part with TIM IE generated by the
1247          * driver/firmware and finishing with the tail part.
1248          */
1249         int (*set_beacon)(void *priv, const u8 *head, size_t head_len,
1250                           const u8 *tail, size_t tail_len, int dtim_period,
1251                           int beacon_int);
1252
1253         /**
1254          * hapd_init - Initialize driver interface (hostapd only)
1255          * @hapd: Pointer to hostapd context
1256          * @params: Configuration for the driver wrapper
1257          * Returns: Pointer to private data, %NULL on failure
1258          *
1259          * This function is used instead of init() or init2() when the driver
1260          * wrapper is used withh hostapd.
1261          */
1262         void * (*hapd_init)(struct hostapd_data *hapd,
1263                             struct wpa_init_params *params);
1264
1265         /**
1266          * hapd_deinit - Deinitialize driver interface (hostapd only)
1267          * @priv: Private driver interface data from hapd_init()
1268          */
1269         void (*hapd_deinit)(void *priv);
1270
1271         /**
1272          * set_ieee8021x - Enable/disable IEEE 802.1X support (AP only)
1273          * @priv: Private driver interface data
1274          * @params: BSS parameters
1275          * Returns: 0 on success, -1 on failure
1276          *
1277          * This is an optional function to configure the kernel driver to
1278          * enable/disable IEEE 802.1X support and set WPA/WPA2 parameters. This
1279          * can be left undefined (set to %NULL) if IEEE 802.1X support is
1280          * always enabled and the driver uses set_beacon() to set WPA/RSN IE
1281          * for Beacon frames.
1282          */
1283         int (*set_ieee8021x)(void *priv, struct wpa_bss_params *params);
1284
1285         /**
1286          * set_privacy - Enable/disable privacy (AP only)
1287          * @priv: Private driver interface data
1288          * @enabled: 1 = privacy enabled, 0 = disabled
1289          * Returns: 0 on success, -1 on failure
1290          *
1291          * This is an optional function to configure privacy field in the
1292          * kernel driver for Beacon frames. This can be left undefined (set to
1293          * %NULL) if the driver uses the Beacon template from set_beacon().
1294          */
1295         int (*set_privacy)(void *priv, int enabled);
1296
1297         /**
1298          * get_seqnum - Fetch the current TSC/packet number (AP only)
1299          * @ifname: The interface name (main or virtual)
1300          * @priv: Private driver interface data
1301          * @addr: MAC address of the station or %NULL for group keys
1302          * @idx: Key index
1303          * @seq: Buffer for returning the latest used TSC/packet number
1304          * Returns: 0 on success, -1 on failure
1305          *
1306          * This function is used to fetch the last used TSC/packet number for
1307          * a TKIP, CCMP, or BIP/IGTK key. It is mainly used with group keys, so
1308          * there is no strict requirement on implementing support for unicast
1309          * keys (i.e., addr != %NULL).
1310          */
1311         int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
1312                           int idx, u8 *seq);
1313
1314         /**
1315          * flush - Flush all association stations (AP only)
1316          * @priv: Private driver interface data
1317          * Returns: 0 on success, -1 on failure
1318          *
1319          * This function requests the driver to disassociate all associated
1320          * stations. This function does not need to be implemented if the
1321          * driver does not process association frames internally.
1322          */
1323         int (*flush)(void *priv);
1324
1325         /**
1326          * set_generic_elem - Add IEs into Beacon/Probe Response frames (AP)
1327          * @priv: Private driver interface data
1328          * @elem: Information elements
1329          * @elem_len: Length of the elem buffer in octets
1330          * Returns: 0 on success, -1 on failure
1331          *
1332          * This is an optional function to add information elements in the
1333          * kernel driver for Beacon and Probe Response frames. This can be left
1334          * undefined (set to %NULL) if the driver uses the Beacon template from
1335          * set_beacon().
1336          */
1337         int (*set_generic_elem)(void *priv, const u8 *elem, size_t elem_len);
1338
1339         /**
1340          * read_sta_data - Fetch station data (AP only)
1341          * @priv: Private driver interface data
1342          * @data: Buffer for returning station information
1343          * @addr: MAC address of the station
1344          * Returns: 0 on success, -1 on failure
1345          */
1346         int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
1347                              const u8 *addr);
1348
1349         /**
1350          * hapd_send_eapol - Send an EAPOL packet (AP only)
1351          * @priv: private driver interface data
1352          * @addr: Destination MAC address
1353          * @data: EAPOL packet starting with IEEE 802.1X header
1354          * @data_len: Length of the EAPOL packet in octets
1355          * @encrypt: Whether the frame should be encrypted
1356          * @own_addr: Source MAC address
1357          *
1358          * Returns: 0 on success, -1 on failure
1359          */
1360         int (*hapd_send_eapol)(void *priv, const u8 *addr, const u8 *data,
1361                                size_t data_len, int encrypt,
1362                                const u8 *own_addr);
1363
1364         /**
1365          * sta_deauth - Deauthenticate a station (AP only)
1366          * @priv: Private driver interface data
1367          * @own_addr: Source address and BSSID for the Deauthentication frame
1368          * @addr: MAC address of the station to deauthenticate
1369          * @reason: Reason code for the Deauthentiation frame
1370          * Returns: 0 on success, -1 on failure
1371          *
1372          * This function requests a specific station to be deauthenticated and
1373          * a Deauthentication frame to be sent to it.
1374          */
1375         int (*sta_deauth)(void *priv, const u8 *own_addr, const u8 *addr,
1376                           int reason);
1377
1378         /**
1379          * sta_disassoc - Disassociate a station (AP only)
1380          * @priv: Private driver interface data
1381          * @own_addr: Source address and BSSID for the Disassociation frame
1382          * @addr: MAC address of the station to disassociate
1383          * @reason: Reason code for the Disassociation frame
1384          * Returns: 0 on success, -1 on failure
1385          *
1386          * This function requests a specific station to be disassociated and
1387          * a Disassociation frame to be sent to it.
1388          */
1389         int (*sta_disassoc)(void *priv, const u8 *own_addr, const u8 *addr,
1390                             int reason);
1391
1392         /**
1393          * sta_remove - Remove a station entry (AP only)
1394          * @priv: Private driver interface data
1395          * @addr: MAC address of the station to be removed
1396          * Returns: 0 on success, -1 on failure
1397          */
1398         int (*sta_remove)(void *priv, const u8 *addr);
1399
1400         /**
1401          * hapd_get_ssid - Get the current SSID (AP only)
1402          * @priv: Private driver interface data
1403          * @buf: Buffer for returning the SSID
1404          * @len: Maximum length of the buffer
1405          * Returns: Length of the SSID on success, -1 on failure
1406          *
1407          * This function need not be implemented if the driver uses Beacon
1408          * template from set_beacon() and does not reply to Probe Request
1409          * frames.
1410          */
1411         int (*hapd_get_ssid)(void *priv, u8 *buf, int len);
1412
1413         /**
1414          * hapd_set_ssid - Set SSID (AP only)
1415          * @priv: Private driver interface data
1416          * @buf: SSID
1417          * @len: Length of the SSID in octets
1418          * Returns: 0 on success, -1 on failure
1419          */
1420         int (*hapd_set_ssid)(void *priv, const u8 *buf, int len);
1421
1422         /**
1423          * hapd_set_countermeasures - Enable/disable TKIP countermeasures (AP)
1424          * @priv: Private driver interface data
1425          * @enabled: 1 = countermeasures enabled, 0 = disabled
1426          * Returns: 0 on success, -1 on failure
1427          *
1428          * This need not be implemented if the driver does not take care of
1429          * association processing.
1430          */
1431         int (*hapd_set_countermeasures)(void *priv, int enabled);
1432
1433         /**
1434          * sta_add - Add a station entry
1435          * @priv: Private driver interface data
1436          * @params: Station parameters
1437          * Returns: 0 on success, -1 on failure
1438          *
1439          * This function is used to add a station entry to the driver once the
1440          * station has completed association. This is only used if the driver
1441          * does not take care of association processing.
1442          */
1443         int (*sta_add)(void *priv, struct hostapd_sta_add_params *params);
1444
1445         /**
1446          * get_inact_sec - Get station inactivity duration (AP only)
1447          * @priv: Private driver interface data
1448          * @addr: Station address
1449          * Returns: Number of seconds station has been inactive, -1 on failure
1450          */
1451         int (*get_inact_sec)(void *priv, const u8 *addr);
1452
1453         /**
1454          * sta_clear_stats - Clear station statistics (AP only)
1455          * @priv: Private driver interface data
1456          * @addr: Station address
1457          * Returns: 0 on success, -1 on failure
1458          */
1459         int (*sta_clear_stats)(void *priv, const u8 *addr);
1460
1461         /**
1462          * set_freq - Set channel/frequency (AP only)
1463          * @priv: Private driver interface data
1464          * @freq: Channel parameters
1465          * Returns: 0 on success, -1 on failure
1466          */
1467         int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
1468
1469         /**
1470          * set_rts - Set RTS threshold
1471          * @priv: Private driver interface data
1472          * @rts: RTS threshold in octets
1473          * Returns: 0 on success, -1 on failure
1474          */
1475         int (*set_rts)(void *priv, int rts);
1476
1477         /**
1478          * set_frag - Set fragmentation threshold
1479          * @priv: Private driver interface data
1480          * @frag: Fragmentation threshold in octets
1481          * Returns: 0 on success, -1 on failure
1482          */
1483         int (*set_frag)(void *priv, int frag);
1484
1485         /**
1486          * sta_set_flags - Set station flags (AP only)
1487          * @priv: Private driver interface data
1488          * @addr: Station address
1489          * @total_flags: Bitmap of all WPA_STA_* flags currently set
1490          * @flags_or: Bitmap of WPA_STA_* flags to add
1491          * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
1492          * Returns: 0 on success, -1 on failure
1493          */
1494         int (*sta_set_flags)(void *priv, const u8 *addr,
1495                              int total_flags, int flags_or, int flags_and);
1496
1497         /**
1498          * set_rate_sets - Set supported and basic rate sets (AP only)
1499          * @priv: Private driver interface data
1500          * @supp_rates: -1 terminated array of supported rates in 100 kbps
1501          * @basic_rates: -1 terminated array of basic rates in 100 kbps
1502          * @mode: hardware mode (HOSTAPD_MODE_*)
1503          * Returns: 0 on success, -1 on failure
1504          */
1505         int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
1506                              int mode);
1507
1508         /**
1509          * set_cts_protect - Set CTS protection mode (AP only)
1510          * @priv: Private driver interface data
1511          * @value: Whether CTS protection is enabled
1512          * Returns: 0 on success, -1 on failure
1513          */
1514         int (*set_cts_protect)(void *priv, int value);
1515
1516         /**
1517          * set_preamble - Set preamble mode (AP only)
1518          * @priv: Private driver interface data
1519          * @value: Whether short preamble is enabled
1520          * Returns: 0 on success, -1 on failure
1521          */
1522         int (*set_preamble)(void *priv, int value);
1523
1524         /**
1525          * set_short_slot_time - Set short slot time (AP only)
1526          * @priv: Private driver interface data
1527          * @value: Whether short slot time is enabled
1528          * Returns: 0 on success, -1 on failure
1529          */
1530         int (*set_short_slot_time)(void *priv, int value);
1531
1532         /**
1533          * set_tx_queue_params - Set TX queue parameters
1534          * @priv: Private driver interface data
1535          * @queue: Queue number (0 = VO, 1 = VI, 2 = BE, 3 = BK)
1536          * @aifs: AIFS
1537          * @cw_min: cwMin
1538          * @cw_max: cwMax
1539          * @burst_time: Maximum length for bursting in 0.1 msec units
1540          */
1541         int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
1542                                    int cw_max, int burst_time);
1543
1544         /**
1545          * valid_bss_mask - Validate BSSID mask
1546          * @priv: Private driver interface data
1547          * @addr: Address
1548          * @mask: Mask
1549          * Returns: 0 if mask is valid, -1 if mask is not valid, 1 if mask can
1550          * be used, but the main interface address must be the first address in
1551          * the block if mask is applied
1552          */
1553         int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
1554
1555         /**
1556          * if_add - Add a virtual interface
1557          * @priv: Private driver interface data
1558          * @type: Interface type
1559          * @ifname: Interface name for the new virtual interface
1560          * @addr: Local address to use for the interface or %NULL to use the
1561          *      parent interface address
1562          * @bss_ctx: BSS context for %WPA_IF_AP_BSS interfaces
1563          * @drv_priv: Pointer for overwriting the driver context or %NULL if
1564          *      not allowed (applies only to %WPA_IF_AP_BSS type)
1565          * @force_ifname: Buffer for returning an interface name that the
1566          *      driver ended up using if it differs from the requested ifname
1567          * @if_addr: Buffer for returning the allocated interface address
1568          *      (this may differ from the requested addr if the driver cannot
1569          *      change interface address)
1570          * Returns: 0 on success, -1 on failure
1571          */
1572         int (*if_add)(void *priv, enum wpa_driver_if_type type,
1573                       const char *ifname, const u8 *addr, void *bss_ctx,
1574                       void **drv_priv, char *force_ifname, u8 *if_addr);
1575
1576         /**
1577          * if_remove - Remove a virtual interface
1578          * @priv: Private driver interface data
1579          * @type: Interface type
1580          * @ifname: Interface name of the virtual interface to be removed
1581          * Returns: 0 on success, -1 on failure
1582          */
1583         int (*if_remove)(void *priv, enum wpa_driver_if_type type,
1584                          const char *ifname);
1585
1586         /**
1587          * set_sta_vlan - Bind a station into a specific interface (AP only)
1588          * @priv: Private driver interface data
1589          * @ifname: Interface (main or virtual BSS or VLAN)
1590          * @addr: MAC address of the associated station
1591          * @vlan_id: VLAN ID
1592          * Returns: 0 on success, -1 on failure
1593          *
1594          * This function is used to bind a station to a specific virtual
1595          * interface. It is only used if when virtual interfaces are supported,
1596          * e.g., to assign stations to different VLAN interfaces based on
1597          * information from a RADIUS server. This allows separate broadcast
1598          * domains to be used with a single BSS.
1599          */
1600         int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
1601                             int vlan_id);
1602
1603         /**
1604          * commit - Optional commit changes handler (AP only)
1605          * @priv: driver private data
1606          * Returns: 0 on success, -1 on failure
1607          *
1608          * This optional handler function can be registered if the driver
1609          * interface implementation needs to commit changes (e.g., by setting
1610          * network interface up) at the end of initial configuration. If set,
1611          * this handler will be called after initial setup has been completed.
1612          */
1613         int (*commit)(void *priv);
1614
1615         /**
1616          * send_ether - Send an ethernet packet (AP only)
1617          * @priv: private driver interface data
1618          * @dst: Destination MAC address
1619          * @src: Source MAC address
1620          * @proto: Ethertype
1621          * @data: EAPOL packet starting with IEEE 802.1X header
1622          * @data_len: Length of the EAPOL packet in octets
1623          * Returns: 0 on success, -1 on failure
1624          */
1625         int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
1626                           const u8 *data, size_t data_len);
1627
1628         /**
1629          * set_radius_acl_auth - Notification of RADIUS ACL change
1630          * @priv: Private driver interface data
1631          * @mac: MAC address of the station
1632          * @accepted: Whether the station was accepted
1633          * @session_timeout: Session timeout for the station
1634          * Returns: 0 on success, -1 on failure
1635          */
1636         int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted, 
1637                                    u32 session_timeout);
1638
1639         /**
1640          * set_radius_acl_expire - Notification of RADIUS ACL expiration
1641          * @priv: Private driver interface data
1642          * @mac: MAC address of the station
1643          * Returns: 0 on success, -1 on failure
1644          */
1645         int (*set_radius_acl_expire)(void *priv, const u8 *mac);
1646
1647         /**
1648          * set_ht_params - Set HT parameters (AP only)
1649          * @priv: Private driver interface data
1650          * @ht_capab: HT Capabilities IE
1651          * @ht_capab_len: Length of ht_capab in octets
1652          * @ht_oper: HT Operation IE
1653          * @ht_oper_len: Length of ht_oper in octets
1654          * Returns: 0 on success, -1 on failure
1655          */
1656         int (*set_ht_params)(void *priv,
1657                              const u8 *ht_capab, size_t ht_capab_len,
1658                              const u8 *ht_oper, size_t ht_oper_len);
1659
1660         /**
1661          * set_ap_wps_ie - Add WPS IE(s) into Beacon/Probe Response frames (AP)
1662          * @priv: Private driver interface data
1663          * @beacon: WPS IE(s) for Beacon frames or %NULL to remove extra IE(s)
1664          * @proberesp: WPS IE(s) for Probe Response frames or %NULL to remove
1665          *      extra IE(s)
1666          * @assocresp: WPS IE(s) for (Re)Association Response frames or %NULL
1667          *      to remove extra IE(s)
1668          * Returns: 0 on success, -1 on failure
1669          *
1670          * This is an optional function to add WPS IE in the kernel driver for
1671          * Beacon and Probe Response frames. This can be left undefined (set
1672          * to %NULL) if the driver uses the Beacon template from set_beacon()
1673          * and does not process Probe Request frames. If the driver takes care
1674          * of (Re)Association frame processing, the assocresp buffer includes
1675          * WPS IE(s) that need to be added to (Re)Association Response frames
1676          * whenever a (Re)Association Request frame indicated use of WPS.
1677          *
1678          * This will also be used to add P2P IE(s) into Beacon/Probe Response
1679          * frames when operating as a GO. The driver is responsible for adding
1680          * timing related attributes (e.g., NoA) in addition to the IEs
1681          * included here by appending them after these buffers. This call is
1682          * also used to provide Probe Response IEs for P2P Listen state
1683          * operations for drivers that generate the Probe Response frames
1684          * internally.
1685          */
1686         int (*set_ap_wps_ie)(void *priv, const struct wpabuf *beacon,
1687                              const struct wpabuf *proberesp,
1688                              const struct wpabuf *assocresp);
1689
1690         /**
1691          * set_supp_port - Set IEEE 802.1X Supplicant Port status
1692          * @priv: Private driver interface data
1693          * @authorized: Whether the port is authorized
1694          * Returns: 0 on success, -1 on failure
1695          */
1696         int (*set_supp_port)(void *priv, int authorized);
1697
1698         /**
1699          * set_wds_sta - Bind a station into a 4-address WDS (AP only)
1700          * @priv: Private driver interface data
1701          * @addr: MAC address of the associated station
1702          * @aid: Association ID
1703          * @val: 1 = bind to 4-address WDS; 0 = unbind
1704          * @bridge_ifname: Bridge interface to use for the WDS station or %NULL
1705          *      to indicate that bridge is not to be used
1706          * Returns: 0 on success, -1 on failure
1707          */
1708         int (*set_wds_sta)(void *priv, const u8 *addr, int aid, int val,
1709                            const char *bridge_ifname);
1710
1711         /**
1712          * send_action - Transmit an Action frame
1713          * @priv: Private driver interface data
1714          * @freq: Frequency (in MHz) of the channel
1715          * @dst: Destination MAC address (Address 1)
1716          * @src: Source MAC address (Address 2)
1717          * @bssid: BSSID (Address 3)
1718          * @data: Frame body
1719          * @data_len: data length in octets
1720          * Returns: 0 on success, -1 on failure
1721          *
1722          * This command can be used to request the driver to transmit an action
1723          * frame to the specified destination. If a remain-on-channel duration
1724          * is in progress, the frame is transmitted on that channel. Otherwise,
1725          * the frame is transmitted on the current operational channel if in
1726          * associated state in station mode or if operating as an AP. If none
1727          * of these conditions is in effect, send_action() cannot be used.
1728          */
1729         int (*send_action)(void *priv, unsigned int freq,
1730                            const u8 *dst, const u8 *src, const u8 *bssid,
1731                            const u8 *data, size_t data_len);
1732
1733         /**
1734          * remain_on_channel - Remain awake on a channel
1735          * @priv: Private driver interface data
1736          * @freq: Frequency (in MHz) of the channel
1737          * @duration: Duration in milliseconds
1738          * Returns: 0 on success, -1 on failure
1739          *
1740          * This command is used to request the driver to remain awake on the
1741          * specified channel for the specified duration and report received
1742          * Action frames with EVENT_RX_ACTION events. Optionally, received
1743          * Probe Request frames may also be requested to be reported by calling
1744          * probe_req_report(). These will be reported with EVENT_RX_PROBE_REQ.
1745          *
1746          * The driver may not be at the requested channel when this function
1747          * returns, i.e., the return code is only indicating whether the
1748          * request was accepted. The caller will need to wait until the
1749          * EVENT_REMAIN_ON_CHANNEL event indicates that the driver has
1750          * completed the channel change. This may take some time due to other
1751          * need for the radio and the caller should be prepared to timing out
1752          * its wait since there are no guarantees on when this request can be
1753          * executed.
1754          */
1755         int (*remain_on_channel)(void *priv, unsigned int freq,
1756                                  unsigned int duration);
1757
1758         /**
1759          * cancel_remain_on_channel - Cancel remain-on-channel operation
1760          * @priv: Private driver interface data
1761          *
1762          * This command can be used to cancel a remain-on-channel operation
1763          * before its originally requested duration has passed. This could be
1764          * used, e.g., when remain_on_channel() is used to request extra time
1765          * to receive a response to an Action frame and the response is
1766          * received when there is still unneeded time remaining on the
1767          * remain-on-channel operation.
1768          */
1769         int (*cancel_remain_on_channel)(void *priv);
1770
1771         /**
1772          * probe_req_report - Request Probe Request frames to be indicated
1773          * @priv: Private driver interface data
1774          * @report: Whether to report received Probe Request frames
1775          * Returns: 0 on success, -1 on failure (or if not supported)
1776          *
1777          * This command can be used to request the driver to indicate when
1778          * Probe Request frames are received with EVENT_RX_PROBE_REQ events.
1779          * Since this operation may require extra resources, e.g., due to less
1780          * optimal hardware/firmware RX filtering, many drivers may disable
1781          * Probe Request reporting at least in station mode. This command is
1782          * used to notify the driver when the Probe Request frames need to be
1783          * reported, e.g., during remain-on-channel operations.
1784          */
1785         int (*probe_req_report)(void *priv, int report);
1786
1787         /**
1788          * disable_11b_rates - Set whether IEEE 802.11b rates are used for TX
1789          * @priv: Private driver interface data
1790          * @disabled: Whether IEEE 802.11b rates are disabled
1791          * Returns: 0 on success, -1 on failure (or if not supported)
1792          *
1793          * This command is used to disable IEEE 802.11b rates (1, 2, 5.5, and
1794          * 11 Mbps) as TX rates for data and management frames. This can be
1795          * used to optimize channel use when there is no need to support IEEE
1796          * 802.11b-only devices.
1797          */
1798         int (*disable_11b_rates)(void *priv, int disabled);
1799
1800         /**
1801          * deinit_ap - Deinitialize AP mode
1802          * @priv: Private driver interface data
1803          * Returns: 0 on success, -1 on failure (or if not supported)
1804          *
1805          * This optional function can be used to disable AP mode related
1806          * configuration and change the driver mode to station mode to allow
1807          * normal station operations like scanning to be completed.
1808          */
1809         int (*deinit_ap)(void *priv);
1810
1811         /**
1812          * suspend - Notification on system suspend/hibernate event
1813          * @priv: Private driver interface data
1814          */
1815         void (*suspend)(void *priv);
1816
1817         /**
1818          * resume - Notification on system resume/thaw event
1819          * @priv: Private driver interface data
1820          */
1821         void (*resume)(void *priv);
1822
1823         /**
1824          * signal_monitor - Set signal monitoring parameters
1825          * @priv: Private driver interface data
1826          * @threshold: Threshold value for signal change events; 0 = disabled
1827          * @hysteresis: Minimum change in signal strength before indicating a
1828          *      new event
1829          * Returns: 0 on success, -1 on failure (or if not supported)
1830          *
1831          * This function can be used to configure monitoring of signal strength
1832          * with the current AP. Whenever signal strength drops below the
1833          * %threshold value or increases above it, EVENT_SIGNAL_CHANGE event
1834          * should be generated assuming the signal strength has changed at
1835          * least %hysteresis from the previously indicated signal change event.
1836          */
1837         int (*signal_monitor)(void *priv, int threshold, int hysteresis);
1838
1839         /**
1840          * send_frame - Send IEEE 802.11 frame (testing use only)
1841          * @priv: Private driver interface data
1842          * @data: IEEE 802.11 frame with IEEE 802.11 header
1843          * @data_len: Size of the frame
1844          * @encrypt: Whether to encrypt the frame (if keys are set)
1845          * Returns: 0 on success, -1 on failure
1846          *
1847          * This function is only used for debugging purposes and is not
1848          * required to be implemented for normal operations.
1849          */
1850         int (*send_frame)(void *priv, const u8 *data, size_t data_len,
1851                           int encrypt);
1852
1853         /**
1854          * shared_freq - Get operating frequency of shared interface(s)
1855          * @priv: Private driver interface data
1856          * Returns: Operating frequency in MHz, 0 if no shared operation in
1857          * use, or -1 on failure
1858          *
1859          * This command can be used to request the current operating frequency
1860          * of any virtual interface that shares the same radio to provide
1861          * information for channel selection for other virtual interfaces.
1862          */
1863         int (*shared_freq)(void *priv);
1864
1865         /**
1866          * get_noa - Get current Notice of Absence attribute payload
1867          * @priv: Private driver interface data
1868          * @buf: Buffer for returning NoA
1869          * @buf_len: Buffer length in octets
1870          * Returns: Number of octets used in buf, 0 to indicate no NoA is being
1871          * advertized, or -1 on failure
1872          *
1873          * This function is used to fetch the current Notice of Absence
1874          * attribute value from GO.
1875          */
1876         int (*get_noa)(void *priv, u8 *buf, size_t buf_len);
1877
1878         /**
1879          * set_noa - Set Notice of Absence parameters for GO (testing)
1880          * @priv: Private driver interface data
1881          * @count: Count
1882          * @start: Start time in ms from next TBTT
1883          * @duration: Duration in ms
1884          * Returns: 0 on success or -1 on failure
1885          *
1886          * This function is used to set Notice of Absence parameters for GO. It
1887          * is used only for testing. To disable NoA, all parameters are set to
1888          * 0.
1889          */
1890         int (*set_noa)(void *priv, u8 count, int start, int duration);
1891
1892         /**
1893          * set_p2p_powersave - Set P2P power save options
1894          * @priv: Private driver interface data
1895          * @legacy_ps: 0 = disable, 1 = enable, 2 = maximum PS, -1 = no change
1896          * @opp_ps: 0 = disable, 1 = enable, -1 = no change
1897          * @ctwindow: 0.. = change (msec), -1 = no change
1898          * Returns: 0 on success or -1 on failure
1899          */
1900         int (*set_p2p_powersave)(void *priv, int legacy_ps, int opp_ps,
1901                                  int ctwindow);
1902
1903         /**
1904          * ampdu - Enable/disable aggregation
1905          * @priv: Private driver interface data
1906          * @ampdu: 1/0 = enable/disable A-MPDU aggregation
1907          * Returns: 0 on success or -1 on failure
1908          */
1909         int (*ampdu)(void *priv, int ampdu);
1910
1911         /**
1912          * set_intra_bss - Enables/Disables intra BSS bridging
1913          */
1914         int (*set_intra_bss)(void *priv, int enabled);
1915 };
1916
1917
1918 /**
1919  * enum wpa_event_type - Event type for wpa_supplicant_event() calls
1920  */
1921 enum wpa_event_type {
1922         /**
1923          * EVENT_ASSOC - Association completed
1924          *
1925          * This event needs to be delivered when the driver completes IEEE
1926          * 802.11 association or reassociation successfully.
1927          * wpa_driver_ops::get_bssid() is expected to provide the current BSSID
1928          * after this event has been generated. In addition, optional
1929          * EVENT_ASSOCINFO may be generated just before EVENT_ASSOC to provide
1930          * more information about the association. If the driver interface gets
1931          * both of these events at the same time, it can also include the
1932          * assoc_info data in EVENT_ASSOC call.
1933          */
1934         EVENT_ASSOC,
1935
1936         /**
1937          * EVENT_DISASSOC - Association lost
1938          *
1939          * This event should be called when association is lost either due to
1940          * receiving deauthenticate or disassociate frame from the AP or when
1941          * sending either of these frames to the current AP. If the driver
1942          * supports separate deauthentication event, EVENT_DISASSOC should only
1943          * be used for disassociation and EVENT_DEAUTH for deauthentication.
1944          * In AP mode, union wpa_event_data::disassoc_info is required.
1945          */
1946         EVENT_DISASSOC,
1947
1948         /**
1949          * EVENT_MICHAEL_MIC_FAILURE - Michael MIC (TKIP) detected
1950          *
1951          * This event must be delivered when a Michael MIC error is detected by
1952          * the local driver. Additional data for event processing is
1953          * provided with union wpa_event_data::michael_mic_failure. This
1954          * information is used to request new encyption key and to initiate
1955          * TKIP countermeasures if needed.
1956          */
1957         EVENT_MICHAEL_MIC_FAILURE,
1958
1959         /**
1960          * EVENT_SCAN_RESULTS - Scan results available
1961          *
1962          * This event must be called whenever scan results are available to be
1963          * fetched with struct wpa_driver_ops::get_scan_results(). This event
1964          * is expected to be used some time after struct wpa_driver_ops::scan()
1965          * is called. If the driver provides an unsolicited event when the scan
1966          * has been completed, this event can be used to trigger
1967          * EVENT_SCAN_RESULTS call. If such event is not available from the
1968          * driver, the driver wrapper code is expected to use a registered
1969          * timeout to generate EVENT_SCAN_RESULTS call after the time that the
1970          * scan is expected to be completed. Optional information about
1971          * completed scan can be provided with union wpa_event_data::scan_info.
1972          */
1973         EVENT_SCAN_RESULTS,
1974
1975         /**
1976          * EVENT_ASSOCINFO - Report optional extra information for association
1977          *
1978          * This event can be used to report extra association information for
1979          * EVENT_ASSOC processing. This extra information includes IEs from
1980          * association frames and Beacon/Probe Response frames in union
1981          * wpa_event_data::assoc_info. EVENT_ASSOCINFO must be send just before
1982          * EVENT_ASSOC. Alternatively, the driver interface can include
1983          * assoc_info data in the EVENT_ASSOC call if it has all the
1984          * information available at the same point.
1985          */
1986         EVENT_ASSOCINFO,
1987
1988         /**
1989          * EVENT_INTERFACE_STATUS - Report interface status changes
1990          *
1991          * This optional event can be used to report changes in interface
1992          * status (interface added/removed) using union
1993          * wpa_event_data::interface_status. This can be used to trigger
1994          * wpa_supplicant to stop and re-start processing for the interface,
1995          * e.g., when a cardbus card is ejected/inserted.
1996          */
1997         EVENT_INTERFACE_STATUS,
1998
1999         /**
2000          * EVENT_PMKID_CANDIDATE - Report a candidate AP for pre-authentication
2001          *
2002          * This event can be used to inform wpa_supplicant about candidates for
2003          * RSN (WPA2) pre-authentication. If wpa_supplicant is not responsible
2004          * for scan request (ap_scan=2 mode), this event is required for
2005          * pre-authentication. If wpa_supplicant is performing scan request
2006          * (ap_scan=1), this event is optional since scan results can be used
2007          * to add pre-authentication candidates. union
2008          * wpa_event_data::pmkid_candidate is used to report the BSSID of the
2009          * candidate and priority of the candidate, e.g., based on the signal
2010          * strength, in order to try to pre-authenticate first with candidates
2011          * that are most likely targets for re-association.
2012          *
2013          * EVENT_PMKID_CANDIDATE can be called whenever the driver has updates
2014          * on the candidate list. In addition, it can be called for the current
2015          * AP and APs that have existing PMKSA cache entries. wpa_supplicant
2016          * will automatically skip pre-authentication in cases where a valid
2017          * PMKSA exists. When more than one candidate exists, this event should
2018          * be generated once for each candidate.
2019          *
2020          * Driver will be notified about successful pre-authentication with
2021          * struct wpa_driver_ops::add_pmkid() calls.
2022          */
2023         EVENT_PMKID_CANDIDATE,
2024
2025         /**
2026          * EVENT_STKSTART - Request STK handshake (MLME-STKSTART.request)
2027          *
2028          * This event can be used to inform wpa_supplicant about desire to set
2029          * up secure direct link connection between two stations as defined in
2030          * IEEE 802.11e with a new PeerKey mechanism that replaced the original
2031          * STAKey negotiation. The caller will need to set peer address for the
2032          * event.
2033          */
2034         EVENT_STKSTART,
2035
2036         /**
2037          * EVENT_FT_RESPONSE - Report FT (IEEE 802.11r) response IEs
2038          *
2039          * The driver is expected to report the received FT IEs from
2040          * FT authentication sequence from the AP. The FT IEs are included in
2041          * the extra information in union wpa_event_data::ft_ies.
2042          */
2043         EVENT_FT_RESPONSE,
2044
2045         /**
2046          * EVENT_IBSS_RSN_START - Request RSN authentication in IBSS
2047          *
2048          * The driver can use this event to inform wpa_supplicant about a STA
2049          * in an IBSS with which protected frames could be exchanged. This
2050          * event starts RSN authentication with the other STA to authenticate
2051          * the STA and set up encryption keys with it.
2052          */
2053         EVENT_IBSS_RSN_START,
2054
2055         /**
2056          * EVENT_AUTH - Authentication result
2057          *
2058          * This event should be called when authentication attempt has been
2059          * completed. This is only used if the driver supports separate
2060          * authentication step (struct wpa_driver_ops::authenticate).
2061          * Information about authentication result is included in
2062          * union wpa_event_data::auth.
2063          */
2064         EVENT_AUTH,
2065
2066         /**
2067          * EVENT_DEAUTH - Authentication lost
2068          *
2069          * This event should be called when authentication is lost either due
2070          * to receiving deauthenticate frame from the AP or when sending that
2071          * frame to the current AP.
2072          * In AP mode, union wpa_event_data::deauth_info is required.
2073          */
2074         EVENT_DEAUTH,
2075
2076         /**
2077          * EVENT_ASSOC_REJECT - Association rejected
2078          *
2079          * This event should be called when (re)association attempt has been
2080          * rejected by the AP. Information about the association response is
2081          * included in union wpa_event_data::assoc_reject.
2082          */
2083         EVENT_ASSOC_REJECT,
2084
2085         /**
2086          * EVENT_AUTH_TIMED_OUT - Authentication timed out
2087          */
2088         EVENT_AUTH_TIMED_OUT,
2089
2090         /**
2091          * EVENT_ASSOC_TIMED_OUT - Association timed out
2092          */
2093         EVENT_ASSOC_TIMED_OUT,
2094
2095         /**
2096          * EVENT_FT_RRB_RX - FT (IEEE 802.11r) RRB frame received
2097          */
2098         EVENT_FT_RRB_RX,
2099
2100         /**
2101          * EVENT_WPS_BUTTON_PUSHED - Report hardware push button press for WPS
2102          */
2103         EVENT_WPS_BUTTON_PUSHED,
2104
2105         /**
2106          * EVENT_TX_STATUS - Report TX status
2107          */
2108         EVENT_TX_STATUS,
2109
2110         /**
2111          * EVENT_RX_FROM_UNKNOWN - Report RX from unknown STA
2112          */
2113         EVENT_RX_FROM_UNKNOWN,
2114
2115         /**
2116          * EVENT_RX_MGMT - Report RX of a management frame
2117          */
2118         EVENT_RX_MGMT,
2119
2120         /**
2121          * EVENT_RX_ACTION - Action frame received
2122          *
2123          * This event is used to indicate when an Action frame has been
2124          * received. Information about the received frame is included in
2125          * union wpa_event_data::rx_action.
2126          */
2127         EVENT_RX_ACTION,
2128
2129         /**
2130          * EVENT_REMAIN_ON_CHANNEL - Remain-on-channel duration started
2131          *
2132          * This event is used to indicate when the driver has started the
2133          * requested remain-on-channel duration. Information about the
2134          * operation is included in union wpa_event_data::remain_on_channel.
2135          */
2136         EVENT_REMAIN_ON_CHANNEL,
2137
2138         /**
2139          * EVENT_CANCEL_REMAIN_ON_CHANNEL - Remain-on-channel timed out
2140          *
2141          * This event is used to indicate when the driver has completed
2142          * remain-on-channel duration, i.e., may noot be available on the
2143          * requested channel anymore. Information about the
2144          * operation is included in union wpa_event_data::remain_on_channel.
2145          */
2146         EVENT_CANCEL_REMAIN_ON_CHANNEL,
2147
2148         /**
2149          * EVENT_MLME_RX - Report reception of frame for MLME (test use only)
2150          *
2151          * This event is used only by driver_test.c and userspace MLME.
2152          */
2153         EVENT_MLME_RX,
2154
2155         /**
2156          * EVENT_RX_PROBE_REQ - Indicate received Probe Request frame
2157          *
2158          * This event is used to indicate when a Probe Request frame has been
2159          * received. Information about the received frame is included in
2160          * union wpa_event_data::rx_probe_req. The driver is required to report
2161          * these events only after successfully completed probe_req_report()
2162          * commands to request the events (i.e., report parameter is non-zero)
2163          * in station mode. In AP mode, Probe Request frames should always be
2164          * reported.
2165          */
2166         EVENT_RX_PROBE_REQ,
2167
2168         /**
2169          * EVENT_NEW_STA - New wired device noticed
2170          *
2171          * This event is used to indicate that a new device has been detected
2172          * in a network that does not use association-like functionality (i.e.,
2173          * mainly wired Ethernet). This can be used to start EAPOL
2174          * authenticator when receiving a frame from a device. The address of
2175          * the device is included in union wpa_event_data::new_sta.
2176          */
2177         EVENT_NEW_STA,
2178
2179         /**
2180          * EVENT_EAPOL_RX - Report received EAPOL frame
2181          *
2182          * When in AP mode with hostapd, this event is required to be used to
2183          * deliver the receive EAPOL frames from the driver. With
2184          * %wpa_supplicant, this event is used only if the send_eapol() handler
2185          * is used to override the use of l2_packet for EAPOL frame TX.
2186          */
2187         EVENT_EAPOL_RX,
2188
2189         /**
2190          * EVENT_SIGNAL_CHANGE - Indicate change in signal strength
2191          *
2192          * This event is used to indicate changes in the signal strength
2193          * observed in frames received from the current AP if signal strength
2194          * monitoring has been enabled with signal_monitor().
2195          */
2196         EVENT_SIGNAL_CHANGE,
2197
2198         /**
2199          * EVENT_INTERFACE_ENABLED - Notify that interface was enabled
2200          *
2201          * This event is used to indicate that the interface was enabled after
2202          * having been previously disabled, e.g., due to rfkill.
2203          */
2204         EVENT_INTERFACE_ENABLED,
2205
2206         /**
2207          * EVENT_INTERFACE_DISABLED - Notify that interface was disabled
2208          *
2209          * This event is used to indicate that the interface was disabled,
2210          * e.g., due to rfkill.
2211          */
2212         EVENT_INTERFACE_DISABLED,
2213
2214         /**
2215          * EVENT_CHANNEL_LIST_CHANGED - Channel list changed
2216          *
2217          * This event is used to indicate that the channel list has changed,
2218          * e.g., because of a regulatory domain change triggered by scan
2219          * results including an AP advertising a country code.
2220          */
2221         EVENT_CHANNEL_LIST_CHANGED,
2222
2223         /**
2224          * EVENT_INTERFACE_UNAVAILABLE - Notify that interface is unavailable
2225          *
2226          * This event is used to indicate that the driver cannot maintain this
2227          * interface in its operation mode anymore. The most likely use for
2228          * this is to indicate that AP mode operation is not available due to
2229          * operating channel would need to be changed to a DFS channel when
2230          * the driver does not support radar detection and another virtual
2231          * interfaces caused the operating channel to change. Other similar
2232          * resource conflicts could also trigger this for station mode
2233          * interfaces.
2234          */
2235         EVENT_INTERFACE_UNAVAILABLE,
2236
2237         /**
2238          * EVENT_BEST_CHANNEL
2239          *
2240          * Driver generates this event whenever it detects a better channel
2241          * (e.g., based on RSSI or channel use). This information can be used
2242          * to improve channel selection for a new AP/P2P group.
2243          */
2244         EVENT_BEST_CHANNEL
2245 };
2246
2247
2248 /**
2249  * union wpa_event_data - Additional data for wpa_supplicant_event() calls
2250  */
2251 union wpa_event_data {
2252         /**
2253          * struct assoc_info - Data for EVENT_ASSOC and EVENT_ASSOCINFO events
2254          *
2255          * This structure is optional for EVENT_ASSOC calls and required for
2256          * EVENT_ASSOCINFO calls. By using EVENT_ASSOC with this data, the
2257          * driver interface does not need to generate separate EVENT_ASSOCINFO
2258          * calls.
2259          */
2260         struct assoc_info {
2261                 /**
2262                  * req_ies - (Re)Association Request IEs
2263                  *
2264                  * If the driver generates WPA/RSN IE, this event data must be
2265                  * returned for WPA handshake to have needed information. If
2266                  * wpa_supplicant-generated WPA/RSN IE is used, this
2267                  * information event is optional.
2268                  *
2269                  * This should start with the first IE (fixed fields before IEs
2270                  * are not included).
2271                  */
2272                 const u8 *req_ies;
2273
2274                 /**
2275                  * req_ies_len - Length of req_ies in bytes
2276                  */
2277                 size_t req_ies_len;
2278
2279                 /**
2280                  * resp_ies - (Re)Association Response IEs
2281                  *
2282                  * Optional association data from the driver. This data is not
2283                  * required WPA, but may be useful for some protocols and as
2284                  * such, should be reported if this is available to the driver
2285                  * interface.
2286                  *
2287                  * This should start with the first IE (fixed fields before IEs
2288                  * are not included).
2289                  */
2290                 const u8 *resp_ies;
2291
2292                 /**
2293                  * resp_ies_len - Length of resp_ies in bytes
2294                  */
2295                 size_t resp_ies_len;
2296
2297                 /**
2298                  * beacon_ies - Beacon or Probe Response IEs
2299                  *
2300                  * Optional Beacon/ProbeResp data: IEs included in Beacon or
2301                  * Probe Response frames from the current AP (i.e., the one
2302                  * that the client just associated with). This information is
2303                  * used to update WPA/RSN IE for the AP. If this field is not
2304                  * set, the results from previous scan will be used. If no
2305                  * data for the new AP is found, scan results will be requested
2306                  * again (without scan request). At this point, the driver is
2307                  * expected to provide WPA/RSN IE for the AP (if WPA/WPA2 is
2308                  * used).
2309                  *
2310                  * This should start with the first IE (fixed fields before IEs
2311                  * are not included).
2312                  */
2313                 const u8 *beacon_ies;
2314
2315                 /**
2316                  * beacon_ies_len - Length of beacon_ies */
2317                 size_t beacon_ies_len;
2318
2319                 /**
2320                  * freq - Frequency of the operational channel in MHz
2321                  */
2322                 unsigned int freq;
2323
2324                 /**
2325                  * addr - Station address (for AP mode)
2326                  */
2327                 const u8 *addr;
2328         } assoc_info;
2329
2330         /**
2331          * struct disassoc_info - Data for EVENT_DISASSOC events
2332          */
2333         struct disassoc_info {
2334                 /**
2335                  * addr - Station address (for AP mode)
2336                  */
2337                 const u8 *addr;
2338
2339                 /**
2340                  * reason_code - Reason Code (host byte order) used in
2341                  *      Deauthentication frame
2342                  */
2343                 u16 reason_code;
2344
2345                 /**
2346                  * ie - Optional IE(s) in Disassociation frame
2347                  */
2348                 const u8 *ie;
2349
2350                 /**
2351                  * ie_len - Length of ie buffer in octets
2352                  */
2353                 size_t ie_len;
2354         } disassoc_info;
2355
2356         /**
2357          * struct deauth_info - Data for EVENT_DEAUTH events
2358          */
2359         struct deauth_info {
2360                 /**
2361                  * addr - Station address (for AP mode)
2362                  */
2363                 const u8 *addr;
2364
2365                 /**
2366                  * reason_code - Reason Code (host byte order) used in
2367                  *      Deauthentication frame
2368                  */
2369                 u16 reason_code;
2370
2371                 /**
2372                  * ie - Optional IE(s) in Deauthentication frame
2373                  */
2374                 const u8 *ie;
2375
2376                 /**
2377                  * ie_len - Length of ie buffer in octets
2378                  */
2379                 size_t ie_len;
2380         } deauth_info;
2381
2382         /**
2383          * struct michael_mic_failure - Data for EVENT_MICHAEL_MIC_FAILURE
2384          */
2385         struct michael_mic_failure {
2386                 int unicast;
2387                 const u8 *src;
2388         } michael_mic_failure;
2389
2390         /**
2391          * struct interface_status - Data for EVENT_INTERFACE_STATUS
2392          */
2393         struct interface_status {
2394                 char ifname[100];
2395                 enum {
2396                         EVENT_INTERFACE_ADDED, EVENT_INTERFACE_REMOVED
2397                 } ievent;
2398         } interface_status;
2399
2400         /**
2401          * struct pmkid_candidate - Data for EVENT_PMKID_CANDIDATE
2402          */
2403         struct pmkid_candidate {
2404                 /** BSSID of the PMKID candidate */
2405                 u8 bssid[ETH_ALEN];
2406                 /** Smaller the index, higher the priority */
2407                 int index;
2408                 /** Whether RSN IE includes pre-authenticate flag */
2409                 int preauth;
2410         } pmkid_candidate;
2411
2412         /**
2413          * struct stkstart - Data for EVENT_STKSTART
2414          */
2415         struct stkstart {
2416                 u8 peer[ETH_ALEN];
2417         } stkstart;
2418
2419         /**
2420          * struct ft_ies - FT information elements (EVENT_FT_RESPONSE)
2421          *
2422          * During FT (IEEE 802.11r) authentication sequence, the driver is
2423          * expected to use this event to report received FT IEs (MDIE, FTIE,
2424          * RSN IE, TIE, possible resource request) to the supplicant. The FT
2425          * IEs for the next message will be delivered through the
2426          * struct wpa_driver_ops::update_ft_ies() callback.
2427          */
2428         struct ft_ies {
2429                 const u8 *ies;
2430                 size_t ies_len;
2431                 int ft_action;
2432                 u8 target_ap[ETH_ALEN];
2433                 /** Optional IE(s), e.g., WMM TSPEC(s), for RIC-Request */
2434                 const u8 *ric_ies;
2435                 /** Length of ric_ies buffer in octets */
2436                 size_t ric_ies_len;
2437         } ft_ies;
2438
2439         /**
2440          * struct ibss_rsn_start - Data for EVENT_IBSS_RSN_START
2441          */
2442         struct ibss_rsn_start {
2443                 u8 peer[ETH_ALEN];
2444         } ibss_rsn_start;
2445
2446         /**
2447          * struct auth_info - Data for EVENT_AUTH events
2448          */
2449         struct auth_info {
2450                 u8 peer[ETH_ALEN];
2451                 u16 auth_type;
2452                 u16 status_code;
2453                 const u8 *ies;
2454                 size_t ies_len;
2455         } auth;
2456
2457         /**
2458          * struct assoc_reject - Data for EVENT_ASSOC_REJECT events
2459          */
2460         struct assoc_reject {
2461                 /**
2462                  * bssid - BSSID of the AP that rejected association
2463                  */
2464                 const u8 *bssid;
2465
2466                 /**
2467                  * resp_ies - (Re)Association Response IEs
2468                  *
2469                  * Optional association data from the driver. This data is not
2470                  * required WPA, but may be useful for some protocols and as
2471                  * such, should be reported if this is available to the driver
2472                  * interface.
2473                  *
2474                  * This should start with the first IE (fixed fields before IEs
2475                  * are not included).
2476                  */
2477                 const u8 *resp_ies;
2478
2479                 /**
2480                  * resp_ies_len - Length of resp_ies in bytes
2481                  */
2482                 size_t resp_ies_len;
2483
2484                 /**
2485                  * status_code - Status Code from (Re)association Response
2486                  */
2487                 u16 status_code;
2488         } assoc_reject;
2489
2490         struct timeout_event {
2491                 u8 addr[ETH_ALEN];
2492         } timeout_event;
2493
2494         /**
2495          * struct ft_rrb_rx - Data for EVENT_FT_RRB_RX events
2496          */
2497         struct ft_rrb_rx {
2498                 const u8 *src;
2499                 const u8 *data;
2500                 size_t data_len;
2501         } ft_rrb_rx;
2502
2503         /**
2504          * struct tx_status - Data for EVENT_TX_STATUS events
2505          */
2506         struct tx_status {
2507                 u16 type;
2508                 u16 stype;
2509                 const u8 *dst;
2510                 const u8 *data;
2511                 size_t data_len;
2512                 int ack;
2513         } tx_status;
2514
2515         /**
2516          * struct rx_from_unknown - Data for EVENT_RX_FROM_UNKNOWN events
2517          */
2518         struct rx_from_unknown {
2519                 const u8 *frame;
2520                 size_t len;
2521         } rx_from_unknown;
2522
2523         /**
2524          * struct rx_mgmt - Data for EVENT_RX_MGMT events
2525          */
2526         struct rx_mgmt {
2527                 const u8 *frame;
2528                 size_t frame_len;
2529                 u32 datarate;
2530                 u32 ssi_signal;
2531         } rx_mgmt;
2532
2533         /**
2534          * struct rx_action - Data for EVENT_RX_ACTION events
2535          */
2536         struct rx_action {
2537                 /**
2538                  * da - Destination address of the received Action frame
2539                  */
2540                 const u8 *da;
2541
2542                 /**
2543                  * sa - Source address of the received Action frame
2544                  */
2545                 const u8 *sa;
2546
2547                 /**
2548                  * bssid - Address 3 of the received Action frame
2549                  */
2550                 const u8 *bssid;
2551
2552                 /**
2553                  * category - Action frame category
2554                  */
2555                 u8 category;
2556
2557                 /**
2558                  * data - Action frame body after category field
2559                  */
2560                 const u8 *data;
2561
2562                 /**
2563                  * len - Length of data in octets
2564                  */
2565                 size_t len;
2566
2567                 /**
2568                  * freq - Frequency (in MHz) on which the frame was received
2569                  */
2570                 int freq;
2571         } rx_action;
2572
2573         /**
2574          * struct remain_on_channel - Data for EVENT_REMAIN_ON_CHANNEL events
2575          *
2576          * This is also used with EVENT_CANCEL_REMAIN_ON_CHANNEL events.
2577          */
2578         struct remain_on_channel {
2579                 /**
2580                  * freq - Channel frequency in MHz
2581                  */
2582                 unsigned int freq;
2583
2584                 /**
2585                  * duration - Duration to remain on the channel in milliseconds
2586                  */
2587                 unsigned int duration;
2588         } remain_on_channel;
2589
2590         /**
2591          * struct scan_info - Optional data for EVENT_SCAN_RESULTS events
2592          * @aborted: Whether the scan was aborted
2593          * @freqs: Scanned frequencies in MHz (%NULL = all channels scanned)
2594          * @num_freqs: Number of entries in freqs array
2595          * @ssids: Scanned SSIDs (%NULL or zero-length SSID indicates wildcard
2596          *      SSID)
2597          * @num_ssids: Number of entries in ssids array
2598          */
2599         struct scan_info {
2600                 int aborted;
2601                 const int *freqs;
2602                 size_t num_freqs;
2603                 struct wpa_driver_scan_ssid ssids[WPAS_MAX_SCAN_SSIDS];
2604                 size_t num_ssids;
2605         } scan_info;
2606
2607         /**
2608          * struct mlme_rx - Data for EVENT_MLME_RX events
2609          */
2610         struct mlme_rx {
2611                 const u8 *buf;
2612                 size_t len;
2613                 int freq;
2614                 int channel;
2615                 int ssi;
2616         } mlme_rx;
2617
2618         /**
2619          * struct rx_probe_req - Data for EVENT_RX_PROBE_REQ events
2620          */
2621         struct rx_probe_req {
2622                 /**
2623                  * sa - Source address of the received Probe Request frame
2624                  */
2625                 const u8 *sa;
2626
2627                 /**
2628                  * ie - IEs from the Probe Request body
2629                  */
2630                 const u8 *ie;
2631
2632                 /**
2633                  * ie_len - Length of ie buffer in octets
2634                  */
2635                 size_t ie_len;
2636         } rx_probe_req;
2637
2638         /**
2639          * struct new_sta - Data for EVENT_NEW_STA events
2640          */
2641         struct new_sta {
2642                 const u8 *addr;
2643         } new_sta;
2644
2645         /**
2646          * struct eapol_rx - Data for EVENT_EAPOL_RX events
2647          */
2648         struct eapol_rx {
2649                 const u8 *src;
2650                 const u8 *data;
2651                 size_t data_len;
2652         } eapol_rx;
2653
2654         /**
2655          * struct signal_change - Data for EVENT_SIGNAL_CHANGE events
2656          */
2657         struct signal_change {
2658                 u32 frequency;
2659                 int above_threshold;
2660                 int current_signal;
2661                 int current_noise;
2662                 int current_txrate;
2663         } signal_change;
2664
2665         /**
2666          * struct best_channel - Data for EVENT_BEST_CHANNEL events
2667          * @freq_24: Best 2.4 GHz band channel frequency in MHz
2668          * @freq_5: Best 5 GHz band channel frequency in MHz
2669          * @freq_overall: Best channel frequency in MHz
2670          *
2671          * 0 can be used to indicate no preference in either band.
2672          */
2673         struct best_channel {
2674                 int freq_24;
2675                 int freq_5;
2676                 int freq_overall;
2677         } best_chan;
2678 };
2679
2680 /**
2681  * wpa_supplicant_event - Report a driver event for wpa_supplicant
2682  * @ctx: Context pointer (wpa_s); this is the ctx variable registered
2683  *      with struct wpa_driver_ops::init()
2684  * @event: event type (defined above)
2685  * @data: possible extra data for the event
2686  *
2687  * Driver wrapper code should call this function whenever an event is received
2688  * from the driver.
2689  */
2690 void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
2691                           union wpa_event_data *data);
2692
2693
2694 /*
2695  * The following inline functions are provided for convenience to simplify
2696  * event indication for some of the common events.
2697  */
2698
2699 static inline void drv_event_assoc(void *ctx, const u8 *addr, const u8 *ie,
2700                                    size_t ielen)
2701 {
2702         union wpa_event_data event;
2703         os_memset(&event, 0, sizeof(event));
2704         event.assoc_info.req_ies = ie;
2705         event.assoc_info.req_ies_len = ielen;
2706         event.assoc_info.addr = addr;
2707         wpa_supplicant_event(ctx, EVENT_ASSOC, &event);
2708 }
2709
2710 static inline void drv_event_disassoc(void *ctx, const u8 *addr)
2711 {
2712         union wpa_event_data event;
2713         os_memset(&event, 0, sizeof(event));
2714         event.disassoc_info.addr = addr;
2715         wpa_supplicant_event(ctx, EVENT_DISASSOC, &event);
2716 }
2717
2718 static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data,
2719                                       size_t data_len)
2720 {
2721         union wpa_event_data event;
2722         os_memset(&event, 0, sizeof(event));
2723         event.eapol_rx.src = src;
2724         event.eapol_rx.data = data;
2725         event.eapol_rx.data_len = data_len;
2726         wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event);
2727 }
2728
2729 #endif /* DRIVER_H */